From a9479ea6bf6fffe6ddef4eea4aaa842f3cae2645 Mon Sep 17 00:00:00 2001 From: "fern-api[bot]" <115122769+fern-api[bot]@users.noreply.github.com> Date: Fri, 21 Nov 2025 21:39:23 +0000 Subject: [PATCH] SDK regeneration --- .github/workflows/label-ai-generated-prs.yml | 11 - README.md | 32 +- build.gradle | 4 +- .../java/com/intercom/api/AsyncIntercom.java | 80 +- src/main/java/com/intercom/api/Intercom.java | 80 +- .../com/intercom/api/core/ApiVersion.java | 30 + .../com/intercom/api/core/ClientOptions.java | 8 +- .../api/errors/TooManyRequestsError.java | 33 + .../api/resources/admins/AdminsClient.java | 13 +- .../resources/admins/AsyncAdminsClient.java | 13 +- .../admins/AsyncRawAdminsClient.java | 41 +- .../api/resources/admins/RawAdminsClient.java | 35 +- .../requests/ConfigureAwayAdminRequest.java | 69 +- .../admins/requests/FindAdminRequest.java | 17 +- .../api/resources/admins/types/Admin.java | 224 +-- .../api/resources/aiagent/types/AiAgent.java | 246 ++- .../resources/aicontent/AiContentClient.java | 174 ++ .../aicontent/AsyncAiContentClient.java | 180 ++ .../aicontent/AsyncRawAiContentClient.java | 746 ++++++++ .../aicontent/RawAiContentClient.java | 593 +++++++ .../CreateContentImportSourceRequest.java | 241 +++ .../requests/CreateExternalPageRequest.java | 370 ++++ .../DeleteContentImportSourceRequest.java | 112 ++ .../requests/DeleteExternalPageRequest.java} | 60 +- .../GetContentImportSourceRequest.java | 112 ++ .../requests/GetExternalPageRequest.java | 112 ++ .../UpdateContentImportSourceRequest.java | 390 +++++ .../requests/UpdateExternalPageRequest.java | 349 ++++ .../aicontent/types/ContentImportSource.java | 499 ++++++ .../types/ContentImportSourcesList.java | 189 ++ .../aicontent/types/ExternalPage.java | 560 ++++++ .../aicontent/types/ExternalPagesList.java | 189 ++ .../aicontentsource/types/ContentSource.java | 139 +- .../resources/articles/ArticlesClient.java | 22 +- .../articles/AsyncArticlesClient.java | 22 +- .../articles/AsyncRawArticlesClient.java | 43 +- .../resources/articles/RawArticlesClient.java | 40 +- .../requests/DeleteArticleRequest.java | 17 +- .../articles/requests/FindArticleRequest.java | 17 +- .../requests/UpdateArticleRequest.java | 108 +- .../api/resources/articles/types/Article.java | 91 +- .../articles/types/ArticleListItem.java | 73 +- .../types/ArticleSearchHighlights.java | 130 +- ...sponse.java => ArticleSearchResponse.java} | 132 +- .../articles/types/IArticleListItem.java | 4 +- .../AsyncAwayStatusReasonsClient.java | 42 + .../AsyncRawAwayStatusReasonsClient.java | 104 ++ .../AwayStatusReasonsClient.java | 41 + .../RawAwayStatusReasonsClient.java | 85 + .../api/resources/calls/AsyncCallsClient.java | 116 ++ .../resources/calls/AsyncRawCallsClient.java | 428 +++++ .../api/resources/calls/CallsClient.java | 113 ++ .../api/resources/calls/RawCallsClient.java | 340 ++++ .../calls/requests/ListCallsRequest.java | 130 ++ .../ListCallsWithTranscriptsRequest.java | 108 ++ .../requests/ShowCallRecordingRequest.java} | 60 +- .../calls/requests/ShowCallRequest.java | 112 ++ .../requests/ShowCallTranscriptRequest.java | 112 ++ .../api/resources/calls/types/Call.java | 653 +++++++ .../api/resources/calls/types/ICall.java | 47 + .../ListCallsWithTranscriptsResponse.java | 818 +++++++++ .../companies/AsyncCompaniesClient.java | 7 +- .../companies/AsyncRawCompaniesClient.java | 64 +- .../resources/companies/CompaniesClient.java | 7 +- .../companies/RawCompaniesClient.java | 63 +- .../AttachContactToCompanyRequest.java | 17 +- .../requests/ListAttachedContactsRequest.java | 96 +- .../requests/UpdateCompanyRequest.java | 40 +- .../resources/companies/types/Company.java | 294 ++-- .../contacts/AsyncContactsClient.java | 72 +- .../contacts/AsyncRawContactsClient.java | 200 ++- .../resources/contacts/ContactsClient.java | 69 +- .../resources/contacts/RawContactsClient.java | 164 +- .../requests/ArchiveContactRequest.java | 6 +- .../requests/BlockContactRequest.java | 112 ++ .../requests/DeleteContactRequest.java | 6 +- .../contacts/requests/FindContactRequest.java | 6 +- .../requests/MergeContactsRequest.java | 74 +- .../ShowContactByExternalIdRequest.java | 112 ++ .../requests/UnarchiveContactRequest.java | 6 +- .../api/resources/contacts/types/Contact.java | 1421 +++++---------- .../types/ContactsCreateResponse.java | 1521 +++++++++++++++++ .../contacts/types/ContactsFindResponse.java | 1521 +++++++++++++++++ .../ContactsMergeLeadInUserResponse.java | 1521 +++++++++++++++++ .../types/ContactsUpdateResponse.java | 1521 +++++++++++++++++ .../resources/contacts/types/IContact.java | 104 ++ .../ShowContactByExternalIdResponse.java | 1521 +++++++++++++++++ .../AsyncConversationsClient.java | 70 +- .../AsyncRawConversationsClient.java | 282 +-- .../conversations/ConversationsClient.java | 67 +- .../conversations/RawConversationsClient.java | 225 ++- .../AutoAssignConversationRequest.java | 10 - .../ConvertConversationToTicketRequest.java | 16 +- .../requests/DeleteConversationRequest.java | 111 ++ .../requests/FindConversationRequest.java | 67 +- .../requests/UpdateConversationRequest.java | 238 ++- .../conversations/types/Conversation.java | 828 ++++----- .../AsyncCustomChannelEventsClient.java | 117 ++ .../AsyncRawCustomChannelEventsClient.java | 439 +++++ .../CustomChannelEventsClient.java | 114 ++ .../RawCustomChannelEventsClient.java | 350 ++++ .../NotifyAttributeCollectedRequest.java | 202 +++ .../requests/NotifyNewMessageRequest.java | 210 +++ .../NotifyQuickReplySelectedRequest.java | 211 +++ .../AsyncCustomObjectInstancesClient.java | 124 ++ .../AsyncRawCustomObjectInstancesClient.java | 440 +++++ .../CustomObjectInstancesClient.java | 121 ++ .../RawCustomObjectInstancesClient.java | 349 ++++ ...teOrUpdateCustomObjectInstanceRequest.java | 301 ++++ ...tomObjectInstancesByExternalIdRequest.java | 153 ++ ...eleteCustomObjectInstancesByIdRequest.java | 139 ++ ...tomObjectInstancesByExternalIdRequest.java | 139 ++ .../GetCustomObjectInstancesByIdRequest.java | 153 ++ .../types/CustomObjectInstance.java | 330 ++++ .../AsyncDataAttributesClient.java | 2 +- .../AsyncRawDataAttributesClient.java | 6 +- .../dataattributes/DataAttributesClient.java | 2 +- .../RawDataAttributesClient.java | 6 +- .../requests/CreateDataAttributeRequest.java | 508 ------ .../requests/UpdateDataAttributeRequest.java | 292 +--- .../dataattributes/types/DataAttribute.java | 62 +- .../dataexport/AsyncDataExportClient.java | 38 + .../dataexport/AsyncRawDataExportClient.java | 146 ++ .../dataexport/DataExportClient.java | 34 + .../dataexport/RawDataExportClient.java | 116 ++ .../DownloadReportingDataExportRequest.java | 134 ++ .../requests/ExportReportingDataRequest.java | 169 ++ .../dataexport/types/DataExport.java | 150 +- ...DataExportExportReportingDataResponse.java | 171 ++ .../resources/export/AsyncExportClient.java | 50 + .../export/AsyncRawExportClient.java | 179 ++ .../api/resources/export/ExportClient.java | 48 + .../api/resources/export/RawExportClient.java | 139 ++ ...PostExportReportingDataEnqueueRequest.java | 196 +++ ...xportReportingDataGetDatasetsResponse.java | 395 +++++ ...ostExportReportingDataEnqueueResponse.java | 171 ++ .../helpcenter/types/Collection.java | 67 +- .../helpcenter/types/HelpCenter.java | 289 ++-- .../helpcenter/types/HelpCenterList.java | 53 +- .../AsyncRawHelpCentersClient.java | 5 +- .../helpcenters/RawHelpCentersClient.java | 5 +- .../AsyncRawCollectionsClient.java | 9 +- .../collections/RawCollectionsClient.java | 9 +- .../requests/DeleteCollectionRequest.java | 17 +- .../requests/FindCollectionRequest.java | 17 +- .../requests/UpdateCollectionRequest.java | 17 +- .../requests/FindHelpCenterRequest.java | 23 +- .../AsyncInternalArticlesClient.java | 141 ++ .../AsyncRawInternalArticlesClient.java | 525 ++++++ .../InternalArticlesClient.java | 138 ++ .../RawInternalArticlesClient.java | 419 +++++ .../DeleteInternalArticleRequest.java | 111 ++ .../RetrieveInternalArticleRequest.java | 111 ++ .../SearchInternalArticlesRequest.java} | 59 +- .../UpdateInternalArticleRequestBody.java | 288 ++++ .../types/InternalArticleListItem.java | 353 ++++ .../types/InternalArticleSearchResponse.java | 273 +++ .../api/resources/jobs/AsyncJobsClient.java | 42 + .../resources/jobs/AsyncRawJobsClient.java | 110 ++ .../api/resources/jobs/JobsClient.java | 41 + .../api/resources/jobs/RawJobsClient.java | 88 + .../jobs/requests/JobsStatusRequest.java | 112 ++ .../api/resources/jobs/types/Jobs.java | 462 +++++ .../messages/AsyncMessagesClient.java | 21 +- .../messages/AsyncRawMessagesClient.java | 28 +- .../resources/messages/MessagesClient.java | 21 +- .../resources/messages/RawMessagesClient.java | 28 +- .../api/resources/messages/types/Message.java | 111 +- .../news/feeds/AsyncFeedsClient.java | 11 +- .../news/feeds/AsyncRawFeedsClient.java | 22 +- .../api/resources/news/feeds/FeedsClient.java | 11 +- .../resources/news/feeds/RawFeedsClient.java | 17 +- .../news/items/AsyncItemsClient.java | 6 +- .../news/items/AsyncRawItemsClient.java | 17 +- .../api/resources/news/items/ItemsClient.java | 6 +- .../resources/news/items/RawItemsClient.java | 15 +- .../items/requests/DeleteNewsItemRequest.java | 17 +- .../items/requests/FindNewsItemRequest.java | 17 +- .../items/requests/UpdateNewsItemRequest.java | 16 +- .../api/resources/news/types/NewsItem.java | 395 ++--- .../api/resources/news/types/Newsfeed.java | 130 +- .../news/types/NewsfeedAssignment.java | 71 +- .../resources/notes/AsyncRawNotesClient.java | 5 +- .../api/resources/notes/RawNotesClient.java | 5 +- .../notes/requests/FindNoteRequest.java | 17 +- .../api/resources/notes/types/Note.java | 190 +- .../AsyncPhoneCallRedirectsClient.java | 18 +- .../AsyncRawPhoneCallRedirectsClient.java | 32 +- .../PhoneCallRedirectsClient.java | 16 +- .../RawPhoneCallRedirectsClient.java | 30 +- .../CreatePhoneCallRedirectRequest.java | 143 -- .../api/resources/segments/types/Segment.java | 215 +-- .../types/SubscriptionType.java | 242 ++- .../requests/UntagConversationRequest.java | 6 +- .../api/resources/tags/types/Tag.java | 76 +- .../tags/types/TagBasic.java} | 87 +- .../api/resources/teams/types/Team.java | 158 +- .../tickets/AsyncRawTicketsClient.java | 240 ++- .../resources/tickets/AsyncTicketsClient.java | 84 +- .../resources/tickets/RawTicketsClient.java | 194 ++- .../api/resources/tickets/TicketsClient.java | 81 +- .../tickets/requests/CreateTicketRequest.java | 914 ++++++++++ .../tickets/requests/DeleteTicketRequest.java | 112 ++ .../requests/EnqueueCreateTicketRequest.java | 914 ++++++++++ .../tickets/requests/UpdateTicketRequest.java | 387 ++--- .../tickets/types/DeleteTicketResponse.java | 161 ++ .../api/resources/tickets/types/Ticket.java | 636 ++----- .../tickets/types/TicketContacts.java | 55 +- .../resources/tickets/types/TicketPart.java | 965 ++++++++--- .../resources/tickets/types/TicketState.java | 321 ++++ .../tickets/types/TicketStateDetailed.java | 504 ++++++ .../resources/tickets/types/TicketType.java | 482 ++++-- .../AsyncRawTicketStatesClient.java | 100 ++ .../ticketstates/AsyncTicketStatesClient.java | 41 + .../ticketstates/RawTicketStatesClient.java | 81 + .../ticketstates/TicketStatesClient.java | 40 + .../AsyncRawTicketTypesClient.java | 53 +- .../tickettypes/AsyncTicketTypesClient.java | 29 +- .../tickettypes/RawTicketTypesClient.java | 50 +- .../tickettypes/TicketTypesClient.java | 27 +- .../attributes/AsyncAttributesClient.java | 9 +- .../attributes/AsyncRawAttributesClient.java | 20 +- .../attributes/AttributesClient.java | 11 +- .../attributes/RawAttributesClient.java | 16 +- .../unstable/AsyncUnstableClient.java | 54 +- .../resources/unstable/UnstableClient.java | 54 +- .../unstable/aiagent/types/AiAgent.java | 64 + .../unstable/brands/AsyncBrandsClient.java | 59 + .../unstable/brands/AsyncRawBrandsClient.java | 178 ++ .../unstable/brands/BrandsClient.java | 58 + .../unstable/brands/RawBrandsClient.java | 142 ++ .../brands/requests/RetrieveBrandRequest.java | 112 ++ .../unstable/brands/types/Brand.java | 330 ++++ .../unstable/brands/types/BrandList.java | 124 ++ .../unstable/calls/AsyncCallsClient.java | 116 ++ .../unstable/calls/AsyncRawCallsClient.java | 429 +++++ .../resources/unstable/calls/CallsClient.java | 113 ++ .../unstable/calls/RawCallsClient.java | 340 ++++ .../calls/requests/ListCallsRequest.java | 130 ++ .../ListCallsWithTranscriptsRequest.java | 108 ++ .../requests/ShowCallRecordingRequest.java} | 60 +- .../calls/requests/ShowCallRequest.java} | 60 +- .../requests/ShowCallTranscriptRequest.java | 112 ++ .../resources/unstable/calls/types/Call.java | 653 +++++++ .../resources/unstable/calls/types/ICall.java | 47 + .../ListCallsWithTranscriptsResponse.java | 818 +++++++++ .../unstable/companies/types/Company.java | 143 +- .../AsyncRawConversationsClient.java | 10 + .../conversations/RawConversationsClient.java | 10 + .../requests/RetrieveConversationRequest.java | 63 +- .../requests/UpdateConversationRequest.java | 58 +- .../conversations/types/Conversation.java | 32 + .../AsyncCustomChannelEventsClient.java | 16 +- .../AsyncRawCustomChannelEventsClient.java | 16 +- .../CustomChannelEventsClient.java | 16 +- .../RawCustomChannelEventsClient.java | 16 +- .../AsyncDataAttributesClient.java | 6 +- .../AsyncRawDataAttributesClient.java | 8 +- .../dataattributes/DataAttributesClient.java | 5 +- .../RawDataAttributesClient.java | 8 +- .../requests/CreateDataAttributeRequest.java | 508 ------ .../requests/UpdateDataAttributeRequest.java | 198 +-- .../unstable/emails/AsyncEmailsClient.java | 57 + .../unstable/emails/AsyncRawEmailsClient.java | 177 ++ .../unstable/emails/EmailsClient.java | 56 + .../unstable/emails/RawEmailsClient.java | 141 ++ .../emails/requests/RetrieveEmailRequest.java | 112 ++ .../unstable/emails/types/EmailList.java | 125 ++ .../unstable/emails/types/EmailSetting.java | 394 +++++ .../unstable/helpcenter/types/HelpCenter.java | 68 +- .../AsyncInternalArticlesClient.java | 141 ++ .../AsyncRawInternalArticlesClient.java | 525 ++++++ .../InternalArticlesClient.java | 138 ++ .../RawInternalArticlesClient.java | 419 +++++ .../DeleteInternalArticleRequest.java | 111 ++ .../RetrieveInternalArticleRequest.java | 111 ++ .../SearchInternalArticlesRequest.java} | 59 +- .../UpdateInternalArticleRequestBody.java | 287 ++++ .../types/InternalArticleListItem.java | 353 ++++ .../types/InternalArticleSearchResponse.java | 273 +++ .../unstable/macros/AsyncMacrosClient.java | 121 ++ .../unstable/macros/AsyncRawMacrosClient.java | 275 +++ .../unstable/macros/MacrosClient.java | 120 ++ .../unstable/macros/RawMacrosClient.java | 231 +++ .../macros/requests/GetMacroRequest.java | 112 ++ .../macros/requests/ListMacrosRequest.java | 163 ++ .../unstable/macros/types/Macro.java | 549 ++++++ .../unstable/macros/types/MacroList.java | 388 +++++ .../messages/AsyncMessagesClient.java | 4 +- .../messages/AsyncRawMessagesClient.java | 4 +- .../unstable/messages/MessagesClient.java | 4 +- .../unstable/messages/RawMessagesClient.java | 4 +- .../unstable/messages/types/Message.java | 16 +- .../unstable/notes/AsyncNotesClient.java | 16 + .../unstable/notes/AsyncRawNotesClient.java | 69 + .../resources/unstable/notes/NotesClient.java | 15 + .../unstable/notes/RawNotesClient.java | 55 + .../requests/ListCompanyNotesRequest.java} | 60 +- .../unstable/notes/types/CompanyNote.java | 365 ++++ .../tickets/AsyncRawTicketsClient.java | 24 +- .../unstable/tickets/AsyncTicketsClient.java | 24 +- .../unstable/tickets/RawTicketsClient.java | 24 +- .../unstable/tickets/TicketsClient.java | 24 +- .../resources/unstable/types/ActivityLog.java | 29 +- .../unstable/types/ActivityLogMetadata.java | 68 +- .../resources/unstable/types/CallList.java | 189 ++ .../unstable/types/ConversationRating.java | 35 +- .../types/ConversationStatistics.java | 36 +- ...estBody.java => CreateArticleRequest.java} | 250 ++- .../types/CreateDataAttributeRequest.java | 489 ++++++ .../types/CreateInternalArticleRequest.java | 223 +++ .../types/CreateOrUpdateCompanyRequest.java | 362 ++++ .../types/CreatePhoneSwitchRequest.java | 255 +++ .../types}/CreateTicketTypeRequest.java | 2 +- .../unstable/types/CustomChannelContact.java | 84 +- .../types/DeletedInternalArticleObject.java | 161 ++ .../unstable/types/IntercomVersion.java | 30 + .../unstable/types/InternalArticleList.java | 189 ++ .../types/UpdateDataAttributeRequestBody.java | 275 +++ .../visitors/AsyncRawVisitorsClient.java | 22 +- .../visitors/AsyncVisitorsClient.java | 9 +- .../resources/visitors/RawVisitorsClient.java | 18 +- .../resources/visitors/VisitorsClient.java | 9 +- .../com/intercom/api/types/ActivityLog.java | 220 ++- .../intercom/api/types/ActivityLogList.java | 56 +- .../api/types/ActivityLogMetadata.java | 275 ++- .../intercom/api/types/AddressableList.java | 105 +- .../com/intercom/api/types/AdminList.java | 53 +- .../types/AdminReplyConversationRequest.java | 70 +- .../com/intercom/api/types/AdminWithApp.java | 377 ++-- src/main/java/com/intercom/api/types/App.java | 230 +-- .../intercom/api/types/ArticleContent.java | 266 ++- .../com/intercom/api/types/ArticleList.java | 133 +- .../intercom/api/types/ArticleStatistics.java | 64 +- .../intercom/api/types/AwayStatusReason.java | 309 ++++ .../intercom/api/types/ButtonComponent.java | 357 ---- .../java/com/intercom/api/types/CallList.java | 189 ++ .../com/intercom/api/types/CanvasObject.java | 202 --- .../intercom/api/types/CheckboxComponent.java | 424 ----- .../intercom/api/types/CheckboxOption.java | 196 --- .../intercom/api/types/CollectionList.java | 133 +- .../api/types/CompanyAttachedContacts.java | 134 +- .../api/types/CompanyAttachedSegments.java | 53 +- .../com/intercom/api/types/CompanyData.java | 161 ++ .../com/intercom/api/types/CompanyList.java | 106 +- .../com/intercom/api/types/CompanyScroll.java | 51 +- .../com/intercom/api/types/Component.java | 776 --------- .../intercom/api/types/ConfigureRequest.java | 611 ------- .../intercom/api/types/ConfigureResponse.java | 199 --- .../intercom/api/types/ContactArchived.java | 127 +- .../api/types/ContactAttachedCompanies.java | 133 +- .../intercom/api/types/ContactBlocked.java | 193 +++ .../intercom/api/types/ContactCompanies.java | 181 +- .../intercom/api/types/ContactCompany.java | 152 -- .../intercom/api/types/ContactDeleted.java | 127 +- .../com/intercom/api/types/ContactList.java | 134 +- .../intercom/api/types/ContactLocation.java | 34 +- .../com/intercom/api/types/ContactNotes.java | 149 +- .../intercom/api/types/ContactReference.java | 94 +- .../api/types/ContactReplyBaseRequest.java | 176 +- .../api/types/ContactReplyEmailRequest.java | 175 +- .../ContactReplyIntercomUserIdRequest.java | 186 +- .../types/ContactReplyTicketEmailRequest.java | 175 +- ...ntactReplyTicketIntercomUserIdRequest.java | 174 +- .../ContactReplyTicketUserIdRequest.java | 175 +- .../api/types/ContactReplyUserIdRequest.java | 175 +- .../intercom/api/types/ContactSegments.java | 53 +- .../api/types/ContactSocialProfiles.java | 24 +- .../api/types/ContactSubscriptionTypes.java | 149 +- .../com/intercom/api/types/ContactTags.java | 149 +- .../intercom/api/types/ContactUnarchived.java | 127 +- .../api/types/ContentSourcesList.java | 110 +- .../java/com/intercom/api/types/Context.java | 363 ---- .../types/ConversationAttachmentFiles.java | 104 +- .../ConversationAttributeUpdatedByAdmin.java | 285 +++ ...onversationAttributeUpdatedByWorkflow.java | 393 +++++ .../api/types/ConversationContacts.java | 57 +- .../api/types/ConversationDeleted.java | 161 ++ .../types/ConversationFirstContactReply.java | 83 +- .../intercom/api/types/ConversationList.java | 189 ++ .../intercom/api/types/ConversationPart.java | 595 ++++--- .../api/types/ConversationPartAuthor.java | 200 ++- .../api/types/ConversationPartMetadata.java | 306 ++++ .../intercom/api/types/ConversationParts.java | 109 +- .../api/types/ConversationRating.java | 189 +- .../api/types/ConversationResponseTime.java | 163 ++ .../api/types/ConversationSource.java | 265 ++- .../api/types/ConversationStatistics.java | 165 +- .../CreateArticleRequest.java | 3 +- .../api/types/CreateDataAttributeRequest.java | 489 ++++++ .../types/CreateInternalArticleRequest.java | 223 +++ .../CreateOrUpdateCompanyRequest.java | 2 +- .../api/types/CreatePhoneSwitchRequest.java | 255 +++ ...uest.java => CreateTicketRequestBody.java} | 257 ++- .../CreateTicketTypeRequest.java} | 190 +- .../com/intercom/api/types/CursorPages.java | 32 +- .../api/types/CustomActionFinished.java | 283 +++ .../api/types/CustomActionStarted.java | 178 ++ ...eItem.java => CustomChannelAttribute.java} | 72 +- .../api/types/CustomChannelBaseEvent.java | 173 ++ .../api/types/CustomChannelContact.java | 313 ++++ .../CustomChannelNotificationResponse.java | 223 +++ .../types/CustomObjectInstanceDeleted.java | 161 ++ .../api/types/CustomObjectInstanceList.java | 128 ++ .../intercom/api/types/DataAttributeList.java | 53 +- .../com/intercom/api/types/DataEventList.java | 55 +- .../intercom/api/types/DataEventSummary.java | 170 +- .../api/types/DataEventSummaryItem.java | 152 +- .../com/intercom/api/types/DataExportCsv.java | 742 +++----- ...FilterSearchRequest.java => Datetime.java} | 42 +- .../api/types/DeletedArticleObject.java | 105 +- .../api/types/DeletedCollectionObject.java | 105 +- .../api/types/DeletedCompanyObject.java | 105 +- .../types/DeletedInternalArticleObject.java | 161 ++ .../com/intercom/api/types/DeletedObject.java | 105 +- .../intercom/api/types/DropdownComponent.java | 433 ----- .../intercom/api/types/DropdownOption.java | 196 --- .../api/types/EmailAddressHeader.java | 161 ++ .../api/types/EmailMessageMetadata.java | 133 ++ .../java/com/intercom/api/types/Event.java | 68 - .../com/intercom/api/types/EventDetails.java | 131 ++ .../com/intercom/api/types/FileAttribute.java | 227 +-- .../com/intercom/api/types/GroupContent.java | 107 +- .../api/types/GroupTranslatedContent.java | 37 +- .../intercom/api/types/IContactReference.java | 14 + .../api/types/ICreateTicketRequestBody.java | 16 + .../api/types/ICustomChannelBaseEvent.java | 12 + .../com/intercom/api/types/IListItem.java | 24 - .../intercom/api/types/IQuickReplyOption.java | 10 + .../intercom/api/types/ImageComponent.java | 498 ------ .../intercom/api/types/InitializeRequest.java | 367 ---- .../intercom/api/types/InputComponent.java | 462 ----- .../api/types/InternalArticleList.java | 189 ++ .../com/intercom/api/types/LinkedObject.java | 94 +- .../intercom/api/types/LinkedObjectList.java | 139 +- .../com/intercom/api/types/ListComponent.java | 224 --- .../java/com/intercom/api/types/ListItem.java | 375 ---- .../intercom/api/types/ListItemWithImage.java | 497 ------ .../api/types/ListItemWithoutImage.java | 523 ------ .../intercom/api/types/LiveCanvasRequest.java | 252 --- .../types/MultipleFilterSearchRequest.java | 103 +- .../intercom/api/types/NotFoundErrorBody.java | 344 ++++ .../java/com/intercom/api/types/NoteList.java | 126 +- .../api/types/OperatorWorkflowEvent.java | 312 ++++ .../com/intercom/api/types/PagesLink.java | 138 +- .../types/PaginatedConversationResponse.java | 210 --- .../api/types/PaginatedNewsItemResponse.java | 210 --- .../api/types/PaginatedNewsfeedResponse.java | 210 --- .../intercom/api/types/PaginatedResponse.java | 265 +++ ...nt.java => PaginatedResponseDataItem.java} | 138 +- .../intercom/api/types/PartAttachment.java | 233 +-- .../com/intercom/api/types/PhoneSwitch.java | 72 +- .../intercom/api/types/QuickReplyOption.java | 144 ++ .../com/intercom/api/types/Recipient.java | 221 +++ .../com/intercom/api/types/Reference.java | 55 +- .../intercom/api/types/ResultsResponse.java | 107 -- .../com/intercom/api/types/SegmentList.java | 54 +- .../api/types/SingleFilterSearchRequest.java | 102 +- .../api/types/SingleSelectComponent.java | 477 ------ .../api/types/SingleSelectOption.java | 196 --- .../com/intercom/api/types/SlaApplied.java | 111 +- .../com/intercom/api/types/SocialProfile.java | 107 +- .../intercom/api/types/SpacerComponent.java | 236 --- .../api/types/StartingAfterPaging.java | 62 +- .../api/types/SubmitActionComponent.java | 59 - .../com/intercom/api/types/SubmitRequest.java | 478 ------ .../intercom/api/types/SubmitResponse.java | 202 --- .../api/types/SubscriptionTypeList.java | 53 +- .../java/com/intercom/api/types/TagList.java | 52 +- .../java/com/intercom/api/types/Tags.java | 52 +- .../java/com/intercom/api/types/TeamList.java | 52 +- .../intercom/api/types/TextAreaComponent.java | 331 ---- .../com/intercom/api/types/TextComponent.java | 470 ----- .../com/intercom/api/types/TicketList.java | 133 +- .../intercom/api/types/TicketPartAuthor.java | 126 +- .../com/intercom/api/types/TicketParts.java | 108 +- .../com/intercom/api/types/TicketReply.java | 261 ++- .../intercom/api/types/TicketStateList.java | 134 ++ .../api/types/TicketTypeAttribute.java | 552 +++--- .../api/types/TicketTypeAttributeList.java | 54 +- .../intercom/api/types/TicketTypeList.java | 65 +- .../com/intercom/api/types/Translation.java | 105 +- .../api/types/UntagCompanyRequest.java | 105 +- .../api/types/UpdateArticleRequestBody.java | 172 ++ .../api/types/UpdateCompanyRequestBody.java | 285 +++ .../types/UpdateDataAttributeRequestBody.java | 275 +++ .../java/com/intercom/api/types/Visitor.java | 894 ++++------ .../api/types/VisitorDeletedObject.java | 107 +- .../api/types/WhatsappMessageStatusList.java | 914 ++++++++++ 489 files changed, 64243 insertions(+), 24602 deletions(-) delete mode 100644 .github/workflows/label-ai-generated-prs.yml create mode 100644 src/main/java/com/intercom/api/errors/TooManyRequestsError.java create mode 100644 src/main/java/com/intercom/api/resources/aicontent/AiContentClient.java create mode 100644 src/main/java/com/intercom/api/resources/aicontent/AsyncAiContentClient.java create mode 100644 src/main/java/com/intercom/api/resources/aicontent/AsyncRawAiContentClient.java create mode 100644 src/main/java/com/intercom/api/resources/aicontent/RawAiContentClient.java create mode 100644 src/main/java/com/intercom/api/resources/aicontent/requests/CreateContentImportSourceRequest.java create mode 100644 src/main/java/com/intercom/api/resources/aicontent/requests/CreateExternalPageRequest.java create mode 100644 src/main/java/com/intercom/api/resources/aicontent/requests/DeleteContentImportSourceRequest.java rename src/main/java/com/intercom/api/{types/CurrentCanvas.java => resources/aicontent/requests/DeleteExternalPageRequest.java} (51%) create mode 100644 src/main/java/com/intercom/api/resources/aicontent/requests/GetContentImportSourceRequest.java create mode 100644 src/main/java/com/intercom/api/resources/aicontent/requests/GetExternalPageRequest.java create mode 100644 src/main/java/com/intercom/api/resources/aicontent/requests/UpdateContentImportSourceRequest.java create mode 100644 src/main/java/com/intercom/api/resources/aicontent/requests/UpdateExternalPageRequest.java create mode 100644 src/main/java/com/intercom/api/resources/aicontent/types/ContentImportSource.java create mode 100644 src/main/java/com/intercom/api/resources/aicontent/types/ContentImportSourcesList.java create mode 100644 src/main/java/com/intercom/api/resources/aicontent/types/ExternalPage.java create mode 100644 src/main/java/com/intercom/api/resources/aicontent/types/ExternalPagesList.java rename src/main/java/com/intercom/api/resources/articles/types/{SearchArticlesResponse.java => ArticleSearchResponse.java} (70%) create mode 100644 src/main/java/com/intercom/api/resources/awaystatusreasons/AsyncAwayStatusReasonsClient.java create mode 100644 src/main/java/com/intercom/api/resources/awaystatusreasons/AsyncRawAwayStatusReasonsClient.java create mode 100644 src/main/java/com/intercom/api/resources/awaystatusreasons/AwayStatusReasonsClient.java create mode 100644 src/main/java/com/intercom/api/resources/awaystatusreasons/RawAwayStatusReasonsClient.java create mode 100644 src/main/java/com/intercom/api/resources/calls/AsyncCallsClient.java create mode 100644 src/main/java/com/intercom/api/resources/calls/AsyncRawCallsClient.java create mode 100644 src/main/java/com/intercom/api/resources/calls/CallsClient.java create mode 100644 src/main/java/com/intercom/api/resources/calls/RawCallsClient.java create mode 100644 src/main/java/com/intercom/api/resources/calls/requests/ListCallsRequest.java create mode 100644 src/main/java/com/intercom/api/resources/calls/requests/ListCallsWithTranscriptsRequest.java rename src/main/java/com/intercom/api/{types/InitializeResponse.java => resources/calls/requests/ShowCallRecordingRequest.java} (54%) create mode 100644 src/main/java/com/intercom/api/resources/calls/requests/ShowCallRequest.java create mode 100644 src/main/java/com/intercom/api/resources/calls/requests/ShowCallTranscriptRequest.java create mode 100644 src/main/java/com/intercom/api/resources/calls/types/Call.java create mode 100644 src/main/java/com/intercom/api/resources/calls/types/ICall.java create mode 100644 src/main/java/com/intercom/api/resources/calls/types/ListCallsWithTranscriptsResponse.java create mode 100644 src/main/java/com/intercom/api/resources/contacts/requests/BlockContactRequest.java create mode 100644 src/main/java/com/intercom/api/resources/contacts/requests/ShowContactByExternalIdRequest.java create mode 100644 src/main/java/com/intercom/api/resources/contacts/types/ContactsCreateResponse.java create mode 100644 src/main/java/com/intercom/api/resources/contacts/types/ContactsFindResponse.java create mode 100644 src/main/java/com/intercom/api/resources/contacts/types/ContactsMergeLeadInUserResponse.java create mode 100644 src/main/java/com/intercom/api/resources/contacts/types/ContactsUpdateResponse.java create mode 100644 src/main/java/com/intercom/api/resources/contacts/types/IContact.java create mode 100644 src/main/java/com/intercom/api/resources/contacts/types/ShowContactByExternalIdResponse.java create mode 100644 src/main/java/com/intercom/api/resources/conversations/requests/DeleteConversationRequest.java create mode 100644 src/main/java/com/intercom/api/resources/customchannelevents/AsyncCustomChannelEventsClient.java create mode 100644 src/main/java/com/intercom/api/resources/customchannelevents/AsyncRawCustomChannelEventsClient.java create mode 100644 src/main/java/com/intercom/api/resources/customchannelevents/CustomChannelEventsClient.java create mode 100644 src/main/java/com/intercom/api/resources/customchannelevents/RawCustomChannelEventsClient.java create mode 100644 src/main/java/com/intercom/api/resources/customchannelevents/requests/NotifyAttributeCollectedRequest.java create mode 100644 src/main/java/com/intercom/api/resources/customchannelevents/requests/NotifyNewMessageRequest.java create mode 100644 src/main/java/com/intercom/api/resources/customchannelevents/requests/NotifyQuickReplySelectedRequest.java create mode 100644 src/main/java/com/intercom/api/resources/customobjectinstances/AsyncCustomObjectInstancesClient.java create mode 100644 src/main/java/com/intercom/api/resources/customobjectinstances/AsyncRawCustomObjectInstancesClient.java create mode 100644 src/main/java/com/intercom/api/resources/customobjectinstances/CustomObjectInstancesClient.java create mode 100644 src/main/java/com/intercom/api/resources/customobjectinstances/RawCustomObjectInstancesClient.java create mode 100644 src/main/java/com/intercom/api/resources/customobjectinstances/requests/CreateOrUpdateCustomObjectInstanceRequest.java create mode 100644 src/main/java/com/intercom/api/resources/customobjectinstances/requests/DeleteCustomObjectInstancesByExternalIdRequest.java create mode 100644 src/main/java/com/intercom/api/resources/customobjectinstances/requests/DeleteCustomObjectInstancesByIdRequest.java create mode 100644 src/main/java/com/intercom/api/resources/customobjectinstances/requests/GetCustomObjectInstancesByExternalIdRequest.java create mode 100644 src/main/java/com/intercom/api/resources/customobjectinstances/requests/GetCustomObjectInstancesByIdRequest.java create mode 100644 src/main/java/com/intercom/api/resources/customobjectinstances/types/CustomObjectInstance.java delete mode 100644 src/main/java/com/intercom/api/resources/dataattributes/requests/CreateDataAttributeRequest.java create mode 100644 src/main/java/com/intercom/api/resources/dataexport/requests/DownloadReportingDataExportRequest.java create mode 100644 src/main/java/com/intercom/api/resources/dataexport/requests/ExportReportingDataRequest.java create mode 100644 src/main/java/com/intercom/api/resources/dataexport/types/DataExportExportReportingDataResponse.java create mode 100644 src/main/java/com/intercom/api/resources/export/AsyncExportClient.java create mode 100644 src/main/java/com/intercom/api/resources/export/AsyncRawExportClient.java create mode 100644 src/main/java/com/intercom/api/resources/export/ExportClient.java create mode 100644 src/main/java/com/intercom/api/resources/export/RawExportClient.java create mode 100644 src/main/java/com/intercom/api/resources/export/requests/PostExportReportingDataEnqueueRequest.java create mode 100644 src/main/java/com/intercom/api/resources/export/types/GetExportReportingDataGetDatasetsResponse.java create mode 100644 src/main/java/com/intercom/api/resources/export/types/PostExportReportingDataEnqueueResponse.java create mode 100644 src/main/java/com/intercom/api/resources/internalarticles/AsyncInternalArticlesClient.java create mode 100644 src/main/java/com/intercom/api/resources/internalarticles/AsyncRawInternalArticlesClient.java create mode 100644 src/main/java/com/intercom/api/resources/internalarticles/InternalArticlesClient.java create mode 100644 src/main/java/com/intercom/api/resources/internalarticles/RawInternalArticlesClient.java create mode 100644 src/main/java/com/intercom/api/resources/internalarticles/requests/DeleteInternalArticleRequest.java create mode 100644 src/main/java/com/intercom/api/resources/internalarticles/requests/RetrieveInternalArticleRequest.java rename src/main/java/com/intercom/api/{types/DataTableComponent.java => resources/internalarticles/requests/SearchInternalArticlesRequest.java} (52%) create mode 100644 src/main/java/com/intercom/api/resources/internalarticles/requests/UpdateInternalArticleRequestBody.java create mode 100644 src/main/java/com/intercom/api/resources/internalarticles/types/InternalArticleListItem.java create mode 100644 src/main/java/com/intercom/api/resources/internalarticles/types/InternalArticleSearchResponse.java create mode 100644 src/main/java/com/intercom/api/resources/jobs/AsyncJobsClient.java create mode 100644 src/main/java/com/intercom/api/resources/jobs/AsyncRawJobsClient.java create mode 100644 src/main/java/com/intercom/api/resources/jobs/JobsClient.java create mode 100644 src/main/java/com/intercom/api/resources/jobs/RawJobsClient.java create mode 100644 src/main/java/com/intercom/api/resources/jobs/requests/JobsStatusRequest.java create mode 100644 src/main/java/com/intercom/api/resources/jobs/types/Jobs.java delete mode 100644 src/main/java/com/intercom/api/resources/phonecallredirects/requests/CreatePhoneCallRedirectRequest.java rename src/main/java/com/intercom/api/{types/DividerComponent.java => resources/tags/types/TagBasic.java} (52%) create mode 100644 src/main/java/com/intercom/api/resources/tickets/requests/CreateTicketRequest.java create mode 100644 src/main/java/com/intercom/api/resources/tickets/requests/DeleteTicketRequest.java create mode 100644 src/main/java/com/intercom/api/resources/tickets/requests/EnqueueCreateTicketRequest.java create mode 100644 src/main/java/com/intercom/api/resources/tickets/types/DeleteTicketResponse.java create mode 100644 src/main/java/com/intercom/api/resources/tickets/types/TicketState.java create mode 100644 src/main/java/com/intercom/api/resources/tickets/types/TicketStateDetailed.java create mode 100644 src/main/java/com/intercom/api/resources/ticketstates/AsyncRawTicketStatesClient.java create mode 100644 src/main/java/com/intercom/api/resources/ticketstates/AsyncTicketStatesClient.java create mode 100644 src/main/java/com/intercom/api/resources/ticketstates/RawTicketStatesClient.java create mode 100644 src/main/java/com/intercom/api/resources/ticketstates/TicketStatesClient.java create mode 100644 src/main/java/com/intercom/api/resources/unstable/brands/AsyncBrandsClient.java create mode 100644 src/main/java/com/intercom/api/resources/unstable/brands/AsyncRawBrandsClient.java create mode 100644 src/main/java/com/intercom/api/resources/unstable/brands/BrandsClient.java create mode 100644 src/main/java/com/intercom/api/resources/unstable/brands/RawBrandsClient.java create mode 100644 src/main/java/com/intercom/api/resources/unstable/brands/requests/RetrieveBrandRequest.java create mode 100644 src/main/java/com/intercom/api/resources/unstable/brands/types/Brand.java create mode 100644 src/main/java/com/intercom/api/resources/unstable/brands/types/BrandList.java create mode 100644 src/main/java/com/intercom/api/resources/unstable/calls/AsyncCallsClient.java create mode 100644 src/main/java/com/intercom/api/resources/unstable/calls/AsyncRawCallsClient.java create mode 100644 src/main/java/com/intercom/api/resources/unstable/calls/CallsClient.java create mode 100644 src/main/java/com/intercom/api/resources/unstable/calls/RawCallsClient.java create mode 100644 src/main/java/com/intercom/api/resources/unstable/calls/requests/ListCallsRequest.java create mode 100644 src/main/java/com/intercom/api/resources/unstable/calls/requests/ListCallsWithTranscriptsRequest.java rename src/main/java/com/intercom/api/{types/SheetActionComponent.java => resources/unstable/calls/requests/ShowCallRecordingRequest.java} (55%) rename src/main/java/com/intercom/api/{types/UrlActionComponent.java => resources/unstable/calls/requests/ShowCallRequest.java} (56%) create mode 100644 src/main/java/com/intercom/api/resources/unstable/calls/requests/ShowCallTranscriptRequest.java create mode 100644 src/main/java/com/intercom/api/resources/unstable/calls/types/Call.java create mode 100644 src/main/java/com/intercom/api/resources/unstable/calls/types/ICall.java create mode 100644 src/main/java/com/intercom/api/resources/unstable/calls/types/ListCallsWithTranscriptsResponse.java delete mode 100644 src/main/java/com/intercom/api/resources/unstable/dataattributes/requests/CreateDataAttributeRequest.java create mode 100644 src/main/java/com/intercom/api/resources/unstable/emails/AsyncEmailsClient.java create mode 100644 src/main/java/com/intercom/api/resources/unstable/emails/AsyncRawEmailsClient.java create mode 100644 src/main/java/com/intercom/api/resources/unstable/emails/EmailsClient.java create mode 100644 src/main/java/com/intercom/api/resources/unstable/emails/RawEmailsClient.java create mode 100644 src/main/java/com/intercom/api/resources/unstable/emails/requests/RetrieveEmailRequest.java create mode 100644 src/main/java/com/intercom/api/resources/unstable/emails/types/EmailList.java create mode 100644 src/main/java/com/intercom/api/resources/unstable/emails/types/EmailSetting.java create mode 100644 src/main/java/com/intercom/api/resources/unstable/internalarticles/AsyncInternalArticlesClient.java create mode 100644 src/main/java/com/intercom/api/resources/unstable/internalarticles/AsyncRawInternalArticlesClient.java create mode 100644 src/main/java/com/intercom/api/resources/unstable/internalarticles/InternalArticlesClient.java create mode 100644 src/main/java/com/intercom/api/resources/unstable/internalarticles/RawInternalArticlesClient.java create mode 100644 src/main/java/com/intercom/api/resources/unstable/internalarticles/requests/DeleteInternalArticleRequest.java create mode 100644 src/main/java/com/intercom/api/resources/unstable/internalarticles/requests/RetrieveInternalArticleRequest.java rename src/main/java/com/intercom/api/{types/ContentObject.java => resources/unstable/internalarticles/requests/SearchInternalArticlesRequest.java} (52%) create mode 100644 src/main/java/com/intercom/api/resources/unstable/internalarticles/requests/UpdateInternalArticleRequestBody.java create mode 100644 src/main/java/com/intercom/api/resources/unstable/internalarticles/types/InternalArticleListItem.java create mode 100644 src/main/java/com/intercom/api/resources/unstable/internalarticles/types/InternalArticleSearchResponse.java create mode 100644 src/main/java/com/intercom/api/resources/unstable/macros/AsyncMacrosClient.java create mode 100644 src/main/java/com/intercom/api/resources/unstable/macros/AsyncRawMacrosClient.java create mode 100644 src/main/java/com/intercom/api/resources/unstable/macros/MacrosClient.java create mode 100644 src/main/java/com/intercom/api/resources/unstable/macros/RawMacrosClient.java create mode 100644 src/main/java/com/intercom/api/resources/unstable/macros/requests/GetMacroRequest.java create mode 100644 src/main/java/com/intercom/api/resources/unstable/macros/requests/ListMacrosRequest.java create mode 100644 src/main/java/com/intercom/api/resources/unstable/macros/types/Macro.java create mode 100644 src/main/java/com/intercom/api/resources/unstable/macros/types/MacroList.java rename src/main/java/com/intercom/api/{types/LiveCanvasResponse.java => resources/unstable/notes/requests/ListCompanyNotesRequest.java} (52%) create mode 100644 src/main/java/com/intercom/api/resources/unstable/notes/types/CompanyNote.java create mode 100644 src/main/java/com/intercom/api/resources/unstable/types/CallList.java rename src/main/java/com/intercom/api/resources/unstable/types/{UpdateArticleRequestBody.java => CreateArticleRequest.java} (60%) create mode 100644 src/main/java/com/intercom/api/resources/unstable/types/CreateDataAttributeRequest.java create mode 100644 src/main/java/com/intercom/api/resources/unstable/types/CreateInternalArticleRequest.java create mode 100644 src/main/java/com/intercom/api/resources/unstable/types/CreateOrUpdateCompanyRequest.java create mode 100644 src/main/java/com/intercom/api/resources/unstable/types/CreatePhoneSwitchRequest.java rename src/main/java/com/intercom/api/resources/{tickettypes/requests => unstable/types}/CreateTicketTypeRequest.java (99%) create mode 100644 src/main/java/com/intercom/api/resources/unstable/types/DeletedInternalArticleObject.java create mode 100644 src/main/java/com/intercom/api/resources/unstable/types/InternalArticleList.java create mode 100644 src/main/java/com/intercom/api/resources/unstable/types/UpdateDataAttributeRequestBody.java create mode 100644 src/main/java/com/intercom/api/types/AwayStatusReason.java delete mode 100644 src/main/java/com/intercom/api/types/ButtonComponent.java create mode 100644 src/main/java/com/intercom/api/types/CallList.java delete mode 100644 src/main/java/com/intercom/api/types/CanvasObject.java delete mode 100644 src/main/java/com/intercom/api/types/CheckboxComponent.java delete mode 100644 src/main/java/com/intercom/api/types/CheckboxOption.java create mode 100644 src/main/java/com/intercom/api/types/CompanyData.java delete mode 100644 src/main/java/com/intercom/api/types/Component.java delete mode 100644 src/main/java/com/intercom/api/types/ConfigureRequest.java delete mode 100644 src/main/java/com/intercom/api/types/ConfigureResponse.java create mode 100644 src/main/java/com/intercom/api/types/ContactBlocked.java delete mode 100644 src/main/java/com/intercom/api/types/ContactCompany.java delete mode 100644 src/main/java/com/intercom/api/types/Context.java create mode 100644 src/main/java/com/intercom/api/types/ConversationAttributeUpdatedByAdmin.java create mode 100644 src/main/java/com/intercom/api/types/ConversationAttributeUpdatedByWorkflow.java create mode 100644 src/main/java/com/intercom/api/types/ConversationDeleted.java create mode 100644 src/main/java/com/intercom/api/types/ConversationList.java create mode 100644 src/main/java/com/intercom/api/types/ConversationPartMetadata.java create mode 100644 src/main/java/com/intercom/api/types/ConversationResponseTime.java rename src/main/java/com/intercom/api/{resources/articles/requests => types}/CreateArticleRequest.java (99%) create mode 100644 src/main/java/com/intercom/api/types/CreateDataAttributeRequest.java create mode 100644 src/main/java/com/intercom/api/types/CreateInternalArticleRequest.java rename src/main/java/com/intercom/api/{resources/companies/requests => types}/CreateOrUpdateCompanyRequest.java (99%) create mode 100644 src/main/java/com/intercom/api/types/CreatePhoneSwitchRequest.java rename src/main/java/com/intercom/api/types/{CreateTicketRequest.java => CreateTicketRequestBody.java} (70%) rename src/main/java/com/intercom/api/{resources/unstable/types/UpdateTicketTypeRequestBody.java => types/CreateTicketTypeRequest.java} (66%) create mode 100644 src/main/java/com/intercom/api/types/CustomActionFinished.java create mode 100644 src/main/java/com/intercom/api/types/CustomActionStarted.java rename src/main/java/com/intercom/api/types/{DataTableItem.java => CustomChannelAttribute.java} (57%) create mode 100644 src/main/java/com/intercom/api/types/CustomChannelBaseEvent.java create mode 100644 src/main/java/com/intercom/api/types/CustomChannelContact.java create mode 100644 src/main/java/com/intercom/api/types/CustomChannelNotificationResponse.java create mode 100644 src/main/java/com/intercom/api/types/CustomObjectInstanceDeleted.java create mode 100644 src/main/java/com/intercom/api/types/CustomObjectInstanceList.java rename src/main/java/com/intercom/api/types/{MultipleOrSingleFilterSearchRequest.java => Datetime.java} (54%) create mode 100644 src/main/java/com/intercom/api/types/DeletedInternalArticleObject.java delete mode 100644 src/main/java/com/intercom/api/types/DropdownComponent.java delete mode 100644 src/main/java/com/intercom/api/types/DropdownOption.java create mode 100644 src/main/java/com/intercom/api/types/EmailAddressHeader.java create mode 100644 src/main/java/com/intercom/api/types/EmailMessageMetadata.java delete mode 100644 src/main/java/com/intercom/api/types/Event.java create mode 100644 src/main/java/com/intercom/api/types/EventDetails.java create mode 100644 src/main/java/com/intercom/api/types/IContactReference.java create mode 100644 src/main/java/com/intercom/api/types/ICreateTicketRequestBody.java create mode 100644 src/main/java/com/intercom/api/types/ICustomChannelBaseEvent.java delete mode 100644 src/main/java/com/intercom/api/types/IListItem.java create mode 100644 src/main/java/com/intercom/api/types/IQuickReplyOption.java delete mode 100644 src/main/java/com/intercom/api/types/ImageComponent.java delete mode 100644 src/main/java/com/intercom/api/types/InitializeRequest.java delete mode 100644 src/main/java/com/intercom/api/types/InputComponent.java create mode 100644 src/main/java/com/intercom/api/types/InternalArticleList.java delete mode 100644 src/main/java/com/intercom/api/types/ListComponent.java delete mode 100644 src/main/java/com/intercom/api/types/ListItem.java delete mode 100644 src/main/java/com/intercom/api/types/ListItemWithImage.java delete mode 100644 src/main/java/com/intercom/api/types/ListItemWithoutImage.java delete mode 100644 src/main/java/com/intercom/api/types/LiveCanvasRequest.java create mode 100644 src/main/java/com/intercom/api/types/NotFoundErrorBody.java create mode 100644 src/main/java/com/intercom/api/types/OperatorWorkflowEvent.java delete mode 100644 src/main/java/com/intercom/api/types/PaginatedConversationResponse.java delete mode 100644 src/main/java/com/intercom/api/types/PaginatedNewsItemResponse.java delete mode 100644 src/main/java/com/intercom/api/types/PaginatedNewsfeedResponse.java create mode 100644 src/main/java/com/intercom/api/types/PaginatedResponse.java rename src/main/java/com/intercom/api/types/{ActionComponent.java => PaginatedResponseDataItem.java} (52%) create mode 100644 src/main/java/com/intercom/api/types/QuickReplyOption.java create mode 100644 src/main/java/com/intercom/api/types/Recipient.java delete mode 100644 src/main/java/com/intercom/api/types/ResultsResponse.java delete mode 100644 src/main/java/com/intercom/api/types/SingleSelectComponent.java delete mode 100644 src/main/java/com/intercom/api/types/SingleSelectOption.java delete mode 100644 src/main/java/com/intercom/api/types/SpacerComponent.java delete mode 100644 src/main/java/com/intercom/api/types/SubmitActionComponent.java delete mode 100644 src/main/java/com/intercom/api/types/SubmitRequest.java delete mode 100644 src/main/java/com/intercom/api/types/SubmitResponse.java delete mode 100644 src/main/java/com/intercom/api/types/TextAreaComponent.java delete mode 100644 src/main/java/com/intercom/api/types/TextComponent.java create mode 100644 src/main/java/com/intercom/api/types/TicketStateList.java create mode 100644 src/main/java/com/intercom/api/types/UpdateArticleRequestBody.java create mode 100644 src/main/java/com/intercom/api/types/UpdateCompanyRequestBody.java create mode 100644 src/main/java/com/intercom/api/types/UpdateDataAttributeRequestBody.java create mode 100644 src/main/java/com/intercom/api/types/WhatsappMessageStatusList.java diff --git a/.github/workflows/label-ai-generated-prs.yml b/.github/workflows/label-ai-generated-prs.yml deleted file mode 100644 index 547cbfe..0000000 --- a/.github/workflows/label-ai-generated-prs.yml +++ /dev/null @@ -1,11 +0,0 @@ -# .github/workflows/label-ai-generated-prs.yml -name: Label AI-generated PRs - -on: - pull_request: - types: [opened, edited, synchronize] # run when the body changes too - -jobs: - call-label-ai-prs: - uses: intercom/github-action-workflows/.github/workflows/label-ai-prs.yml@main - secrets: inherit \ No newline at end of file diff --git a/README.md b/README.md index f50483c..aaee550 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,19 @@ [![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-Built%20with%20Fern-brightgreen)](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2Fintercom%2Fintercom-java) -The Intercom Java library provides convenient access to the Intercom API from Java. +The Intercom Java library provides convenient access to the Intercom APIs from Java. + +## Table of Contents + +- [Usage](#usage) +- [Environments](#environments) +- [Base Url](#base-url) +- [Exception Handling](#exception-handling) +- [Advanced](#advanced) + - [Custom Client](#custom-client) + - [Retries](#retries) + - [Timeouts](#timeouts) +- [Contributing](#contributing) ## Usage @@ -12,8 +24,7 @@ Instantiate and use the client with the following: package com.example.usage; import com.intercom.api.Intercom; -import com.intercom.api.resources.articles.requests.CreateArticleRequest; -import com.intercom.api.resources.articles.types.CreateArticleRequestState; +import com.intercom.api.resources.aicontent.requests.CreateContentImportSourceRequest; public class Example { public static void main(String[] args) { @@ -22,14 +33,11 @@ public class Example { .token("") .build(); - client.articles().create( - CreateArticleRequest + client.aiContent().createContentImportSource( + CreateContentImportSourceRequest .builder() - .title("Thanks for everything") - .authorId(1295) - .description("Description of the Article") - .body("Body of the Article") - .state(CreateArticleRequestState.PUBLISHED) + .syncBehavior("api") + .url("https://www.example.com") .build() ); } @@ -71,7 +79,7 @@ When the API returns a non-success status code (4xx or 5xx response), an API exc import com.intercom.api.core.IntercomApiApiException; try { - client.articles().create(...); + client.aiContent().createContentImportSource(...); } catch (IntercomApiApiException e) { // Do something with the API exception... } @@ -134,7 +142,7 @@ Intercom client = Intercom .build(); // Request level -client.articles().create( +client.aiContent().createContentImportSource( ..., RequestOptions .builder() diff --git a/build.gradle b/build.gradle index c4409ab..18965ed 100644 --- a/build.gradle +++ b/build.gradle @@ -46,7 +46,7 @@ java { group = 'io.intercom' -version = '3.0.0' +version = '3.1.0' jar { dependsOn(":generatePomFileForMavenPublication") @@ -77,7 +77,7 @@ publishing { maven(MavenPublication) { groupId = 'io.intercom' artifactId = 'intercom-java' - version = '3.0.0' + version = '3.1.0' from components.java pom { name = 'intercom' diff --git a/src/main/java/com/intercom/api/AsyncIntercom.java b/src/main/java/com/intercom/api/AsyncIntercom.java index 7973c6a..1a036b6 100644 --- a/src/main/java/com/intercom/api/AsyncIntercom.java +++ b/src/main/java/com/intercom/api/AsyncIntercom.java @@ -6,14 +6,22 @@ import com.intercom.api.core.ClientOptions; import com.intercom.api.core.Suppliers; import com.intercom.api.resources.admins.AsyncAdminsClient; +import com.intercom.api.resources.aicontent.AsyncAiContentClient; import com.intercom.api.resources.articles.AsyncArticlesClient; +import com.intercom.api.resources.awaystatusreasons.AsyncAwayStatusReasonsClient; +import com.intercom.api.resources.calls.AsyncCallsClient; import com.intercom.api.resources.companies.AsyncCompaniesClient; import com.intercom.api.resources.contacts.AsyncContactsClient; import com.intercom.api.resources.conversations.AsyncConversationsClient; +import com.intercom.api.resources.customchannelevents.AsyncCustomChannelEventsClient; +import com.intercom.api.resources.customobjectinstances.AsyncCustomObjectInstancesClient; import com.intercom.api.resources.dataattributes.AsyncDataAttributesClient; import com.intercom.api.resources.dataexport.AsyncDataExportClient; import com.intercom.api.resources.events.AsyncEventsClient; +import com.intercom.api.resources.export.AsyncExportClient; import com.intercom.api.resources.helpcenters.AsyncHelpCentersClient; +import com.intercom.api.resources.internalarticles.AsyncInternalArticlesClient; +import com.intercom.api.resources.jobs.AsyncJobsClient; import com.intercom.api.resources.messages.AsyncMessagesClient; import com.intercom.api.resources.news.AsyncNewsClient; import com.intercom.api.resources.notes.AsyncNotesClient; @@ -23,6 +31,7 @@ import com.intercom.api.resources.tags.AsyncTagsClient; import com.intercom.api.resources.teams.AsyncTeamsClient; import com.intercom.api.resources.tickets.AsyncTicketsClient; +import com.intercom.api.resources.ticketstates.AsyncTicketStatesClient; import com.intercom.api.resources.tickettypes.AsyncTicketTypesClient; import com.intercom.api.resources.unstable.AsyncUnstableClient; import com.intercom.api.resources.visitors.AsyncVisitorsClient; @@ -33,10 +42,20 @@ public class AsyncIntercom { protected final Supplier adminsClient; + protected final Supplier aiContentClient; + protected final Supplier articlesClient; + protected final Supplier awayStatusReasonsClient; + + protected final Supplier exportClient; + + protected final Supplier dataExportClient; + protected final Supplier helpCentersClient; + protected final Supplier internalArticlesClient; + protected final Supplier companiesClient; protected final Supplier contactsClient; @@ -47,11 +66,15 @@ public class AsyncIntercom { protected final Supplier conversationsClient; + protected final Supplier customChannelEventsClient; + + protected final Supplier customObjectInstancesClient; + protected final Supplier dataAttributesClient; protected final Supplier eventsClient; - protected final Supplier dataExportClient; + protected final Supplier jobsClient; protected final Supplier messagesClient; @@ -61,8 +84,12 @@ public class AsyncIntercom { protected final Supplier phoneCallRedirectsClient; + protected final Supplier callsClient; + protected final Supplier teamsClient; + protected final Supplier ticketStatesClient; + protected final Supplier ticketTypesClient; protected final Supplier ticketsClient; @@ -76,21 +103,30 @@ public class AsyncIntercom { public AsyncIntercom(ClientOptions clientOptions) { this.clientOptions = clientOptions; this.adminsClient = Suppliers.memoize(() -> new AsyncAdminsClient(clientOptions)); + this.aiContentClient = Suppliers.memoize(() -> new AsyncAiContentClient(clientOptions)); this.articlesClient = Suppliers.memoize(() -> new AsyncArticlesClient(clientOptions)); + this.awayStatusReasonsClient = Suppliers.memoize(() -> new AsyncAwayStatusReasonsClient(clientOptions)); + this.exportClient = Suppliers.memoize(() -> new AsyncExportClient(clientOptions)); + this.dataExportClient = Suppliers.memoize(() -> new AsyncDataExportClient(clientOptions)); this.helpCentersClient = Suppliers.memoize(() -> new AsyncHelpCentersClient(clientOptions)); + this.internalArticlesClient = Suppliers.memoize(() -> new AsyncInternalArticlesClient(clientOptions)); this.companiesClient = Suppliers.memoize(() -> new AsyncCompaniesClient(clientOptions)); this.contactsClient = Suppliers.memoize(() -> new AsyncContactsClient(clientOptions)); this.notesClient = Suppliers.memoize(() -> new AsyncNotesClient(clientOptions)); this.tagsClient = Suppliers.memoize(() -> new AsyncTagsClient(clientOptions)); this.conversationsClient = Suppliers.memoize(() -> new AsyncConversationsClient(clientOptions)); + this.customChannelEventsClient = Suppliers.memoize(() -> new AsyncCustomChannelEventsClient(clientOptions)); + this.customObjectInstancesClient = Suppliers.memoize(() -> new AsyncCustomObjectInstancesClient(clientOptions)); this.dataAttributesClient = Suppliers.memoize(() -> new AsyncDataAttributesClient(clientOptions)); this.eventsClient = Suppliers.memoize(() -> new AsyncEventsClient(clientOptions)); - this.dataExportClient = Suppliers.memoize(() -> new AsyncDataExportClient(clientOptions)); + this.jobsClient = Suppliers.memoize(() -> new AsyncJobsClient(clientOptions)); this.messagesClient = Suppliers.memoize(() -> new AsyncMessagesClient(clientOptions)); this.segmentsClient = Suppliers.memoize(() -> new AsyncSegmentsClient(clientOptions)); this.subscriptionTypesClient = Suppliers.memoize(() -> new AsyncSubscriptionTypesClient(clientOptions)); this.phoneCallRedirectsClient = Suppliers.memoize(() -> new AsyncPhoneCallRedirectsClient(clientOptions)); + this.callsClient = Suppliers.memoize(() -> new AsyncCallsClient(clientOptions)); this.teamsClient = Suppliers.memoize(() -> new AsyncTeamsClient(clientOptions)); + this.ticketStatesClient = Suppliers.memoize(() -> new AsyncTicketStatesClient(clientOptions)); this.ticketTypesClient = Suppliers.memoize(() -> new AsyncTicketTypesClient(clientOptions)); this.ticketsClient = Suppliers.memoize(() -> new AsyncTicketsClient(clientOptions)); this.visitorsClient = Suppliers.memoize(() -> new AsyncVisitorsClient(clientOptions)); @@ -102,14 +138,34 @@ public AsyncAdminsClient admins() { return this.adminsClient.get(); } + public AsyncAiContentClient aiContent() { + return this.aiContentClient.get(); + } + public AsyncArticlesClient articles() { return this.articlesClient.get(); } + public AsyncAwayStatusReasonsClient awayStatusReasons() { + return this.awayStatusReasonsClient.get(); + } + + public AsyncExportClient export() { + return this.exportClient.get(); + } + + public AsyncDataExportClient dataExport() { + return this.dataExportClient.get(); + } + public AsyncHelpCentersClient helpCenters() { return this.helpCentersClient.get(); } + public AsyncInternalArticlesClient internalArticles() { + return this.internalArticlesClient.get(); + } + public AsyncCompaniesClient companies() { return this.companiesClient.get(); } @@ -130,6 +186,14 @@ public AsyncConversationsClient conversations() { return this.conversationsClient.get(); } + public AsyncCustomChannelEventsClient customChannelEvents() { + return this.customChannelEventsClient.get(); + } + + public AsyncCustomObjectInstancesClient customObjectInstances() { + return this.customObjectInstancesClient.get(); + } + public AsyncDataAttributesClient dataAttributes() { return this.dataAttributesClient.get(); } @@ -138,8 +202,8 @@ public AsyncEventsClient events() { return this.eventsClient.get(); } - public AsyncDataExportClient dataExport() { - return this.dataExportClient.get(); + public AsyncJobsClient jobs() { + return this.jobsClient.get(); } public AsyncMessagesClient messages() { @@ -158,10 +222,18 @@ public AsyncPhoneCallRedirectsClient phoneCallRedirects() { return this.phoneCallRedirectsClient.get(); } + public AsyncCallsClient calls() { + return this.callsClient.get(); + } + public AsyncTeamsClient teams() { return this.teamsClient.get(); } + public AsyncTicketStatesClient ticketStates() { + return this.ticketStatesClient.get(); + } + public AsyncTicketTypesClient ticketTypes() { return this.ticketTypesClient.get(); } diff --git a/src/main/java/com/intercom/api/Intercom.java b/src/main/java/com/intercom/api/Intercom.java index 4d9bfec..11fa252 100644 --- a/src/main/java/com/intercom/api/Intercom.java +++ b/src/main/java/com/intercom/api/Intercom.java @@ -6,14 +6,22 @@ import com.intercom.api.core.ClientOptions; import com.intercom.api.core.Suppliers; import com.intercom.api.resources.admins.AdminsClient; +import com.intercom.api.resources.aicontent.AiContentClient; import com.intercom.api.resources.articles.ArticlesClient; +import com.intercom.api.resources.awaystatusreasons.AwayStatusReasonsClient; +import com.intercom.api.resources.calls.CallsClient; import com.intercom.api.resources.companies.CompaniesClient; import com.intercom.api.resources.contacts.ContactsClient; import com.intercom.api.resources.conversations.ConversationsClient; +import com.intercom.api.resources.customchannelevents.CustomChannelEventsClient; +import com.intercom.api.resources.customobjectinstances.CustomObjectInstancesClient; import com.intercom.api.resources.dataattributes.DataAttributesClient; import com.intercom.api.resources.dataexport.DataExportClient; import com.intercom.api.resources.events.EventsClient; +import com.intercom.api.resources.export.ExportClient; import com.intercom.api.resources.helpcenters.HelpCentersClient; +import com.intercom.api.resources.internalarticles.InternalArticlesClient; +import com.intercom.api.resources.jobs.JobsClient; import com.intercom.api.resources.messages.MessagesClient; import com.intercom.api.resources.news.NewsClient; import com.intercom.api.resources.notes.NotesClient; @@ -23,6 +31,7 @@ import com.intercom.api.resources.tags.TagsClient; import com.intercom.api.resources.teams.TeamsClient; import com.intercom.api.resources.tickets.TicketsClient; +import com.intercom.api.resources.ticketstates.TicketStatesClient; import com.intercom.api.resources.tickettypes.TicketTypesClient; import com.intercom.api.resources.unstable.UnstableClient; import com.intercom.api.resources.visitors.VisitorsClient; @@ -33,10 +42,20 @@ public class Intercom { protected final Supplier adminsClient; + protected final Supplier aiContentClient; + protected final Supplier articlesClient; + protected final Supplier awayStatusReasonsClient; + + protected final Supplier exportClient; + + protected final Supplier dataExportClient; + protected final Supplier helpCentersClient; + protected final Supplier internalArticlesClient; + protected final Supplier companiesClient; protected final Supplier contactsClient; @@ -47,11 +66,15 @@ public class Intercom { protected final Supplier conversationsClient; + protected final Supplier customChannelEventsClient; + + protected final Supplier customObjectInstancesClient; + protected final Supplier dataAttributesClient; protected final Supplier eventsClient; - protected final Supplier dataExportClient; + protected final Supplier jobsClient; protected final Supplier messagesClient; @@ -61,8 +84,12 @@ public class Intercom { protected final Supplier phoneCallRedirectsClient; + protected final Supplier callsClient; + protected final Supplier teamsClient; + protected final Supplier ticketStatesClient; + protected final Supplier ticketTypesClient; protected final Supplier ticketsClient; @@ -76,21 +103,30 @@ public class Intercom { public Intercom(ClientOptions clientOptions) { this.clientOptions = clientOptions; this.adminsClient = Suppliers.memoize(() -> new AdminsClient(clientOptions)); + this.aiContentClient = Suppliers.memoize(() -> new AiContentClient(clientOptions)); this.articlesClient = Suppliers.memoize(() -> new ArticlesClient(clientOptions)); + this.awayStatusReasonsClient = Suppliers.memoize(() -> new AwayStatusReasonsClient(clientOptions)); + this.exportClient = Suppliers.memoize(() -> new ExportClient(clientOptions)); + this.dataExportClient = Suppliers.memoize(() -> new DataExportClient(clientOptions)); this.helpCentersClient = Suppliers.memoize(() -> new HelpCentersClient(clientOptions)); + this.internalArticlesClient = Suppliers.memoize(() -> new InternalArticlesClient(clientOptions)); this.companiesClient = Suppliers.memoize(() -> new CompaniesClient(clientOptions)); this.contactsClient = Suppliers.memoize(() -> new ContactsClient(clientOptions)); this.notesClient = Suppliers.memoize(() -> new NotesClient(clientOptions)); this.tagsClient = Suppliers.memoize(() -> new TagsClient(clientOptions)); this.conversationsClient = Suppliers.memoize(() -> new ConversationsClient(clientOptions)); + this.customChannelEventsClient = Suppliers.memoize(() -> new CustomChannelEventsClient(clientOptions)); + this.customObjectInstancesClient = Suppliers.memoize(() -> new CustomObjectInstancesClient(clientOptions)); this.dataAttributesClient = Suppliers.memoize(() -> new DataAttributesClient(clientOptions)); this.eventsClient = Suppliers.memoize(() -> new EventsClient(clientOptions)); - this.dataExportClient = Suppliers.memoize(() -> new DataExportClient(clientOptions)); + this.jobsClient = Suppliers.memoize(() -> new JobsClient(clientOptions)); this.messagesClient = Suppliers.memoize(() -> new MessagesClient(clientOptions)); this.segmentsClient = Suppliers.memoize(() -> new SegmentsClient(clientOptions)); this.subscriptionTypesClient = Suppliers.memoize(() -> new SubscriptionTypesClient(clientOptions)); this.phoneCallRedirectsClient = Suppliers.memoize(() -> new PhoneCallRedirectsClient(clientOptions)); + this.callsClient = Suppliers.memoize(() -> new CallsClient(clientOptions)); this.teamsClient = Suppliers.memoize(() -> new TeamsClient(clientOptions)); + this.ticketStatesClient = Suppliers.memoize(() -> new TicketStatesClient(clientOptions)); this.ticketTypesClient = Suppliers.memoize(() -> new TicketTypesClient(clientOptions)); this.ticketsClient = Suppliers.memoize(() -> new TicketsClient(clientOptions)); this.visitorsClient = Suppliers.memoize(() -> new VisitorsClient(clientOptions)); @@ -102,14 +138,34 @@ public AdminsClient admins() { return this.adminsClient.get(); } + public AiContentClient aiContent() { + return this.aiContentClient.get(); + } + public ArticlesClient articles() { return this.articlesClient.get(); } + public AwayStatusReasonsClient awayStatusReasons() { + return this.awayStatusReasonsClient.get(); + } + + public ExportClient export() { + return this.exportClient.get(); + } + + public DataExportClient dataExport() { + return this.dataExportClient.get(); + } + public HelpCentersClient helpCenters() { return this.helpCentersClient.get(); } + public InternalArticlesClient internalArticles() { + return this.internalArticlesClient.get(); + } + public CompaniesClient companies() { return this.companiesClient.get(); } @@ -130,6 +186,14 @@ public ConversationsClient conversations() { return this.conversationsClient.get(); } + public CustomChannelEventsClient customChannelEvents() { + return this.customChannelEventsClient.get(); + } + + public CustomObjectInstancesClient customObjectInstances() { + return this.customObjectInstancesClient.get(); + } + public DataAttributesClient dataAttributes() { return this.dataAttributesClient.get(); } @@ -138,8 +202,8 @@ public EventsClient events() { return this.eventsClient.get(); } - public DataExportClient dataExport() { - return this.dataExportClient.get(); + public JobsClient jobs() { + return this.jobsClient.get(); } public MessagesClient messages() { @@ -158,10 +222,18 @@ public PhoneCallRedirectsClient phoneCallRedirects() { return this.phoneCallRedirectsClient.get(); } + public CallsClient calls() { + return this.callsClient.get(); + } + public TeamsClient teams() { return this.teamsClient.get(); } + public TicketStatesClient ticketStates() { + return this.ticketStatesClient.get(); + } + public TicketTypesClient ticketTypes() { return this.ticketTypesClient.get(); } diff --git a/src/main/java/com/intercom/api/core/ApiVersion.java b/src/main/java/com/intercom/api/core/ApiVersion.java index e0f2c7b..86f308c 100644 --- a/src/main/java/com/intercom/api/core/ApiVersion.java +++ b/src/main/java/com/intercom/api/core/ApiVersion.java @@ -9,6 +9,8 @@ public final class ApiVersion { public static final ApiVersion _2_1 = new ApiVersion(Value._2_1, "2.1"); + public static final ApiVersion _2_14 = new ApiVersion(Value._2_14, "2.14"); + public static final ApiVersion _2_2 = new ApiVersion(Value._2_2, "2.2"); public static final ApiVersion _1_0 = new ApiVersion(Value._1_0, "1.0"); @@ -41,8 +43,12 @@ public final class ApiVersion { public static final ApiVersion UNSTABLE = new ApiVersion(Value.UNSTABLE, "Unstable"); + public static final ApiVersion _2_12 = new ApiVersion(Value._2_12, "2.12"); + public static final ApiVersion _2_0 = new ApiVersion(Value._2_0, "2.0"); + public static final ApiVersion _2_13 = new ApiVersion(Value._2_13, "2.13"); + private final Value value; private final String string; @@ -76,6 +82,8 @@ public T visit(Visitor visitor) { switch (value) { case _2_1: return visitor.visit_21(); + case _2_14: + return visitor.visit_214(); case _2_2: return visitor.visit_22(); case _1_0: @@ -108,8 +116,12 @@ public T visit(Visitor visitor) { return visitor.visit_211(); case UNSTABLE: return visitor.visitUnstable(); + case _2_12: + return visitor.visit_212(); case _2_0: return visitor.visit_20(); + case _2_13: + return visitor.visit_213(); case UNKNOWN: default: return visitor.visitUnknown(string); @@ -121,6 +133,8 @@ public static ApiVersion valueOf(String value) { switch (value) { case "2.1": return _2_1; + case "2.14": + return _2_14; case "2.2": return _2_2; case "1.0": @@ -153,8 +167,12 @@ public static ApiVersion valueOf(String value) { return _2_11; case "Unstable": return UNSTABLE; + case "2.12": + return _2_12; case "2.0": return _2_0; + case "2.13": + return _2_13; default: return new ApiVersion(Value.UNKNOWN, value); } @@ -195,6 +213,12 @@ public enum Value { _2_11, + _2_12, + + _2_13, + + _2_14, + UNSTABLE, UNKNOWN @@ -235,6 +259,12 @@ public interface Visitor { T visit_211(); + T visit_212(); + + T visit_213(); + + T visit_214(); + T visitUnstable(); T visitUnknown(String unknownType); diff --git a/src/main/java/com/intercom/api/core/ClientOptions.java b/src/main/java/com/intercom/api/core/ClientOptions.java index 4c66e52..2544043 100644 --- a/src/main/java/com/intercom/api/core/ClientOptions.java +++ b/src/main/java/com/intercom/api/core/ClientOptions.java @@ -27,7 +27,7 @@ public final class ClientOptions { private final ApiVersion version; /** - * @param version Defaults to "2.11" if empty + * @param version Defaults to "2.14" if empty */ private ClientOptions( Environment environment, @@ -41,16 +41,16 @@ private ClientOptions( this.headers.putAll(headers); this.headers.putAll(new HashMap() { { - put("User-Agent", "io.intercom:intercom-java/3.0.0"); + put("User-Agent", "io.intercom:intercom-java/3.1.0"); put("X-Fern-Language", "JAVA"); put("X-Fern-SDK-Name", "com.intercom.fern:api-sdk"); - put("X-Fern-SDK-Version", "3.0.0"); + put("X-Fern-SDK-Version", "3.1.0"); } }); this.headerSuppliers = headerSuppliers; this.httpClient = httpClient; this.timeout = timeout; - this.version = version.orElse(ApiVersion._2_11); + this.version = version.orElse(ApiVersion._2_14); this.headers.put("Intercom-Version", this.version.toString()); } diff --git a/src/main/java/com/intercom/api/errors/TooManyRequestsError.java b/src/main/java/com/intercom/api/errors/TooManyRequestsError.java new file mode 100644 index 0000000..f6dc658 --- /dev/null +++ b/src/main/java/com/intercom/api/errors/TooManyRequestsError.java @@ -0,0 +1,33 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.errors; + +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.types.Error; +import okhttp3.Response; + +public final class TooManyRequestsError extends IntercomApiException { + /** + * The body of the response that triggered the exception. + */ + private final Error body; + + public TooManyRequestsError(Error body) { + super("TooManyRequestsError", 429, body); + this.body = body; + } + + public TooManyRequestsError(Error body, Response rawResponse) { + super("TooManyRequestsError", 429, body, rawResponse); + this.body = body; + } + + /** + * @return the body + */ + @java.lang.Override + public Error body() { + return this.body; + } +} diff --git a/src/main/java/com/intercom/api/resources/admins/AdminsClient.java b/src/main/java/com/intercom/api/resources/admins/AdminsClient.java index bc494a2..702eb09 100644 --- a/src/main/java/com/intercom/api/resources/admins/AdminsClient.java +++ b/src/main/java/com/intercom/api/resources/admins/AdminsClient.java @@ -12,6 +12,7 @@ import com.intercom.api.types.ActivityLogList; import com.intercom.api.types.AdminList; import com.intercom.api.types.AdminWithApp; +import java.util.Optional; public class AdminsClient { protected final ClientOptions clientOptions; @@ -37,7 +38,7 @@ public RawAdminsClient withRawResponse() { *

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.

* */ - public AdminWithApp identify() { + public Optional identify() { return this.rawClient.identify().body(); } @@ -48,21 +49,21 @@ public AdminWithApp identify() { *

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.

* */ - public AdminWithApp identify(RequestOptions requestOptions) { + public Optional identify(RequestOptions requestOptions) { return this.rawClient.identify(requestOptions).body(); } /** * You can set an Admin as away for the Inbox. */ - public Admin away(ConfigureAwayAdminRequest request) { + public Optional away(ConfigureAwayAdminRequest request) { return this.rawClient.away(request).body(); } /** * You can set an Admin as away for the Inbox. */ - public Admin away(ConfigureAwayAdminRequest request, RequestOptions requestOptions) { + public Optional away(ConfigureAwayAdminRequest request, RequestOptions requestOptions) { return this.rawClient.away(request, requestOptions).body(); } @@ -97,14 +98,14 @@ public AdminList list(RequestOptions requestOptions) { /** * You can retrieve the details of a single admin. */ - public Admin find(FindAdminRequest request) { + public Optional find(FindAdminRequest request) { return this.rawClient.find(request).body(); } /** * You can retrieve the details of a single admin. */ - public Admin find(FindAdminRequest request, RequestOptions requestOptions) { + public Optional find(FindAdminRequest request, RequestOptions requestOptions) { return this.rawClient.find(request, requestOptions).body(); } } diff --git a/src/main/java/com/intercom/api/resources/admins/AsyncAdminsClient.java b/src/main/java/com/intercom/api/resources/admins/AsyncAdminsClient.java index 6a00a05..f06b0ab 100644 --- a/src/main/java/com/intercom/api/resources/admins/AsyncAdminsClient.java +++ b/src/main/java/com/intercom/api/resources/admins/AsyncAdminsClient.java @@ -12,6 +12,7 @@ import com.intercom.api.types.ActivityLogList; import com.intercom.api.types.AdminList; import com.intercom.api.types.AdminWithApp; +import java.util.Optional; import java.util.concurrent.CompletableFuture; public class AsyncAdminsClient { @@ -38,7 +39,7 @@ public AsyncRawAdminsClient withRawResponse() { *

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.

* */ - public CompletableFuture identify() { + public CompletableFuture> identify() { return this.rawClient.identify().thenApply(response -> response.body()); } @@ -49,21 +50,21 @@ public CompletableFuture identify() { *

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.

* */ - public CompletableFuture identify(RequestOptions requestOptions) { + public CompletableFuture> identify(RequestOptions requestOptions) { return this.rawClient.identify(requestOptions).thenApply(response -> response.body()); } /** * You can set an Admin as away for the Inbox. */ - public CompletableFuture away(ConfigureAwayAdminRequest request) { + public CompletableFuture> away(ConfigureAwayAdminRequest request) { return this.rawClient.away(request).thenApply(response -> response.body()); } /** * You can set an Admin as away for the Inbox. */ - public CompletableFuture away(ConfigureAwayAdminRequest request, RequestOptions requestOptions) { + public CompletableFuture> away(ConfigureAwayAdminRequest request, RequestOptions requestOptions) { return this.rawClient.away(request, requestOptions).thenApply(response -> response.body()); } @@ -99,14 +100,14 @@ public CompletableFuture list(RequestOptions requestOptions) { /** * You can retrieve the details of a single admin. */ - public CompletableFuture find(FindAdminRequest request) { + public CompletableFuture> find(FindAdminRequest request) { return this.rawClient.find(request).thenApply(response -> response.body()); } /** * You can retrieve the details of a single admin. */ - public CompletableFuture find(FindAdminRequest request, RequestOptions requestOptions) { + public CompletableFuture> find(FindAdminRequest request, RequestOptions requestOptions) { return this.rawClient.find(request, requestOptions).thenApply(response -> response.body()); } } diff --git a/src/main/java/com/intercom/api/resources/admins/AsyncRawAdminsClient.java b/src/main/java/com/intercom/api/resources/admins/AsyncRawAdminsClient.java index 91b3115..11d7989 100644 --- a/src/main/java/com/intercom/api/resources/admins/AsyncRawAdminsClient.java +++ b/src/main/java/com/intercom/api/resources/admins/AsyncRawAdminsClient.java @@ -4,6 +4,7 @@ package com.intercom.api.resources.admins; import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; import com.intercom.api.core.ClientOptions; import com.intercom.api.core.IntercomApiException; import com.intercom.api.core.IntercomException; @@ -12,6 +13,7 @@ import com.intercom.api.core.ObjectMappers; import com.intercom.api.core.QueryStringMapper; import com.intercom.api.core.RequestOptions; +import com.intercom.api.errors.BadRequestError; import com.intercom.api.errors.NotFoundError; import com.intercom.api.errors.UnauthorizedError; import com.intercom.api.resources.admins.requests.ConfigureAwayAdminRequest; @@ -23,6 +25,7 @@ import com.intercom.api.types.AdminWithApp; import com.intercom.api.types.Error; import java.io.IOException; +import java.util.Optional; import java.util.concurrent.CompletableFuture; import okhttp3.Call; import okhttp3.Callback; @@ -49,7 +52,7 @@ public AsyncRawAdminsClient(ClientOptions clientOptions) { *

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.

* */ - public CompletableFuture> identify() { + public CompletableFuture>> identify() { return identify(null); } @@ -60,7 +63,7 @@ public CompletableFuture> identify() { *

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.

* */ - public CompletableFuture> identify(RequestOptions requestOptions) { + public CompletableFuture>> identify(RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("me") @@ -76,14 +79,15 @@ public CompletableFuture> identify(RequestOpt if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } - CompletableFuture> future = new CompletableFuture<>(); + CompletableFuture>> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AdminWithApp.class), + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), response)); return; } @@ -110,19 +114,19 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { /** * You can set an Admin as away for the Inbox. */ - public CompletableFuture> away(ConfigureAwayAdminRequest request) { + public CompletableFuture>> away(ConfigureAwayAdminRequest request) { return away(request, null); } /** * You can set an Admin as away for the Inbox. */ - public CompletableFuture> away( + public CompletableFuture>> away( ConfigureAwayAdminRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("admins") - .addPathSegment(request.getAdminId()) + .addPathSegment(Integer.toString(request.getAdminId())) .addPathSegments("away") .build(); RequestBody body; @@ -143,19 +147,26 @@ public CompletableFuture> away( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } - CompletableFuture> future = new CompletableFuture<>(); + CompletableFuture>> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Admin.class), response)); + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response)); return; } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; case 401: future.completeExceptionally(new UnauthorizedError( ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), @@ -329,19 +340,19 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { /** * You can retrieve the details of a single admin. */ - public CompletableFuture> find(FindAdminRequest request) { + public CompletableFuture>> find(FindAdminRequest request) { return find(request, null); } /** * You can retrieve the details of a single admin. */ - public CompletableFuture> find( + public CompletableFuture>> find( FindAdminRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("admins") - .addPathSegment(request.getAdminId()) + .addPathSegment(Integer.toString(request.getAdminId())) .build(); Request.Builder _requestBuilder = new Request.Builder() .url(httpUrl) @@ -354,14 +365,16 @@ public CompletableFuture> find( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } - CompletableFuture> future = new CompletableFuture<>(); + CompletableFuture>> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Admin.class), response)); + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response)); return; } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; diff --git a/src/main/java/com/intercom/api/resources/admins/RawAdminsClient.java b/src/main/java/com/intercom/api/resources/admins/RawAdminsClient.java index e34c4c2..9c53e89 100644 --- a/src/main/java/com/intercom/api/resources/admins/RawAdminsClient.java +++ b/src/main/java/com/intercom/api/resources/admins/RawAdminsClient.java @@ -4,6 +4,7 @@ package com.intercom.api.resources.admins; import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; import com.intercom.api.core.ClientOptions; import com.intercom.api.core.IntercomApiException; import com.intercom.api.core.IntercomException; @@ -12,6 +13,7 @@ import com.intercom.api.core.ObjectMappers; import com.intercom.api.core.QueryStringMapper; import com.intercom.api.core.RequestOptions; +import com.intercom.api.errors.BadRequestError; import com.intercom.api.errors.NotFoundError; import com.intercom.api.errors.UnauthorizedError; import com.intercom.api.resources.admins.requests.ConfigureAwayAdminRequest; @@ -23,6 +25,7 @@ import com.intercom.api.types.AdminWithApp; import com.intercom.api.types.Error; import java.io.IOException; +import java.util.Optional; import okhttp3.Headers; import okhttp3.HttpUrl; import okhttp3.OkHttpClient; @@ -45,7 +48,7 @@ public RawAdminsClient(ClientOptions clientOptions) { *

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.

* */ - public IntercomHttpResponse identify() { + public IntercomHttpResponse> identify() { return identify(null); } @@ -56,7 +59,7 @@ public IntercomHttpResponse identify() { *

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.

* */ - public IntercomHttpResponse identify(RequestOptions requestOptions) { + public IntercomHttpResponse> identify(RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("me") @@ -76,7 +79,9 @@ public IntercomHttpResponse identify(RequestOptions requestOptions ResponseBody responseBody = response.body(); if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AdminWithApp.class), response); + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; throw new IntercomApiException( @@ -92,18 +97,19 @@ public IntercomHttpResponse identify(RequestOptions requestOptions /** * You can set an Admin as away for the Inbox. */ - public IntercomHttpResponse away(ConfigureAwayAdminRequest request) { + public IntercomHttpResponse> away(ConfigureAwayAdminRequest request) { return away(request, null); } /** * You can set an Admin as away for the Inbox. */ - public IntercomHttpResponse away(ConfigureAwayAdminRequest request, RequestOptions requestOptions) { + public IntercomHttpResponse> away( + ConfigureAwayAdminRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("admins") - .addPathSegment(request.getAdminId()) + .addPathSegment(Integer.toString(request.getAdminId())) .addPathSegments("away") .build(); RequestBody body; @@ -128,11 +134,16 @@ public IntercomHttpResponse away(ConfigureAwayAdminRequest request, Reque ResponseBody responseBody = response.body(); if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Admin.class), response); + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); case 401: throw new UnauthorizedError( ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); @@ -263,18 +274,18 @@ public IntercomHttpResponse list(RequestOptions requestOptions) { /** * You can retrieve the details of a single admin. */ - public IntercomHttpResponse find(FindAdminRequest request) { + public IntercomHttpResponse> find(FindAdminRequest request) { return find(request, null); } /** * You can retrieve the details of a single admin. */ - public IntercomHttpResponse find(FindAdminRequest request, RequestOptions requestOptions) { + public IntercomHttpResponse> find(FindAdminRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("admins") - .addPathSegment(request.getAdminId()) + .addPathSegment(Integer.toString(request.getAdminId())) .build(); Request.Builder _requestBuilder = new Request.Builder() .url(httpUrl) @@ -291,7 +302,9 @@ public IntercomHttpResponse find(FindAdminRequest request, RequestOptions ResponseBody responseBody = response.body(); if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Admin.class), response); + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { diff --git a/src/main/java/com/intercom/api/resources/admins/requests/ConfigureAwayAdminRequest.java b/src/main/java/com/intercom/api/resources/admins/requests/ConfigureAwayAdminRequest.java index bd7c8f1..cb5911e 100644 --- a/src/main/java/com/intercom/api/resources/admins/requests/ConfigureAwayAdminRequest.java +++ b/src/main/java/com/intercom/api/resources/admins/requests/ConfigureAwayAdminRequest.java @@ -9,32 +9,37 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.intercom.api.core.ObjectMappers; import java.util.HashMap; import java.util.Map; import java.util.Objects; -import org.jetbrains.annotations.NotNull; +import java.util.Optional; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ConfigureAwayAdminRequest.Builder.class) public final class ConfigureAwayAdminRequest { - private final String adminId; + private final int adminId; private final boolean awayModeEnabled; private final boolean awayModeReassign; + private final Optional awayStatusReasonId; + private final Map additionalProperties; private ConfigureAwayAdminRequest( - String adminId, + int adminId, boolean awayModeEnabled, boolean awayModeReassign, + Optional awayStatusReasonId, Map additionalProperties) { this.adminId = adminId; this.awayModeEnabled = awayModeEnabled; this.awayModeReassign = awayModeReassign; + this.awayStatusReasonId = awayStatusReasonId; this.additionalProperties = additionalProperties; } @@ -42,7 +47,7 @@ private ConfigureAwayAdminRequest( * @return The unique identifier of a given admin */ @JsonProperty("admin_id") - public String getAdminId() { + public int getAdminId() { return adminId; } @@ -62,6 +67,14 @@ public boolean getAwayModeReassign() { return awayModeReassign; } + /** + * @return The unique identifier of the away status reason + */ + @JsonProperty("away_status_reason_id") + public Optional getAwayStatusReasonId() { + return awayStatusReasonId; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -74,14 +87,15 @@ public Map getAdditionalProperties() { } private boolean equalTo(ConfigureAwayAdminRequest other) { - return adminId.equals(other.adminId) + return adminId == other.adminId && awayModeEnabled == other.awayModeEnabled - && awayModeReassign == other.awayModeReassign; + && awayModeReassign == other.awayModeReassign + && awayStatusReasonId.equals(other.awayStatusReasonId); } @java.lang.Override public int hashCode() { - return Objects.hash(this.adminId, this.awayModeEnabled, this.awayModeReassign); + return Objects.hash(this.adminId, this.awayModeEnabled, this.awayModeReassign, this.awayStatusReasonId); } @java.lang.Override @@ -97,7 +111,7 @@ public interface AdminIdStage { /** * The unique identifier of a given admin */ - AwayModeEnabledStage adminId(@NotNull String adminId); + AwayModeEnabledStage adminId(int adminId); Builder from(ConfigureAwayAdminRequest other); } @@ -118,17 +132,26 @@ public interface AwayModeReassignStage { public interface _FinalStage { ConfigureAwayAdminRequest build(); + + /** + *

The unique identifier of the away status reason

+ */ + _FinalStage awayStatusReasonId(Optional awayStatusReasonId); + + _FinalStage awayStatusReasonId(Integer awayStatusReasonId); } @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements AdminIdStage, AwayModeEnabledStage, AwayModeReassignStage, _FinalStage { - private String adminId; + private int adminId; private boolean awayModeEnabled; private boolean awayModeReassign; + private Optional awayStatusReasonId = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -139,6 +162,7 @@ public Builder from(ConfigureAwayAdminRequest other) { adminId(other.getAdminId()); awayModeEnabled(other.getAwayModeEnabled()); awayModeReassign(other.getAwayModeReassign()); + awayStatusReasonId(other.getAwayStatusReasonId()); return this; } @@ -148,8 +172,8 @@ public Builder from(ConfigureAwayAdminRequest other) { */ @java.lang.Override @JsonSetter("admin_id") - public AwayModeEnabledStage adminId(@NotNull String adminId) { - this.adminId = Objects.requireNonNull(adminId, "adminId must not be null"); + public AwayModeEnabledStage adminId(int adminId) { + this.adminId = adminId; return this; } @@ -175,9 +199,30 @@ public _FinalStage awayModeReassign(boolean awayModeReassign) { return this; } + /** + *

The unique identifier of the away status reason

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage awayStatusReasonId(Integer awayStatusReasonId) { + this.awayStatusReasonId = Optional.ofNullable(awayStatusReasonId); + return this; + } + + /** + *

The unique identifier of the away status reason

+ */ + @java.lang.Override + @JsonSetter(value = "away_status_reason_id", nulls = Nulls.SKIP) + public _FinalStage awayStatusReasonId(Optional awayStatusReasonId) { + this.awayStatusReasonId = awayStatusReasonId; + return this; + } + @java.lang.Override public ConfigureAwayAdminRequest build() { - return new ConfigureAwayAdminRequest(adminId, awayModeEnabled, awayModeReassign, additionalProperties); + return new ConfigureAwayAdminRequest( + adminId, awayModeEnabled, awayModeReassign, awayStatusReasonId, additionalProperties); } } } diff --git a/src/main/java/com/intercom/api/resources/admins/requests/FindAdminRequest.java b/src/main/java/com/intercom/api/resources/admins/requests/FindAdminRequest.java index c843ffb..ff3f1dd 100644 --- a/src/main/java/com/intercom/api/resources/admins/requests/FindAdminRequest.java +++ b/src/main/java/com/intercom/api/resources/admins/requests/FindAdminRequest.java @@ -14,16 +14,15 @@ import java.util.HashMap; import java.util.Map; import java.util.Objects; -import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = FindAdminRequest.Builder.class) public final class FindAdminRequest { - private final String adminId; + private final int adminId; private final Map additionalProperties; - private FindAdminRequest(String adminId, Map additionalProperties) { + private FindAdminRequest(int adminId, Map additionalProperties) { this.adminId = adminId; this.additionalProperties = additionalProperties; } @@ -32,7 +31,7 @@ private FindAdminRequest(String adminId, Map additionalPropertie * @return The unique identifier of a given admin */ @JsonProperty("admin_id") - public String getAdminId() { + public int getAdminId() { return adminId; } @@ -48,7 +47,7 @@ public Map getAdditionalProperties() { } private boolean equalTo(FindAdminRequest other) { - return adminId.equals(other.adminId); + return adminId == other.adminId; } @java.lang.Override @@ -69,7 +68,7 @@ public interface AdminIdStage { /** * The unique identifier of a given admin */ - _FinalStage adminId(@NotNull String adminId); + _FinalStage adminId(int adminId); Builder from(FindAdminRequest other); } @@ -80,7 +79,7 @@ public interface _FinalStage { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements AdminIdStage, _FinalStage { - private String adminId; + private int adminId; @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -99,8 +98,8 @@ public Builder from(FindAdminRequest other) { */ @java.lang.Override @JsonSetter("admin_id") - public _FinalStage adminId(@NotNull String adminId) { - this.adminId = Objects.requireNonNull(adminId, "adminId must not be null"); + public _FinalStage adminId(int adminId) { + this.adminId = adminId; return this; } diff --git a/src/main/java/com/intercom/api/resources/admins/types/Admin.java b/src/main/java/com/intercom/api/resources/admins/types/Admin.java index 74e3849..07eb6e1 100644 --- a/src/main/java/com/intercom/api/resources/admins/types/Admin.java +++ b/src/main/java/com/intercom/api/resources/admins/types/Admin.java @@ -32,17 +32,19 @@ public final class Admin { private final String email; - private final String jobTitle; + private final Optional jobTitle; private final boolean awayModeEnabled; private final boolean awayModeReassign; + private final Optional awayStatusReasonId; + private final boolean hasInboxSeat; private final List teamIds; - private final Optional avatar; + private final Optional avatar; private final Optional teamPriorityLevel; @@ -53,12 +55,13 @@ private Admin( String id, String name, String email, - String jobTitle, + Optional jobTitle, boolean awayModeEnabled, boolean awayModeReassign, + Optional awayStatusReasonId, boolean hasInboxSeat, List teamIds, - Optional avatar, + Optional avatar, Optional teamPriorityLevel, Map additionalProperties) { this.type = type; @@ -68,6 +71,7 @@ private Admin( this.jobTitle = jobTitle; this.awayModeEnabled = awayModeEnabled; this.awayModeReassign = awayModeReassign; + this.awayStatusReasonId = awayStatusReasonId; this.hasInboxSeat = hasInboxSeat; this.teamIds = teamIds; this.avatar = avatar; @@ -111,7 +115,7 @@ public String getEmail() { * @return The job title of the admin. */ @JsonProperty("job_title") - public String getJobTitle() { + public Optional getJobTitle() { return jobTitle; } @@ -131,6 +135,14 @@ public boolean getAwayModeReassign() { return awayModeReassign; } + /** + * @return The unique identifier of the away status reason + */ + @JsonProperty("away_status_reason_id") + public Optional getAwayStatusReasonId() { + return awayStatusReasonId; + } + /** * @return Identifies if this admin has a paid inbox seat to restrict/allow features that require them. */ @@ -148,10 +160,10 @@ public List getTeamIds() { } /** - * @return The avatar object associated with the admin + * @return Image for the associated team or teammate */ @JsonProperty("avatar") - public Optional getAvatar() { + public Optional getAvatar() { return avatar; } @@ -179,6 +191,7 @@ private boolean equalTo(Admin other) { && jobTitle.equals(other.jobTitle) && awayModeEnabled == other.awayModeEnabled && awayModeReassign == other.awayModeReassign + && awayStatusReasonId.equals(other.awayStatusReasonId) && hasInboxSeat == other.hasInboxSeat && teamIds.equals(other.teamIds) && avatar.equals(other.avatar) @@ -195,6 +208,7 @@ public int hashCode() { this.jobTitle, this.awayModeEnabled, this.awayModeReassign, + this.awayStatusReasonId, this.hasInboxSeat, this.teamIds, this.avatar, @@ -230,14 +244,7 @@ public interface EmailStage { /** * The email of the admin. */ - JobTitleStage email(@NotNull String email); - } - - public interface JobTitleStage { - /** - * The job title of the admin. - */ - AwayModeEnabledStage jobTitle(@NotNull String jobTitle); + AwayModeEnabledStage email(@NotNull String email); } public interface AwayModeEnabledStage { @@ -271,6 +278,20 @@ public interface _FinalStage { _FinalStage type(String type); + /** + *

The job title of the admin.

+ */ + _FinalStage jobTitle(Optional jobTitle); + + _FinalStage jobTitle(String jobTitle); + + /** + *

The unique identifier of the away status reason

+ */ + _FinalStage awayStatusReasonId(Optional awayStatusReasonId); + + _FinalStage awayStatusReasonId(Integer awayStatusReasonId); + /** *

This object represents the avatar associated with the admin.

*/ @@ -281,11 +302,11 @@ public interface _FinalStage { _FinalStage addAllTeamIds(List teamIds); /** - *

The avatar object associated with the admin

+ *

Image for the associated team or teammate

*/ - _FinalStage avatar(Optional avatar); + _FinalStage avatar(Optional avatar); - _FinalStage avatar(Avatar avatar); + _FinalStage avatar(String avatar); _FinalStage teamPriorityLevel(Optional teamPriorityLevel); @@ -297,7 +318,6 @@ public static final class Builder implements IdStage, NameStage, EmailStage, - JobTitleStage, AwayModeEnabledStage, AwayModeReassignStage, HasInboxSeatStage, @@ -308,8 +328,6 @@ public static final class Builder private String email; - private String jobTitle; - private boolean awayModeEnabled; private boolean awayModeReassign; @@ -318,10 +336,14 @@ public static final class Builder private Optional teamPriorityLevel = Optional.empty(); - private Optional avatar = Optional.empty(); + private Optional avatar = Optional.empty(); private List teamIds = new ArrayList<>(); + private Optional awayStatusReasonId = Optional.empty(); + + private Optional jobTitle = Optional.empty(); + private Optional type = Optional.empty(); @JsonAnySetter @@ -338,6 +360,7 @@ public Builder from(Admin other) { jobTitle(other.getJobTitle()); awayModeEnabled(other.getAwayModeEnabled()); awayModeReassign(other.getAwayModeReassign()); + awayStatusReasonId(other.getAwayStatusReasonId()); hasInboxSeat(other.getHasInboxSeat()); teamIds(other.getTeamIds()); avatar(other.getAvatar()); @@ -373,22 +396,11 @@ public EmailStage name(@NotNull String name) { */ @java.lang.Override @JsonSetter("email") - public JobTitleStage email(@NotNull String email) { + public AwayModeEnabledStage email(@NotNull String email) { this.email = Objects.requireNonNull(email, "email must not be null"); return this; } - /** - * The job title of the admin.

The job title of the admin.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("job_title") - public AwayModeEnabledStage jobTitle(@NotNull String jobTitle) { - this.jobTitle = Objects.requireNonNull(jobTitle, "jobTitle must not be null"); - return this; - } - /** * Identifies if this admin is currently set in away mode.

Identifies if this admin is currently set in away mode.

* @return Reference to {@code this} so that method calls can be chained together. @@ -436,21 +448,21 @@ public _FinalStage teamPriorityLevel(Optional teamPriorityLev } /** - *

The avatar object associated with the admin

+ *

Image for the associated team or teammate

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override - public _FinalStage avatar(Avatar avatar) { + public _FinalStage avatar(String avatar) { this.avatar = Optional.ofNullable(avatar); return this; } /** - *

The avatar object associated with the admin

+ *

Image for the associated team or teammate

*/ @java.lang.Override @JsonSetter(value = "avatar", nulls = Nulls.SKIP) - public _FinalStage avatar(Optional avatar) { + public _FinalStage avatar(Optional avatar) { this.avatar = avatar; return this; } @@ -486,6 +498,46 @@ public _FinalStage teamIds(List teamIds) { return this; } + /** + *

The unique identifier of the away status reason

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage awayStatusReasonId(Integer awayStatusReasonId) { + this.awayStatusReasonId = Optional.ofNullable(awayStatusReasonId); + return this; + } + + /** + *

The unique identifier of the away status reason

+ */ + @java.lang.Override + @JsonSetter(value = "away_status_reason_id", nulls = Nulls.SKIP) + public _FinalStage awayStatusReasonId(Optional awayStatusReasonId) { + this.awayStatusReasonId = awayStatusReasonId; + return this; + } + + /** + *

The job title of the admin.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage jobTitle(String jobTitle) { + this.jobTitle = Optional.ofNullable(jobTitle); + return this; + } + + /** + *

The job title of the admin.

+ */ + @java.lang.Override + @JsonSetter(value = "job_title", nulls = Nulls.SKIP) + public _FinalStage jobTitle(Optional jobTitle) { + this.jobTitle = jobTitle; + return this; + } + /** *

String representing the object's type. Always has the value admin.

* @return Reference to {@code this} so that method calls can be chained together. @@ -516,6 +568,7 @@ public Admin build() { jobTitle, awayModeEnabled, awayModeReassign, + awayStatusReasonId, hasInboxSeat, teamIds, avatar, @@ -523,99 +576,4 @@ public Admin build() { additionalProperties); } } - - @JsonInclude(JsonInclude.Include.NON_ABSENT) - @JsonDeserialize(builder = Avatar.Builder.class) - public static final class Avatar { - private final String imageUrl; - - private final Map additionalProperties; - - private Avatar(String imageUrl, Map additionalProperties) { - this.imageUrl = imageUrl; - this.additionalProperties = additionalProperties; - } - - /** - * @return URL of the admin's avatar image - */ - @JsonProperty("image_url") - public String getImageUrl() { - return imageUrl; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Avatar && equalTo((Avatar) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(Avatar other) { - return imageUrl.equals(other.imageUrl); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.imageUrl); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static ImageUrlStage builder() { - return new Builder(); - } - - public interface ImageUrlStage { - /** - * URL of the admin's avatar image - */ - _FinalStage imageUrl(@NotNull String imageUrl); - - Builder from(Avatar other); - } - - public interface _FinalStage { - Avatar build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements ImageUrlStage, _FinalStage { - private String imageUrl; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(Avatar other) { - imageUrl(other.getImageUrl()); - return this; - } - - /** - * URL of the admin's avatar image

URL of the admin's avatar image

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("image_url") - public _FinalStage imageUrl(@NotNull String imageUrl) { - this.imageUrl = Objects.requireNonNull(imageUrl, "imageUrl must not be null"); - return this; - } - - @java.lang.Override - public Avatar build() { - return new Avatar(imageUrl, additionalProperties); - } - } - } } diff --git a/src/main/java/com/intercom/api/resources/aiagent/types/AiAgent.java b/src/main/java/com/intercom/api/resources/aiagent/types/AiAgent.java index 75995d7..ccae6bc 100644 --- a/src/main/java/com/intercom/api/resources/aiagent/types/AiAgent.java +++ b/src/main/java/com/intercom/api/resources/aiagent/types/AiAgent.java @@ -19,12 +19,11 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; -import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = AiAgent.Builder.class) public final class AiAgent { - private final SourceType sourceType; + private final Optional sourceType; private final Optional sourceTitle; @@ -36,17 +35,23 @@ public final class AiAgent { private final Optional ratingRemark; + private final Optional createdAt; + + private final Optional updatedAt; + private final Optional contentSources; private final Map additionalProperties; private AiAgent( - SourceType sourceType, + Optional sourceType, Optional sourceTitle, Optional lastAnswerType, Optional resolutionState, Optional rating, Optional ratingRemark, + Optional createdAt, + Optional updatedAt, Optional contentSources, Map additionalProperties) { this.sourceType = sourceType; @@ -55,6 +60,8 @@ private AiAgent( this.resolutionState = resolutionState; this.rating = rating; this.ratingRemark = ratingRemark; + this.createdAt = createdAt; + this.updatedAt = updatedAt; this.contentSources = contentSources; this.additionalProperties = additionalProperties; } @@ -63,7 +70,7 @@ private AiAgent( * @return The type of the source that triggered AI Agent involvement in the conversation. */ @JsonProperty("source_type") - public SourceType getSourceType() { + public Optional getSourceType() { return sourceType; } @@ -107,6 +114,22 @@ public Optional getRatingRemark() { return ratingRemark; } + /** + * @return The time when the AI agent rating was created. + */ + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + /** + * @return The time when the AI agent rating was last updated. + */ + @JsonProperty("updated_at") + public Optional getUpdatedAt() { + return updatedAt; + } + @JsonProperty("content_sources") public Optional getContentSources() { return contentSources; @@ -130,6 +153,8 @@ private boolean equalTo(AiAgent other) { && resolutionState.equals(other.resolutionState) && rating.equals(other.rating) && ratingRemark.equals(other.ratingRemark) + && createdAt.equals(other.createdAt) + && updatedAt.equals(other.updatedAt) && contentSources.equals(other.contentSources); } @@ -142,6 +167,8 @@ public int hashCode() { this.resolutionState, this.rating, this.ratingRemark, + this.createdAt, + this.updatedAt, this.contentSources); } @@ -150,84 +177,35 @@ public String toString() { return ObjectMappers.stringify(this); } - public static SourceTypeStage builder() { + public static Builder builder() { return new Builder(); } - public interface SourceTypeStage { - /** - * The type of the source that triggered AI Agent involvement in the conversation. - */ - _FinalStage sourceType(@NotNull SourceType sourceType); - - Builder from(AiAgent other); - } - - public interface _FinalStage { - AiAgent build(); - - /** - *

The title of the source that triggered AI Agent involvement in the conversation. If this is essentials_plan_setup then it will return null.

- */ - _FinalStage sourceTitle(Optional sourceTitle); - - _FinalStage sourceTitle(String sourceTitle); - - /** - *

The type of the last answer delivered by AI Agent. If no answer was delivered then this will return null

- */ - _FinalStage lastAnswerType(Optional lastAnswerType); - - _FinalStage lastAnswerType(String lastAnswerType); - - /** - *

The resolution state of AI Agent. If no AI or custom answer has been delivered then this will return null.

- */ - _FinalStage resolutionState(Optional resolutionState); - - _FinalStage resolutionState(String resolutionState); - - /** - *

The customer satisfaction rating given to AI Agent, from 1-5.

- */ - _FinalStage rating(Optional rating); - - _FinalStage rating(Integer rating); - - /** - *

The customer satisfaction rating remark given to AI Agent.

- */ - _FinalStage ratingRemark(Optional ratingRemark); - - _FinalStage ratingRemark(String ratingRemark); + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional sourceType = Optional.empty(); - _FinalStage contentSources(Optional contentSources); + private Optional sourceTitle = Optional.empty(); - _FinalStage contentSources(ContentSourcesList contentSources); - } + private Optional lastAnswerType = Optional.empty(); - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements SourceTypeStage, _FinalStage { - private SourceType sourceType; + private Optional resolutionState = Optional.empty(); - private Optional contentSources = Optional.empty(); + private Optional rating = Optional.empty(); private Optional ratingRemark = Optional.empty(); - private Optional rating = Optional.empty(); + private Optional createdAt = Optional.empty(); - private Optional resolutionState = Optional.empty(); - - private Optional lastAnswerType = Optional.empty(); + private Optional updatedAt = Optional.empty(); - private Optional sourceTitle = Optional.empty(); + private Optional contentSources = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} - @java.lang.Override public Builder from(AiAgent other) { sourceType(other.getSourceType()); sourceTitle(other.getSourceTitle()); @@ -235,135 +213,135 @@ public Builder from(AiAgent other) { resolutionState(other.getResolutionState()); rating(other.getRating()); ratingRemark(other.getRatingRemark()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); contentSources(other.getContentSources()); return this; } /** - * The type of the source that triggered AI Agent involvement in the conversation.

The type of the source that triggered AI Agent involvement in the conversation.

- * @return Reference to {@code this} so that method calls can be chained together. + *

The type of the source that triggered AI Agent involvement in the conversation.

*/ - @java.lang.Override - @JsonSetter("source_type") - public _FinalStage sourceType(@NotNull SourceType sourceType) { - this.sourceType = Objects.requireNonNull(sourceType, "sourceType must not be null"); + @JsonSetter(value = "source_type", nulls = Nulls.SKIP) + public Builder sourceType(Optional sourceType) { + this.sourceType = sourceType; return this; } - @java.lang.Override - public _FinalStage contentSources(ContentSourcesList contentSources) { - this.contentSources = Optional.ofNullable(contentSources); + public Builder sourceType(SourceType sourceType) { + this.sourceType = Optional.ofNullable(sourceType); return this; } - @java.lang.Override - @JsonSetter(value = "content_sources", nulls = Nulls.SKIP) - public _FinalStage contentSources(Optional contentSources) { - this.contentSources = contentSources; + /** + *

The title of the source that triggered AI Agent involvement in the conversation. If this is essentials_plan_setup then it will return null.

+ */ + @JsonSetter(value = "source_title", nulls = Nulls.SKIP) + public Builder sourceTitle(Optional sourceTitle) { + this.sourceTitle = sourceTitle; return this; } - /** - *

The customer satisfaction rating remark given to AI Agent.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage ratingRemark(String ratingRemark) { - this.ratingRemark = Optional.ofNullable(ratingRemark); + public Builder sourceTitle(String sourceTitle) { + this.sourceTitle = Optional.ofNullable(sourceTitle); return this; } /** - *

The customer satisfaction rating remark given to AI Agent.

+ *

The type of the last answer delivered by AI Agent. If no answer was delivered then this will return null

*/ - @java.lang.Override - @JsonSetter(value = "rating_remark", nulls = Nulls.SKIP) - public _FinalStage ratingRemark(Optional ratingRemark) { - this.ratingRemark = ratingRemark; + @JsonSetter(value = "last_answer_type", nulls = Nulls.SKIP) + public Builder lastAnswerType(Optional lastAnswerType) { + this.lastAnswerType = lastAnswerType; + return this; + } + + public Builder lastAnswerType(String lastAnswerType) { + this.lastAnswerType = Optional.ofNullable(lastAnswerType); return this; } /** - *

The customer satisfaction rating given to AI Agent, from 1-5.

- * @return Reference to {@code this} so that method calls can be chained together. + *

The resolution state of AI Agent. If no AI or custom answer has been delivered then this will return null.

*/ - @java.lang.Override - public _FinalStage rating(Integer rating) { - this.rating = Optional.ofNullable(rating); + @JsonSetter(value = "resolution_state", nulls = Nulls.SKIP) + public Builder resolutionState(Optional resolutionState) { + this.resolutionState = resolutionState; + return this; + } + + public Builder resolutionState(String resolutionState) { + this.resolutionState = Optional.ofNullable(resolutionState); return this; } /** *

The customer satisfaction rating given to AI Agent, from 1-5.

*/ - @java.lang.Override @JsonSetter(value = "rating", nulls = Nulls.SKIP) - public _FinalStage rating(Optional rating) { + public Builder rating(Optional rating) { this.rating = rating; return this; } - /** - *

The resolution state of AI Agent. If no AI or custom answer has been delivered then this will return null.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage resolutionState(String resolutionState) { - this.resolutionState = Optional.ofNullable(resolutionState); + public Builder rating(Integer rating) { + this.rating = Optional.ofNullable(rating); return this; } /** - *

The resolution state of AI Agent. If no AI or custom answer has been delivered then this will return null.

+ *

The customer satisfaction rating remark given to AI Agent.

*/ - @java.lang.Override - @JsonSetter(value = "resolution_state", nulls = Nulls.SKIP) - public _FinalStage resolutionState(Optional resolutionState) { - this.resolutionState = resolutionState; + @JsonSetter(value = "rating_remark", nulls = Nulls.SKIP) + public Builder ratingRemark(Optional ratingRemark) { + this.ratingRemark = ratingRemark; return this; } - /** - *

The type of the last answer delivered by AI Agent. If no answer was delivered then this will return null

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage lastAnswerType(String lastAnswerType) { - this.lastAnswerType = Optional.ofNullable(lastAnswerType); + public Builder ratingRemark(String ratingRemark) { + this.ratingRemark = Optional.ofNullable(ratingRemark); return this; } /** - *

The type of the last answer delivered by AI Agent. If no answer was delivered then this will return null

+ *

The time when the AI agent rating was created.

*/ - @java.lang.Override - @JsonSetter(value = "last_answer_type", nulls = Nulls.SKIP) - public _FinalStage lastAnswerType(Optional lastAnswerType) { - this.lastAnswerType = lastAnswerType; + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public Builder createdAt(Optional createdAt) { + this.createdAt = createdAt; return this; } - /** - *

The title of the source that triggered AI Agent involvement in the conversation. If this is essentials_plan_setup then it will return null.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage sourceTitle(String sourceTitle) { - this.sourceTitle = Optional.ofNullable(sourceTitle); + public Builder createdAt(Integer createdAt) { + this.createdAt = Optional.ofNullable(createdAt); return this; } /** - *

The title of the source that triggered AI Agent involvement in the conversation. If this is essentials_plan_setup then it will return null.

+ *

The time when the AI agent rating was last updated.

*/ - @java.lang.Override - @JsonSetter(value = "source_title", nulls = Nulls.SKIP) - public _FinalStage sourceTitle(Optional sourceTitle) { - this.sourceTitle = sourceTitle; + @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) + public Builder updatedAt(Optional updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + public Builder updatedAt(Integer updatedAt) { + this.updatedAt = Optional.ofNullable(updatedAt); + return this; + } + + @JsonSetter(value = "content_sources", nulls = Nulls.SKIP) + public Builder contentSources(Optional contentSources) { + this.contentSources = contentSources; + return this; + } + + public Builder contentSources(ContentSourcesList contentSources) { + this.contentSources = Optional.ofNullable(contentSources); return this; } - @java.lang.Override public AiAgent build() { return new AiAgent( sourceType, @@ -372,6 +350,8 @@ public AiAgent build() { resolutionState, rating, ratingRemark, + createdAt, + updatedAt, contentSources, additionalProperties); } diff --git a/src/main/java/com/intercom/api/resources/aicontent/AiContentClient.java b/src/main/java/com/intercom/api/resources/aicontent/AiContentClient.java new file mode 100644 index 0000000..495fbdf --- /dev/null +++ b/src/main/java/com/intercom/api/resources/aicontent/AiContentClient.java @@ -0,0 +1,174 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.aicontent; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.aicontent.requests.CreateContentImportSourceRequest; +import com.intercom.api.resources.aicontent.requests.CreateExternalPageRequest; +import com.intercom.api.resources.aicontent.requests.DeleteContentImportSourceRequest; +import com.intercom.api.resources.aicontent.requests.DeleteExternalPageRequest; +import com.intercom.api.resources.aicontent.requests.GetContentImportSourceRequest; +import com.intercom.api.resources.aicontent.requests.GetExternalPageRequest; +import com.intercom.api.resources.aicontent.requests.UpdateContentImportSourceRequest; +import com.intercom.api.resources.aicontent.requests.UpdateExternalPageRequest; +import com.intercom.api.resources.aicontent.types.ContentImportSource; +import com.intercom.api.resources.aicontent.types.ContentImportSourcesList; +import com.intercom.api.resources.aicontent.types.ExternalPage; +import com.intercom.api.resources.aicontent.types.ExternalPagesList; + +public class AiContentClient { + protected final ClientOptions clientOptions; + + private final RawAiContentClient rawClient; + + public AiContentClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawAiContentClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawAiContentClient withRawResponse() { + return this.rawClient; + } + + /** + * You can retrieve a list of all content import sources for a workspace. + */ + public ContentImportSourcesList listContentImportSources() { + return this.rawClient.listContentImportSources().body(); + } + + /** + * You can retrieve a list of all content import sources for a workspace. + */ + public ContentImportSourcesList listContentImportSources(RequestOptions requestOptions) { + return this.rawClient.listContentImportSources(requestOptions).body(); + } + + /** + * You can create a new content import source by sending a POST request to this endpoint. + */ + public ContentImportSource createContentImportSource(CreateContentImportSourceRequest request) { + return this.rawClient.createContentImportSource(request).body(); + } + + /** + * You can create a new content import source by sending a POST request to this endpoint. + */ + public ContentImportSource createContentImportSource( + CreateContentImportSourceRequest request, RequestOptions requestOptions) { + return this.rawClient.createContentImportSource(request, requestOptions).body(); + } + + public ContentImportSource getContentImportSource(GetContentImportSourceRequest request) { + return this.rawClient.getContentImportSource(request).body(); + } + + public ContentImportSource getContentImportSource( + GetContentImportSourceRequest request, RequestOptions requestOptions) { + return this.rawClient.getContentImportSource(request, requestOptions).body(); + } + + /** + * You can update an existing content import source. + */ + public ContentImportSource updateContentImportSource(UpdateContentImportSourceRequest request) { + return this.rawClient.updateContentImportSource(request).body(); + } + + /** + * You can update an existing content import source. + */ + public ContentImportSource updateContentImportSource( + UpdateContentImportSourceRequest request, RequestOptions requestOptions) { + return this.rawClient.updateContentImportSource(request, requestOptions).body(); + } + + /** + * 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. + */ + public void deleteContentImportSource(DeleteContentImportSourceRequest request) { + this.rawClient.deleteContentImportSource(request).body(); + } + + /** + * 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. + */ + public void deleteContentImportSource(DeleteContentImportSourceRequest request, RequestOptions requestOptions) { + this.rawClient.deleteContentImportSource(request, requestOptions).body(); + } + + /** + * You can retrieve a list of all external pages for a workspace. + */ + public ExternalPagesList listExternalPages() { + return this.rawClient.listExternalPages().body(); + } + + /** + * You can retrieve a list of all external pages for a workspace. + */ + public ExternalPagesList listExternalPages(RequestOptions requestOptions) { + return this.rawClient.listExternalPages(requestOptions).body(); + } + + /** + * 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. + */ + public ExternalPage createExternalPage(CreateExternalPageRequest request) { + return this.rawClient.createExternalPage(request).body(); + } + + /** + * 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. + */ + public ExternalPage createExternalPage(CreateExternalPageRequest request, RequestOptions requestOptions) { + return this.rawClient.createExternalPage(request, requestOptions).body(); + } + + /** + * You can retrieve an external page. + */ + public ExternalPage getExternalPage(GetExternalPageRequest request) { + return this.rawClient.getExternalPage(request).body(); + } + + /** + * You can retrieve an external page. + */ + public ExternalPage getExternalPage(GetExternalPageRequest request, RequestOptions requestOptions) { + return this.rawClient.getExternalPage(request, requestOptions).body(); + } + + /** + * You can update an existing external page (if it was created via the API). + */ + public ExternalPage updateExternalPage(UpdateExternalPageRequest request) { + return this.rawClient.updateExternalPage(request).body(); + } + + /** + * You can update an existing external page (if it was created via the API). + */ + public ExternalPage updateExternalPage(UpdateExternalPageRequest request, RequestOptions requestOptions) { + return this.rawClient.updateExternalPage(request, requestOptions).body(); + } + + /** + * Sending a DELETE request for an external page will remove it from the content library UI and from being used for AI answers. + */ + public ExternalPage deleteExternalPage(DeleteExternalPageRequest request) { + return this.rawClient.deleteExternalPage(request).body(); + } + + /** + * Sending a DELETE request for an external page will remove it from the content library UI and from being used for AI answers. + */ + public ExternalPage deleteExternalPage(DeleteExternalPageRequest request, RequestOptions requestOptions) { + return this.rawClient.deleteExternalPage(request, requestOptions).body(); + } +} diff --git a/src/main/java/com/intercom/api/resources/aicontent/AsyncAiContentClient.java b/src/main/java/com/intercom/api/resources/aicontent/AsyncAiContentClient.java new file mode 100644 index 0000000..0043a84 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/aicontent/AsyncAiContentClient.java @@ -0,0 +1,180 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.aicontent; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.aicontent.requests.CreateContentImportSourceRequest; +import com.intercom.api.resources.aicontent.requests.CreateExternalPageRequest; +import com.intercom.api.resources.aicontent.requests.DeleteContentImportSourceRequest; +import com.intercom.api.resources.aicontent.requests.DeleteExternalPageRequest; +import com.intercom.api.resources.aicontent.requests.GetContentImportSourceRequest; +import com.intercom.api.resources.aicontent.requests.GetExternalPageRequest; +import com.intercom.api.resources.aicontent.requests.UpdateContentImportSourceRequest; +import com.intercom.api.resources.aicontent.requests.UpdateExternalPageRequest; +import com.intercom.api.resources.aicontent.types.ContentImportSource; +import com.intercom.api.resources.aicontent.types.ContentImportSourcesList; +import com.intercom.api.resources.aicontent.types.ExternalPage; +import com.intercom.api.resources.aicontent.types.ExternalPagesList; +import java.util.concurrent.CompletableFuture; + +public class AsyncAiContentClient { + protected final ClientOptions clientOptions; + + private final AsyncRawAiContentClient rawClient; + + public AsyncAiContentClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawAiContentClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawAiContentClient withRawResponse() { + return this.rawClient; + } + + /** + * You can retrieve a list of all content import sources for a workspace. + */ + public CompletableFuture listContentImportSources() { + return this.rawClient.listContentImportSources().thenApply(response -> response.body()); + } + + /** + * You can retrieve a list of all content import sources for a workspace. + */ + public CompletableFuture listContentImportSources(RequestOptions requestOptions) { + return this.rawClient.listContentImportSources(requestOptions).thenApply(response -> response.body()); + } + + /** + * You can create a new content import source by sending a POST request to this endpoint. + */ + public CompletableFuture createContentImportSource(CreateContentImportSourceRequest request) { + return this.rawClient.createContentImportSource(request).thenApply(response -> response.body()); + } + + /** + * You can create a new content import source by sending a POST request to this endpoint. + */ + public CompletableFuture createContentImportSource( + CreateContentImportSourceRequest request, RequestOptions requestOptions) { + return this.rawClient.createContentImportSource(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture getContentImportSource(GetContentImportSourceRequest request) { + return this.rawClient.getContentImportSource(request).thenApply(response -> response.body()); + } + + public CompletableFuture getContentImportSource( + GetContentImportSourceRequest request, RequestOptions requestOptions) { + return this.rawClient.getContentImportSource(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can update an existing content import source. + */ + public CompletableFuture updateContentImportSource(UpdateContentImportSourceRequest request) { + return this.rawClient.updateContentImportSource(request).thenApply(response -> response.body()); + } + + /** + * You can update an existing content import source. + */ + public CompletableFuture updateContentImportSource( + UpdateContentImportSourceRequest request, RequestOptions requestOptions) { + return this.rawClient.updateContentImportSource(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * 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. + */ + public CompletableFuture deleteContentImportSource(DeleteContentImportSourceRequest request) { + return this.rawClient.deleteContentImportSource(request).thenApply(response -> response.body()); + } + + /** + * 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. + */ + public CompletableFuture deleteContentImportSource( + DeleteContentImportSourceRequest request, RequestOptions requestOptions) { + return this.rawClient.deleteContentImportSource(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can retrieve a list of all external pages for a workspace. + */ + public CompletableFuture listExternalPages() { + return this.rawClient.listExternalPages().thenApply(response -> response.body()); + } + + /** + * You can retrieve a list of all external pages for a workspace. + */ + public CompletableFuture listExternalPages(RequestOptions requestOptions) { + return this.rawClient.listExternalPages(requestOptions).thenApply(response -> response.body()); + } + + /** + * 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. + */ + public CompletableFuture createExternalPage(CreateExternalPageRequest request) { + return this.rawClient.createExternalPage(request).thenApply(response -> response.body()); + } + + /** + * 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. + */ + public CompletableFuture createExternalPage( + CreateExternalPageRequest request, RequestOptions requestOptions) { + return this.rawClient.createExternalPage(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can retrieve an external page. + */ + public CompletableFuture getExternalPage(GetExternalPageRequest request) { + return this.rawClient.getExternalPage(request).thenApply(response -> response.body()); + } + + /** + * You can retrieve an external page. + */ + public CompletableFuture getExternalPage( + GetExternalPageRequest request, RequestOptions requestOptions) { + return this.rawClient.getExternalPage(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can update an existing external page (if it was created via the API). + */ + public CompletableFuture updateExternalPage(UpdateExternalPageRequest request) { + return this.rawClient.updateExternalPage(request).thenApply(response -> response.body()); + } + + /** + * You can update an existing external page (if it was created via the API). + */ + public CompletableFuture updateExternalPage( + UpdateExternalPageRequest request, RequestOptions requestOptions) { + return this.rawClient.updateExternalPage(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Sending a DELETE request for an external page will remove it from the content library UI and from being used for AI answers. + */ + public CompletableFuture deleteExternalPage(DeleteExternalPageRequest request) { + return this.rawClient.deleteExternalPage(request).thenApply(response -> response.body()); + } + + /** + * Sending a DELETE request for an external page will remove it from the content library UI and from being used for AI answers. + */ + public CompletableFuture deleteExternalPage( + DeleteExternalPageRequest request, RequestOptions requestOptions) { + return this.rawClient.deleteExternalPage(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/intercom/api/resources/aicontent/AsyncRawAiContentClient.java b/src/main/java/com/intercom/api/resources/aicontent/AsyncRawAiContentClient.java new file mode 100644 index 0000000..5c3aa68 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/aicontent/AsyncRawAiContentClient.java @@ -0,0 +1,746 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.aicontent; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.errors.UnauthorizedError; +import com.intercom.api.resources.aicontent.requests.CreateContentImportSourceRequest; +import com.intercom.api.resources.aicontent.requests.CreateExternalPageRequest; +import com.intercom.api.resources.aicontent.requests.DeleteContentImportSourceRequest; +import com.intercom.api.resources.aicontent.requests.DeleteExternalPageRequest; +import com.intercom.api.resources.aicontent.requests.GetContentImportSourceRequest; +import com.intercom.api.resources.aicontent.requests.GetExternalPageRequest; +import com.intercom.api.resources.aicontent.requests.UpdateContentImportSourceRequest; +import com.intercom.api.resources.aicontent.requests.UpdateExternalPageRequest; +import com.intercom.api.resources.aicontent.types.ContentImportSource; +import com.intercom.api.resources.aicontent.types.ContentImportSourcesList; +import com.intercom.api.resources.aicontent.types.ExternalPage; +import com.intercom.api.resources.aicontent.types.ExternalPagesList; +import com.intercom.api.types.Error; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawAiContentClient { + protected final ClientOptions clientOptions; + + public AsyncRawAiContentClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can retrieve a list of all content import sources for a workspace. + */ + public CompletableFuture> listContentImportSources() { + return listContentImportSources(null); + } + + /** + * You can retrieve a list of all content import sources for a workspace. + */ + public CompletableFuture> listContentImportSources( + RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ai/content_import_sources") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ContentImportSourcesList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can create a new content import source by sending a POST request to this endpoint. + */ + public CompletableFuture> createContentImportSource( + CreateContentImportSourceRequest request) { + return createContentImportSource(request, null); + } + + /** + * You can create a new content import source by sending a POST request to this endpoint. + */ + public CompletableFuture> createContentImportSource( + CreateContentImportSourceRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ai/content_import_sources") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ContentImportSource.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> getContentImportSource( + GetContentImportSourceRequest request) { + return getContentImportSource(request, null); + } + + public CompletableFuture> getContentImportSource( + GetContentImportSourceRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ai/content_import_sources") + .addPathSegment(request.getSourceId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ContentImportSource.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can update an existing content import source. + */ + public CompletableFuture> updateContentImportSource( + UpdateContentImportSourceRequest request) { + return updateContentImportSource(request, null); + } + + /** + * You can update an existing content import source. + */ + public CompletableFuture> updateContentImportSource( + UpdateContentImportSourceRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ai/content_import_sources") + .addPathSegment(request.getSourceId()) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ContentImportSource.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * 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. + */ + public CompletableFuture> deleteContentImportSource( + DeleteContentImportSourceRequest request) { + return deleteContentImportSource(request, null); + } + + /** + * 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. + */ + public CompletableFuture> deleteContentImportSource( + DeleteContentImportSourceRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ai/content_import_sources") + .addPathSegment(request.getSourceId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>(null, response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can retrieve a list of all external pages for a workspace. + */ + public CompletableFuture> listExternalPages() { + return listExternalPages(null); + } + + /** + * You can retrieve a list of all external pages for a workspace. + */ + public CompletableFuture> listExternalPages(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ai/external_pages") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ExternalPagesList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * 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. + */ + public CompletableFuture> createExternalPage(CreateExternalPageRequest request) { + return createExternalPage(request, null); + } + + /** + * 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. + */ + public CompletableFuture> createExternalPage( + CreateExternalPageRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ai/external_pages") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ExternalPage.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can retrieve an external page. + */ + public CompletableFuture> getExternalPage(GetExternalPageRequest request) { + return getExternalPage(request, null); + } + + /** + * You can retrieve an external page. + */ + public CompletableFuture> getExternalPage( + GetExternalPageRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ai/external_pages") + .addPathSegment(request.getPageId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ExternalPage.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can update an existing external page (if it was created via the API). + */ + public CompletableFuture> updateExternalPage(UpdateExternalPageRequest request) { + return updateExternalPage(request, null); + } + + /** + * You can update an existing external page (if it was created via the API). + */ + public CompletableFuture> updateExternalPage( + UpdateExternalPageRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ai/external_pages") + .addPathSegment(request.getPageId()) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ExternalPage.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Sending a DELETE request for an external page will remove it from the content library UI and from being used for AI answers. + */ + public CompletableFuture> deleteExternalPage(DeleteExternalPageRequest request) { + return deleteExternalPage(request, null); + } + + /** + * Sending a DELETE request for an external page will remove it from the content library UI and from being used for AI answers. + */ + public CompletableFuture> deleteExternalPage( + DeleteExternalPageRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ai/external_pages") + .addPathSegment(request.getPageId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ExternalPage.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/intercom/api/resources/aicontent/RawAiContentClient.java b/src/main/java/com/intercom/api/resources/aicontent/RawAiContentClient.java new file mode 100644 index 0000000..50a9040 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/aicontent/RawAiContentClient.java @@ -0,0 +1,593 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.aicontent; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.errors.UnauthorizedError; +import com.intercom.api.resources.aicontent.requests.CreateContentImportSourceRequest; +import com.intercom.api.resources.aicontent.requests.CreateExternalPageRequest; +import com.intercom.api.resources.aicontent.requests.DeleteContentImportSourceRequest; +import com.intercom.api.resources.aicontent.requests.DeleteExternalPageRequest; +import com.intercom.api.resources.aicontent.requests.GetContentImportSourceRequest; +import com.intercom.api.resources.aicontent.requests.GetExternalPageRequest; +import com.intercom.api.resources.aicontent.requests.UpdateContentImportSourceRequest; +import com.intercom.api.resources.aicontent.requests.UpdateExternalPageRequest; +import com.intercom.api.resources.aicontent.types.ContentImportSource; +import com.intercom.api.resources.aicontent.types.ContentImportSourcesList; +import com.intercom.api.resources.aicontent.types.ExternalPage; +import com.intercom.api.resources.aicontent.types.ExternalPagesList; +import com.intercom.api.types.Error; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawAiContentClient { + protected final ClientOptions clientOptions; + + public RawAiContentClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can retrieve a list of all content import sources for a workspace. + */ + public IntercomHttpResponse listContentImportSources() { + return listContentImportSources(null); + } + + /** + * You can retrieve a list of all content import sources for a workspace. + */ + public IntercomHttpResponse listContentImportSources(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ai/content_import_sources") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ContentImportSourcesList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can create a new content import source by sending a POST request to this endpoint. + */ + public IntercomHttpResponse createContentImportSource( + CreateContentImportSourceRequest request) { + return createContentImportSource(request, null); + } + + /** + * You can create a new content import source by sending a POST request to this endpoint. + */ + public IntercomHttpResponse createContentImportSource( + CreateContentImportSourceRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ai/content_import_sources") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ContentImportSource.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + public IntercomHttpResponse getContentImportSource(GetContentImportSourceRequest request) { + return getContentImportSource(request, null); + } + + public IntercomHttpResponse getContentImportSource( + GetContentImportSourceRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ai/content_import_sources") + .addPathSegment(request.getSourceId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ContentImportSource.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can update an existing content import source. + */ + public IntercomHttpResponse updateContentImportSource( + UpdateContentImportSourceRequest request) { + return updateContentImportSource(request, null); + } + + /** + * You can update an existing content import source. + */ + public IntercomHttpResponse updateContentImportSource( + UpdateContentImportSourceRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ai/content_import_sources") + .addPathSegment(request.getSourceId()) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ContentImportSource.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * 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. + */ + public IntercomHttpResponse deleteContentImportSource(DeleteContentImportSourceRequest request) { + return deleteContentImportSource(request, null); + } + + /** + * 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. + */ + public IntercomHttpResponse deleteContentImportSource( + DeleteContentImportSourceRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ai/content_import_sources") + .addPathSegment(request.getSourceId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>(null, response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can retrieve a list of all external pages for a workspace. + */ + public IntercomHttpResponse listExternalPages() { + return listExternalPages(null); + } + + /** + * You can retrieve a list of all external pages for a workspace. + */ + public IntercomHttpResponse listExternalPages(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ai/external_pages") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ExternalPagesList.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * 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. + */ + public IntercomHttpResponse createExternalPage(CreateExternalPageRequest request) { + return createExternalPage(request, null); + } + + /** + * 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. + */ + public IntercomHttpResponse createExternalPage( + CreateExternalPageRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ai/external_pages") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ExternalPage.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can retrieve an external page. + */ + public IntercomHttpResponse getExternalPage(GetExternalPageRequest request) { + return getExternalPage(request, null); + } + + /** + * You can retrieve an external page. + */ + public IntercomHttpResponse getExternalPage( + GetExternalPageRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ai/external_pages") + .addPathSegment(request.getPageId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ExternalPage.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can update an existing external page (if it was created via the API). + */ + public IntercomHttpResponse updateExternalPage(UpdateExternalPageRequest request) { + return updateExternalPage(request, null); + } + + /** + * You can update an existing external page (if it was created via the API). + */ + public IntercomHttpResponse updateExternalPage( + UpdateExternalPageRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ai/external_pages") + .addPathSegment(request.getPageId()) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ExternalPage.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * Sending a DELETE request for an external page will remove it from the content library UI and from being used for AI answers. + */ + public IntercomHttpResponse deleteExternalPage(DeleteExternalPageRequest request) { + return deleteExternalPage(request, null); + } + + /** + * Sending a DELETE request for an external page will remove it from the content library UI and from being used for AI answers. + */ + public IntercomHttpResponse deleteExternalPage( + DeleteExternalPageRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ai/external_pages") + .addPathSegment(request.getPageId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ExternalPage.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/aicontent/requests/CreateContentImportSourceRequest.java b/src/main/java/com/intercom/api/resources/aicontent/requests/CreateContentImportSourceRequest.java new file mode 100644 index 0000000..a1d6dc2 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/aicontent/requests/CreateContentImportSourceRequest.java @@ -0,0 +1,241 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.aicontent.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CreateContentImportSourceRequest.Builder.class) +public final class CreateContentImportSourceRequest { + private final Optional status; + + private final String url; + + private final Map additionalProperties; + + private CreateContentImportSourceRequest( + Optional status, String url, Map additionalProperties) { + this.status = status; + this.url = url; + this.additionalProperties = additionalProperties; + } + + /** + * @return If you intend to create or update External Pages via the API, this should be set to api. + */ + @JsonProperty("sync_behavior") + public String getSyncBehavior() { + return "api"; + } + + /** + * @return The status of the content import source. + */ + @JsonProperty("status") + public Optional getStatus() { + return status; + } + + /** + * @return The URL of the content import source. + */ + @JsonProperty("url") + public String getUrl() { + return url; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreateContentImportSourceRequest && equalTo((CreateContentImportSourceRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreateContentImportSourceRequest other) { + return status.equals(other.status) && url.equals(other.url); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.status, this.url); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static UrlStage builder() { + return new Builder(); + } + + public interface UrlStage { + /** + * The URL of the content import source. + */ + _FinalStage url(@NotNull String url); + + Builder from(CreateContentImportSourceRequest other); + } + + public interface _FinalStage { + CreateContentImportSourceRequest build(); + + /** + *

The status of the content import source.

+ */ + _FinalStage status(Optional status); + + _FinalStage status(Status status); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements UrlStage, _FinalStage { + private String url; + + private Optional status = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CreateContentImportSourceRequest other) { + status(other.getStatus()); + url(other.getUrl()); + return this; + } + + /** + * The URL of the content import source.

The URL of the content import source.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("url") + public _FinalStage url(@NotNull String url) { + this.url = Objects.requireNonNull(url, "url must not be null"); + return this; + } + + /** + *

The status of the content import source.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage status(Status status) { + this.status = Optional.ofNullable(status); + return this; + } + + /** + *

The status of the content import source.

+ */ + @java.lang.Override + @JsonSetter(value = "status", nulls = Nulls.SKIP) + public _FinalStage status(Optional status) { + this.status = status; + return this; + } + + @java.lang.Override + public CreateContentImportSourceRequest build() { + return new CreateContentImportSourceRequest(status, url, additionalProperties); + } + } + + public static final class Status { + public static final Status DEACTIVATED = new Status(Value.DEACTIVATED, "deactivated"); + + public static final Status ACTIVE = new Status(Value.ACTIVE, "active"); + + private final Value value; + + private final String string; + + Status(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) || (other instanceof Status && this.string.equals(((Status) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case DEACTIVATED: + return visitor.visitDeactivated(); + case ACTIVE: + return visitor.visitActive(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static Status valueOf(String value) { + switch (value) { + case "deactivated": + return DEACTIVATED; + case "active": + return ACTIVE; + default: + return new Status(Value.UNKNOWN, value); + } + } + + public enum Value { + ACTIVE, + + DEACTIVATED, + + UNKNOWN + } + + public interface Visitor { + T visitActive(); + + T visitDeactivated(); + + T visitUnknown(String unknownType); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/aicontent/requests/CreateExternalPageRequest.java b/src/main/java/com/intercom/api/resources/aicontent/requests/CreateExternalPageRequest.java new file mode 100644 index 0000000..a9b2b41 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/aicontent/requests/CreateExternalPageRequest.java @@ -0,0 +1,370 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.aicontent.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CreateExternalPageRequest.Builder.class) +public final class CreateExternalPageRequest { + private final String title; + + private final String html; + + private final Optional url; + + private final Optional aiAgentAvailability; + + private final Optional aiCopilotAvailability; + + private final int sourceId; + + private final String externalId; + + private final Map additionalProperties; + + private CreateExternalPageRequest( + String title, + String html, + Optional url, + Optional aiAgentAvailability, + Optional aiCopilotAvailability, + int sourceId, + String externalId, + Map additionalProperties) { + this.title = title; + this.html = html; + this.url = url; + this.aiAgentAvailability = aiAgentAvailability; + this.aiCopilotAvailability = aiCopilotAvailability; + this.sourceId = sourceId; + this.externalId = externalId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The title of the external page. + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * @return The body of the external page in HTML. + */ + @JsonProperty("html") + public String getHtml() { + return html; + } + + /** + * @return The URL of the external page. This will be used by Fin to link end users to the page it based its answer on. When a URL is not present, Fin will not reference the source. + */ + @JsonProperty("url") + public Optional getUrl() { + return url; + } + + /** + * @return Whether the external page should be used to answer questions by AI Agent. Will not default when updating an existing external page. + */ + @JsonProperty("ai_agent_availability") + public Optional getAiAgentAvailability() { + return aiAgentAvailability; + } + + /** + * @return Whether the external page should be used to answer questions by AI Copilot. Will not default when updating an existing external page. + */ + @JsonProperty("ai_copilot_availability") + public Optional getAiCopilotAvailability() { + return aiCopilotAvailability; + } + + /** + * @return Always en + */ + @JsonProperty("locale") + public String getLocale() { + return "en"; + } + + /** + * @return 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. + */ + @JsonProperty("source_id") + public int getSourceId() { + return sourceId; + } + + /** + * @return The identifier for the external page which was given by the source. Must be unique for the source. + */ + @JsonProperty("external_id") + public String getExternalId() { + return externalId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreateExternalPageRequest && equalTo((CreateExternalPageRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreateExternalPageRequest other) { + return title.equals(other.title) + && html.equals(other.html) + && url.equals(other.url) + && aiAgentAvailability.equals(other.aiAgentAvailability) + && aiCopilotAvailability.equals(other.aiCopilotAvailability) + && sourceId == other.sourceId + && externalId.equals(other.externalId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.title, + this.html, + this.url, + this.aiAgentAvailability, + this.aiCopilotAvailability, + this.sourceId, + this.externalId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TitleStage builder() { + return new Builder(); + } + + public interface TitleStage { + /** + * The title of the external page. + */ + HtmlStage title(@NotNull String title); + + Builder from(CreateExternalPageRequest other); + } + + public interface HtmlStage { + /** + * The body of the external page in HTML. + */ + SourceIdStage html(@NotNull String html); + } + + public interface SourceIdStage { + /** + * 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. + */ + ExternalIdStage sourceId(int sourceId); + } + + public interface ExternalIdStage { + /** + * The identifier for the external page which was given by the source. Must be unique for the source. + */ + _FinalStage externalId(@NotNull String externalId); + } + + public interface _FinalStage { + CreateExternalPageRequest build(); + + /** + *

The URL of the external page. This will be used by Fin to link end users to the page it based its answer on. When a URL is not present, Fin will not reference the source.

+ */ + _FinalStage url(Optional url); + + _FinalStage url(String url); + + /** + *

Whether the external page should be used to answer questions by AI Agent. Will not default when updating an existing external page.

+ */ + _FinalStage aiAgentAvailability(Optional aiAgentAvailability); + + _FinalStage aiAgentAvailability(Boolean aiAgentAvailability); + + /** + *

Whether the external page should be used to answer questions by AI Copilot. Will not default when updating an existing external page.

+ */ + _FinalStage aiCopilotAvailability(Optional aiCopilotAvailability); + + _FinalStage aiCopilotAvailability(Boolean aiCopilotAvailability); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements TitleStage, HtmlStage, SourceIdStage, ExternalIdStage, _FinalStage { + private String title; + + private String html; + + private int sourceId; + + private String externalId; + + private Optional aiCopilotAvailability = Optional.empty(); + + private Optional aiAgentAvailability = Optional.empty(); + + private Optional url = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CreateExternalPageRequest other) { + title(other.getTitle()); + html(other.getHtml()); + url(other.getUrl()); + aiAgentAvailability(other.getAiAgentAvailability()); + aiCopilotAvailability(other.getAiCopilotAvailability()); + sourceId(other.getSourceId()); + externalId(other.getExternalId()); + return this; + } + + /** + * The title of the external page.

The title of the external page.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("title") + public HtmlStage title(@NotNull String title) { + this.title = Objects.requireNonNull(title, "title must not be null"); + return this; + } + + /** + * The body of the external page in HTML.

The body of the external page in HTML.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("html") + public SourceIdStage html(@NotNull String html) { + this.html = Objects.requireNonNull(html, "html must not be null"); + return this; + } + + /** + * 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.

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.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("source_id") + public ExternalIdStage sourceId(int sourceId) { + this.sourceId = sourceId; + return this; + } + + /** + * The identifier for the external page which was given by the source. Must be unique for the source.

The identifier for the external page which was given by the source. Must be unique for the source.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("external_id") + public _FinalStage externalId(@NotNull String externalId) { + this.externalId = Objects.requireNonNull(externalId, "externalId must not be null"); + return this; + } + + /** + *

Whether the external page should be used to answer questions by AI Copilot. Will not default when updating an existing external page.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage aiCopilotAvailability(Boolean aiCopilotAvailability) { + this.aiCopilotAvailability = Optional.ofNullable(aiCopilotAvailability); + return this; + } + + /** + *

Whether the external page should be used to answer questions by AI Copilot. Will not default when updating an existing external page.

+ */ + @java.lang.Override + @JsonSetter(value = "ai_copilot_availability", nulls = Nulls.SKIP) + public _FinalStage aiCopilotAvailability(Optional aiCopilotAvailability) { + this.aiCopilotAvailability = aiCopilotAvailability; + return this; + } + + /** + *

Whether the external page should be used to answer questions by AI Agent. Will not default when updating an existing external page.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage aiAgentAvailability(Boolean aiAgentAvailability) { + this.aiAgentAvailability = Optional.ofNullable(aiAgentAvailability); + return this; + } + + /** + *

Whether the external page should be used to answer questions by AI Agent. Will not default when updating an existing external page.

+ */ + @java.lang.Override + @JsonSetter(value = "ai_agent_availability", nulls = Nulls.SKIP) + public _FinalStage aiAgentAvailability(Optional aiAgentAvailability) { + this.aiAgentAvailability = aiAgentAvailability; + return this; + } + + /** + *

The URL of the external page. This will be used by Fin to link end users to the page it based its answer on. When a URL is not present, Fin will not reference the source.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage url(String url) { + this.url = Optional.ofNullable(url); + return this; + } + + /** + *

The URL of the external page. This will be used by Fin to link end users to the page it based its answer on. When a URL is not present, Fin will not reference the source.

+ */ + @java.lang.Override + @JsonSetter(value = "url", nulls = Nulls.SKIP) + public _FinalStage url(Optional url) { + this.url = url; + return this; + } + + @java.lang.Override + public CreateExternalPageRequest build() { + return new CreateExternalPageRequest( + title, + html, + url, + aiAgentAvailability, + aiCopilotAvailability, + sourceId, + externalId, + additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/aicontent/requests/DeleteContentImportSourceRequest.java b/src/main/java/com/intercom/api/resources/aicontent/requests/DeleteContentImportSourceRequest.java new file mode 100644 index 0000000..461999c --- /dev/null +++ b/src/main/java/com/intercom/api/resources/aicontent/requests/DeleteContentImportSourceRequest.java @@ -0,0 +1,112 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.aicontent.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = DeleteContentImportSourceRequest.Builder.class) +public final class DeleteContentImportSourceRequest { + private final String sourceId; + + private final Map additionalProperties; + + private DeleteContentImportSourceRequest(String sourceId, Map additionalProperties) { + this.sourceId = sourceId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the content import source which is given by Intercom. + */ + @JsonProperty("source_id") + public String getSourceId() { + return sourceId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeleteContentImportSourceRequest && equalTo((DeleteContentImportSourceRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeleteContentImportSourceRequest other) { + return sourceId.equals(other.sourceId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.sourceId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static SourceIdStage builder() { + return new Builder(); + } + + public interface SourceIdStage { + /** + * The unique identifier for the content import source which is given by Intercom. + */ + _FinalStage sourceId(@NotNull String sourceId); + + Builder from(DeleteContentImportSourceRequest other); + } + + public interface _FinalStage { + DeleteContentImportSourceRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements SourceIdStage, _FinalStage { + private String sourceId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DeleteContentImportSourceRequest other) { + sourceId(other.getSourceId()); + return this; + } + + /** + * The unique identifier for the content import source which is given by Intercom.

The unique identifier for the content import source which is given by Intercom.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("source_id") + public _FinalStage sourceId(@NotNull String sourceId) { + this.sourceId = Objects.requireNonNull(sourceId, "sourceId must not be null"); + return this; + } + + @java.lang.Override + public DeleteContentImportSourceRequest build() { + return new DeleteContentImportSourceRequest(sourceId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/types/CurrentCanvas.java b/src/main/java/com/intercom/api/resources/aicontent/requests/DeleteExternalPageRequest.java similarity index 51% rename from src/main/java/com/intercom/api/types/CurrentCanvas.java rename to src/main/java/com/intercom/api/resources/aicontent/requests/DeleteExternalPageRequest.java index e3373a7..351bb87 100644 --- a/src/main/java/com/intercom/api/types/CurrentCanvas.java +++ b/src/main/java/com/intercom/api/resources/aicontent/requests/DeleteExternalPageRequest.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.intercom.api.types; +package com.intercom.api.resources.aicontent.requests; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; @@ -17,29 +17,29 @@ import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = CurrentCanvas.Builder.class) -public final class CurrentCanvas { - private final CanvasObject currentCanvas; +@JsonDeserialize(builder = DeleteExternalPageRequest.Builder.class) +public final class DeleteExternalPageRequest { + private final String pageId; private final Map additionalProperties; - private CurrentCanvas(CanvasObject currentCanvas, Map additionalProperties) { - this.currentCanvas = currentCanvas; + private DeleteExternalPageRequest(String pageId, Map additionalProperties) { + this.pageId = pageId; this.additionalProperties = additionalProperties; } /** - * @return The canvas object representing the current canvas state. + * @return The unique identifier for the external page which is given by Intercom. */ - @JsonProperty("current_canvas") - public CanvasObject getCurrentCanvas() { - return currentCanvas; + @JsonProperty("page_id") + public String getPageId() { + return pageId; } @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof CurrentCanvas && equalTo((CurrentCanvas) other); + return other instanceof DeleteExternalPageRequest && equalTo((DeleteExternalPageRequest) other); } @JsonAnyGetter @@ -47,13 +47,13 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(CurrentCanvas other) { - return currentCanvas.equals(other.currentCanvas); + private boolean equalTo(DeleteExternalPageRequest other) { + return pageId.equals(other.pageId); } @java.lang.Override public int hashCode() { - return Objects.hash(this.currentCanvas); + return Objects.hash(this.pageId); } @java.lang.Override @@ -61,26 +61,26 @@ public String toString() { return ObjectMappers.stringify(this); } - public static CurrentCanvasStage builder() { + public static PageIdStage builder() { return new Builder(); } - public interface CurrentCanvasStage { + public interface PageIdStage { /** - * The canvas object representing the current canvas state. + * The unique identifier for the external page which is given by Intercom. */ - _FinalStage currentCanvas(@NotNull CanvasObject currentCanvas); + _FinalStage pageId(@NotNull String pageId); - Builder from(CurrentCanvas other); + Builder from(DeleteExternalPageRequest other); } public interface _FinalStage { - CurrentCanvas build(); + DeleteExternalPageRequest build(); } @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements CurrentCanvasStage, _FinalStage { - private CanvasObject currentCanvas; + public static final class Builder implements PageIdStage, _FinalStage { + private String pageId; @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -88,25 +88,25 @@ public static final class Builder implements CurrentCanvasStage, _FinalStage { private Builder() {} @java.lang.Override - public Builder from(CurrentCanvas other) { - currentCanvas(other.getCurrentCanvas()); + public Builder from(DeleteExternalPageRequest other) { + pageId(other.getPageId()); return this; } /** - * The canvas object representing the current canvas state.

The canvas object representing the current canvas state.

+ * The unique identifier for the external page which is given by Intercom.

The unique identifier for the external page which is given by Intercom.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override - @JsonSetter("current_canvas") - public _FinalStage currentCanvas(@NotNull CanvasObject currentCanvas) { - this.currentCanvas = Objects.requireNonNull(currentCanvas, "currentCanvas must not be null"); + @JsonSetter("page_id") + public _FinalStage pageId(@NotNull String pageId) { + this.pageId = Objects.requireNonNull(pageId, "pageId must not be null"); return this; } @java.lang.Override - public CurrentCanvas build() { - return new CurrentCanvas(currentCanvas, additionalProperties); + public DeleteExternalPageRequest build() { + return new DeleteExternalPageRequest(pageId, additionalProperties); } } } diff --git a/src/main/java/com/intercom/api/resources/aicontent/requests/GetContentImportSourceRequest.java b/src/main/java/com/intercom/api/resources/aicontent/requests/GetContentImportSourceRequest.java new file mode 100644 index 0000000..cc38db4 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/aicontent/requests/GetContentImportSourceRequest.java @@ -0,0 +1,112 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.aicontent.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = GetContentImportSourceRequest.Builder.class) +public final class GetContentImportSourceRequest { + private final String sourceId; + + private final Map additionalProperties; + + private GetContentImportSourceRequest(String sourceId, Map additionalProperties) { + this.sourceId = sourceId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the content import source which is given by Intercom. + */ + @JsonProperty("source_id") + public String getSourceId() { + return sourceId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GetContentImportSourceRequest && equalTo((GetContentImportSourceRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GetContentImportSourceRequest other) { + return sourceId.equals(other.sourceId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.sourceId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static SourceIdStage builder() { + return new Builder(); + } + + public interface SourceIdStage { + /** + * The unique identifier for the content import source which is given by Intercom. + */ + _FinalStage sourceId(@NotNull String sourceId); + + Builder from(GetContentImportSourceRequest other); + } + + public interface _FinalStage { + GetContentImportSourceRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements SourceIdStage, _FinalStage { + private String sourceId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(GetContentImportSourceRequest other) { + sourceId(other.getSourceId()); + return this; + } + + /** + * The unique identifier for the content import source which is given by Intercom.

The unique identifier for the content import source which is given by Intercom.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("source_id") + public _FinalStage sourceId(@NotNull String sourceId) { + this.sourceId = Objects.requireNonNull(sourceId, "sourceId must not be null"); + return this; + } + + @java.lang.Override + public GetContentImportSourceRequest build() { + return new GetContentImportSourceRequest(sourceId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/aicontent/requests/GetExternalPageRequest.java b/src/main/java/com/intercom/api/resources/aicontent/requests/GetExternalPageRequest.java new file mode 100644 index 0000000..0efd174 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/aicontent/requests/GetExternalPageRequest.java @@ -0,0 +1,112 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.aicontent.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = GetExternalPageRequest.Builder.class) +public final class GetExternalPageRequest { + private final String pageId; + + private final Map additionalProperties; + + private GetExternalPageRequest(String pageId, Map additionalProperties) { + this.pageId = pageId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the external page which is given by Intercom. + */ + @JsonProperty("page_id") + public String getPageId() { + return pageId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GetExternalPageRequest && equalTo((GetExternalPageRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GetExternalPageRequest other) { + return pageId.equals(other.pageId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.pageId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static PageIdStage builder() { + return new Builder(); + } + + public interface PageIdStage { + /** + * The unique identifier for the external page which is given by Intercom. + */ + _FinalStage pageId(@NotNull String pageId); + + Builder from(GetExternalPageRequest other); + } + + public interface _FinalStage { + GetExternalPageRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements PageIdStage, _FinalStage { + private String pageId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(GetExternalPageRequest other) { + pageId(other.getPageId()); + return this; + } + + /** + * The unique identifier for the external page which is given by Intercom.

The unique identifier for the external page which is given by Intercom.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("page_id") + public _FinalStage pageId(@NotNull String pageId) { + this.pageId = Objects.requireNonNull(pageId, "pageId must not be null"); + return this; + } + + @java.lang.Override + public GetExternalPageRequest build() { + return new GetExternalPageRequest(pageId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/aicontent/requests/UpdateContentImportSourceRequest.java b/src/main/java/com/intercom/api/resources/aicontent/requests/UpdateContentImportSourceRequest.java new file mode 100644 index 0000000..5a1f9fa --- /dev/null +++ b/src/main/java/com/intercom/api/resources/aicontent/requests/UpdateContentImportSourceRequest.java @@ -0,0 +1,390 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.aicontent.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = UpdateContentImportSourceRequest.Builder.class) +public final class UpdateContentImportSourceRequest { + private final String sourceId; + + private final SyncBehavior syncBehavior; + + private final Optional status; + + private final String url; + + private final Map additionalProperties; + + private UpdateContentImportSourceRequest( + String sourceId, + SyncBehavior syncBehavior, + Optional status, + String url, + Map additionalProperties) { + this.sourceId = sourceId; + this.syncBehavior = syncBehavior; + this.status = status; + this.url = url; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the content import source which is given by Intercom. + */ + @JsonProperty("source_id") + public String getSourceId() { + return sourceId; + } + + /** + * @return If you intend to create or update External Pages via the API, this should be set to api. You can not change the value to or from api. + */ + @JsonProperty("sync_behavior") + public SyncBehavior getSyncBehavior() { + return syncBehavior; + } + + /** + * @return The status of the content import source. + */ + @JsonProperty("status") + public Optional getStatus() { + return status; + } + + /** + * @return The URL of the content import source. This may only be different from the existing value if the sync behavior is API. + */ + @JsonProperty("url") + public String getUrl() { + return url; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UpdateContentImportSourceRequest && equalTo((UpdateContentImportSourceRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UpdateContentImportSourceRequest other) { + return sourceId.equals(other.sourceId) + && syncBehavior.equals(other.syncBehavior) + && status.equals(other.status) + && url.equals(other.url); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.sourceId, this.syncBehavior, this.status, this.url); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static SourceIdStage builder() { + return new Builder(); + } + + public interface SourceIdStage { + /** + * The unique identifier for the content import source which is given by Intercom. + */ + SyncBehaviorStage sourceId(@NotNull String sourceId); + + Builder from(UpdateContentImportSourceRequest other); + } + + public interface SyncBehaviorStage { + /** + * If you intend to create or update External Pages via the API, this should be set to `api`. You can not change the value to or from api. + */ + UrlStage syncBehavior(@NotNull SyncBehavior syncBehavior); + } + + public interface UrlStage { + /** + * The URL of the content import source. This may only be different from the existing value if the sync behavior is API. + */ + _FinalStage url(@NotNull String url); + } + + public interface _FinalStage { + UpdateContentImportSourceRequest build(); + + /** + *

The status of the content import source.

+ */ + _FinalStage status(Optional status); + + _FinalStage status(Status status); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements SourceIdStage, SyncBehaviorStage, UrlStage, _FinalStage { + private String sourceId; + + private SyncBehavior syncBehavior; + + private String url; + + private Optional status = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(UpdateContentImportSourceRequest other) { + sourceId(other.getSourceId()); + syncBehavior(other.getSyncBehavior()); + status(other.getStatus()); + url(other.getUrl()); + return this; + } + + /** + * The unique identifier for the content import source which is given by Intercom.

The unique identifier for the content import source which is given by Intercom.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("source_id") + public SyncBehaviorStage sourceId(@NotNull String sourceId) { + this.sourceId = Objects.requireNonNull(sourceId, "sourceId must not be null"); + return this; + } + + /** + * If you intend to create or update External Pages via the API, this should be set to `api`. You can not change the value to or from api.

If you intend to create or update External Pages via the API, this should be set to api. You can not change the value to or from api.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("sync_behavior") + public UrlStage syncBehavior(@NotNull SyncBehavior syncBehavior) { + this.syncBehavior = Objects.requireNonNull(syncBehavior, "syncBehavior must not be null"); + return this; + } + + /** + * The URL of the content import source. This may only be different from the existing value if the sync behavior is API.

The URL of the content import source. This may only be different from the existing value if the sync behavior is API.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("url") + public _FinalStage url(@NotNull String url) { + this.url = Objects.requireNonNull(url, "url must not be null"); + return this; + } + + /** + *

The status of the content import source.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage status(Status status) { + this.status = Optional.ofNullable(status); + return this; + } + + /** + *

The status of the content import source.

+ */ + @java.lang.Override + @JsonSetter(value = "status", nulls = Nulls.SKIP) + public _FinalStage status(Optional status) { + this.status = status; + return this; + } + + @java.lang.Override + public UpdateContentImportSourceRequest build() { + return new UpdateContentImportSourceRequest(sourceId, syncBehavior, status, url, additionalProperties); + } + } + + public static final class SyncBehavior { + public static final SyncBehavior AUTOMATED = new SyncBehavior(Value.AUTOMATED, "automated"); + + public static final SyncBehavior MANUAL = new SyncBehavior(Value.MANUAL, "manual"); + + public static final SyncBehavior API = new SyncBehavior(Value.API, "api"); + + private final Value value; + + private final String string; + + SyncBehavior(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof SyncBehavior && this.string.equals(((SyncBehavior) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case AUTOMATED: + return visitor.visitAutomated(); + case MANUAL: + return visitor.visitManual(); + case API: + return visitor.visitApi(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static SyncBehavior valueOf(String value) { + switch (value) { + case "automated": + return AUTOMATED; + case "manual": + return MANUAL; + case "api": + return API; + default: + return new SyncBehavior(Value.UNKNOWN, value); + } + } + + public enum Value { + API, + + AUTOMATED, + + MANUAL, + + UNKNOWN + } + + public interface Visitor { + T visitApi(); + + T visitAutomated(); + + T visitManual(); + + T visitUnknown(String unknownType); + } + } + + public static final class Status { + public static final Status DEACTIVATED = new Status(Value.DEACTIVATED, "deactivated"); + + public static final Status ACTIVE = new Status(Value.ACTIVE, "active"); + + private final Value value; + + private final String string; + + Status(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) || (other instanceof Status && this.string.equals(((Status) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case DEACTIVATED: + return visitor.visitDeactivated(); + case ACTIVE: + return visitor.visitActive(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static Status valueOf(String value) { + switch (value) { + case "deactivated": + return DEACTIVATED; + case "active": + return ACTIVE; + default: + return new Status(Value.UNKNOWN, value); + } + } + + public enum Value { + ACTIVE, + + DEACTIVATED, + + UNKNOWN + } + + public interface Visitor { + T visitActive(); + + T visitDeactivated(); + + T visitUnknown(String unknownType); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/aicontent/requests/UpdateExternalPageRequest.java b/src/main/java/com/intercom/api/resources/aicontent/requests/UpdateExternalPageRequest.java new file mode 100644 index 0000000..7b40e2a --- /dev/null +++ b/src/main/java/com/intercom/api/resources/aicontent/requests/UpdateExternalPageRequest.java @@ -0,0 +1,349 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.aicontent.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = UpdateExternalPageRequest.Builder.class) +public final class UpdateExternalPageRequest { + private final String pageId; + + private final String title; + + private final String html; + + private final String url; + + private final Optional finAvailability; + + private final int sourceId; + + private final Optional externalId; + + private final Map additionalProperties; + + private UpdateExternalPageRequest( + String pageId, + String title, + String html, + String url, + Optional finAvailability, + int sourceId, + Optional externalId, + Map additionalProperties) { + this.pageId = pageId; + this.title = title; + this.html = html; + this.url = url; + this.finAvailability = finAvailability; + this.sourceId = sourceId; + this.externalId = externalId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the external page which is given by Intercom. + */ + @JsonProperty("page_id") + public String getPageId() { + return pageId; + } + + /** + * @return The title of the external page. + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * @return The body of the external page in HTML. + */ + @JsonProperty("html") + public String getHtml() { + return html; + } + + /** + * @return The URL of the external page. This will be used by Fin to link end users to the page it based its answer on. + */ + @JsonProperty("url") + public String getUrl() { + return url; + } + + /** + * @return Whether the external page should be used to answer questions by Fin. + */ + @JsonProperty("fin_availability") + public Optional getFinAvailability() { + return finAvailability; + } + + /** + * @return Always en + */ + @JsonProperty("locale") + public String getLocale() { + return "en"; + } + + /** + * @return 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. + */ + @JsonProperty("source_id") + public int getSourceId() { + return sourceId; + } + + /** + * @return The identifier for the external page which was given by the source. Must be unique for the source. + */ + @JsonProperty("external_id") + public Optional getExternalId() { + return externalId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UpdateExternalPageRequest && equalTo((UpdateExternalPageRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UpdateExternalPageRequest other) { + return pageId.equals(other.pageId) + && title.equals(other.title) + && html.equals(other.html) + && url.equals(other.url) + && finAvailability.equals(other.finAvailability) + && sourceId == other.sourceId + && externalId.equals(other.externalId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.pageId, this.title, this.html, this.url, this.finAvailability, this.sourceId, this.externalId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static PageIdStage builder() { + return new Builder(); + } + + public interface PageIdStage { + /** + * The unique identifier for the external page which is given by Intercom. + */ + TitleStage pageId(@NotNull String pageId); + + Builder from(UpdateExternalPageRequest other); + } + + public interface TitleStage { + /** + * The title of the external page. + */ + HtmlStage title(@NotNull String title); + } + + public interface HtmlStage { + /** + * The body of the external page in HTML. + */ + UrlStage html(@NotNull String html); + } + + public interface UrlStage { + /** + * The URL of the external page. This will be used by Fin to link end users to the page it based its answer on. + */ + SourceIdStage url(@NotNull String url); + } + + public interface SourceIdStage { + /** + * 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. + */ + _FinalStage sourceId(int sourceId); + } + + public interface _FinalStage { + UpdateExternalPageRequest build(); + + /** + *

Whether the external page should be used to answer questions by Fin.

+ */ + _FinalStage finAvailability(Optional finAvailability); + + _FinalStage finAvailability(Boolean finAvailability); + + /** + *

The identifier for the external page which was given by the source. Must be unique for the source.

+ */ + _FinalStage externalId(Optional externalId); + + _FinalStage externalId(String externalId); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements PageIdStage, TitleStage, HtmlStage, UrlStage, SourceIdStage, _FinalStage { + private String pageId; + + private String title; + + private String html; + + private String url; + + private int sourceId; + + private Optional externalId = Optional.empty(); + + private Optional finAvailability = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(UpdateExternalPageRequest other) { + pageId(other.getPageId()); + title(other.getTitle()); + html(other.getHtml()); + url(other.getUrl()); + finAvailability(other.getFinAvailability()); + sourceId(other.getSourceId()); + externalId(other.getExternalId()); + return this; + } + + /** + * The unique identifier for the external page which is given by Intercom.

The unique identifier for the external page which is given by Intercom.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("page_id") + public TitleStage pageId(@NotNull String pageId) { + this.pageId = Objects.requireNonNull(pageId, "pageId must not be null"); + return this; + } + + /** + * The title of the external page.

The title of the external page.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("title") + public HtmlStage title(@NotNull String title) { + this.title = Objects.requireNonNull(title, "title must not be null"); + return this; + } + + /** + * The body of the external page in HTML.

The body of the external page in HTML.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("html") + public UrlStage html(@NotNull String html) { + this.html = Objects.requireNonNull(html, "html must not be null"); + return this; + } + + /** + * The URL of the external page. This will be used by Fin to link end users to the page it based its answer on.

The URL of the external page. This will be used by Fin to link end users to the page it based its answer on.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("url") + public SourceIdStage url(@NotNull String url) { + this.url = Objects.requireNonNull(url, "url must not be null"); + return this; + } + + /** + * 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.

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.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("source_id") + public _FinalStage sourceId(int sourceId) { + this.sourceId = sourceId; + return this; + } + + /** + *

The identifier for the external page which was given by the source. Must be unique for the source.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage externalId(String externalId) { + this.externalId = Optional.ofNullable(externalId); + return this; + } + + /** + *

The identifier for the external page which was given by the source. Must be unique for the source.

+ */ + @java.lang.Override + @JsonSetter(value = "external_id", nulls = Nulls.SKIP) + public _FinalStage externalId(Optional externalId) { + this.externalId = externalId; + return this; + } + + /** + *

Whether the external page should be used to answer questions by Fin.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage finAvailability(Boolean finAvailability) { + this.finAvailability = Optional.ofNullable(finAvailability); + return this; + } + + /** + *

Whether the external page should be used to answer questions by Fin.

+ */ + @java.lang.Override + @JsonSetter(value = "fin_availability", nulls = Nulls.SKIP) + public _FinalStage finAvailability(Optional finAvailability) { + this.finAvailability = finAvailability; + return this; + } + + @java.lang.Override + public UpdateExternalPageRequest build() { + return new UpdateExternalPageRequest( + pageId, title, html, url, finAvailability, sourceId, externalId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/aicontent/types/ContentImportSource.java b/src/main/java/com/intercom/api/resources/aicontent/types/ContentImportSource.java new file mode 100644 index 0000000..b04854b --- /dev/null +++ b/src/main/java/com/intercom/api/resources/aicontent/types/ContentImportSource.java @@ -0,0 +1,499 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.aicontent.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ContentImportSource.Builder.class) +public final class ContentImportSource { + private final int id; + + private final int lastSyncedAt; + + private final SyncBehavior syncBehavior; + + private final Status status; + + private final String url; + + private final int createdAt; + + private final int updatedAt; + + private final Map additionalProperties; + + private ContentImportSource( + int id, + int lastSyncedAt, + SyncBehavior syncBehavior, + Status status, + String url, + int createdAt, + int updatedAt, + Map additionalProperties) { + this.id = id; + this.lastSyncedAt = lastSyncedAt; + this.syncBehavior = syncBehavior; + this.status = status; + this.url = url; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.additionalProperties = additionalProperties; + } + + /** + * @return Always external_page + */ + @JsonProperty("type") + public String getType() { + return "content_import_source"; + } + + /** + * @return The unique identifier for the content import source which is given by Intercom. + */ + @JsonProperty("id") + public int getId() { + return id; + } + + /** + * @return The time when the content import source was last synced. + */ + @JsonProperty("last_synced_at") + public int getLastSyncedAt() { + return lastSyncedAt; + } + + /** + * @return If you intend to create or update External Pages via the API, this should be set to api. + */ + @JsonProperty("sync_behavior") + public SyncBehavior getSyncBehavior() { + return syncBehavior; + } + + /** + * @return The status of the content import source. + */ + @JsonProperty("status") + public Status getStatus() { + return status; + } + + /** + * @return The URL of the root of the external source. + */ + @JsonProperty("url") + public String getUrl() { + return url; + } + + /** + * @return The time when the content import source was created. + */ + @JsonProperty("created_at") + public int getCreatedAt() { + return createdAt; + } + + /** + * @return The time when the content import source was last updated. + */ + @JsonProperty("updated_at") + public int getUpdatedAt() { + return updatedAt; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ContentImportSource && equalTo((ContentImportSource) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ContentImportSource other) { + return id == other.id + && lastSyncedAt == other.lastSyncedAt + && syncBehavior.equals(other.syncBehavior) + && status.equals(other.status) + && url.equals(other.url) + && createdAt == other.createdAt + && updatedAt == other.updatedAt; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.id, this.lastSyncedAt, this.syncBehavior, this.status, this.url, this.createdAt, this.updatedAt); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * The unique identifier for the content import source which is given by Intercom. + */ + LastSyncedAtStage id(int id); + + Builder from(ContentImportSource other); + } + + public interface LastSyncedAtStage { + /** + * The time when the content import source was last synced. + */ + SyncBehaviorStage lastSyncedAt(int lastSyncedAt); + } + + public interface SyncBehaviorStage { + /** + * If you intend to create or update External Pages via the API, this should be set to `api`. + */ + StatusStage syncBehavior(@NotNull SyncBehavior syncBehavior); + } + + public interface StatusStage { + /** + * The status of the content import source. + */ + UrlStage status(@NotNull Status status); + } + + public interface UrlStage { + /** + * The URL of the root of the external source. + */ + CreatedAtStage url(@NotNull String url); + } + + public interface CreatedAtStage { + /** + * The time when the content import source was created. + */ + UpdatedAtStage createdAt(int createdAt); + } + + public interface UpdatedAtStage { + /** + * The time when the content import source was last updated. + */ + _FinalStage updatedAt(int updatedAt); + } + + public interface _FinalStage { + ContentImportSource build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements IdStage, + LastSyncedAtStage, + SyncBehaviorStage, + StatusStage, + UrlStage, + CreatedAtStage, + UpdatedAtStage, + _FinalStage { + private int id; + + private int lastSyncedAt; + + private SyncBehavior syncBehavior; + + private Status status; + + private String url; + + private int createdAt; + + private int updatedAt; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ContentImportSource other) { + id(other.getId()); + lastSyncedAt(other.getLastSyncedAt()); + syncBehavior(other.getSyncBehavior()); + status(other.getStatus()); + url(other.getUrl()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + return this; + } + + /** + * The unique identifier for the content import source which is given by Intercom.

The unique identifier for the content import source which is given by Intercom.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public LastSyncedAtStage id(int id) { + this.id = id; + return this; + } + + /** + * The time when the content import source was last synced.

The time when the content import source was last synced.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("last_synced_at") + public SyncBehaviorStage lastSyncedAt(int lastSyncedAt) { + this.lastSyncedAt = lastSyncedAt; + return this; + } + + /** + * If you intend to create or update External Pages via the API, this should be set to `api`.

If you intend to create or update External Pages via the API, this should be set to api.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("sync_behavior") + public StatusStage syncBehavior(@NotNull SyncBehavior syncBehavior) { + this.syncBehavior = Objects.requireNonNull(syncBehavior, "syncBehavior must not be null"); + return this; + } + + /** + * The status of the content import source.

The status of the content import source.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("status") + public UrlStage status(@NotNull Status status) { + this.status = Objects.requireNonNull(status, "status must not be null"); + return this; + } + + /** + * The URL of the root of the external source.

The URL of the root of the external source.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("url") + public CreatedAtStage url(@NotNull String url) { + this.url = Objects.requireNonNull(url, "url must not be null"); + return this; + } + + /** + * The time when the content import source was created.

The time when the content import source was created.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("created_at") + public UpdatedAtStage createdAt(int createdAt) { + this.createdAt = createdAt; + return this; + } + + /** + * The time when the content import source was last updated.

The time when the content import source was last updated.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("updated_at") + public _FinalStage updatedAt(int updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + @java.lang.Override + public ContentImportSource build() { + return new ContentImportSource( + id, lastSyncedAt, syncBehavior, status, url, createdAt, updatedAt, additionalProperties); + } + } + + public static final class Status { + public static final Status DEACTIVATED = new Status(Value.DEACTIVATED, "deactivated"); + + public static final Status ACTIVE = new Status(Value.ACTIVE, "active"); + + private final Value value; + + private final String string; + + Status(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) || (other instanceof Status && this.string.equals(((Status) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case DEACTIVATED: + return visitor.visitDeactivated(); + case ACTIVE: + return visitor.visitActive(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static Status valueOf(String value) { + switch (value) { + case "deactivated": + return DEACTIVATED; + case "active": + return ACTIVE; + default: + return new Status(Value.UNKNOWN, value); + } + } + + public enum Value { + ACTIVE, + + DEACTIVATED, + + UNKNOWN + } + + public interface Visitor { + T visitActive(); + + T visitDeactivated(); + + T visitUnknown(String unknownType); + } + } + + public static final class SyncBehavior { + public static final SyncBehavior MANUAL = new SyncBehavior(Value.MANUAL, "manual"); + + public static final SyncBehavior API = new SyncBehavior(Value.API, "api"); + + public static final SyncBehavior AUTOMATIC = new SyncBehavior(Value.AUTOMATIC, "automatic"); + + private final Value value; + + private final String string; + + SyncBehavior(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof SyncBehavior && this.string.equals(((SyncBehavior) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case MANUAL: + return visitor.visitManual(); + case API: + return visitor.visitApi(); + case AUTOMATIC: + return visitor.visitAutomatic(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static SyncBehavior valueOf(String value) { + switch (value) { + case "manual": + return MANUAL; + case "api": + return API; + case "automatic": + return AUTOMATIC; + default: + return new SyncBehavior(Value.UNKNOWN, value); + } + } + + public enum Value { + API, + + AUTOMATIC, + + MANUAL, + + UNKNOWN + } + + public interface Visitor { + T visitApi(); + + T visitAutomatic(); + + T visitManual(); + + T visitUnknown(String unknownType); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/aicontent/types/ContentImportSourcesList.java b/src/main/java/com/intercom/api/resources/aicontent/types/ContentImportSourcesList.java new file mode 100644 index 0000000..2828601 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/aicontent/types/ContentImportSourcesList.java @@ -0,0 +1,189 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.aicontent.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.types.PagesLink; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ContentImportSourcesList.Builder.class) +public final class ContentImportSourcesList { + private final Optional type; + + private final Optional pages; + + private final Optional totalCount; + + private final Optional> data; + + private final Map additionalProperties; + + private ContentImportSourcesList( + Optional type, + Optional pages, + Optional totalCount, + Optional> data, + Map additionalProperties) { + this.type = type; + this.pages = pages; + this.totalCount = totalCount; + this.data = data; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of the object - list. + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + @JsonProperty("pages") + public Optional getPages() { + return pages; + } + + /** + * @return A count of the total number of content import sources. + */ + @JsonProperty("total_count") + public Optional getTotalCount() { + return totalCount; + } + + /** + * @return An array of Content Import Source objects + */ + @JsonProperty("data") + public Optional> getData() { + return data; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ContentImportSourcesList && equalTo((ContentImportSourcesList) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ContentImportSourcesList other) { + return type.equals(other.type) + && pages.equals(other.pages) + && totalCount.equals(other.totalCount) + && data.equals(other.data); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.pages, this.totalCount, this.data); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); + + private Optional pages = Optional.empty(); + + private Optional totalCount = Optional.empty(); + + private Optional> data = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ContentImportSourcesList other) { + type(other.getType()); + pages(other.getPages()); + totalCount(other.getTotalCount()); + data(other.getData()); + return this; + } + + /** + *

The type of the object - list.

+ */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + @JsonSetter(value = "pages", nulls = Nulls.SKIP) + public Builder pages(Optional pages) { + this.pages = pages; + return this; + } + + public Builder pages(PagesLink pages) { + this.pages = Optional.ofNullable(pages); + return this; + } + + /** + *

A count of the total number of content import sources.

+ */ + @JsonSetter(value = "total_count", nulls = Nulls.SKIP) + public Builder totalCount(Optional totalCount) { + this.totalCount = totalCount; + return this; + } + + public Builder totalCount(Integer totalCount) { + this.totalCount = Optional.ofNullable(totalCount); + return this; + } + + /** + *

An array of Content Import Source objects

+ */ + @JsonSetter(value = "data", nulls = Nulls.SKIP) + public Builder data(Optional> data) { + this.data = data; + return this; + } + + public Builder data(List data) { + this.data = Optional.ofNullable(data); + return this; + } + + public ContentImportSourcesList build() { + return new ContentImportSourcesList(type, pages, totalCount, data, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/aicontent/types/ExternalPage.java b/src/main/java/com/intercom/api/resources/aicontent/types/ExternalPage.java new file mode 100644 index 0000000..6918081 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/aicontent/types/ExternalPage.java @@ -0,0 +1,560 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.aicontent.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ExternalPage.Builder.class) +public final class ExternalPage { + private final String id; + + private final String title; + + private final String html; + + private final Optional url; + + private final boolean aiAgentAvailability; + + private final boolean aiCopilotAvailability; + + private final Optional finAvailability; + + private final int sourceId; + + private final String externalId; + + private final int createdAt; + + private final int updatedAt; + + private final int lastIngestedAt; + + private final Map additionalProperties; + + private ExternalPage( + String id, + String title, + String html, + Optional url, + boolean aiAgentAvailability, + boolean aiCopilotAvailability, + Optional finAvailability, + int sourceId, + String externalId, + int createdAt, + int updatedAt, + int lastIngestedAt, + Map additionalProperties) { + this.id = id; + this.title = title; + this.html = html; + this.url = url; + this.aiAgentAvailability = aiAgentAvailability; + this.aiCopilotAvailability = aiCopilotAvailability; + this.finAvailability = finAvailability; + this.sourceId = sourceId; + this.externalId = externalId; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.lastIngestedAt = lastIngestedAt; + this.additionalProperties = additionalProperties; + } + + /** + * @return Always external_page + */ + @JsonProperty("type") + public String getType() { + return "external_page"; + } + + /** + * @return The unique identifier for the external page which is given by Intercom. + */ + @JsonProperty("id") + public String getId() { + return id; + } + + /** + * @return The title of the external page. + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * @return The body of the external page in HTML. + */ + @JsonProperty("html") + public String getHtml() { + return html; + } + + /** + * @return The URL of the external page. This will be used by Fin to link end users to the page it based its answer on. + */ + @JsonProperty("url") + public Optional getUrl() { + return url; + } + + /** + * @return Whether the external page should be used to answer questions by AI Agent. + */ + @JsonProperty("ai_agent_availability") + public boolean getAiAgentAvailability() { + return aiAgentAvailability; + } + + /** + * @return Whether the external page should be used to answer questions by AI Copilot. + */ + @JsonProperty("ai_copilot_availability") + public boolean getAiCopilotAvailability() { + return aiCopilotAvailability; + } + + /** + * @return Deprecated. Use ai_agent_availability and ai_copilot_availability instead. + */ + @JsonProperty("fin_availability") + public Optional getFinAvailability() { + return finAvailability; + } + + /** + * @return Always en + */ + @JsonProperty("locale") + public String getLocale() { + return "en"; + } + + /** + * @return 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. + */ + @JsonProperty("source_id") + public int getSourceId() { + return sourceId; + } + + /** + * @return The identifier for the external page which was given by the source. Must be unique for the source. + */ + @JsonProperty("external_id") + public String getExternalId() { + return externalId; + } + + /** + * @return The time when the external page was created. + */ + @JsonProperty("created_at") + public int getCreatedAt() { + return createdAt; + } + + /** + * @return The time when the external page was last updated. + */ + @JsonProperty("updated_at") + public int getUpdatedAt() { + return updatedAt; + } + + /** + * @return The time when the external page was last ingested. + */ + @JsonProperty("last_ingested_at") + public int getLastIngestedAt() { + return lastIngestedAt; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ExternalPage && equalTo((ExternalPage) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ExternalPage other) { + return id.equals(other.id) + && title.equals(other.title) + && html.equals(other.html) + && url.equals(other.url) + && aiAgentAvailability == other.aiAgentAvailability + && aiCopilotAvailability == other.aiCopilotAvailability + && finAvailability.equals(other.finAvailability) + && sourceId == other.sourceId + && externalId.equals(other.externalId) + && createdAt == other.createdAt + && updatedAt == other.updatedAt + && lastIngestedAt == other.lastIngestedAt; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.id, + this.title, + this.html, + this.url, + this.aiAgentAvailability, + this.aiCopilotAvailability, + this.finAvailability, + this.sourceId, + this.externalId, + this.createdAt, + this.updatedAt, + this.lastIngestedAt); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * The unique identifier for the external page which is given by Intercom. + */ + TitleStage id(@NotNull String id); + + Builder from(ExternalPage other); + } + + public interface TitleStage { + /** + * The title of the external page. + */ + HtmlStage title(@NotNull String title); + } + + public interface HtmlStage { + /** + * The body of the external page in HTML. + */ + AiAgentAvailabilityStage html(@NotNull String html); + } + + public interface AiAgentAvailabilityStage { + /** + * Whether the external page should be used to answer questions by AI Agent. + */ + AiCopilotAvailabilityStage aiAgentAvailability(boolean aiAgentAvailability); + } + + public interface AiCopilotAvailabilityStage { + /** + * Whether the external page should be used to answer questions by AI Copilot. + */ + SourceIdStage aiCopilotAvailability(boolean aiCopilotAvailability); + } + + public interface SourceIdStage { + /** + * 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. + */ + ExternalIdStage sourceId(int sourceId); + } + + public interface ExternalIdStage { + /** + * The identifier for the external page which was given by the source. Must be unique for the source. + */ + CreatedAtStage externalId(@NotNull String externalId); + } + + public interface CreatedAtStage { + /** + * The time when the external page was created. + */ + UpdatedAtStage createdAt(int createdAt); + } + + public interface UpdatedAtStage { + /** + * The time when the external page was last updated. + */ + LastIngestedAtStage updatedAt(int updatedAt); + } + + public interface LastIngestedAtStage { + /** + * The time when the external page was last ingested. + */ + _FinalStage lastIngestedAt(int lastIngestedAt); + } + + public interface _FinalStage { + ExternalPage build(); + + /** + *

The URL of the external page. This will be used by Fin to link end users to the page it based its answer on.

+ */ + _FinalStage url(Optional url); + + _FinalStage url(String url); + + /** + *

Deprecated. Use ai_agent_availability and ai_copilot_availability instead.

+ */ + _FinalStage finAvailability(Optional finAvailability); + + _FinalStage finAvailability(Boolean finAvailability); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements IdStage, + TitleStage, + HtmlStage, + AiAgentAvailabilityStage, + AiCopilotAvailabilityStage, + SourceIdStage, + ExternalIdStage, + CreatedAtStage, + UpdatedAtStage, + LastIngestedAtStage, + _FinalStage { + private String id; + + private String title; + + private String html; + + private boolean aiAgentAvailability; + + private boolean aiCopilotAvailability; + + private int sourceId; + + private String externalId; + + private int createdAt; + + private int updatedAt; + + private int lastIngestedAt; + + private Optional finAvailability = Optional.empty(); + + private Optional url = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ExternalPage other) { + id(other.getId()); + title(other.getTitle()); + html(other.getHtml()); + url(other.getUrl()); + aiAgentAvailability(other.getAiAgentAvailability()); + aiCopilotAvailability(other.getAiCopilotAvailability()); + finAvailability(other.getFinAvailability()); + sourceId(other.getSourceId()); + externalId(other.getExternalId()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + lastIngestedAt(other.getLastIngestedAt()); + return this; + } + + /** + * The unique identifier for the external page which is given by Intercom.

The unique identifier for the external page which is given by Intercom.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public TitleStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + /** + * The title of the external page.

The title of the external page.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("title") + public HtmlStage title(@NotNull String title) { + this.title = Objects.requireNonNull(title, "title must not be null"); + return this; + } + + /** + * The body of the external page in HTML.

The body of the external page in HTML.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("html") + public AiAgentAvailabilityStage html(@NotNull String html) { + this.html = Objects.requireNonNull(html, "html must not be null"); + return this; + } + + /** + * Whether the external page should be used to answer questions by AI Agent.

Whether the external page should be used to answer questions by AI Agent.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("ai_agent_availability") + public AiCopilotAvailabilityStage aiAgentAvailability(boolean aiAgentAvailability) { + this.aiAgentAvailability = aiAgentAvailability; + return this; + } + + /** + * Whether the external page should be used to answer questions by AI Copilot.

Whether the external page should be used to answer questions by AI Copilot.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("ai_copilot_availability") + public SourceIdStage aiCopilotAvailability(boolean aiCopilotAvailability) { + this.aiCopilotAvailability = aiCopilotAvailability; + return this; + } + + /** + * 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.

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.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("source_id") + public ExternalIdStage sourceId(int sourceId) { + this.sourceId = sourceId; + return this; + } + + /** + * The identifier for the external page which was given by the source. Must be unique for the source.

The identifier for the external page which was given by the source. Must be unique for the source.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("external_id") + public CreatedAtStage externalId(@NotNull String externalId) { + this.externalId = Objects.requireNonNull(externalId, "externalId must not be null"); + return this; + } + + /** + * The time when the external page was created.

The time when the external page was created.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("created_at") + public UpdatedAtStage createdAt(int createdAt) { + this.createdAt = createdAt; + return this; + } + + /** + * The time when the external page was last updated.

The time when the external page was last updated.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("updated_at") + public LastIngestedAtStage updatedAt(int updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + /** + * The time when the external page was last ingested.

The time when the external page was last ingested.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("last_ingested_at") + public _FinalStage lastIngestedAt(int lastIngestedAt) { + this.lastIngestedAt = lastIngestedAt; + return this; + } + + /** + *

Deprecated. Use ai_agent_availability and ai_copilot_availability instead.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage finAvailability(Boolean finAvailability) { + this.finAvailability = Optional.ofNullable(finAvailability); + return this; + } + + /** + *

Deprecated. Use ai_agent_availability and ai_copilot_availability instead.

+ */ + @java.lang.Override + @JsonSetter(value = "fin_availability", nulls = Nulls.SKIP) + public _FinalStage finAvailability(Optional finAvailability) { + this.finAvailability = finAvailability; + return this; + } + + /** + *

The URL of the external page. This will be used by Fin to link end users to the page it based its answer on.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage url(String url) { + this.url = Optional.ofNullable(url); + return this; + } + + /** + *

The URL of the external page. This will be used by Fin to link end users to the page it based its answer on.

+ */ + @java.lang.Override + @JsonSetter(value = "url", nulls = Nulls.SKIP) + public _FinalStage url(Optional url) { + this.url = url; + return this; + } + + @java.lang.Override + public ExternalPage build() { + return new ExternalPage( + id, + title, + html, + url, + aiAgentAvailability, + aiCopilotAvailability, + finAvailability, + sourceId, + externalId, + createdAt, + updatedAt, + lastIngestedAt, + additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/aicontent/types/ExternalPagesList.java b/src/main/java/com/intercom/api/resources/aicontent/types/ExternalPagesList.java new file mode 100644 index 0000000..fbeef33 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/aicontent/types/ExternalPagesList.java @@ -0,0 +1,189 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.aicontent.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.types.PagesLink; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ExternalPagesList.Builder.class) +public final class ExternalPagesList { + private final Optional type; + + private final Optional pages; + + private final Optional totalCount; + + private final Optional> data; + + private final Map additionalProperties; + + private ExternalPagesList( + Optional type, + Optional pages, + Optional totalCount, + Optional> data, + Map additionalProperties) { + this.type = type; + this.pages = pages; + this.totalCount = totalCount; + this.data = data; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of the object - list. + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + @JsonProperty("pages") + public Optional getPages() { + return pages; + } + + /** + * @return A count of the total number of external pages. + */ + @JsonProperty("total_count") + public Optional getTotalCount() { + return totalCount; + } + + /** + * @return An array of External Page objects + */ + @JsonProperty("data") + public Optional> getData() { + return data; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ExternalPagesList && equalTo((ExternalPagesList) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ExternalPagesList other) { + return type.equals(other.type) + && pages.equals(other.pages) + && totalCount.equals(other.totalCount) + && data.equals(other.data); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.pages, this.totalCount, this.data); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); + + private Optional pages = Optional.empty(); + + private Optional totalCount = Optional.empty(); + + private Optional> data = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ExternalPagesList other) { + type(other.getType()); + pages(other.getPages()); + totalCount(other.getTotalCount()); + data(other.getData()); + return this; + } + + /** + *

The type of the object - list.

+ */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + @JsonSetter(value = "pages", nulls = Nulls.SKIP) + public Builder pages(Optional pages) { + this.pages = pages; + return this; + } + + public Builder pages(PagesLink pages) { + this.pages = Optional.ofNullable(pages); + return this; + } + + /** + *

A count of the total number of external pages.

+ */ + @JsonSetter(value = "total_count", nulls = Nulls.SKIP) + public Builder totalCount(Optional totalCount) { + this.totalCount = totalCount; + return this; + } + + public Builder totalCount(Integer totalCount) { + this.totalCount = Optional.ofNullable(totalCount); + return this; + } + + /** + *

An array of External Page objects

+ */ + @JsonSetter(value = "data", nulls = Nulls.SKIP) + public Builder data(Optional> data) { + this.data = data; + return this; + } + + public Builder data(List data) { + this.data = Optional.ofNullable(data); + return this; + } + + public ExternalPagesList build() { + return new ExternalPagesList(type, pages, totalCount, data, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/aicontentsource/types/ContentSource.java b/src/main/java/com/intercom/api/resources/aicontentsource/types/ContentSource.java index cdfb998..db9483c 100644 --- a/src/main/java/com/intercom/api/resources/aicontentsource/types/ContentSource.java +++ b/src/main/java/com/intercom/api/resources/aicontentsource/types/ContentSource.java @@ -9,25 +9,34 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.intercom.api.core.ObjectMappers; import java.util.HashMap; import java.util.Map; import java.util.Objects; -import org.jetbrains.annotations.NotNull; +import java.util.Optional; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ContentSource.Builder.class) public final class ContentSource { - private final String url; + private final Optional contentType; - private final String title; + private final Optional url; - private final String locale; + private final Optional title; + + private final Optional locale; private final Map additionalProperties; - private ContentSource(String url, String title, String locale, Map additionalProperties) { + private ContentSource( + Optional contentType, + Optional url, + Optional title, + Optional locale, + Map additionalProperties) { + this.contentType = contentType; this.url = url; this.title = title; this.locale = locale; @@ -38,15 +47,15 @@ private ContentSource(String url, String title, String locale, Map getContentType() { + return contentType; } /** * @return The internal URL linking to the content source for teammates. */ @JsonProperty("url") - public String getUrl() { + public Optional getUrl() { return url; } @@ -54,7 +63,7 @@ public String getUrl() { * @return The title of the content source. */ @JsonProperty("title") - public String getTitle() { + public Optional getTitle() { return title; } @@ -62,7 +71,7 @@ public String getTitle() { * @return The ISO 639 language code of the content source. */ @JsonProperty("locale") - public String getLocale() { + public Optional getLocale() { return locale; } @@ -78,12 +87,15 @@ public Map getAdditionalProperties() { } private boolean equalTo(ContentSource other) { - return url.equals(other.url) && title.equals(other.title) && locale.equals(other.locale); + return contentType.equals(other.contentType) + && url.equals(other.url) + && title.equals(other.title) + && locale.equals(other.locale); } @java.lang.Override public int hashCode() { - return Objects.hash(this.url, this.title, this.locale); + return Objects.hash(this.contentType, this.url, this.title, this.locale); } @java.lang.Override @@ -91,52 +103,27 @@ public String toString() { return ObjectMappers.stringify(this); } - public static UrlStage builder() { + public static Builder builder() { return new Builder(); } - public interface UrlStage { - /** - * The internal URL linking to the content source for teammates. - */ - TitleStage url(@NotNull String url); - - Builder from(ContentSource other); - } - - public interface TitleStage { - /** - * The title of the content source. - */ - LocaleStage title(@NotNull String title); - } - - public interface LocaleStage { - /** - * The ISO 639 language code of the content source. - */ - _FinalStage locale(@NotNull String locale); - } - - public interface _FinalStage { - ContentSource build(); - } - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements UrlStage, TitleStage, LocaleStage, _FinalStage { - private String url; + public static final class Builder { + private Optional contentType = Optional.empty(); + + private Optional url = Optional.empty(); - private String title; + private Optional title = Optional.empty(); - private String locale; + private Optional locale = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} - @java.lang.Override public Builder from(ContentSource other) { + contentType(other.getContentType()); url(other.getUrl()); title(other.getTitle()); locale(other.getLocale()); @@ -144,41 +131,63 @@ public Builder from(ContentSource other) { } /** - * The internal URL linking to the content source for teammates.

The internal URL linking to the content source for teammates.

- * @return Reference to {@code this} so that method calls can be chained together. + *

The type of the content source.

*/ - @java.lang.Override - @JsonSetter("url") - public TitleStage url(@NotNull String url) { - this.url = Objects.requireNonNull(url, "url must not be null"); + @JsonSetter(value = "content_type", nulls = Nulls.SKIP) + public Builder contentType(Optional contentType) { + this.contentType = contentType; + return this; + } + + public Builder contentType(String contentType) { + this.contentType = Optional.ofNullable(contentType); return this; } /** - * The title of the content source.

The title of the content source.

- * @return Reference to {@code this} so that method calls can be chained together. + *

The internal URL linking to the content source for teammates.

*/ - @java.lang.Override - @JsonSetter("title") - public LocaleStage title(@NotNull String title) { - this.title = Objects.requireNonNull(title, "title must not be null"); + @JsonSetter(value = "url", nulls = Nulls.SKIP) + public Builder url(Optional url) { + this.url = url; + return this; + } + + public Builder url(String url) { + this.url = Optional.ofNullable(url); return this; } /** - * The ISO 639 language code of the content source.

The ISO 639 language code of the content source.

- * @return Reference to {@code this} so that method calls can be chained together. + *

The title of the content source.

*/ - @java.lang.Override - @JsonSetter("locale") - public _FinalStage locale(@NotNull String locale) { - this.locale = Objects.requireNonNull(locale, "locale must not be null"); + @JsonSetter(value = "title", nulls = Nulls.SKIP) + public Builder title(Optional title) { + this.title = title; + return this; + } + + public Builder title(String title) { + this.title = Optional.ofNullable(title); + return this; + } + + /** + *

The ISO 639 language code of the content source.

+ */ + @JsonSetter(value = "locale", nulls = Nulls.SKIP) + public Builder locale(Optional locale) { + this.locale = locale; + return this; + } + + public Builder locale(String locale) { + this.locale = Optional.ofNullable(locale); return this; } - @java.lang.Override public ContentSource build() { - return new ContentSource(url, title, locale, additionalProperties); + return new ContentSource(contentType, url, title, locale, additionalProperties); } } } diff --git a/src/main/java/com/intercom/api/resources/articles/ArticlesClient.java b/src/main/java/com/intercom/api/resources/articles/ArticlesClient.java index e7d0664..0feb90f 100644 --- a/src/main/java/com/intercom/api/resources/articles/ArticlesClient.java +++ b/src/main/java/com/intercom/api/resources/articles/ArticlesClient.java @@ -6,7 +6,6 @@ import com.intercom.api.core.ClientOptions; import com.intercom.api.core.RequestOptions; import com.intercom.api.core.pagination.SyncPagingIterable; -import com.intercom.api.resources.articles.requests.CreateArticleRequest; import com.intercom.api.resources.articles.requests.DeleteArticleRequest; import com.intercom.api.resources.articles.requests.FindArticleRequest; import com.intercom.api.resources.articles.requests.ListArticlesRequest; @@ -14,8 +13,10 @@ import com.intercom.api.resources.articles.requests.UpdateArticleRequest; import com.intercom.api.resources.articles.types.Article; import com.intercom.api.resources.articles.types.ArticleListItem; -import com.intercom.api.resources.articles.types.SearchArticlesResponse; +import com.intercom.api.resources.articles.types.ArticleSearchResponse; +import com.intercom.api.types.CreateArticleRequest; import com.intercom.api.types.DeletedArticleObject; +import java.util.Optional; public class ArticlesClient { protected final ClientOptions clientOptions; @@ -70,14 +71,21 @@ public SyncPagingIterable list(ListArticlesRequest request, Req /** * You can create a new article by making a POST request to https://api.intercom.io/articles. */ - public Article create(CreateArticleRequest request) { + public Article create() { + return this.rawClient.create().body(); + } + + /** + * You can create a new article by making a POST request to https://api.intercom.io/articles. + */ + public Article create(Optional request) { return this.rawClient.create(request).body(); } /** * You can create a new article by making a POST request to https://api.intercom.io/articles. */ - public Article create(CreateArticleRequest request, RequestOptions requestOptions) { + public Article create(Optional request, RequestOptions requestOptions) { return this.rawClient.create(request, requestOptions).body(); } @@ -126,21 +134,21 @@ public DeletedArticleObject delete(DeleteArticleRequest request, RequestOptions /** * You can search for articles by making a GET request to https://api.intercom.io/articles/search. */ - public SearchArticlesResponse search() { + public ArticleSearchResponse search() { return this.rawClient.search().body(); } /** * You can search for articles by making a GET request to https://api.intercom.io/articles/search. */ - public SearchArticlesResponse search(SearchArticlesRequest request) { + public ArticleSearchResponse search(SearchArticlesRequest request) { return this.rawClient.search(request).body(); } /** * You can search for articles by making a GET request to https://api.intercom.io/articles/search. */ - public SearchArticlesResponse search(SearchArticlesRequest request, RequestOptions requestOptions) { + public ArticleSearchResponse search(SearchArticlesRequest request, RequestOptions requestOptions) { return this.rawClient.search(request, requestOptions).body(); } } diff --git a/src/main/java/com/intercom/api/resources/articles/AsyncArticlesClient.java b/src/main/java/com/intercom/api/resources/articles/AsyncArticlesClient.java index b0c29c4..ddafa89 100644 --- a/src/main/java/com/intercom/api/resources/articles/AsyncArticlesClient.java +++ b/src/main/java/com/intercom/api/resources/articles/AsyncArticlesClient.java @@ -6,7 +6,6 @@ import com.intercom.api.core.ClientOptions; import com.intercom.api.core.RequestOptions; import com.intercom.api.core.pagination.SyncPagingIterable; -import com.intercom.api.resources.articles.requests.CreateArticleRequest; import com.intercom.api.resources.articles.requests.DeleteArticleRequest; import com.intercom.api.resources.articles.requests.FindArticleRequest; import com.intercom.api.resources.articles.requests.ListArticlesRequest; @@ -14,8 +13,10 @@ import com.intercom.api.resources.articles.requests.UpdateArticleRequest; import com.intercom.api.resources.articles.types.Article; import com.intercom.api.resources.articles.types.ArticleListItem; -import com.intercom.api.resources.articles.types.SearchArticlesResponse; +import com.intercom.api.resources.articles.types.ArticleSearchResponse; +import com.intercom.api.types.CreateArticleRequest; import com.intercom.api.types.DeletedArticleObject; +import java.util.Optional; import java.util.concurrent.CompletableFuture; public class AsyncArticlesClient { @@ -72,14 +73,21 @@ public CompletableFuture> list( /** * You can create a new article by making a POST request to https://api.intercom.io/articles. */ - public CompletableFuture
create(CreateArticleRequest request) { + public CompletableFuture
create() { + return this.rawClient.create().thenApply(response -> response.body()); + } + + /** + * You can create a new article by making a POST request to https://api.intercom.io/articles. + */ + public CompletableFuture
create(Optional request) { return this.rawClient.create(request).thenApply(response -> response.body()); } /** * You can create a new article by making a POST request to https://api.intercom.io/articles. */ - public CompletableFuture
create(CreateArticleRequest request, RequestOptions requestOptions) { + public CompletableFuture
create(Optional request, RequestOptions requestOptions) { return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); } @@ -128,21 +136,21 @@ public CompletableFuture delete(DeleteArticleRequest reque /** * You can search for articles by making a GET request to https://api.intercom.io/articles/search. */ - public CompletableFuture search() { + public CompletableFuture search() { return this.rawClient.search().thenApply(response -> response.body()); } /** * You can search for articles by making a GET request to https://api.intercom.io/articles/search. */ - public CompletableFuture search(SearchArticlesRequest request) { + public CompletableFuture search(SearchArticlesRequest request) { return this.rawClient.search(request).thenApply(response -> response.body()); } /** * You can search for articles by making a GET request to https://api.intercom.io/articles/search. */ - public CompletableFuture search( + public CompletableFuture search( SearchArticlesRequest request, RequestOptions requestOptions) { return this.rawClient.search(request, requestOptions).thenApply(response -> response.body()); } diff --git a/src/main/java/com/intercom/api/resources/articles/AsyncRawArticlesClient.java b/src/main/java/com/intercom/api/resources/articles/AsyncRawArticlesClient.java index f7b5511..f3a9823 100644 --- a/src/main/java/com/intercom/api/resources/articles/AsyncRawArticlesClient.java +++ b/src/main/java/com/intercom/api/resources/articles/AsyncRawArticlesClient.java @@ -16,7 +16,6 @@ import com.intercom.api.errors.BadRequestError; import com.intercom.api.errors.NotFoundError; import com.intercom.api.errors.UnauthorizedError; -import com.intercom.api.resources.articles.requests.CreateArticleRequest; import com.intercom.api.resources.articles.requests.DeleteArticleRequest; import com.intercom.api.resources.articles.requests.FindArticleRequest; import com.intercom.api.resources.articles.requests.ListArticlesRequest; @@ -24,12 +23,15 @@ import com.intercom.api.resources.articles.requests.UpdateArticleRequest; import com.intercom.api.resources.articles.types.Article; import com.intercom.api.resources.articles.types.ArticleListItem; -import com.intercom.api.resources.articles.types.SearchArticlesResponse; +import com.intercom.api.resources.articles.types.ArticleSearchResponse; import com.intercom.api.types.ArticleList; +import com.intercom.api.types.CreateArticleRequest; import com.intercom.api.types.DeletedArticleObject; import com.intercom.api.types.Error; import java.io.IOException; +import java.util.Collections; import java.util.List; +import java.util.Optional; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; import okhttp3.Call; @@ -118,7 +120,7 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO .from(request) .page(newPageNumber) .build(); - List result = parsedResponse.getData(); + List result = parsedResponse.getData().orElse(Collections.emptyList()); future.complete(new IntercomHttpResponse<>( new SyncPagingIterable(true, result, () -> { try { @@ -164,7 +166,14 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { /** * You can create a new article by making a POST request to https://api.intercom.io/articles. */ - public CompletableFuture> create(CreateArticleRequest request) { + public CompletableFuture> create() { + return create(Optional.empty()); + } + + /** + * You can create a new article by making a POST request to https://api.intercom.io/articles. + */ + public CompletableFuture> create(Optional request) { return create(request, null); } @@ -172,15 +181,18 @@ public CompletableFuture> create(CreateArticleRequ * You can create a new article by making a POST request to https://api.intercom.io/articles. */ public CompletableFuture> create( - CreateArticleRequest request, RequestOptions requestOptions) { + Optional request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("articles") .build(); RequestBody body; try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + body = RequestBody.create("", null); + if (request.isPresent()) { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } } catch (JsonProcessingException e) { throw new IntercomException("Failed to serialize request", e); } @@ -256,7 +268,7 @@ public CompletableFuture> find( HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("articles") - .addPathSegment(request.getArticleId()) + .addPathSegment(Integer.toString(request.getArticleId())) .build(); Request.Builder _requestBuilder = new Request.Builder() .url(httpUrl) @@ -330,7 +342,7 @@ public CompletableFuture> update( HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("articles") - .addPathSegment(request.getArticleId()) + .addPathSegment(Integer.toString(request.getArticleId())) .build(); RequestBody body; try { @@ -411,7 +423,7 @@ public CompletableFuture> delete( HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("articles") - .addPathSegment(request.getArticleId()) + .addPathSegment(Integer.toString(request.getArticleId())) .build(); Request.Builder _requestBuilder = new Request.Builder() .url(httpUrl) @@ -474,21 +486,21 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { /** * You can search for articles by making a GET request to https://api.intercom.io/articles/search. */ - public CompletableFuture> search() { + public CompletableFuture> search() { return search(SearchArticlesRequest.builder().build()); } /** * You can search for articles by making a GET request to https://api.intercom.io/articles/search. */ - public CompletableFuture> search(SearchArticlesRequest request) { + public CompletableFuture> search(SearchArticlesRequest request) { return search(request, null); } /** * You can search for articles by making a GET request to https://api.intercom.io/articles/search. */ - public CompletableFuture> search( + public CompletableFuture> search( SearchArticlesRequest request, RequestOptions requestOptions) { HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -520,15 +532,14 @@ public CompletableFuture> search( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } - CompletableFuture> future = new CompletableFuture<>(); + CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), SearchArticlesResponse.class), + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ArticleSearchResponse.class), response)); return; } diff --git a/src/main/java/com/intercom/api/resources/articles/RawArticlesClient.java b/src/main/java/com/intercom/api/resources/articles/RawArticlesClient.java index 85302d6..72f72f9 100644 --- a/src/main/java/com/intercom/api/resources/articles/RawArticlesClient.java +++ b/src/main/java/com/intercom/api/resources/articles/RawArticlesClient.java @@ -16,7 +16,6 @@ import com.intercom.api.errors.BadRequestError; import com.intercom.api.errors.NotFoundError; import com.intercom.api.errors.UnauthorizedError; -import com.intercom.api.resources.articles.requests.CreateArticleRequest; import com.intercom.api.resources.articles.requests.DeleteArticleRequest; import com.intercom.api.resources.articles.requests.FindArticleRequest; import com.intercom.api.resources.articles.requests.ListArticlesRequest; @@ -24,12 +23,15 @@ import com.intercom.api.resources.articles.requests.UpdateArticleRequest; import com.intercom.api.resources.articles.types.Article; import com.intercom.api.resources.articles.types.ArticleListItem; -import com.intercom.api.resources.articles.types.SearchArticlesResponse; +import com.intercom.api.resources.articles.types.ArticleSearchResponse; import com.intercom.api.types.ArticleList; +import com.intercom.api.types.CreateArticleRequest; import com.intercom.api.types.DeletedArticleObject; import com.intercom.api.types.Error; import java.io.IOException; +import java.util.Collections; import java.util.List; +import java.util.Optional; import okhttp3.Headers; import okhttp3.HttpUrl; import okhttp3.OkHttpClient; @@ -108,7 +110,7 @@ public IntercomHttpResponse> list( .from(request) .page(newPageNumber) .build(); - List result = parsedResponse.getData(); + List result = parsedResponse.getData().orElse(Collections.emptyList()); return new IntercomHttpResponse<>( new SyncPagingIterable(true, result, () -> list(nextRequest, requestOptions) .body()), @@ -136,22 +138,32 @@ public IntercomHttpResponse> list( /** * You can create a new article by making a POST request to https://api.intercom.io/articles. */ - public IntercomHttpResponse
create(CreateArticleRequest request) { + public IntercomHttpResponse
create() { + return create(Optional.empty()); + } + + /** + * You can create a new article by making a POST request to https://api.intercom.io/articles. + */ + public IntercomHttpResponse
create(Optional request) { return create(request, null); } /** * You can create a new article by making a POST request to https://api.intercom.io/articles. */ - public IntercomHttpResponse
create(CreateArticleRequest request, RequestOptions requestOptions) { + public IntercomHttpResponse
create(Optional request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("articles") .build(); RequestBody body; try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + body = RequestBody.create("", null); + if (request.isPresent()) { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } } catch (JsonProcessingException e) { throw new IntercomException("Failed to serialize request", e); } @@ -209,7 +221,7 @@ public IntercomHttpResponse
find(FindArticleRequest request, RequestOpt HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("articles") - .addPathSegment(request.getArticleId()) + .addPathSegment(Integer.toString(request.getArticleId())) .build(); Request.Builder _requestBuilder = new Request.Builder() .url(httpUrl) @@ -265,7 +277,7 @@ public IntercomHttpResponse
update(UpdateArticleRequest request, Reques HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("articles") - .addPathSegment(request.getArticleId()) + .addPathSegment(Integer.toString(request.getArticleId())) .build(); RequestBody body; try { @@ -329,7 +341,7 @@ public IntercomHttpResponse delete( HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("articles") - .addPathSegment(request.getArticleId()) + .addPathSegment(Integer.toString(request.getArticleId())) .build(); Request.Builder _requestBuilder = new Request.Builder() .url(httpUrl) @@ -375,21 +387,21 @@ public IntercomHttpResponse delete( /** * You can search for articles by making a GET request to https://api.intercom.io/articles/search. */ - public IntercomHttpResponse search() { + public IntercomHttpResponse search() { return search(SearchArticlesRequest.builder().build()); } /** * You can search for articles by making a GET request to https://api.intercom.io/articles/search. */ - public IntercomHttpResponse search(SearchArticlesRequest request) { + public IntercomHttpResponse search(SearchArticlesRequest request) { return search(request, null); } /** * You can search for articles by making a GET request to https://api.intercom.io/articles/search. */ - public IntercomHttpResponse search( + public IntercomHttpResponse search( SearchArticlesRequest request, RequestOptions requestOptions) { HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -425,7 +437,7 @@ public IntercomHttpResponse search( ResponseBody responseBody = response.body(); if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SearchArticlesResponse.class), + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ArticleSearchResponse.class), response); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; diff --git a/src/main/java/com/intercom/api/resources/articles/requests/DeleteArticleRequest.java b/src/main/java/com/intercom/api/resources/articles/requests/DeleteArticleRequest.java index dd09632..bf673d5 100644 --- a/src/main/java/com/intercom/api/resources/articles/requests/DeleteArticleRequest.java +++ b/src/main/java/com/intercom/api/resources/articles/requests/DeleteArticleRequest.java @@ -14,16 +14,15 @@ import java.util.HashMap; import java.util.Map; import java.util.Objects; -import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = DeleteArticleRequest.Builder.class) public final class DeleteArticleRequest { - private final String articleId; + private final int articleId; private final Map additionalProperties; - private DeleteArticleRequest(String articleId, Map additionalProperties) { + private DeleteArticleRequest(int articleId, Map additionalProperties) { this.articleId = articleId; this.additionalProperties = additionalProperties; } @@ -32,7 +31,7 @@ private DeleteArticleRequest(String articleId, Map additionalPro * @return The unique identifier for the article which is given by Intercom. */ @JsonProperty("article_id") - public String getArticleId() { + public int getArticleId() { return articleId; } @@ -48,7 +47,7 @@ public Map getAdditionalProperties() { } private boolean equalTo(DeleteArticleRequest other) { - return articleId.equals(other.articleId); + return articleId == other.articleId; } @java.lang.Override @@ -69,7 +68,7 @@ public interface ArticleIdStage { /** * The unique identifier for the article which is given by Intercom. */ - _FinalStage articleId(@NotNull String articleId); + _FinalStage articleId(int articleId); Builder from(DeleteArticleRequest other); } @@ -80,7 +79,7 @@ public interface _FinalStage { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements ArticleIdStage, _FinalStage { - private String articleId; + private int articleId; @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -99,8 +98,8 @@ public Builder from(DeleteArticleRequest other) { */ @java.lang.Override @JsonSetter("article_id") - public _FinalStage articleId(@NotNull String articleId) { - this.articleId = Objects.requireNonNull(articleId, "articleId must not be null"); + public _FinalStage articleId(int articleId) { + this.articleId = articleId; return this; } diff --git a/src/main/java/com/intercom/api/resources/articles/requests/FindArticleRequest.java b/src/main/java/com/intercom/api/resources/articles/requests/FindArticleRequest.java index 66535e1..8127463 100644 --- a/src/main/java/com/intercom/api/resources/articles/requests/FindArticleRequest.java +++ b/src/main/java/com/intercom/api/resources/articles/requests/FindArticleRequest.java @@ -14,16 +14,15 @@ import java.util.HashMap; import java.util.Map; import java.util.Objects; -import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = FindArticleRequest.Builder.class) public final class FindArticleRequest { - private final String articleId; + private final int articleId; private final Map additionalProperties; - private FindArticleRequest(String articleId, Map additionalProperties) { + private FindArticleRequest(int articleId, Map additionalProperties) { this.articleId = articleId; this.additionalProperties = additionalProperties; } @@ -32,7 +31,7 @@ private FindArticleRequest(String articleId, Map additionalPrope * @return The unique identifier for the article which is given by Intercom. */ @JsonProperty("article_id") - public String getArticleId() { + public int getArticleId() { return articleId; } @@ -48,7 +47,7 @@ public Map getAdditionalProperties() { } private boolean equalTo(FindArticleRequest other) { - return articleId.equals(other.articleId); + return articleId == other.articleId; } @java.lang.Override @@ -69,7 +68,7 @@ public interface ArticleIdStage { /** * The unique identifier for the article which is given by Intercom. */ - _FinalStage articleId(@NotNull String articleId); + _FinalStage articleId(int articleId); Builder from(FindArticleRequest other); } @@ -80,7 +79,7 @@ public interface _FinalStage { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements ArticleIdStage, _FinalStage { - private String articleId; + private int articleId; @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -99,8 +98,8 @@ public Builder from(FindArticleRequest other) { */ @java.lang.Override @JsonSetter("article_id") - public _FinalStage articleId(@NotNull String articleId) { - this.articleId = Objects.requireNonNull(articleId, "articleId must not be null"); + public _FinalStage articleId(int articleId) { + this.articleId = articleId; return this; } diff --git a/src/main/java/com/intercom/api/resources/articles/requests/UpdateArticleRequest.java b/src/main/java/com/intercom/api/resources/articles/requests/UpdateArticleRequest.java index fb1bf1c..ac0e213 100644 --- a/src/main/java/com/intercom/api/resources/articles/requests/UpdateArticleRequest.java +++ b/src/main/java/com/intercom/api/resources/articles/requests/UpdateArticleRequest.java @@ -19,12 +19,11 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; -import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = UpdateArticleRequest.Builder.class) public final class UpdateArticleRequest { - private final String articleId; + private final int articleId; private final Optional title; @@ -38,21 +37,21 @@ public final class UpdateArticleRequest { private final Optional parentId; - private final Optional parentType; + private final Optional parentType; private final Optional translatedContent; private final Map additionalProperties; private UpdateArticleRequest( - String articleId, + int articleId, Optional title, Optional description, Optional body, Optional authorId, Optional state, Optional parentId, - Optional parentType, + Optional parentType, Optional translatedContent, Map additionalProperties) { this.articleId = articleId; @@ -71,7 +70,7 @@ private UpdateArticleRequest( * @return The unique identifier for the article which is given by Intercom. */ @JsonProperty("article_id") - public String getArticleId() { + public int getArticleId() { return articleId; } @@ -127,7 +126,7 @@ public Optional getParentId() { * @return The type of parent, which can either be a collection or section. */ @JsonProperty("parent_type") - public Optional getParentType() { + public Optional getParentType() { return parentType; } @@ -148,7 +147,7 @@ public Map getAdditionalProperties() { } private boolean equalTo(UpdateArticleRequest other) { - return articleId.equals(other.articleId) + return articleId == other.articleId && title.equals(other.title) && description.equals(other.description) && body.equals(other.body) @@ -186,7 +185,7 @@ public interface ArticleIdStage { /** * The unique identifier for the article which is given by Intercom. */ - _FinalStage articleId(@NotNull String articleId); + _FinalStage articleId(int articleId); Builder from(UpdateArticleRequest other); } @@ -239,9 +238,9 @@ public interface _FinalStage { /** *

The type of parent, which can either be a collection or section.

*/ - _FinalStage parentType(Optional parentType); + _FinalStage parentType(Optional parentType); - _FinalStage parentType(ParentType parentType); + _FinalStage parentType(String parentType); _FinalStage translatedContent(Optional translatedContent); @@ -250,11 +249,11 @@ public interface _FinalStage { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements ArticleIdStage, _FinalStage { - private String articleId; + private int articleId; private Optional translatedContent = Optional.empty(); - private Optional parentType = Optional.empty(); + private Optional parentType = Optional.empty(); private Optional parentId = Optional.empty(); @@ -293,8 +292,8 @@ public Builder from(UpdateArticleRequest other) { */ @java.lang.Override @JsonSetter("article_id") - public _FinalStage articleId(@NotNull String articleId) { - this.articleId = Objects.requireNonNull(articleId, "articleId must not be null"); + public _FinalStage articleId(int articleId) { + this.articleId = articleId; return this; } @@ -316,7 +315,7 @@ public _FinalStage translatedContent(Optional translat * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override - public _FinalStage parentType(ParentType parentType) { + public _FinalStage parentType(String parentType) { this.parentType = Optional.ofNullable(parentType); return this; } @@ -326,7 +325,7 @@ public _FinalStage parentType(ParentType parentType) { */ @java.lang.Override @JsonSetter(value = "parent_type", nulls = Nulls.SKIP) - public _FinalStage parentType(Optional parentType) { + public _FinalStage parentType(Optional parentType) { this.parentType = parentType; return this; } @@ -467,81 +466,6 @@ public UpdateArticleRequest build() { } } - public static final class ParentType { - public static final ParentType SECTION = new ParentType(Value.SECTION, "section"); - - public static final ParentType COLLECTION = new ParentType(Value.COLLECTION, "collection"); - - private final Value value; - - private final String string; - - ParentType(Value value, String string) { - this.value = value; - this.string = string; - } - - public Value getEnumValue() { - return value; - } - - @java.lang.Override - @JsonValue - public String toString() { - return this.string; - } - - @java.lang.Override - public boolean equals(Object other) { - return (this == other) || (other instanceof ParentType && this.string.equals(((ParentType) other).string)); - } - - @java.lang.Override - public int hashCode() { - return this.string.hashCode(); - } - - public T visit(Visitor visitor) { - switch (value) { - case SECTION: - return visitor.visitSection(); - case COLLECTION: - return visitor.visitCollection(); - case UNKNOWN: - default: - return visitor.visitUnknown(string); - } - } - - @JsonCreator(mode = JsonCreator.Mode.DELEGATING) - public static ParentType valueOf(String value) { - switch (value) { - case "section": - return SECTION; - case "collection": - return COLLECTION; - default: - return new ParentType(Value.UNKNOWN, value); - } - } - - public enum Value { - COLLECTION, - - SECTION, - - UNKNOWN - } - - public interface Visitor { - T visitCollection(); - - T visitSection(); - - T visitUnknown(String unknownType); - } - } - public static final class State { public static final State PUBLISHED = new State(Value.PUBLISHED, "published"); diff --git a/src/main/java/com/intercom/api/resources/articles/types/Article.java b/src/main/java/com/intercom/api/resources/articles/types/Article.java index aee34c2..762c99e 100644 --- a/src/main/java/com/intercom/api/resources/articles/types/Article.java +++ b/src/main/java/com/intercom/api/resources/articles/types/Article.java @@ -54,9 +54,9 @@ public final class Article implements IArticleListItem { private final Optional parentType; - private final String defaultLocale; + private final Optional defaultLocale; - private final ArticleTranslatedContent translatedContent; + private final Optional translatedContent; private final Optional statistics; @@ -77,8 +77,8 @@ private Article( Optional parentId, Optional> parentIds, Optional parentType, - String defaultLocale, - ArticleTranslatedContent translatedContent, + Optional defaultLocale, + Optional translatedContent, Optional statistics, Map additionalProperties) { this.type = type; @@ -217,12 +217,12 @@ public Optional getParentType() { * @return The default locale of the help center. This field is only returned for multilingual help centers. */ @JsonProperty("default_locale") - public String getDefaultLocale() { + public Optional getDefaultLocale() { return defaultLocale; } @JsonProperty("translated_content") - public ArticleTranslatedContent getTranslatedContent() { + public Optional getTranslatedContent() { return translatedContent; } @@ -341,18 +341,7 @@ public interface UpdatedAtStage { /** * 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. */ - DefaultLocaleStage updatedAt(int updatedAt); - } - - public interface DefaultLocaleStage { - /** - * The default locale of the help center. This field is only returned for multilingual help centers. - */ - TranslatedContentStage defaultLocale(@NotNull String defaultLocale); - } - - public interface TranslatedContentStage { - _FinalStage translatedContent(@NotNull ArticleTranslatedContent translatedContent); + _FinalStage updatedAt(int updatedAt); } public interface _FinalStage { @@ -407,6 +396,17 @@ public interface _FinalStage { _FinalStage parentType(String parentType); + /** + *

The default locale of the help center. This field is only returned for multilingual help centers.

+ */ + _FinalStage defaultLocale(Optional defaultLocale); + + _FinalStage defaultLocale(String defaultLocale); + + _FinalStage translatedContent(Optional translatedContent); + + _FinalStage translatedContent(ArticleTranslatedContent translatedContent); + _FinalStage statistics(Optional statistics); _FinalStage statistics(ArticleStatistics statistics); @@ -421,8 +421,6 @@ public static final class Builder StateStage, CreatedAtStage, UpdatedAtStage, - DefaultLocaleStage, - TranslatedContentStage, _FinalStage { private String id; @@ -438,11 +436,11 @@ public static final class Builder private int updatedAt; - private String defaultLocale; + private Optional statistics = Optional.empty(); - private ArticleTranslatedContent translatedContent; + private Optional translatedContent = Optional.empty(); - private Optional statistics = Optional.empty(); + private Optional defaultLocale = Optional.empty(); private Optional parentType = Optional.empty(); @@ -557,39 +555,54 @@ public UpdatedAtStage createdAt(int createdAt) { */ @java.lang.Override @JsonSetter("updated_at") - public DefaultLocaleStage updatedAt(int updatedAt) { + public _FinalStage updatedAt(int updatedAt) { this.updatedAt = updatedAt; return this; } - /** - * The default locale of the help center. This field is only returned for multilingual help centers.

The default locale of the help center. This field is only returned for multilingual help centers.

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override - @JsonSetter("default_locale") - public TranslatedContentStage defaultLocale(@NotNull String defaultLocale) { - this.defaultLocale = Objects.requireNonNull(defaultLocale, "defaultLocale must not be null"); + public _FinalStage statistics(ArticleStatistics statistics) { + this.statistics = Optional.ofNullable(statistics); + return this; + } + + @java.lang.Override + @JsonSetter(value = "statistics", nulls = Nulls.SKIP) + public _FinalStage statistics(Optional statistics) { + this.statistics = statistics; return this; } @java.lang.Override - @JsonSetter("translated_content") - public _FinalStage translatedContent(@NotNull ArticleTranslatedContent translatedContent) { - this.translatedContent = Objects.requireNonNull(translatedContent, "translatedContent must not be null"); + public _FinalStage translatedContent(ArticleTranslatedContent translatedContent) { + this.translatedContent = Optional.ofNullable(translatedContent); return this; } @java.lang.Override - public _FinalStage statistics(ArticleStatistics statistics) { - this.statistics = Optional.ofNullable(statistics); + @JsonSetter(value = "translated_content", nulls = Nulls.SKIP) + public _FinalStage translatedContent(Optional translatedContent) { + this.translatedContent = translatedContent; + return this; + } + + /** + *

The default locale of the help center. This field is only returned for multilingual help centers.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage defaultLocale(String defaultLocale) { + this.defaultLocale = Optional.ofNullable(defaultLocale); return this; } + /** + *

The default locale of the help center. This field is only returned for multilingual help centers.

+ */ @java.lang.Override - @JsonSetter(value = "statistics", nulls = Nulls.SKIP) - public _FinalStage statistics(Optional statistics) { - this.statistics = statistics; + @JsonSetter(value = "default_locale", nulls = Nulls.SKIP) + public _FinalStage defaultLocale(Optional defaultLocale) { + this.defaultLocale = defaultLocale; return this; } diff --git a/src/main/java/com/intercom/api/resources/articles/types/ArticleListItem.java b/src/main/java/com/intercom/api/resources/articles/types/ArticleListItem.java index ec33c25..e139c75 100644 --- a/src/main/java/com/intercom/api/resources/articles/types/ArticleListItem.java +++ b/src/main/java/com/intercom/api/resources/articles/types/ArticleListItem.java @@ -53,9 +53,9 @@ public final class ArticleListItem implements IArticleListItem { private final Optional parentType; - private final String defaultLocale; + private final Optional defaultLocale; - private final ArticleTranslatedContent translatedContent; + private final Optional translatedContent; private final Map additionalProperties; @@ -74,8 +74,8 @@ private ArticleListItem( Optional parentId, Optional> parentIds, Optional parentType, - String defaultLocale, - ArticleTranslatedContent translatedContent, + Optional defaultLocale, + Optional translatedContent, Map additionalProperties) { this.type = type; this.id = id; @@ -212,12 +212,12 @@ public Optional getParentType() { * @return The default locale of the help center. This field is only returned for multilingual help centers. */ @JsonProperty("default_locale") - public String getDefaultLocale() { + public Optional getDefaultLocale() { return defaultLocale; } @JsonProperty("translated_content") - public ArticleTranslatedContent getTranslatedContent() { + public Optional getTranslatedContent() { return translatedContent; } @@ -329,18 +329,7 @@ public interface UpdatedAtStage { /** * 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. */ - DefaultLocaleStage updatedAt(int updatedAt); - } - - public interface DefaultLocaleStage { - /** - * The default locale of the help center. This field is only returned for multilingual help centers. - */ - TranslatedContentStage defaultLocale(@NotNull String defaultLocale); - } - - public interface TranslatedContentStage { - _FinalStage translatedContent(@NotNull ArticleTranslatedContent translatedContent); + _FinalStage updatedAt(int updatedAt); } public interface _FinalStage { @@ -394,6 +383,17 @@ public interface _FinalStage { _FinalStage parentType(Optional parentType); _FinalStage parentType(String parentType); + + /** + *

The default locale of the help center. This field is only returned for multilingual help centers.

+ */ + _FinalStage defaultLocale(Optional defaultLocale); + + _FinalStage defaultLocale(String defaultLocale); + + _FinalStage translatedContent(Optional translatedContent); + + _FinalStage translatedContent(ArticleTranslatedContent translatedContent); } @JsonIgnoreProperties(ignoreUnknown = true) @@ -405,8 +405,6 @@ public static final class Builder StateStage, CreatedAtStage, UpdatedAtStage, - DefaultLocaleStage, - TranslatedContentStage, _FinalStage { private String id; @@ -422,9 +420,9 @@ public static final class Builder private int updatedAt; - private String defaultLocale; + private Optional translatedContent = Optional.empty(); - private ArticleTranslatedContent translatedContent; + private Optional defaultLocale = Optional.empty(); private Optional parentType = Optional.empty(); @@ -538,26 +536,41 @@ public UpdatedAtStage createdAt(int createdAt) { */ @java.lang.Override @JsonSetter("updated_at") - public DefaultLocaleStage updatedAt(int updatedAt) { + public _FinalStage updatedAt(int updatedAt) { this.updatedAt = updatedAt; return this; } + @java.lang.Override + public _FinalStage translatedContent(ArticleTranslatedContent translatedContent) { + this.translatedContent = Optional.ofNullable(translatedContent); + return this; + } + + @java.lang.Override + @JsonSetter(value = "translated_content", nulls = Nulls.SKIP) + public _FinalStage translatedContent(Optional translatedContent) { + this.translatedContent = translatedContent; + return this; + } + /** - * The default locale of the help center. This field is only returned for multilingual help centers.

The default locale of the help center. This field is only returned for multilingual help centers.

+ *

The default locale of the help center. This field is only returned for multilingual help centers.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override - @JsonSetter("default_locale") - public TranslatedContentStage defaultLocale(@NotNull String defaultLocale) { - this.defaultLocale = Objects.requireNonNull(defaultLocale, "defaultLocale must not be null"); + public _FinalStage defaultLocale(String defaultLocale) { + this.defaultLocale = Optional.ofNullable(defaultLocale); return this; } + /** + *

The default locale of the help center. This field is only returned for multilingual help centers.

+ */ @java.lang.Override - @JsonSetter("translated_content") - public _FinalStage translatedContent(@NotNull ArticleTranslatedContent translatedContent) { - this.translatedContent = Objects.requireNonNull(translatedContent, "translatedContent must not be null"); + @JsonSetter(value = "default_locale", nulls = Nulls.SKIP) + public _FinalStage defaultLocale(Optional defaultLocale) { + this.defaultLocale = defaultLocale; return this; } diff --git a/src/main/java/com/intercom/api/resources/articles/types/ArticleSearchHighlights.java b/src/main/java/com/intercom/api/resources/articles/types/ArticleSearchHighlights.java index dbb6bc6..c429741 100644 --- a/src/main/java/com/intercom/api/resources/articles/types/ArticleSearchHighlights.java +++ b/src/main/java/com/intercom/api/resources/articles/types/ArticleSearchHighlights.java @@ -14,29 +14,27 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.intercom.api.core.ObjectMappers; -import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; -import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ArticleSearchHighlights.Builder.class) public final class ArticleSearchHighlights { - private final String articleId; + private final Optional articleId; - private final List highlightedTitle; + private final Optional> highlightedTitle; - private final List> highlightedSummary; + private final Optional>> highlightedSummary; private final Map additionalProperties; private ArticleSearchHighlights( - String articleId, - List highlightedTitle, - List> highlightedSummary, + Optional articleId, + Optional> highlightedTitle, + Optional>> highlightedSummary, Map additionalProperties) { this.articleId = articleId; this.highlightedTitle = highlightedTitle; @@ -48,7 +46,7 @@ private ArticleSearchHighlights( * @return The ID of the corresponding article. */ @JsonProperty("article_id") - public String getArticleId() { + public Optional getArticleId() { return articleId; } @@ -56,7 +54,7 @@ public String getArticleId() { * @return An Article title highlighted. */ @JsonProperty("highlighted_title") - public List getHighlightedTitle() { + public Optional> getHighlightedTitle() { return highlightedTitle; } @@ -64,7 +62,7 @@ public List getHighlightedTitle() { * @return An Article description and body text highlighted. */ @JsonProperty("highlighted_summary") - public List> getHighlightedSummary() { + public Optional>> getHighlightedSummary() { return highlightedSummary; } @@ -95,55 +93,23 @@ public String toString() { return ObjectMappers.stringify(this); } - public static ArticleIdStage builder() { + public static Builder builder() { return new Builder(); } - public interface ArticleIdStage { - /** - * The ID of the corresponding article. - */ - _FinalStage articleId(@NotNull String articleId); - - Builder from(ArticleSearchHighlights other); - } - - public interface _FinalStage { - ArticleSearchHighlights build(); - - /** - *

An Article title highlighted.

- */ - _FinalStage highlightedTitle(List highlightedTitle); - - _FinalStage addHighlightedTitle(HighlightedTitleItem highlightedTitle); - - _FinalStage addAllHighlightedTitle(List highlightedTitle); - - /** - *

An Article description and body text highlighted.

- */ - _FinalStage highlightedSummary(List> highlightedSummary); - - _FinalStage addHighlightedSummary(List highlightedSummary); - - _FinalStage addAllHighlightedSummary(List> highlightedSummary); - } - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements ArticleIdStage, _FinalStage { - private String articleId; + public static final class Builder { + private Optional articleId = Optional.empty(); - private List> highlightedSummary = new ArrayList<>(); + private Optional> highlightedTitle = Optional.empty(); - private List highlightedTitle = new ArrayList<>(); + private Optional>> highlightedSummary = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} - @java.lang.Override public Builder from(ArticleSearchHighlights other) { articleId(other.getArticleId()); highlightedTitle(other.getHighlightedTitle()); @@ -152,79 +118,47 @@ public Builder from(ArticleSearchHighlights other) { } /** - * The ID of the corresponding article.

The ID of the corresponding article.

- * @return Reference to {@code this} so that method calls can be chained together. + *

The ID of the corresponding article.

*/ - @java.lang.Override - @JsonSetter("article_id") - public _FinalStage articleId(@NotNull String articleId) { - this.articleId = Objects.requireNonNull(articleId, "articleId must not be null"); + @JsonSetter(value = "article_id", nulls = Nulls.SKIP) + public Builder articleId(Optional articleId) { + this.articleId = articleId; return this; } - /** - *

An Article description and body text highlighted.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage addAllHighlightedSummary(List> highlightedSummary) { - this.highlightedSummary.addAll(highlightedSummary); + public Builder articleId(String articleId) { + this.articleId = Optional.ofNullable(articleId); return this; } /** - *

An Article description and body text highlighted.

- * @return Reference to {@code this} so that method calls can be chained together. + *

An Article title highlighted.

*/ - @java.lang.Override - public _FinalStage addHighlightedSummary(List highlightedSummary) { - this.highlightedSummary.add(highlightedSummary); + @JsonSetter(value = "highlighted_title", nulls = Nulls.SKIP) + public Builder highlightedTitle(Optional> highlightedTitle) { + this.highlightedTitle = highlightedTitle; return this; } - /** - *

An Article description and body text highlighted.

- */ - @java.lang.Override - @JsonSetter(value = "highlighted_summary", nulls = Nulls.SKIP) - public _FinalStage highlightedSummary(List> highlightedSummary) { - this.highlightedSummary.clear(); - this.highlightedSummary.addAll(highlightedSummary); + public Builder highlightedTitle(List highlightedTitle) { + this.highlightedTitle = Optional.ofNullable(highlightedTitle); return this; } /** - *

An Article title highlighted.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage addAllHighlightedTitle(List highlightedTitle) { - this.highlightedTitle.addAll(highlightedTitle); - return this; - } - - /** - *

An Article title highlighted.

- * @return Reference to {@code this} so that method calls can be chained together. + *

An Article description and body text highlighted.

*/ - @java.lang.Override - public _FinalStage addHighlightedTitle(HighlightedTitleItem highlightedTitle) { - this.highlightedTitle.add(highlightedTitle); + @JsonSetter(value = "highlighted_summary", nulls = Nulls.SKIP) + public Builder highlightedSummary(Optional>> highlightedSummary) { + this.highlightedSummary = highlightedSummary; return this; } - /** - *

An Article title highlighted.

- */ - @java.lang.Override - @JsonSetter(value = "highlighted_title", nulls = Nulls.SKIP) - public _FinalStage highlightedTitle(List highlightedTitle) { - this.highlightedTitle.clear(); - this.highlightedTitle.addAll(highlightedTitle); + public Builder highlightedSummary(List> highlightedSummary) { + this.highlightedSummary = Optional.ofNullable(highlightedSummary); return this; } - @java.lang.Override public ArticleSearchHighlights build() { return new ArticleSearchHighlights(articleId, highlightedTitle, highlightedSummary, additionalProperties); } diff --git a/src/main/java/com/intercom/api/resources/articles/types/SearchArticlesResponse.java b/src/main/java/com/intercom/api/resources/articles/types/ArticleSearchResponse.java similarity index 70% rename from src/main/java/com/intercom/api/resources/articles/types/SearchArticlesResponse.java rename to src/main/java/com/intercom/api/resources/articles/types/ArticleSearchResponse.java index 173874f..c188596 100644 --- a/src/main/java/com/intercom/api/resources/articles/types/SearchArticlesResponse.java +++ b/src/main/java/com/intercom/api/resources/articles/types/ArticleSearchResponse.java @@ -18,21 +18,27 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; -import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = SearchArticlesResponse.Builder.class) -public final class SearchArticlesResponse { - private final int totalCount; +@JsonDeserialize(builder = ArticleSearchResponse.Builder.class) +public final class ArticleSearchResponse { + private final Optional type; - private final Data data; + private final Optional totalCount; + + private final Optional data; private final Optional pages; private final Map additionalProperties; - private SearchArticlesResponse( - int totalCount, Data data, Optional pages, Map additionalProperties) { + private ArticleSearchResponse( + Optional type, + Optional totalCount, + Optional data, + Optional pages, + Map additionalProperties) { + this.type = type; this.totalCount = totalCount; this.data = data; this.pages = pages; @@ -43,15 +49,15 @@ private SearchArticlesResponse( * @return The type of the object - list. */ @JsonProperty("type") - public String getType() { - return "list"; + public Optional getType() { + return type; } /** * @return The total number of Articles matching the search query */ @JsonProperty("total_count") - public int getTotalCount() { + public Optional getTotalCount() { return totalCount; } @@ -59,7 +65,7 @@ public int getTotalCount() { * @return An object containing the results of the search. */ @JsonProperty("data") - public Data getData() { + public Optional getData() { return data; } @@ -71,7 +77,7 @@ public Optional getPages() { @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof SearchArticlesResponse && equalTo((SearchArticlesResponse) other); + return other instanceof ArticleSearchResponse && equalTo((ArticleSearchResponse) other); } @JsonAnyGetter @@ -79,13 +85,16 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(SearchArticlesResponse other) { - return totalCount == other.totalCount && data.equals(other.data) && pages.equals(other.pages); + private boolean equalTo(ArticleSearchResponse other) { + return type.equals(other.type) + && totalCount.equals(other.totalCount) + && data.equals(other.data) + && pages.equals(other.pages); } @java.lang.Override public int hashCode() { - return Objects.hash(this.totalCount, this.data, this.pages); + return Objects.hash(this.type, this.totalCount, this.data, this.pages); } @java.lang.Override @@ -93,39 +102,17 @@ public String toString() { return ObjectMappers.stringify(this); } - public static TotalCountStage builder() { + public static Builder builder() { return new Builder(); } - public interface TotalCountStage { - /** - * The total number of Articles matching the search query - */ - DataStage totalCount(int totalCount); - - Builder from(SearchArticlesResponse other); - } - - public interface DataStage { - /** - * An object containing the results of the search. - */ - _FinalStage data(@NotNull Data data); - } - - public interface _FinalStage { - SearchArticlesResponse build(); - - _FinalStage pages(Optional pages); - - _FinalStage pages(CursorPages pages); - } - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements TotalCountStage, DataStage, _FinalStage { - private int totalCount; + public static final class Builder { + private Optional type = Optional.empty(); + + private Optional totalCount = Optional.empty(); - private Data data; + private Optional data = Optional.empty(); private Optional pages = Optional.empty(); @@ -134,8 +121,8 @@ public static final class Builder implements TotalCountStage, DataStage, _FinalS private Builder() {} - @java.lang.Override - public Builder from(SearchArticlesResponse other) { + public Builder from(ArticleSearchResponse other) { + type(other.getType()); totalCount(other.getTotalCount()); data(other.getData()); pages(other.getPages()); @@ -143,43 +130,60 @@ public Builder from(SearchArticlesResponse other) { } /** - * The total number of Articles matching the search query

The total number of Articles matching the search query

- * @return Reference to {@code this} so that method calls can be chained together. + *

The type of the object - list.

*/ - @java.lang.Override - @JsonSetter("total_count") - public DataStage totalCount(int totalCount) { + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + /** + *

The total number of Articles matching the search query

+ */ + @JsonSetter(value = "total_count", nulls = Nulls.SKIP) + public Builder totalCount(Optional totalCount) { this.totalCount = totalCount; return this; } + public Builder totalCount(Integer totalCount) { + this.totalCount = Optional.ofNullable(totalCount); + return this; + } + /** - * An object containing the results of the search.

An object containing the results of the search.

- * @return Reference to {@code this} so that method calls can be chained together. + *

An object containing the results of the search.

*/ - @java.lang.Override - @JsonSetter("data") - public _FinalStage data(@NotNull Data data) { - this.data = Objects.requireNonNull(data, "data must not be null"); + @JsonSetter(value = "data", nulls = Nulls.SKIP) + public Builder data(Optional data) { + this.data = data; return this; } - @java.lang.Override - public _FinalStage pages(CursorPages pages) { - this.pages = Optional.ofNullable(pages); + public Builder data(Data data) { + this.data = Optional.ofNullable(data); return this; } - @java.lang.Override @JsonSetter(value = "pages", nulls = Nulls.SKIP) - public _FinalStage pages(Optional pages) { + public Builder pages(Optional pages) { this.pages = pages; return this; } - @java.lang.Override - public SearchArticlesResponse build() { - return new SearchArticlesResponse(totalCount, data, pages, additionalProperties); + public Builder pages(CursorPages pages) { + this.pages = Optional.ofNullable(pages); + return this; + } + + public ArticleSearchResponse build() { + return new ArticleSearchResponse(type, totalCount, data, pages, additionalProperties); } } diff --git a/src/main/java/com/intercom/api/resources/articles/types/IArticleListItem.java b/src/main/java/com/intercom/api/resources/articles/types/IArticleListItem.java index 8d53ce1..f43a4be 100644 --- a/src/main/java/com/intercom/api/resources/articles/types/IArticleListItem.java +++ b/src/main/java/com/intercom/api/resources/articles/types/IArticleListItem.java @@ -34,7 +34,7 @@ public interface IArticleListItem { Optional getParentType(); - String getDefaultLocale(); + Optional getDefaultLocale(); - ArticleTranslatedContent getTranslatedContent(); + Optional getTranslatedContent(); } diff --git a/src/main/java/com/intercom/api/resources/awaystatusreasons/AsyncAwayStatusReasonsClient.java b/src/main/java/com/intercom/api/resources/awaystatusreasons/AsyncAwayStatusReasonsClient.java new file mode 100644 index 0000000..bc2b839 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/awaystatusreasons/AsyncAwayStatusReasonsClient.java @@ -0,0 +1,42 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.awaystatusreasons; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.types.AwayStatusReason; +import java.util.List; +import java.util.concurrent.CompletableFuture; + +public class AsyncAwayStatusReasonsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawAwayStatusReasonsClient rawClient; + + public AsyncAwayStatusReasonsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawAwayStatusReasonsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawAwayStatusReasonsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of all away status reasons configured for the workspace, including deleted ones. + */ + public CompletableFuture> listAwayStatusReasons() { + return this.rawClient.listAwayStatusReasons().thenApply(response -> response.body()); + } + + /** + * Returns a list of all away status reasons configured for the workspace, including deleted ones. + */ + public CompletableFuture> listAwayStatusReasons(RequestOptions requestOptions) { + return this.rawClient.listAwayStatusReasons(requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/intercom/api/resources/awaystatusreasons/AsyncRawAwayStatusReasonsClient.java b/src/main/java/com/intercom/api/resources/awaystatusreasons/AsyncRawAwayStatusReasonsClient.java new file mode 100644 index 0000000..1807bc3 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/awaystatusreasons/AsyncRawAwayStatusReasonsClient.java @@ -0,0 +1,104 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.awaystatusreasons; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.errors.UnauthorizedError; +import com.intercom.api.types.AwayStatusReason; +import com.intercom.api.types.Error; +import java.io.IOException; +import java.util.List; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawAwayStatusReasonsClient { + protected final ClientOptions clientOptions; + + public AsyncRawAwayStatusReasonsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of all away status reasons configured for the workspace, including deleted ones. + */ + public CompletableFuture>> listAwayStatusReasons() { + return listAwayStatusReasons(null); + } + + /** + * Returns a list of all away status reasons configured for the workspace, including deleted ones. + */ + public CompletableFuture>> listAwayStatusReasons( + RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("away_status_reasons") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture>> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/intercom/api/resources/awaystatusreasons/AwayStatusReasonsClient.java b/src/main/java/com/intercom/api/resources/awaystatusreasons/AwayStatusReasonsClient.java new file mode 100644 index 0000000..5aef2c5 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/awaystatusreasons/AwayStatusReasonsClient.java @@ -0,0 +1,41 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.awaystatusreasons; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.types.AwayStatusReason; +import java.util.List; + +public class AwayStatusReasonsClient { + protected final ClientOptions clientOptions; + + private final RawAwayStatusReasonsClient rawClient; + + public AwayStatusReasonsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawAwayStatusReasonsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawAwayStatusReasonsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of all away status reasons configured for the workspace, including deleted ones. + */ + public List listAwayStatusReasons() { + return this.rawClient.listAwayStatusReasons().body(); + } + + /** + * Returns a list of all away status reasons configured for the workspace, including deleted ones. + */ + public List listAwayStatusReasons(RequestOptions requestOptions) { + return this.rawClient.listAwayStatusReasons(requestOptions).body(); + } +} diff --git a/src/main/java/com/intercom/api/resources/awaystatusreasons/RawAwayStatusReasonsClient.java b/src/main/java/com/intercom/api/resources/awaystatusreasons/RawAwayStatusReasonsClient.java new file mode 100644 index 0000000..6605977 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/awaystatusreasons/RawAwayStatusReasonsClient.java @@ -0,0 +1,85 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.awaystatusreasons; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.errors.UnauthorizedError; +import com.intercom.api.types.AwayStatusReason; +import com.intercom.api.types.Error; +import java.io.IOException; +import java.util.List; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawAwayStatusReasonsClient { + protected final ClientOptions clientOptions; + + public RawAwayStatusReasonsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of all away status reasons configured for the workspace, including deleted ones. + */ + public IntercomHttpResponse> listAwayStatusReasons() { + return listAwayStatusReasons(null); + } + + /** + * Returns a list of all away status reasons configured for the workspace, including deleted ones. + */ + public IntercomHttpResponse> listAwayStatusReasons(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("away_status_reasons") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/calls/AsyncCallsClient.java b/src/main/java/com/intercom/api/resources/calls/AsyncCallsClient.java new file mode 100644 index 0000000..3158eee --- /dev/null +++ b/src/main/java/com/intercom/api/resources/calls/AsyncCallsClient.java @@ -0,0 +1,116 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.calls; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.calls.requests.ListCallsRequest; +import com.intercom.api.resources.calls.requests.ListCallsWithTranscriptsRequest; +import com.intercom.api.resources.calls.requests.ShowCallRecordingRequest; +import com.intercom.api.resources.calls.requests.ShowCallRequest; +import com.intercom.api.resources.calls.requests.ShowCallTranscriptRequest; +import com.intercom.api.resources.calls.types.Call; +import com.intercom.api.resources.calls.types.ListCallsWithTranscriptsResponse; +import com.intercom.api.types.CallList; +import java.util.concurrent.CompletableFuture; + +public class AsyncCallsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawCallsClient rawClient; + + public AsyncCallsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawCallsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawCallsClient withRawResponse() { + return this.rawClient; + } + + /** + * Retrieve a paginated list of calls. + */ + public CompletableFuture listCalls() { + return this.rawClient.listCalls().thenApply(response -> response.body()); + } + + /** + * Retrieve a paginated list of calls. + */ + public CompletableFuture listCalls(ListCallsRequest request) { + return this.rawClient.listCalls(request).thenApply(response -> response.body()); + } + + /** + * Retrieve a paginated list of calls. + */ + public CompletableFuture listCalls(ListCallsRequest request, RequestOptions requestOptions) { + return this.rawClient.listCalls(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Retrieve a single call by id. + */ + public CompletableFuture showCall(ShowCallRequest request) { + return this.rawClient.showCall(request).thenApply(response -> response.body()); + } + + /** + * Retrieve a single call by id. + */ + public CompletableFuture showCall(ShowCallRequest request, RequestOptions requestOptions) { + return this.rawClient.showCall(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Redirects to a signed URL for the call's recording if it exists. + */ + public CompletableFuture showCallRecording(ShowCallRecordingRequest request) { + return this.rawClient.showCallRecording(request).thenApply(response -> response.body()); + } + + /** + * Redirects to a signed URL for the call's recording if it exists. + */ + public CompletableFuture showCallRecording(ShowCallRecordingRequest request, RequestOptions requestOptions) { + return this.rawClient.showCallRecording(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns the transcript for the specified call as a downloadable text file. + */ + public CompletableFuture showCallTranscript(ShowCallTranscriptRequest request) { + return this.rawClient.showCallTranscript(request).thenApply(response -> response.body()); + } + + /** + * Returns the transcript for the specified call as a downloadable text file. + */ + public CompletableFuture showCallTranscript( + ShowCallTranscriptRequest request, RequestOptions requestOptions) { + return this.rawClient.showCallTranscript(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * 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. + */ + public CompletableFuture listCallsWithTranscripts( + ListCallsWithTranscriptsRequest request) { + return this.rawClient.listCallsWithTranscripts(request).thenApply(response -> response.body()); + } + + /** + * 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. + */ + public CompletableFuture listCallsWithTranscripts( + ListCallsWithTranscriptsRequest request, RequestOptions requestOptions) { + return this.rawClient.listCallsWithTranscripts(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/intercom/api/resources/calls/AsyncRawCallsClient.java b/src/main/java/com/intercom/api/resources/calls/AsyncRawCallsClient.java new file mode 100644 index 0000000..b00b400 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/calls/AsyncRawCallsClient.java @@ -0,0 +1,428 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.calls; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.QueryStringMapper; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.errors.BadRequestError; +import com.intercom.api.errors.NotFoundError; +import com.intercom.api.errors.UnauthorizedError; +import com.intercom.api.resources.calls.requests.ListCallsRequest; +import com.intercom.api.resources.calls.requests.ListCallsWithTranscriptsRequest; +import com.intercom.api.resources.calls.requests.ShowCallRecordingRequest; +import com.intercom.api.resources.calls.requests.ShowCallRequest; +import com.intercom.api.resources.calls.requests.ShowCallTranscriptRequest; +import com.intercom.api.resources.calls.types.ListCallsWithTranscriptsResponse; +import com.intercom.api.types.CallList; +import com.intercom.api.types.Error; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawCallsClient { + protected final ClientOptions clientOptions; + + public AsyncRawCallsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Retrieve a paginated list of calls. + */ + public CompletableFuture> listCalls() { + return listCalls(ListCallsRequest.builder().build()); + } + + /** + * Retrieve a paginated list of calls. + */ + public CompletableFuture> listCalls(ListCallsRequest request) { + return listCalls(request, null); + } + + /** + * Retrieve a paginated list of calls. + */ + public CompletableFuture> listCalls( + ListCallsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("calls"); + if (request.getPage().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page", request.getPage().get().toString(), false); + } + if (request.getPerPage().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "per_page", request.getPerPage().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CallList.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Retrieve a single call by id. + */ + public CompletableFuture> showCall( + ShowCallRequest request) { + return showCall(request, null); + } + + /** + * Retrieve a single call by id. + */ + public CompletableFuture> showCall( + ShowCallRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("calls") + .addPathSegment(request.getCallId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = + new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), com.intercom.api.resources.calls.types.Call.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Redirects to a signed URL for the call's recording if it exists. + */ + public CompletableFuture> showCallRecording(ShowCallRecordingRequest request) { + return showCallRecording(request, null); + } + + /** + * Redirects to a signed URL for the call's recording if it exists. + */ + public CompletableFuture> showCallRecording( + ShowCallRecordingRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("calls") + .addPathSegment(request.getCallId()) + .addPathSegments("recording") + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>(null, response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns the transcript for the specified call as a downloadable text file. + */ + public CompletableFuture> showCallTranscript(ShowCallTranscriptRequest request) { + return showCallTranscript(request, null); + } + + /** + * Returns the transcript for the specified call as a downloadable text file. + */ + public CompletableFuture> showCallTranscript( + ShowCallTranscriptRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("calls") + .addPathSegment(request.getCallId()) + .addPathSegments("transcript") + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>(responseBody.string(), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 404) { + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * 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. + */ + public CompletableFuture> listCallsWithTranscripts( + ListCallsWithTranscriptsRequest request) { + return listCallsWithTranscripts(request, null); + } + + /** + * 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. + */ + public CompletableFuture> listCallsWithTranscripts( + ListCallsWithTranscriptsRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("calls/search") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ListCallsWithTranscriptsResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/intercom/api/resources/calls/CallsClient.java b/src/main/java/com/intercom/api/resources/calls/CallsClient.java new file mode 100644 index 0000000..3375eb4 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/calls/CallsClient.java @@ -0,0 +1,113 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.calls; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.calls.requests.ListCallsRequest; +import com.intercom.api.resources.calls.requests.ListCallsWithTranscriptsRequest; +import com.intercom.api.resources.calls.requests.ShowCallRecordingRequest; +import com.intercom.api.resources.calls.requests.ShowCallRequest; +import com.intercom.api.resources.calls.requests.ShowCallTranscriptRequest; +import com.intercom.api.resources.calls.types.Call; +import com.intercom.api.resources.calls.types.ListCallsWithTranscriptsResponse; +import com.intercom.api.types.CallList; + +public class CallsClient { + protected final ClientOptions clientOptions; + + private final RawCallsClient rawClient; + + public CallsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawCallsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawCallsClient withRawResponse() { + return this.rawClient; + } + + /** + * Retrieve a paginated list of calls. + */ + public CallList listCalls() { + return this.rawClient.listCalls().body(); + } + + /** + * Retrieve a paginated list of calls. + */ + public CallList listCalls(ListCallsRequest request) { + return this.rawClient.listCalls(request).body(); + } + + /** + * Retrieve a paginated list of calls. + */ + public CallList listCalls(ListCallsRequest request, RequestOptions requestOptions) { + return this.rawClient.listCalls(request, requestOptions).body(); + } + + /** + * Retrieve a single call by id. + */ + public Call showCall(ShowCallRequest request) { + return this.rawClient.showCall(request).body(); + } + + /** + * Retrieve a single call by id. + */ + public Call showCall(ShowCallRequest request, RequestOptions requestOptions) { + return this.rawClient.showCall(request, requestOptions).body(); + } + + /** + * Redirects to a signed URL for the call's recording if it exists. + */ + public void showCallRecording(ShowCallRecordingRequest request) { + this.rawClient.showCallRecording(request).body(); + } + + /** + * Redirects to a signed URL for the call's recording if it exists. + */ + public void showCallRecording(ShowCallRecordingRequest request, RequestOptions requestOptions) { + this.rawClient.showCallRecording(request, requestOptions).body(); + } + + /** + * Returns the transcript for the specified call as a downloadable text file. + */ + public String showCallTranscript(ShowCallTranscriptRequest request) { + return this.rawClient.showCallTranscript(request).body(); + } + + /** + * Returns the transcript for the specified call as a downloadable text file. + */ + public String showCallTranscript(ShowCallTranscriptRequest request, RequestOptions requestOptions) { + return this.rawClient.showCallTranscript(request, requestOptions).body(); + } + + /** + * 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. + */ + public ListCallsWithTranscriptsResponse listCallsWithTranscripts(ListCallsWithTranscriptsRequest request) { + return this.rawClient.listCallsWithTranscripts(request).body(); + } + + /** + * 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. + */ + public ListCallsWithTranscriptsResponse listCallsWithTranscripts( + ListCallsWithTranscriptsRequest request, RequestOptions requestOptions) { + return this.rawClient.listCallsWithTranscripts(request, requestOptions).body(); + } +} diff --git a/src/main/java/com/intercom/api/resources/calls/RawCallsClient.java b/src/main/java/com/intercom/api/resources/calls/RawCallsClient.java new file mode 100644 index 0000000..3a1ccf4 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/calls/RawCallsClient.java @@ -0,0 +1,340 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.calls; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.QueryStringMapper; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.errors.BadRequestError; +import com.intercom.api.errors.NotFoundError; +import com.intercom.api.errors.UnauthorizedError; +import com.intercom.api.resources.calls.requests.ListCallsRequest; +import com.intercom.api.resources.calls.requests.ListCallsWithTranscriptsRequest; +import com.intercom.api.resources.calls.requests.ShowCallRecordingRequest; +import com.intercom.api.resources.calls.requests.ShowCallRequest; +import com.intercom.api.resources.calls.requests.ShowCallTranscriptRequest; +import com.intercom.api.resources.calls.types.Call; +import com.intercom.api.resources.calls.types.ListCallsWithTranscriptsResponse; +import com.intercom.api.types.CallList; +import com.intercom.api.types.Error; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawCallsClient { + protected final ClientOptions clientOptions; + + public RawCallsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Retrieve a paginated list of calls. + */ + public IntercomHttpResponse listCalls() { + return listCalls(ListCallsRequest.builder().build()); + } + + /** + * Retrieve a paginated list of calls. + */ + public IntercomHttpResponse listCalls(ListCallsRequest request) { + return listCalls(request, null); + } + + /** + * Retrieve a paginated list of calls. + */ + public IntercomHttpResponse listCalls(ListCallsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("calls"); + if (request.getPage().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page", request.getPage().get().toString(), false); + } + if (request.getPerPage().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "per_page", request.getPerPage().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CallList.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * Retrieve a single call by id. + */ + public IntercomHttpResponse showCall(ShowCallRequest request) { + return showCall(request, null); + } + + /** + * Retrieve a single call by id. + */ + public IntercomHttpResponse showCall(ShowCallRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("calls") + .addPathSegment(request.getCallId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Call.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * Redirects to a signed URL for the call's recording if it exists. + */ + public IntercomHttpResponse showCallRecording(ShowCallRecordingRequest request) { + return showCallRecording(request, null); + } + + /** + * Redirects to a signed URL for the call's recording if it exists. + */ + public IntercomHttpResponse showCallRecording( + ShowCallRecordingRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("calls") + .addPathSegment(request.getCallId()) + .addPathSegments("recording") + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>(null, response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * Returns the transcript for the specified call as a downloadable text file. + */ + public IntercomHttpResponse showCallTranscript(ShowCallTranscriptRequest request) { + return showCallTranscript(request, null); + } + + /** + * Returns the transcript for the specified call as a downloadable text file. + */ + public IntercomHttpResponse showCallTranscript( + ShowCallTranscriptRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("calls") + .addPathSegment(request.getCallId()) + .addPathSegments("transcript") + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>(responseBody.string(), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 404) { + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * 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. + */ + public IntercomHttpResponse listCallsWithTranscripts( + ListCallsWithTranscriptsRequest request) { + return listCallsWithTranscripts(request, null); + } + + /** + * 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. + */ + public IntercomHttpResponse listCallsWithTranscripts( + ListCallsWithTranscriptsRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("calls/search") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ListCallsWithTranscriptsResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/calls/requests/ListCallsRequest.java b/src/main/java/com/intercom/api/resources/calls/requests/ListCallsRequest.java new file mode 100644 index 0000000..06d43b4 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/calls/requests/ListCallsRequest.java @@ -0,0 +1,130 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.calls.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListCallsRequest.Builder.class) +public final class ListCallsRequest { + private final Optional page; + + private final Optional perPage; + + private final Map additionalProperties; + + private ListCallsRequest( + Optional page, Optional perPage, Map additionalProperties) { + this.page = page; + this.perPage = perPage; + this.additionalProperties = additionalProperties; + } + + /** + * @return The page of results to fetch. Defaults to first page + */ + @JsonProperty("page") + public Optional getPage() { + return page; + } + + /** + * @return How many results to display per page. Defaults to 25. Max 25. + */ + @JsonProperty("per_page") + public Optional getPerPage() { + return perPage; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListCallsRequest && equalTo((ListCallsRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListCallsRequest other) { + return page.equals(other.page) && perPage.equals(other.perPage); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.page, this.perPage); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional page = Optional.empty(); + + private Optional perPage = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ListCallsRequest other) { + page(other.getPage()); + perPage(other.getPerPage()); + return this; + } + + /** + *

The page of results to fetch. Defaults to first page

+ */ + @JsonSetter(value = "page", nulls = Nulls.SKIP) + public Builder page(Optional page) { + this.page = page; + return this; + } + + public Builder page(Integer page) { + this.page = Optional.ofNullable(page); + return this; + } + + /** + *

How many results to display per page. Defaults to 25. Max 25.

+ */ + @JsonSetter(value = "per_page", nulls = Nulls.SKIP) + public Builder perPage(Optional perPage) { + this.perPage = perPage; + return this; + } + + public Builder perPage(Integer perPage) { + this.perPage = Optional.ofNullable(perPage); + return this; + } + + public ListCallsRequest build() { + return new ListCallsRequest(page, perPage, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/calls/requests/ListCallsWithTranscriptsRequest.java b/src/main/java/com/intercom/api/resources/calls/requests/ListCallsWithTranscriptsRequest.java new file mode 100644 index 0000000..af56c99 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/calls/requests/ListCallsWithTranscriptsRequest.java @@ -0,0 +1,108 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.calls.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListCallsWithTranscriptsRequest.Builder.class) +public final class ListCallsWithTranscriptsRequest { + private final List conversationIds; + + private final Map additionalProperties; + + private ListCallsWithTranscriptsRequest(List conversationIds, Map additionalProperties) { + this.conversationIds = conversationIds; + this.additionalProperties = additionalProperties; + } + + /** + * @return A list of conversation ids to fetch calls for. Maximum 20. + */ + @JsonProperty("conversation_ids") + public List getConversationIds() { + return conversationIds; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListCallsWithTranscriptsRequest && equalTo((ListCallsWithTranscriptsRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListCallsWithTranscriptsRequest other) { + return conversationIds.equals(other.conversationIds); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.conversationIds); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private List conversationIds = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ListCallsWithTranscriptsRequest other) { + conversationIds(other.getConversationIds()); + return this; + } + + /** + *

A list of conversation ids to fetch calls for. Maximum 20.

+ */ + @JsonSetter(value = "conversation_ids", nulls = Nulls.SKIP) + public Builder conversationIds(List conversationIds) { + this.conversationIds.clear(); + this.conversationIds.addAll(conversationIds); + return this; + } + + public Builder addConversationIds(String conversationIds) { + this.conversationIds.add(conversationIds); + return this; + } + + public Builder addAllConversationIds(List conversationIds) { + this.conversationIds.addAll(conversationIds); + return this; + } + + public ListCallsWithTranscriptsRequest build() { + return new ListCallsWithTranscriptsRequest(conversationIds, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/types/InitializeResponse.java b/src/main/java/com/intercom/api/resources/calls/requests/ShowCallRecordingRequest.java similarity index 54% rename from src/main/java/com/intercom/api/types/InitializeResponse.java rename to src/main/java/com/intercom/api/resources/calls/requests/ShowCallRecordingRequest.java index bdaf38c..4e12be2 100644 --- a/src/main/java/com/intercom/api/types/InitializeResponse.java +++ b/src/main/java/com/intercom/api/resources/calls/requests/ShowCallRecordingRequest.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.intercom.api.types; +package com.intercom.api.resources.calls.requests; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; @@ -17,29 +17,29 @@ import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = InitializeResponse.Builder.class) -public final class InitializeResponse { - private final CanvasObject canvas; +@JsonDeserialize(builder = ShowCallRecordingRequest.Builder.class) +public final class ShowCallRecordingRequest { + private final String callId; private final Map additionalProperties; - private InitializeResponse(CanvasObject canvas, Map additionalProperties) { - this.canvas = canvas; + private ShowCallRecordingRequest(String callId, Map additionalProperties) { + this.callId = callId; this.additionalProperties = additionalProperties; } /** - * @return The canvas object that defines the UI to be shown for the app. + * @return The id of the call */ - @JsonProperty("canvas") - public CanvasObject getCanvas() { - return canvas; + @JsonProperty("call_id") + public String getCallId() { + return callId; } @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof InitializeResponse && equalTo((InitializeResponse) other); + return other instanceof ShowCallRecordingRequest && equalTo((ShowCallRecordingRequest) other); } @JsonAnyGetter @@ -47,13 +47,13 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(InitializeResponse other) { - return canvas.equals(other.canvas); + private boolean equalTo(ShowCallRecordingRequest other) { + return callId.equals(other.callId); } @java.lang.Override public int hashCode() { - return Objects.hash(this.canvas); + return Objects.hash(this.callId); } @java.lang.Override @@ -61,26 +61,26 @@ public String toString() { return ObjectMappers.stringify(this); } - public static CanvasStage builder() { + public static CallIdStage builder() { return new Builder(); } - public interface CanvasStage { + public interface CallIdStage { /** - * The canvas object that defines the UI to be shown for the app. + * The id of the call */ - _FinalStage canvas(@NotNull CanvasObject canvas); + _FinalStage callId(@NotNull String callId); - Builder from(InitializeResponse other); + Builder from(ShowCallRecordingRequest other); } public interface _FinalStage { - InitializeResponse build(); + ShowCallRecordingRequest build(); } @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements CanvasStage, _FinalStage { - private CanvasObject canvas; + public static final class Builder implements CallIdStage, _FinalStage { + private String callId; @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -88,25 +88,25 @@ public static final class Builder implements CanvasStage, _FinalStage { private Builder() {} @java.lang.Override - public Builder from(InitializeResponse other) { - canvas(other.getCanvas()); + public Builder from(ShowCallRecordingRequest other) { + callId(other.getCallId()); return this; } /** - * The canvas object that defines the UI to be shown for the app.

The canvas object that defines the UI to be shown for the app.

+ * The id of the call

The id of the call

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override - @JsonSetter("canvas") - public _FinalStage canvas(@NotNull CanvasObject canvas) { - this.canvas = Objects.requireNonNull(canvas, "canvas must not be null"); + @JsonSetter("call_id") + public _FinalStage callId(@NotNull String callId) { + this.callId = Objects.requireNonNull(callId, "callId must not be null"); return this; } @java.lang.Override - public InitializeResponse build() { - return new InitializeResponse(canvas, additionalProperties); + public ShowCallRecordingRequest build() { + return new ShowCallRecordingRequest(callId, additionalProperties); } } } diff --git a/src/main/java/com/intercom/api/resources/calls/requests/ShowCallRequest.java b/src/main/java/com/intercom/api/resources/calls/requests/ShowCallRequest.java new file mode 100644 index 0000000..ff38bd6 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/calls/requests/ShowCallRequest.java @@ -0,0 +1,112 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.calls.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ShowCallRequest.Builder.class) +public final class ShowCallRequest { + private final String callId; + + private final Map additionalProperties; + + private ShowCallRequest(String callId, Map additionalProperties) { + this.callId = callId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The id of the call to retrieve + */ + @JsonProperty("call_id") + public String getCallId() { + return callId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ShowCallRequest && equalTo((ShowCallRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ShowCallRequest other) { + return callId.equals(other.callId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.callId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static CallIdStage builder() { + return new Builder(); + } + + public interface CallIdStage { + /** + * The id of the call to retrieve + */ + _FinalStage callId(@NotNull String callId); + + Builder from(ShowCallRequest other); + } + + public interface _FinalStage { + ShowCallRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements CallIdStage, _FinalStage { + private String callId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ShowCallRequest other) { + callId(other.getCallId()); + return this; + } + + /** + * The id of the call to retrieve

The id of the call to retrieve

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("call_id") + public _FinalStage callId(@NotNull String callId) { + this.callId = Objects.requireNonNull(callId, "callId must not be null"); + return this; + } + + @java.lang.Override + public ShowCallRequest build() { + return new ShowCallRequest(callId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/calls/requests/ShowCallTranscriptRequest.java b/src/main/java/com/intercom/api/resources/calls/requests/ShowCallTranscriptRequest.java new file mode 100644 index 0000000..30e7baa --- /dev/null +++ b/src/main/java/com/intercom/api/resources/calls/requests/ShowCallTranscriptRequest.java @@ -0,0 +1,112 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.calls.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ShowCallTranscriptRequest.Builder.class) +public final class ShowCallTranscriptRequest { + private final String callId; + + private final Map additionalProperties; + + private ShowCallTranscriptRequest(String callId, Map additionalProperties) { + this.callId = callId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The id of the call + */ + @JsonProperty("call_id") + public String getCallId() { + return callId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ShowCallTranscriptRequest && equalTo((ShowCallTranscriptRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ShowCallTranscriptRequest other) { + return callId.equals(other.callId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.callId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static CallIdStage builder() { + return new Builder(); + } + + public interface CallIdStage { + /** + * The id of the call + */ + _FinalStage callId(@NotNull String callId); + + Builder from(ShowCallTranscriptRequest other); + } + + public interface _FinalStage { + ShowCallTranscriptRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements CallIdStage, _FinalStage { + private String callId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ShowCallTranscriptRequest other) { + callId(other.getCallId()); + return this; + } + + /** + * The id of the call

The id of the call

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("call_id") + public _FinalStage callId(@NotNull String callId) { + this.callId = Objects.requireNonNull(callId, "callId must not be null"); + return this; + } + + @java.lang.Override + public ShowCallTranscriptRequest build() { + return new ShowCallTranscriptRequest(callId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/calls/types/Call.java b/src/main/java/com/intercom/api/resources/calls/types/Call.java new file mode 100644 index 0000000..fa2b8cd --- /dev/null +++ b/src/main/java/com/intercom/api/resources/calls/types/Call.java @@ -0,0 +1,653 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.calls.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.types.Datetime; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = Call.Builder.class) +public final class Call implements ICall { + private final Optional type; + + private final Optional id; + + private final Optional conversationId; + + private final Optional adminId; + + private final Optional contactId; + + private final Optional state; + + private final Optional initiatedAt; + + private final Optional answeredAt; + + private final Optional endedAt; + + private final Optional createdAt; + + private final Optional updatedAt; + + private final Optional recordingUrl; + + private final Optional transcriptionUrl; + + private final Optional callType; + + private final Optional direction; + + private final Optional endedReason; + + private final Optional phone; + + private final Optional finRecordingUrl; + + private final Optional finTranscriptionUrl; + + private final Map additionalProperties; + + private Call( + Optional type, + Optional id, + Optional conversationId, + Optional adminId, + Optional contactId, + Optional state, + Optional initiatedAt, + Optional answeredAt, + Optional endedAt, + Optional createdAt, + Optional updatedAt, + Optional recordingUrl, + Optional transcriptionUrl, + Optional callType, + Optional direction, + Optional endedReason, + Optional phone, + Optional finRecordingUrl, + Optional finTranscriptionUrl, + Map additionalProperties) { + this.type = type; + this.id = id; + this.conversationId = conversationId; + this.adminId = adminId; + this.contactId = contactId; + this.state = state; + this.initiatedAt = initiatedAt; + this.answeredAt = answeredAt; + this.endedAt = endedAt; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.recordingUrl = recordingUrl; + this.transcriptionUrl = transcriptionUrl; + this.callType = callType; + this.direction = direction; + this.endedReason = endedReason; + this.phone = phone; + this.finRecordingUrl = finRecordingUrl; + this.finTranscriptionUrl = finTranscriptionUrl; + this.additionalProperties = additionalProperties; + } + + /** + * @return String representing the object's type. Always has the value call. + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return The id of the call. + */ + @JsonProperty("id") + public Optional getId() { + return id; + } + + /** + * @return The id of the conversation associated with the call, if any. + */ + @JsonProperty("conversation_id") + public Optional getConversationId() { + return conversationId; + } + + /** + * @return The id of the admin associated with the call, if any. + */ + @JsonProperty("admin_id") + public Optional getAdminId() { + return adminId; + } + + /** + * @return The id of the contact associated with the call, if any. + */ + @JsonProperty("contact_id") + public Optional getContactId() { + return contactId; + } + + /** + * @return The current state of the call. + */ + @JsonProperty("state") + public Optional getState() { + return state; + } + + @JsonProperty("initiated_at") + public Optional getInitiatedAt() { + return initiatedAt; + } + + @JsonProperty("answered_at") + public Optional getAnsweredAt() { + return answeredAt; + } + + @JsonProperty("ended_at") + public Optional getEndedAt() { + return endedAt; + } + + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + @JsonProperty("updated_at") + public Optional getUpdatedAt() { + return updatedAt; + } + + /** + * @return API URL to download or redirect to the call recording if available. + */ + @JsonProperty("recording_url") + public Optional getRecordingUrl() { + return recordingUrl; + } + + /** + * @return API URL to download or redirect to the call transcript if available. + */ + @JsonProperty("transcription_url") + public Optional getTranscriptionUrl() { + return transcriptionUrl; + } + + /** + * @return The type of call. + */ + @JsonProperty("call_type") + public Optional getCallType() { + return callType; + } + + /** + * @return The direction of the call. + */ + @JsonProperty("direction") + public Optional getDirection() { + return direction; + } + + /** + * @return The reason for the call end, if applicable. + */ + @JsonProperty("ended_reason") + public Optional getEndedReason() { + return endedReason; + } + + /** + * @return The phone number involved in the call, in E.164 format. + */ + @JsonProperty("phone") + public Optional getPhone() { + return phone; + } + + /** + * @return API URL to the AI Agent (Fin) call recording if available. + */ + @JsonProperty("fin_recording_url") + public Optional getFinRecordingUrl() { + return finRecordingUrl; + } + + /** + * @return API URL to the AI Agent (Fin) call transcript if available. + */ + @JsonProperty("fin_transcription_url") + public Optional getFinTranscriptionUrl() { + return finTranscriptionUrl; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Call && equalTo((Call) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Call other) { + return type.equals(other.type) + && id.equals(other.id) + && conversationId.equals(other.conversationId) + && adminId.equals(other.adminId) + && contactId.equals(other.contactId) + && state.equals(other.state) + && initiatedAt.equals(other.initiatedAt) + && answeredAt.equals(other.answeredAt) + && endedAt.equals(other.endedAt) + && createdAt.equals(other.createdAt) + && updatedAt.equals(other.updatedAt) + && recordingUrl.equals(other.recordingUrl) + && transcriptionUrl.equals(other.transcriptionUrl) + && callType.equals(other.callType) + && direction.equals(other.direction) + && endedReason.equals(other.endedReason) + && phone.equals(other.phone) + && finRecordingUrl.equals(other.finRecordingUrl) + && finTranscriptionUrl.equals(other.finTranscriptionUrl); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.type, + this.id, + this.conversationId, + this.adminId, + this.contactId, + this.state, + this.initiatedAt, + this.answeredAt, + this.endedAt, + this.createdAt, + this.updatedAt, + this.recordingUrl, + this.transcriptionUrl, + this.callType, + this.direction, + this.endedReason, + this.phone, + this.finRecordingUrl, + this.finTranscriptionUrl); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); + + private Optional id = Optional.empty(); + + private Optional conversationId = Optional.empty(); + + private Optional adminId = Optional.empty(); + + private Optional contactId = Optional.empty(); + + private Optional state = Optional.empty(); + + private Optional initiatedAt = Optional.empty(); + + private Optional answeredAt = Optional.empty(); + + private Optional endedAt = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + private Optional updatedAt = Optional.empty(); + + private Optional recordingUrl = Optional.empty(); + + private Optional transcriptionUrl = Optional.empty(); + + private Optional callType = Optional.empty(); + + private Optional direction = Optional.empty(); + + private Optional endedReason = Optional.empty(); + + private Optional phone = Optional.empty(); + + private Optional finRecordingUrl = Optional.empty(); + + private Optional finTranscriptionUrl = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(Call other) { + type(other.getType()); + id(other.getId()); + conversationId(other.getConversationId()); + adminId(other.getAdminId()); + contactId(other.getContactId()); + state(other.getState()); + initiatedAt(other.getInitiatedAt()); + answeredAt(other.getAnsweredAt()); + endedAt(other.getEndedAt()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + recordingUrl(other.getRecordingUrl()); + transcriptionUrl(other.getTranscriptionUrl()); + callType(other.getCallType()); + direction(other.getDirection()); + endedReason(other.getEndedReason()); + phone(other.getPhone()); + finRecordingUrl(other.getFinRecordingUrl()); + finTranscriptionUrl(other.getFinTranscriptionUrl()); + return this; + } + + /** + *

String representing the object's type. Always has the value call.

+ */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + /** + *

The id of the call.

+ */ + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.ofNullable(id); + return this; + } + + /** + *

The id of the conversation associated with the call, if any.

+ */ + @JsonSetter(value = "conversation_id", nulls = Nulls.SKIP) + public Builder conversationId(Optional conversationId) { + this.conversationId = conversationId; + return this; + } + + public Builder conversationId(String conversationId) { + this.conversationId = Optional.ofNullable(conversationId); + return this; + } + + /** + *

The id of the admin associated with the call, if any.

+ */ + @JsonSetter(value = "admin_id", nulls = Nulls.SKIP) + public Builder adminId(Optional adminId) { + this.adminId = adminId; + return this; + } + + public Builder adminId(String adminId) { + this.adminId = Optional.ofNullable(adminId); + return this; + } + + /** + *

The id of the contact associated with the call, if any.

+ */ + @JsonSetter(value = "contact_id", nulls = Nulls.SKIP) + public Builder contactId(Optional contactId) { + this.contactId = contactId; + return this; + } + + public Builder contactId(String contactId) { + this.contactId = Optional.ofNullable(contactId); + return this; + } + + /** + *

The current state of the call.

+ */ + @JsonSetter(value = "state", nulls = Nulls.SKIP) + public Builder state(Optional state) { + this.state = state; + return this; + } + + public Builder state(String state) { + this.state = Optional.ofNullable(state); + return this; + } + + @JsonSetter(value = "initiated_at", nulls = Nulls.SKIP) + public Builder initiatedAt(Optional initiatedAt) { + this.initiatedAt = initiatedAt; + return this; + } + + public Builder initiatedAt(Datetime initiatedAt) { + this.initiatedAt = Optional.ofNullable(initiatedAt); + return this; + } + + @JsonSetter(value = "answered_at", nulls = Nulls.SKIP) + public Builder answeredAt(Optional answeredAt) { + this.answeredAt = answeredAt; + return this; + } + + public Builder answeredAt(Datetime answeredAt) { + this.answeredAt = Optional.ofNullable(answeredAt); + return this; + } + + @JsonSetter(value = "ended_at", nulls = Nulls.SKIP) + public Builder endedAt(Optional endedAt) { + this.endedAt = endedAt; + return this; + } + + public Builder endedAt(Datetime endedAt) { + this.endedAt = Optional.ofNullable(endedAt); + return this; + } + + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public Builder createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + public Builder createdAt(Datetime createdAt) { + this.createdAt = Optional.ofNullable(createdAt); + return this; + } + + @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) + public Builder updatedAt(Optional updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + public Builder updatedAt(Datetime updatedAt) { + this.updatedAt = Optional.ofNullable(updatedAt); + return this; + } + + /** + *

API URL to download or redirect to the call recording if available.

+ */ + @JsonSetter(value = "recording_url", nulls = Nulls.SKIP) + public Builder recordingUrl(Optional recordingUrl) { + this.recordingUrl = recordingUrl; + return this; + } + + public Builder recordingUrl(String recordingUrl) { + this.recordingUrl = Optional.ofNullable(recordingUrl); + return this; + } + + /** + *

API URL to download or redirect to the call transcript if available.

+ */ + @JsonSetter(value = "transcription_url", nulls = Nulls.SKIP) + public Builder transcriptionUrl(Optional transcriptionUrl) { + this.transcriptionUrl = transcriptionUrl; + return this; + } + + public Builder transcriptionUrl(String transcriptionUrl) { + this.transcriptionUrl = Optional.ofNullable(transcriptionUrl); + return this; + } + + /** + *

The type of call.

+ */ + @JsonSetter(value = "call_type", nulls = Nulls.SKIP) + public Builder callType(Optional callType) { + this.callType = callType; + return this; + } + + public Builder callType(String callType) { + this.callType = Optional.ofNullable(callType); + return this; + } + + /** + *

The direction of the call.

+ */ + @JsonSetter(value = "direction", nulls = Nulls.SKIP) + public Builder direction(Optional direction) { + this.direction = direction; + return this; + } + + public Builder direction(String direction) { + this.direction = Optional.ofNullable(direction); + return this; + } + + /** + *

The reason for the call end, if applicable.

+ */ + @JsonSetter(value = "ended_reason", nulls = Nulls.SKIP) + public Builder endedReason(Optional endedReason) { + this.endedReason = endedReason; + return this; + } + + public Builder endedReason(String endedReason) { + this.endedReason = Optional.ofNullable(endedReason); + return this; + } + + /** + *

The phone number involved in the call, in E.164 format.

+ */ + @JsonSetter(value = "phone", nulls = Nulls.SKIP) + public Builder phone(Optional phone) { + this.phone = phone; + return this; + } + + public Builder phone(String phone) { + this.phone = Optional.ofNullable(phone); + return this; + } + + /** + *

API URL to the AI Agent (Fin) call recording if available.

+ */ + @JsonSetter(value = "fin_recording_url", nulls = Nulls.SKIP) + public Builder finRecordingUrl(Optional finRecordingUrl) { + this.finRecordingUrl = finRecordingUrl; + return this; + } + + public Builder finRecordingUrl(String finRecordingUrl) { + this.finRecordingUrl = Optional.ofNullable(finRecordingUrl); + return this; + } + + /** + *

API URL to the AI Agent (Fin) call transcript if available.

+ */ + @JsonSetter(value = "fin_transcription_url", nulls = Nulls.SKIP) + public Builder finTranscriptionUrl(Optional finTranscriptionUrl) { + this.finTranscriptionUrl = finTranscriptionUrl; + return this; + } + + public Builder finTranscriptionUrl(String finTranscriptionUrl) { + this.finTranscriptionUrl = Optional.ofNullable(finTranscriptionUrl); + return this; + } + + public Call build() { + return new Call( + type, + id, + conversationId, + adminId, + contactId, + state, + initiatedAt, + answeredAt, + endedAt, + createdAt, + updatedAt, + recordingUrl, + transcriptionUrl, + callType, + direction, + endedReason, + phone, + finRecordingUrl, + finTranscriptionUrl, + additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/calls/types/ICall.java b/src/main/java/com/intercom/api/resources/calls/types/ICall.java new file mode 100644 index 0000000..d6bbf5f --- /dev/null +++ b/src/main/java/com/intercom/api/resources/calls/types/ICall.java @@ -0,0 +1,47 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.calls.types; + +import com.intercom.api.types.Datetime; +import java.util.Optional; + +public interface ICall { + Optional getType(); + + Optional getId(); + + Optional getConversationId(); + + Optional getAdminId(); + + Optional getContactId(); + + Optional getState(); + + Optional getInitiatedAt(); + + Optional getAnsweredAt(); + + Optional getEndedAt(); + + Optional getCreatedAt(); + + Optional getUpdatedAt(); + + Optional getRecordingUrl(); + + Optional getTranscriptionUrl(); + + Optional getCallType(); + + Optional getDirection(); + + Optional getEndedReason(); + + Optional getPhone(); + + Optional getFinRecordingUrl(); + + Optional getFinTranscriptionUrl(); +} diff --git a/src/main/java/com/intercom/api/resources/calls/types/ListCallsWithTranscriptsResponse.java b/src/main/java/com/intercom/api/resources/calls/types/ListCallsWithTranscriptsResponse.java new file mode 100644 index 0000000..36e30c5 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/calls/types/ListCallsWithTranscriptsResponse.java @@ -0,0 +1,818 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.calls.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.types.Datetime; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListCallsWithTranscriptsResponse.Builder.class) +public final class ListCallsWithTranscriptsResponse { + private final Optional type; + + private final Optional> data; + + private final Map additionalProperties; + + private ListCallsWithTranscriptsResponse( + Optional type, Optional> data, Map additionalProperties) { + this.type = type; + this.data = data; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("type") + public Optional getType() { + return type; + } + + @JsonProperty("data") + public Optional> getData() { + return data; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListCallsWithTranscriptsResponse && equalTo((ListCallsWithTranscriptsResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListCallsWithTranscriptsResponse other) { + return type.equals(other.type) && data.equals(other.data); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.data); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); + + private Optional> data = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ListCallsWithTranscriptsResponse other) { + type(other.getType()); + data(other.getData()); + return this; + } + + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + @JsonSetter(value = "data", nulls = Nulls.SKIP) + public Builder data(Optional> data) { + this.data = data; + return this; + } + + public Builder data(List data) { + this.data = Optional.ofNullable(data); + return this; + } + + public ListCallsWithTranscriptsResponse build() { + return new ListCallsWithTranscriptsResponse(type, data, additionalProperties); + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = DataItem.Builder.class) + public static final class DataItem implements ICall { + private final Optional type; + + private final Optional id; + + private final Optional conversationId; + + private final Optional adminId; + + private final Optional contactId; + + private final Optional state; + + private final Optional initiatedAt; + + private final Optional answeredAt; + + private final Optional endedAt; + + private final Optional createdAt; + + private final Optional updatedAt; + + private final Optional recordingUrl; + + private final Optional transcriptionUrl; + + private final Optional callType; + + private final Optional direction; + + private final Optional endedReason; + + private final Optional phone; + + private final Optional finRecordingUrl; + + private final Optional finTranscriptionUrl; + + private final Optional>> transcript; + + private final Optional transcriptStatus; + + private final Map additionalProperties; + + private DataItem( + Optional type, + Optional id, + Optional conversationId, + Optional adminId, + Optional contactId, + Optional state, + Optional initiatedAt, + Optional answeredAt, + Optional endedAt, + Optional createdAt, + Optional updatedAt, + Optional recordingUrl, + Optional transcriptionUrl, + Optional callType, + Optional direction, + Optional endedReason, + Optional phone, + Optional finRecordingUrl, + Optional finTranscriptionUrl, + Optional>> transcript, + Optional transcriptStatus, + Map additionalProperties) { + this.type = type; + this.id = id; + this.conversationId = conversationId; + this.adminId = adminId; + this.contactId = contactId; + this.state = state; + this.initiatedAt = initiatedAt; + this.answeredAt = answeredAt; + this.endedAt = endedAt; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.recordingUrl = recordingUrl; + this.transcriptionUrl = transcriptionUrl; + this.callType = callType; + this.direction = direction; + this.endedReason = endedReason; + this.phone = phone; + this.finRecordingUrl = finRecordingUrl; + this.finTranscriptionUrl = finTranscriptionUrl; + this.transcript = transcript; + this.transcriptStatus = transcriptStatus; + this.additionalProperties = additionalProperties; + } + + /** + * @return String representing the object's type. Always has the value call. + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return The id of the call. + */ + @JsonProperty("id") + public Optional getId() { + return id; + } + + /** + * @return The id of the conversation associated with the call, if any. + */ + @JsonProperty("conversation_id") + public Optional getConversationId() { + return conversationId; + } + + /** + * @return The id of the admin associated with the call, if any. + */ + @JsonProperty("admin_id") + public Optional getAdminId() { + return adminId; + } + + /** + * @return The id of the contact associated with the call, if any. + */ + @JsonProperty("contact_id") + public Optional getContactId() { + return contactId; + } + + /** + * @return The current state of the call. + */ + @JsonProperty("state") + public Optional getState() { + return state; + } + + @JsonProperty("initiated_at") + public Optional getInitiatedAt() { + return initiatedAt; + } + + @JsonProperty("answered_at") + public Optional getAnsweredAt() { + return answeredAt; + } + + @JsonProperty("ended_at") + public Optional getEndedAt() { + return endedAt; + } + + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + @JsonProperty("updated_at") + public Optional getUpdatedAt() { + return updatedAt; + } + + /** + * @return API URL to download or redirect to the call recording if available. + */ + @JsonProperty("recording_url") + public Optional getRecordingUrl() { + return recordingUrl; + } + + /** + * @return API URL to download or redirect to the call transcript if available. + */ + @JsonProperty("transcription_url") + public Optional getTranscriptionUrl() { + return transcriptionUrl; + } + + /** + * @return The type of call. + */ + @JsonProperty("call_type") + public Optional getCallType() { + return callType; + } + + /** + * @return The direction of the call. + */ + @JsonProperty("direction") + public Optional getDirection() { + return direction; + } + + /** + * @return The reason for the call end, if applicable. + */ + @JsonProperty("ended_reason") + public Optional getEndedReason() { + return endedReason; + } + + /** + * @return The phone number involved in the call, in E.164 format. + */ + @JsonProperty("phone") + public Optional getPhone() { + return phone; + } + + /** + * @return API URL to the AI Agent (Fin) call recording if available. + */ + @JsonProperty("fin_recording_url") + public Optional getFinRecordingUrl() { + return finRecordingUrl; + } + + /** + * @return API URL to the AI Agent (Fin) call transcript if available. + */ + @JsonProperty("fin_transcription_url") + public Optional getFinTranscriptionUrl() { + return finTranscriptionUrl; + } + + /** + * @return The call transcript if available, otherwise an empty array. + */ + @JsonProperty("transcript") + public Optional>> getTranscript() { + return transcript; + } + + /** + * @return The status of the transcript if available. + */ + @JsonProperty("transcript_status") + public Optional getTranscriptStatus() { + return transcriptStatus; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DataItem && equalTo((DataItem) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DataItem other) { + return type.equals(other.type) + && id.equals(other.id) + && conversationId.equals(other.conversationId) + && adminId.equals(other.adminId) + && contactId.equals(other.contactId) + && state.equals(other.state) + && initiatedAt.equals(other.initiatedAt) + && answeredAt.equals(other.answeredAt) + && endedAt.equals(other.endedAt) + && createdAt.equals(other.createdAt) + && updatedAt.equals(other.updatedAt) + && recordingUrl.equals(other.recordingUrl) + && transcriptionUrl.equals(other.transcriptionUrl) + && callType.equals(other.callType) + && direction.equals(other.direction) + && endedReason.equals(other.endedReason) + && phone.equals(other.phone) + && finRecordingUrl.equals(other.finRecordingUrl) + && finTranscriptionUrl.equals(other.finTranscriptionUrl) + && transcript.equals(other.transcript) + && transcriptStatus.equals(other.transcriptStatus); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.type, + this.id, + this.conversationId, + this.adminId, + this.contactId, + this.state, + this.initiatedAt, + this.answeredAt, + this.endedAt, + this.createdAt, + this.updatedAt, + this.recordingUrl, + this.transcriptionUrl, + this.callType, + this.direction, + this.endedReason, + this.phone, + this.finRecordingUrl, + this.finTranscriptionUrl, + this.transcript, + this.transcriptStatus); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); + + private Optional id = Optional.empty(); + + private Optional conversationId = Optional.empty(); + + private Optional adminId = Optional.empty(); + + private Optional contactId = Optional.empty(); + + private Optional state = Optional.empty(); + + private Optional initiatedAt = Optional.empty(); + + private Optional answeredAt = Optional.empty(); + + private Optional endedAt = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + private Optional updatedAt = Optional.empty(); + + private Optional recordingUrl = Optional.empty(); + + private Optional transcriptionUrl = Optional.empty(); + + private Optional callType = Optional.empty(); + + private Optional direction = Optional.empty(); + + private Optional endedReason = Optional.empty(); + + private Optional phone = Optional.empty(); + + private Optional finRecordingUrl = Optional.empty(); + + private Optional finTranscriptionUrl = Optional.empty(); + + private Optional>> transcript = Optional.empty(); + + private Optional transcriptStatus = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(DataItem other) { + type(other.getType()); + id(other.getId()); + conversationId(other.getConversationId()); + adminId(other.getAdminId()); + contactId(other.getContactId()); + state(other.getState()); + initiatedAt(other.getInitiatedAt()); + answeredAt(other.getAnsweredAt()); + endedAt(other.getEndedAt()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + recordingUrl(other.getRecordingUrl()); + transcriptionUrl(other.getTranscriptionUrl()); + callType(other.getCallType()); + direction(other.getDirection()); + endedReason(other.getEndedReason()); + phone(other.getPhone()); + finRecordingUrl(other.getFinRecordingUrl()); + finTranscriptionUrl(other.getFinTranscriptionUrl()); + transcript(other.getTranscript()); + transcriptStatus(other.getTranscriptStatus()); + return this; + } + + /** + *

String representing the object's type. Always has the value call.

+ */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + /** + *

The id of the call.

+ */ + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.ofNullable(id); + return this; + } + + /** + *

The id of the conversation associated with the call, if any.

+ */ + @JsonSetter(value = "conversation_id", nulls = Nulls.SKIP) + public Builder conversationId(Optional conversationId) { + this.conversationId = conversationId; + return this; + } + + public Builder conversationId(String conversationId) { + this.conversationId = Optional.ofNullable(conversationId); + return this; + } + + /** + *

The id of the admin associated with the call, if any.

+ */ + @JsonSetter(value = "admin_id", nulls = Nulls.SKIP) + public Builder adminId(Optional adminId) { + this.adminId = adminId; + return this; + } + + public Builder adminId(String adminId) { + this.adminId = Optional.ofNullable(adminId); + return this; + } + + /** + *

The id of the contact associated with the call, if any.

+ */ + @JsonSetter(value = "contact_id", nulls = Nulls.SKIP) + public Builder contactId(Optional contactId) { + this.contactId = contactId; + return this; + } + + public Builder contactId(String contactId) { + this.contactId = Optional.ofNullable(contactId); + return this; + } + + /** + *

The current state of the call.

+ */ + @JsonSetter(value = "state", nulls = Nulls.SKIP) + public Builder state(Optional state) { + this.state = state; + return this; + } + + public Builder state(String state) { + this.state = Optional.ofNullable(state); + return this; + } + + @JsonSetter(value = "initiated_at", nulls = Nulls.SKIP) + public Builder initiatedAt(Optional initiatedAt) { + this.initiatedAt = initiatedAt; + return this; + } + + public Builder initiatedAt(Datetime initiatedAt) { + this.initiatedAt = Optional.ofNullable(initiatedAt); + return this; + } + + @JsonSetter(value = "answered_at", nulls = Nulls.SKIP) + public Builder answeredAt(Optional answeredAt) { + this.answeredAt = answeredAt; + return this; + } + + public Builder answeredAt(Datetime answeredAt) { + this.answeredAt = Optional.ofNullable(answeredAt); + return this; + } + + @JsonSetter(value = "ended_at", nulls = Nulls.SKIP) + public Builder endedAt(Optional endedAt) { + this.endedAt = endedAt; + return this; + } + + public Builder endedAt(Datetime endedAt) { + this.endedAt = Optional.ofNullable(endedAt); + return this; + } + + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public Builder createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + public Builder createdAt(Datetime createdAt) { + this.createdAt = Optional.ofNullable(createdAt); + return this; + } + + @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) + public Builder updatedAt(Optional updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + public Builder updatedAt(Datetime updatedAt) { + this.updatedAt = Optional.ofNullable(updatedAt); + return this; + } + + /** + *

API URL to download or redirect to the call recording if available.

+ */ + @JsonSetter(value = "recording_url", nulls = Nulls.SKIP) + public Builder recordingUrl(Optional recordingUrl) { + this.recordingUrl = recordingUrl; + return this; + } + + public Builder recordingUrl(String recordingUrl) { + this.recordingUrl = Optional.ofNullable(recordingUrl); + return this; + } + + /** + *

API URL to download or redirect to the call transcript if available.

+ */ + @JsonSetter(value = "transcription_url", nulls = Nulls.SKIP) + public Builder transcriptionUrl(Optional transcriptionUrl) { + this.transcriptionUrl = transcriptionUrl; + return this; + } + + public Builder transcriptionUrl(String transcriptionUrl) { + this.transcriptionUrl = Optional.ofNullable(transcriptionUrl); + return this; + } + + /** + *

The type of call.

+ */ + @JsonSetter(value = "call_type", nulls = Nulls.SKIP) + public Builder callType(Optional callType) { + this.callType = callType; + return this; + } + + public Builder callType(String callType) { + this.callType = Optional.ofNullable(callType); + return this; + } + + /** + *

The direction of the call.

+ */ + @JsonSetter(value = "direction", nulls = Nulls.SKIP) + public Builder direction(Optional direction) { + this.direction = direction; + return this; + } + + public Builder direction(String direction) { + this.direction = Optional.ofNullable(direction); + return this; + } + + /** + *

The reason for the call end, if applicable.

+ */ + @JsonSetter(value = "ended_reason", nulls = Nulls.SKIP) + public Builder endedReason(Optional endedReason) { + this.endedReason = endedReason; + return this; + } + + public Builder endedReason(String endedReason) { + this.endedReason = Optional.ofNullable(endedReason); + return this; + } + + /** + *

The phone number involved in the call, in E.164 format.

+ */ + @JsonSetter(value = "phone", nulls = Nulls.SKIP) + public Builder phone(Optional phone) { + this.phone = phone; + return this; + } + + public Builder phone(String phone) { + this.phone = Optional.ofNullable(phone); + return this; + } + + /** + *

API URL to the AI Agent (Fin) call recording if available.

+ */ + @JsonSetter(value = "fin_recording_url", nulls = Nulls.SKIP) + public Builder finRecordingUrl(Optional finRecordingUrl) { + this.finRecordingUrl = finRecordingUrl; + return this; + } + + public Builder finRecordingUrl(String finRecordingUrl) { + this.finRecordingUrl = Optional.ofNullable(finRecordingUrl); + return this; + } + + /** + *

API URL to the AI Agent (Fin) call transcript if available.

+ */ + @JsonSetter(value = "fin_transcription_url", nulls = Nulls.SKIP) + public Builder finTranscriptionUrl(Optional finTranscriptionUrl) { + this.finTranscriptionUrl = finTranscriptionUrl; + return this; + } + + public Builder finTranscriptionUrl(String finTranscriptionUrl) { + this.finTranscriptionUrl = Optional.ofNullable(finTranscriptionUrl); + return this; + } + + /** + *

The call transcript if available, otherwise an empty array.

+ */ + @JsonSetter(value = "transcript", nulls = Nulls.SKIP) + public Builder transcript(Optional>> transcript) { + this.transcript = transcript; + return this; + } + + public Builder transcript(List> transcript) { + this.transcript = Optional.ofNullable(transcript); + return this; + } + + /** + *

The status of the transcript if available.

+ */ + @JsonSetter(value = "transcript_status", nulls = Nulls.SKIP) + public Builder transcriptStatus(Optional transcriptStatus) { + this.transcriptStatus = transcriptStatus; + return this; + } + + public Builder transcriptStatus(String transcriptStatus) { + this.transcriptStatus = Optional.ofNullable(transcriptStatus); + return this; + } + + public DataItem build() { + return new DataItem( + type, + id, + conversationId, + adminId, + contactId, + state, + initiatedAt, + answeredAt, + endedAt, + createdAt, + updatedAt, + recordingUrl, + transcriptionUrl, + callType, + direction, + endedReason, + phone, + finRecordingUrl, + finTranscriptionUrl, + transcript, + transcriptStatus, + additionalProperties); + } + } + } +} diff --git a/src/main/java/com/intercom/api/resources/companies/AsyncCompaniesClient.java b/src/main/java/com/intercom/api/resources/companies/AsyncCompaniesClient.java index 39c37ff..a7167dc 100644 --- a/src/main/java/com/intercom/api/resources/companies/AsyncCompaniesClient.java +++ b/src/main/java/com/intercom/api/resources/companies/AsyncCompaniesClient.java @@ -7,7 +7,6 @@ import com.intercom.api.core.RequestOptions; import com.intercom.api.core.pagination.SyncPagingIterable; import com.intercom.api.resources.companies.requests.AttachContactToCompanyRequest; -import com.intercom.api.resources.companies.requests.CreateOrUpdateCompanyRequest; import com.intercom.api.resources.companies.requests.DeleteCompanyRequest; import com.intercom.api.resources.companies.requests.DetachContactFromCompanyRequest; import com.intercom.api.resources.companies.requests.FindCompanyRequest; @@ -21,7 +20,9 @@ import com.intercom.api.resources.companies.types.Company; import com.intercom.api.types.CompanyAttachedContacts; import com.intercom.api.types.CompanyAttachedSegments; +import com.intercom.api.types.CreateOrUpdateCompanyRequest; import com.intercom.api.types.DeletedCompanyObject; +import java.util.Optional; import java.util.concurrent.CompletableFuture; public class AsyncCompaniesClient { @@ -98,7 +99,7 @@ public CompletableFuture createOrUpdate() { * 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 %}

*/ - public CompletableFuture createOrUpdate(CreateOrUpdateCompanyRequest request) { + public CompletableFuture createOrUpdate(Optional request) { return this.rawClient.createOrUpdate(request).thenApply(response -> response.body()); } @@ -111,7 +112,7 @@ public CompletableFuture createOrUpdate(CreateOrUpdateCompanyRequest re * {% /admonition %}

*/ public CompletableFuture createOrUpdate( - CreateOrUpdateCompanyRequest request, RequestOptions requestOptions) { + Optional request, RequestOptions requestOptions) { return this.rawClient.createOrUpdate(request, requestOptions).thenApply(response -> response.body()); } diff --git a/src/main/java/com/intercom/api/resources/companies/AsyncRawCompaniesClient.java b/src/main/java/com/intercom/api/resources/companies/AsyncRawCompaniesClient.java index eb44232..36914ca 100644 --- a/src/main/java/com/intercom/api/resources/companies/AsyncRawCompaniesClient.java +++ b/src/main/java/com/intercom/api/resources/companies/AsyncRawCompaniesClient.java @@ -4,6 +4,7 @@ package com.intercom.api.resources.companies; import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; import com.intercom.api.core.ClientOptions; import com.intercom.api.core.IntercomApiException; import com.intercom.api.core.IntercomException; @@ -17,7 +18,6 @@ import com.intercom.api.errors.NotFoundError; import com.intercom.api.errors.UnauthorizedError; import com.intercom.api.resources.companies.requests.AttachContactToCompanyRequest; -import com.intercom.api.resources.companies.requests.CreateOrUpdateCompanyRequest; import com.intercom.api.resources.companies.requests.DeleteCompanyRequest; import com.intercom.api.resources.companies.requests.DetachContactFromCompanyRequest; import com.intercom.api.resources.companies.requests.FindCompanyRequest; @@ -33,9 +33,11 @@ import com.intercom.api.types.CompanyAttachedSegments; import com.intercom.api.types.CompanyList; import com.intercom.api.types.CompanyScroll; +import com.intercom.api.types.CreateOrUpdateCompanyRequest; import com.intercom.api.types.DeletedCompanyObject; import com.intercom.api.types.Error; import java.io.IOException; +import java.util.Collections; import java.util.List; import java.util.Optional; import java.util.concurrent.CompletableFuture; @@ -187,7 +189,7 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { * {% /admonition %}

*/ public CompletableFuture> createOrUpdate() { - return createOrUpdate(CreateOrUpdateCompanyRequest.builder().build()); + return createOrUpdate(Optional.empty()); } /** @@ -198,7 +200,8 @@ public CompletableFuture> createOrUpdate() { * 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 %}

*/ - public CompletableFuture> createOrUpdate(CreateOrUpdateCompanyRequest request) { + public CompletableFuture> createOrUpdate( + Optional request) { return createOrUpdate(request, null); } @@ -211,15 +214,18 @@ public CompletableFuture> createOrUpdate(CreateOrU * {% /admonition %}

*/ public CompletableFuture> createOrUpdate( - CreateOrUpdateCompanyRequest request, RequestOptions requestOptions) { + Optional request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("companies") .build(); RequestBody body; try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + body = RequestBody.create("", null); + if (request.isPresent()) { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } } catch (JsonProcessingException e) { throw new IntercomException("Failed to serialize request", e); } @@ -377,13 +383,23 @@ public CompletableFuture> update( .addPathSegments("companies") .addPathSegment(request.getCompanyId()) .build(); - Request.Builder _requestBuilder = new Request.Builder() + RequestBody body; + try { + body = RequestBody.create("", null); + if (request.isPresent()) { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request.getBody()), MediaTypes.APPLICATION_JSON); + } + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() .url(httpUrl) - .method("PUT", RequestBody.create("", null)) + .method("PUT", body) .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); + .addHeader("Accept", "application/json") + .build(); OkHttpClient client = clientOptions.httpClient(); if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); @@ -522,21 +538,14 @@ public CompletableFuture> listAtta */ public CompletableFuture> listAttachedContacts( ListAttachedContactsRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("companies") .addPathSegment(request.getCompanyId()) - .addPathSegments("contacts"); - if (request.getPage().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "page", request.getPage().get().toString(), false); - } - if (request.getPerPage().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "per_page", request.getPerPage().get().toString(), false); - } + .addPathSegments("contacts") + .build(); Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) + .url(httpUrl) .method("GET", null) .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Content-Type", "application/json") @@ -749,7 +758,7 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO .from(request) .page(newPageNumber) .build(); - List result = parsedResponse.getData(); + List result = parsedResponse.getData().orElse(Collections.emptyList()); future.complete(new IntercomHttpResponse<>( new SyncPagingIterable(true, result, () -> { try { @@ -877,14 +886,15 @@ public CompletableFuture>> scro public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { if (response.isSuccessful()) { - CompanyScroll parsedResponse = - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CompanyScroll.class); - Optional startingAfter = parsedResponse.getScrollParam(); + Optional parsedResponse = ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}); + Optional startingAfter = parsedResponse.flatMap(CompanyScroll::getScrollParam); ScrollCompaniesRequest nextRequest = ScrollCompaniesRequest.builder() .from(request) .scrollParam(startingAfter) .build(); - List result = parsedResponse.getData(); + List result = + parsedResponse.flatMap(CompanyScroll::getData).orElse(Collections.emptyList()); future.complete(new IntercomHttpResponse<>( new SyncPagingIterable(startingAfter.isPresent(), result, () -> { try { @@ -942,7 +952,7 @@ public CompletableFuture> attachContact( HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("contacts") - .addPathSegment(request.getContactId()) + .addPathSegment(Integer.toString(request.getContactId())) .addPathSegments("companies") .build(); RequestBody body; diff --git a/src/main/java/com/intercom/api/resources/companies/CompaniesClient.java b/src/main/java/com/intercom/api/resources/companies/CompaniesClient.java index c3eef41..d187543 100644 --- a/src/main/java/com/intercom/api/resources/companies/CompaniesClient.java +++ b/src/main/java/com/intercom/api/resources/companies/CompaniesClient.java @@ -7,7 +7,6 @@ import com.intercom.api.core.RequestOptions; import com.intercom.api.core.pagination.SyncPagingIterable; import com.intercom.api.resources.companies.requests.AttachContactToCompanyRequest; -import com.intercom.api.resources.companies.requests.CreateOrUpdateCompanyRequest; import com.intercom.api.resources.companies.requests.DeleteCompanyRequest; import com.intercom.api.resources.companies.requests.DetachContactFromCompanyRequest; import com.intercom.api.resources.companies.requests.FindCompanyRequest; @@ -21,7 +20,9 @@ import com.intercom.api.resources.companies.types.Company; import com.intercom.api.types.CompanyAttachedContacts; import com.intercom.api.types.CompanyAttachedSegments; +import com.intercom.api.types.CreateOrUpdateCompanyRequest; import com.intercom.api.types.DeletedCompanyObject; +import java.util.Optional; public class CompaniesClient { protected final ClientOptions clientOptions; @@ -96,7 +97,7 @@ public Company createOrUpdate() { * 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 %}

*/ - public Company createOrUpdate(CreateOrUpdateCompanyRequest request) { + public Company createOrUpdate(Optional request) { return this.rawClient.createOrUpdate(request).body(); } @@ -108,7 +109,7 @@ public Company createOrUpdate(CreateOrUpdateCompanyRequest request) { * 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 %}

*/ - public Company createOrUpdate(CreateOrUpdateCompanyRequest request, RequestOptions requestOptions) { + public Company createOrUpdate(Optional request, RequestOptions requestOptions) { return this.rawClient.createOrUpdate(request, requestOptions).body(); } diff --git a/src/main/java/com/intercom/api/resources/companies/RawCompaniesClient.java b/src/main/java/com/intercom/api/resources/companies/RawCompaniesClient.java index e156a5c..41c845a 100644 --- a/src/main/java/com/intercom/api/resources/companies/RawCompaniesClient.java +++ b/src/main/java/com/intercom/api/resources/companies/RawCompaniesClient.java @@ -4,6 +4,7 @@ package com.intercom.api.resources.companies; import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; import com.intercom.api.core.ClientOptions; import com.intercom.api.core.IntercomApiException; import com.intercom.api.core.IntercomException; @@ -17,7 +18,6 @@ import com.intercom.api.errors.NotFoundError; import com.intercom.api.errors.UnauthorizedError; import com.intercom.api.resources.companies.requests.AttachContactToCompanyRequest; -import com.intercom.api.resources.companies.requests.CreateOrUpdateCompanyRequest; import com.intercom.api.resources.companies.requests.DeleteCompanyRequest; import com.intercom.api.resources.companies.requests.DetachContactFromCompanyRequest; import com.intercom.api.resources.companies.requests.FindCompanyRequest; @@ -33,9 +33,11 @@ import com.intercom.api.types.CompanyAttachedSegments; import com.intercom.api.types.CompanyList; import com.intercom.api.types.CompanyScroll; +import com.intercom.api.types.CreateOrUpdateCompanyRequest; import com.intercom.api.types.DeletedCompanyObject; import com.intercom.api.types.Error; import java.io.IOException; +import java.util.Collections; import java.util.List; import java.util.Optional; import okhttp3.Headers; @@ -164,7 +166,7 @@ public IntercomHttpResponse retrieve( * {% /admonition %}

*/ public IntercomHttpResponse createOrUpdate() { - return createOrUpdate(CreateOrUpdateCompanyRequest.builder().build()); + return createOrUpdate(Optional.empty()); } /** @@ -175,7 +177,7 @@ public IntercomHttpResponse createOrUpdate() { * 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 %}

*/ - public IntercomHttpResponse createOrUpdate(CreateOrUpdateCompanyRequest request) { + public IntercomHttpResponse createOrUpdate(Optional request) { return createOrUpdate(request, null); } @@ -188,15 +190,18 @@ public IntercomHttpResponse createOrUpdate(CreateOrUpdateCompanyRequest * {% /admonition %}

*/ public IntercomHttpResponse createOrUpdate( - CreateOrUpdateCompanyRequest request, RequestOptions requestOptions) { + Optional request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("companies") .build(); RequestBody body; try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + body = RequestBody.create("", null); + if (request.isPresent()) { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } } catch (JsonProcessingException e) { throw new IntercomException("Failed to serialize request", e); } @@ -318,13 +323,23 @@ public IntercomHttpResponse update(UpdateCompanyRequest request, Reques .addPathSegments("companies") .addPathSegment(request.getCompanyId()) .build(); - Request.Builder _requestBuilder = new Request.Builder() + RequestBody body; + try { + body = RequestBody.create("", null); + if (request.isPresent()) { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request.getBody()), MediaTypes.APPLICATION_JSON); + } + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() .url(httpUrl) - .method("PUT", RequestBody.create("", null)) + .method("PUT", body) .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); + .addHeader("Accept", "application/json") + .build(); OkHttpClient client = clientOptions.httpClient(); if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); @@ -428,21 +443,14 @@ public IntercomHttpResponse listAttachedContacts(ListAt */ public IntercomHttpResponse listAttachedContacts( ListAttachedContactsRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("companies") .addPathSegment(request.getCompanyId()) - .addPathSegments("contacts"); - if (request.getPage().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "page", request.getPage().get().toString(), false); - } - if (request.getPerPage().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "per_page", request.getPerPage().get().toString(), false); - } + .addPathSegments("contacts") + .build(); Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) + .url(httpUrl) .method("GET", null) .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Content-Type", "application/json") @@ -615,7 +623,7 @@ public IntercomHttpResponse> list( .from(request) .page(newPageNumber) .build(); - List result = parsedResponse.getData(); + List result = parsedResponse.getData().orElse(Collections.emptyList()); return new IntercomHttpResponse<>( new SyncPagingIterable(true, result, () -> list(nextRequest, requestOptions) .body()), @@ -722,14 +730,15 @@ public IntercomHttpResponse> scroll( try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); if (response.isSuccessful()) { - CompanyScroll parsedResponse = - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CompanyScroll.class); - Optional startingAfter = parsedResponse.getScrollParam(); + Optional parsedResponse = ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}); + Optional startingAfter = parsedResponse.flatMap(CompanyScroll::getScrollParam); ScrollCompaniesRequest nextRequest = ScrollCompaniesRequest.builder() .from(request) .scrollParam(startingAfter) .build(); - List result = parsedResponse.getData(); + List result = + parsedResponse.flatMap(CompanyScroll::getData).orElse(Collections.emptyList()); return new IntercomHttpResponse<>( new SyncPagingIterable( startingAfter.isPresent(), result, () -> scroll(nextRequest, requestOptions) @@ -770,7 +779,7 @@ public IntercomHttpResponse attachContact( HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("contacts") - .addPathSegment(request.getContactId()) + .addPathSegment(Integer.toString(request.getContactId())) .addPathSegments("companies") .build(); RequestBody body; diff --git a/src/main/java/com/intercom/api/resources/companies/requests/AttachContactToCompanyRequest.java b/src/main/java/com/intercom/api/resources/companies/requests/AttachContactToCompanyRequest.java index 615bf52..e211571 100644 --- a/src/main/java/com/intercom/api/resources/companies/requests/AttachContactToCompanyRequest.java +++ b/src/main/java/com/intercom/api/resources/companies/requests/AttachContactToCompanyRequest.java @@ -19,14 +19,13 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = AttachContactToCompanyRequest.Builder.class) public final class AttachContactToCompanyRequest { - private final String contactId; + private final int contactId; private final String companyId; private final Map additionalProperties; - private AttachContactToCompanyRequest( - String contactId, String companyId, Map additionalProperties) { + private AttachContactToCompanyRequest(int contactId, String companyId, Map additionalProperties) { this.contactId = contactId; this.companyId = companyId; this.additionalProperties = additionalProperties; @@ -36,7 +35,7 @@ private AttachContactToCompanyRequest( * @return The unique identifier for the contact which is given by Intercom */ @JsonProperty("contact_id") - public String getContactId() { + public int getContactId() { return contactId; } @@ -60,7 +59,7 @@ public Map getAdditionalProperties() { } private boolean equalTo(AttachContactToCompanyRequest other) { - return contactId.equals(other.contactId) && companyId.equals(other.companyId); + return contactId == other.contactId && companyId.equals(other.companyId); } @java.lang.Override @@ -81,7 +80,7 @@ public interface ContactIdStage { /** * The unique identifier for the contact which is given by Intercom */ - CompanyIdStage contactId(@NotNull String contactId); + CompanyIdStage contactId(int contactId); Builder from(AttachContactToCompanyRequest other); } @@ -99,7 +98,7 @@ public interface _FinalStage { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements ContactIdStage, CompanyIdStage, _FinalStage { - private String contactId; + private int contactId; private String companyId; @@ -121,8 +120,8 @@ public Builder from(AttachContactToCompanyRequest other) { */ @java.lang.Override @JsonSetter("contact_id") - public CompanyIdStage contactId(@NotNull String contactId) { - this.contactId = Objects.requireNonNull(contactId, "contactId must not be null"); + public CompanyIdStage contactId(int contactId) { + this.contactId = contactId; return this; } diff --git a/src/main/java/com/intercom/api/resources/companies/requests/ListAttachedContactsRequest.java b/src/main/java/com/intercom/api/resources/companies/requests/ListAttachedContactsRequest.java index 9985bf0..a695057 100644 --- a/src/main/java/com/intercom/api/resources/companies/requests/ListAttachedContactsRequest.java +++ b/src/main/java/com/intercom/api/resources/companies/requests/ListAttachedContactsRequest.java @@ -9,13 +9,11 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.intercom.api.core.ObjectMappers; import java.util.HashMap; import java.util.Map; import java.util.Objects; -import java.util.Optional; import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @@ -23,20 +21,10 @@ public final class ListAttachedContactsRequest { private final String companyId; - private final Optional page; - - private final Optional perPage; - private final Map additionalProperties; - private ListAttachedContactsRequest( - String companyId, - Optional page, - Optional perPage, - Map additionalProperties) { + private ListAttachedContactsRequest(String companyId, Map additionalProperties) { this.companyId = companyId; - this.page = page; - this.perPage = perPage; this.additionalProperties = additionalProperties; } @@ -48,22 +36,6 @@ public String getCompanyId() { return companyId; } - /** - * @return The page of results to fetch. Defaults to first page - */ - @JsonProperty("page") - public Optional getPage() { - return page; - } - - /** - * @return How many results to return per page. Defaults to 15 - */ - @JsonProperty("per_page") - public Optional getPerPage() { - return perPage; - } - @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -76,12 +48,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(ListAttachedContactsRequest other) { - return companyId.equals(other.companyId) && page.equals(other.page) && perPage.equals(other.perPage); + return companyId.equals(other.companyId); } @java.lang.Override public int hashCode() { - return Objects.hash(this.companyId, this.page, this.perPage); + return Objects.hash(this.companyId); } @java.lang.Override @@ -104,30 +76,12 @@ public interface CompanyIdStage { public interface _FinalStage { ListAttachedContactsRequest build(); - - /** - *

The page of results to fetch. Defaults to first page

- */ - _FinalStage page(Optional page); - - _FinalStage page(Integer page); - - /** - *

How many results to return per page. Defaults to 15

- */ - _FinalStage perPage(Optional perPage); - - _FinalStage perPage(Integer perPage); } @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements CompanyIdStage, _FinalStage { private String companyId; - private Optional perPage = Optional.empty(); - - private Optional page = Optional.empty(); - @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -136,8 +90,6 @@ private Builder() {} @java.lang.Override public Builder from(ListAttachedContactsRequest other) { companyId(other.getCompanyId()); - page(other.getPage()); - perPage(other.getPerPage()); return this; } @@ -152,49 +104,9 @@ public _FinalStage companyId(@NotNull String companyId) { return this; } - /** - *

How many results to return per page. Defaults to 15

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage perPage(Integer perPage) { - this.perPage = Optional.ofNullable(perPage); - return this; - } - - /** - *

How many results to return per page. Defaults to 15

- */ - @java.lang.Override - @JsonSetter(value = "per_page", nulls = Nulls.SKIP) - public _FinalStage perPage(Optional perPage) { - this.perPage = perPage; - return this; - } - - /** - *

The page of results to fetch. Defaults to first page

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage page(Integer page) { - this.page = Optional.ofNullable(page); - return this; - } - - /** - *

The page of results to fetch. Defaults to first page

- */ - @java.lang.Override - @JsonSetter(value = "page", nulls = Nulls.SKIP) - public _FinalStage page(Optional page) { - this.page = page; - return this; - } - @java.lang.Override public ListAttachedContactsRequest build() { - return new ListAttachedContactsRequest(companyId, page, perPage, additionalProperties); + return new ListAttachedContactsRequest(companyId, additionalProperties); } } } diff --git a/src/main/java/com/intercom/api/resources/companies/requests/UpdateCompanyRequest.java b/src/main/java/com/intercom/api/resources/companies/requests/UpdateCompanyRequest.java index 8d77e60..16b9afc 100644 --- a/src/main/java/com/intercom/api/resources/companies/requests/UpdateCompanyRequest.java +++ b/src/main/java/com/intercom/api/resources/companies/requests/UpdateCompanyRequest.java @@ -9,11 +9,14 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.intercom.api.core.ObjectMappers; +import com.intercom.api.types.UpdateCompanyRequestBody; import java.util.HashMap; import java.util.Map; import java.util.Objects; +import java.util.Optional; import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @@ -21,10 +24,14 @@ public final class UpdateCompanyRequest { private final String companyId; + private final Optional body; + private final Map additionalProperties; - private UpdateCompanyRequest(String companyId, Map additionalProperties) { + private UpdateCompanyRequest( + String companyId, Optional body, Map additionalProperties) { this.companyId = companyId; + this.body = body; this.additionalProperties = additionalProperties; } @@ -36,6 +43,11 @@ public String getCompanyId() { return companyId; } + @JsonProperty("body") + public Optional getBody() { + return body; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -48,12 +60,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(UpdateCompanyRequest other) { - return companyId.equals(other.companyId); + return companyId.equals(other.companyId) && body.equals(other.body); } @java.lang.Override public int hashCode() { - return Objects.hash(this.companyId); + return Objects.hash(this.companyId, this.body); } @java.lang.Override @@ -76,12 +88,18 @@ public interface CompanyIdStage { public interface _FinalStage { UpdateCompanyRequest build(); + + _FinalStage body(Optional body); + + _FinalStage body(UpdateCompanyRequestBody body); } @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements CompanyIdStage, _FinalStage { private String companyId; + private Optional body = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -90,6 +108,7 @@ private Builder() {} @java.lang.Override public Builder from(UpdateCompanyRequest other) { companyId(other.getCompanyId()); + body(other.getBody()); return this; } @@ -104,9 +123,22 @@ public _FinalStage companyId(@NotNull String companyId) { return this; } + @java.lang.Override + public _FinalStage body(UpdateCompanyRequestBody body) { + this.body = Optional.ofNullable(body); + return this; + } + + @java.lang.Override + @JsonSetter(value = "body", nulls = Nulls.SKIP) + public _FinalStage body(Optional body) { + this.body = body; + return this; + } + @java.lang.Override public UpdateCompanyRequest build() { - return new UpdateCompanyRequest(companyId, additionalProperties); + return new UpdateCompanyRequest(companyId, body, additionalProperties); } } } diff --git a/src/main/java/com/intercom/api/resources/companies/types/Company.java b/src/main/java/com/intercom/api/resources/companies/types/Company.java index 4231d07..08ca9fc 100644 --- a/src/main/java/com/intercom/api/resources/companies/types/Company.java +++ b/src/main/java/com/intercom/api/resources/companies/types/Company.java @@ -33,19 +33,19 @@ public final class Company { private final String companyId; - private final int remoteCreatedAt; + private final Optional remoteCreatedAt; private final int createdAt; private final int updatedAt; - private final int lastRequestAt; + private final Optional lastRequestAt; - private final int size; + private final Optional size; - private final String website; + private final Optional website; - private final String industry; + private final Optional industry; private final int monthlySpend; @@ -67,13 +67,13 @@ private Company( String appId, Optional plan, String companyId, - int remoteCreatedAt, + Optional remoteCreatedAt, int createdAt, int updatedAt, - int lastRequestAt, - int size, - String website, - String industry, + Optional lastRequestAt, + Optional size, + Optional website, + Optional industry, int monthlySpend, int sessionCount, int userCount, @@ -143,7 +143,7 @@ public String getCompanyId() { * @return The time the company was created by you. */ @JsonProperty("remote_created_at") - public int getRemoteCreatedAt() { + public Optional getRemoteCreatedAt() { return remoteCreatedAt; } @@ -167,7 +167,7 @@ public int getUpdatedAt() { * @return The time the company last recorded making a request. */ @JsonProperty("last_request_at") - public int getLastRequestAt() { + public Optional getLastRequestAt() { return lastRequestAt; } @@ -175,7 +175,7 @@ public int getLastRequestAt() { * @return The number of employees in the company. */ @JsonProperty("size") - public int getSize() { + public Optional getSize() { return size; } @@ -183,7 +183,7 @@ public int getSize() { * @return The URL for the company website. */ @JsonProperty("website") - public String getWebsite() { + public Optional getWebsite() { return website; } @@ -191,7 +191,7 @@ public String getWebsite() { * @return The industry that the company operates in. */ @JsonProperty("industry") - public String getIndustry() { + public Optional getIndustry() { return industry; } @@ -260,11 +260,11 @@ private boolean equalTo(Company other) { && appId.equals(other.appId) && plan.equals(other.plan) && companyId.equals(other.companyId) - && remoteCreatedAt == other.remoteCreatedAt + && remoteCreatedAt.equals(other.remoteCreatedAt) && createdAt == other.createdAt && updatedAt == other.updatedAt - && lastRequestAt == other.lastRequestAt - && size == other.size + && lastRequestAt.equals(other.lastRequestAt) + && size.equals(other.size) && website.equals(other.website) && industry.equals(other.industry) && monthlySpend == other.monthlySpend @@ -334,14 +334,7 @@ public interface CompanyIdStage { /** * The company id you have defined for the company. */ - RemoteCreatedAtStage companyId(@NotNull String companyId); - } - - public interface RemoteCreatedAtStage { - /** - * The time the company was created by you. - */ - CreatedAtStage remoteCreatedAt(int remoteCreatedAt); + CreatedAtStage companyId(@NotNull String companyId); } public interface CreatedAtStage { @@ -355,35 +348,7 @@ public interface UpdatedAtStage { /** * The last time the company was updated. */ - LastRequestAtStage updatedAt(int updatedAt); - } - - public interface LastRequestAtStage { - /** - * The time the company last recorded making a request. - */ - SizeStage lastRequestAt(int lastRequestAt); - } - - public interface SizeStage { - /** - * The number of employees in the company. - */ - WebsiteStage size(int size); - } - - public interface WebsiteStage { - /** - * The URL for the company website. - */ - IndustryStage website(@NotNull String website); - } - - public interface IndustryStage { - /** - * The industry that the company operates in. - */ - MonthlySpendStage industry(@NotNull String industry); + MonthlySpendStage updatedAt(int updatedAt); } public interface MonthlySpendStage { @@ -414,6 +379,41 @@ public interface _FinalStage { _FinalStage plan(Plan plan); + /** + *

The time the company was created by you.

+ */ + _FinalStage remoteCreatedAt(Optional remoteCreatedAt); + + _FinalStage remoteCreatedAt(Integer remoteCreatedAt); + + /** + *

The time the company last recorded making a request.

+ */ + _FinalStage lastRequestAt(Optional lastRequestAt); + + _FinalStage lastRequestAt(Integer lastRequestAt); + + /** + *

The number of employees in the company.

+ */ + _FinalStage size(Optional size); + + _FinalStage size(Integer size); + + /** + *

The URL for the company website.

+ */ + _FinalStage website(Optional website); + + _FinalStage website(String website); + + /** + *

The industry that the company operates in.

+ */ + _FinalStage industry(Optional industry); + + _FinalStage industry(String industry); + /** *

The custom attributes you have set on the company.

*/ @@ -442,13 +442,8 @@ public static final class Builder NameStage, AppIdStage, CompanyIdStage, - RemoteCreatedAtStage, CreatedAtStage, UpdatedAtStage, - LastRequestAtStage, - SizeStage, - WebsiteStage, - IndustryStage, MonthlySpendStage, SessionCountStage, UserCountStage, @@ -461,20 +456,10 @@ public static final class Builder private String companyId; - private int remoteCreatedAt; - private int createdAt; private int updatedAt; - private int lastRequestAt; - - private int size; - - private String website; - - private String industry; - private int monthlySpend; private int sessionCount; @@ -487,6 +472,16 @@ public static final class Builder private Optional> customAttributes = Optional.empty(); + private Optional industry = Optional.empty(); + + private Optional website = Optional.empty(); + + private Optional size = Optional.empty(); + + private Optional lastRequestAt = Optional.empty(); + + private Optional remoteCreatedAt = Optional.empty(); + private Optional plan = Optional.empty(); @JsonAnySetter @@ -556,22 +551,11 @@ public CompanyIdStage appId(@NotNull String appId) { */ @java.lang.Override @JsonSetter("company_id") - public RemoteCreatedAtStage companyId(@NotNull String companyId) { + public CreatedAtStage companyId(@NotNull String companyId) { this.companyId = Objects.requireNonNull(companyId, "companyId must not be null"); return this; } - /** - * The time the company was created by you.

The time the company was created by you.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("remote_created_at") - public CreatedAtStage remoteCreatedAt(int remoteCreatedAt) { - this.remoteCreatedAt = remoteCreatedAt; - return this; - } - /** * The time the company was added in Intercom.

The time the company was added in Intercom.

* @return Reference to {@code this} so that method calls can be chained together. @@ -589,55 +573,11 @@ public UpdatedAtStage createdAt(int createdAt) { */ @java.lang.Override @JsonSetter("updated_at") - public LastRequestAtStage updatedAt(int updatedAt) { + public MonthlySpendStage updatedAt(int updatedAt) { this.updatedAt = updatedAt; return this; } - /** - * The time the company last recorded making a request.

The time the company last recorded making a request.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("last_request_at") - public SizeStage lastRequestAt(int lastRequestAt) { - this.lastRequestAt = lastRequestAt; - return this; - } - - /** - * The number of employees in the company.

The number of employees in the company.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("size") - public WebsiteStage size(int size) { - this.size = size; - return this; - } - - /** - * The URL for the company website.

The URL for the company website.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("website") - public IndustryStage website(@NotNull String website) { - this.website = Objects.requireNonNull(website, "website must not be null"); - return this; - } - - /** - * The industry that the company operates in.

The industry that the company operates in.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("industry") - public MonthlySpendStage industry(@NotNull String industry) { - this.industry = Objects.requireNonNull(industry, "industry must not be null"); - return this; - } - /** * How much revenue the company generates for your business.

How much revenue the company generates for your business.

* @return Reference to {@code this} so that method calls can be chained together. @@ -731,6 +671,106 @@ public _FinalStage customAttributes(Optional> customAttribut return this; } + /** + *

The industry that the company operates in.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage industry(String industry) { + this.industry = Optional.ofNullable(industry); + return this; + } + + /** + *

The industry that the company operates in.

+ */ + @java.lang.Override + @JsonSetter(value = "industry", nulls = Nulls.SKIP) + public _FinalStage industry(Optional industry) { + this.industry = industry; + return this; + } + + /** + *

The URL for the company website.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage website(String website) { + this.website = Optional.ofNullable(website); + return this; + } + + /** + *

The URL for the company website.

+ */ + @java.lang.Override + @JsonSetter(value = "website", nulls = Nulls.SKIP) + public _FinalStage website(Optional website) { + this.website = website; + return this; + } + + /** + *

The number of employees in the company.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage size(Integer size) { + this.size = Optional.ofNullable(size); + return this; + } + + /** + *

The number of employees in the company.

+ */ + @java.lang.Override + @JsonSetter(value = "size", nulls = Nulls.SKIP) + public _FinalStage size(Optional size) { + this.size = size; + return this; + } + + /** + *

The time the company last recorded making a request.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage lastRequestAt(Integer lastRequestAt) { + this.lastRequestAt = Optional.ofNullable(lastRequestAt); + return this; + } + + /** + *

The time the company last recorded making a request.

+ */ + @java.lang.Override + @JsonSetter(value = "last_request_at", nulls = Nulls.SKIP) + public _FinalStage lastRequestAt(Optional lastRequestAt) { + this.lastRequestAt = lastRequestAt; + return this; + } + + /** + *

The time the company was created by you.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage remoteCreatedAt(Integer remoteCreatedAt) { + this.remoteCreatedAt = Optional.ofNullable(remoteCreatedAt); + return this; + } + + /** + *

The time the company was created by you.

+ */ + @java.lang.Override + @JsonSetter(value = "remote_created_at", nulls = Nulls.SKIP) + public _FinalStage remoteCreatedAt(Optional remoteCreatedAt) { + this.remoteCreatedAt = remoteCreatedAt; + return this; + } + @java.lang.Override public _FinalStage plan(Plan plan) { this.plan = Optional.ofNullable(plan); diff --git a/src/main/java/com/intercom/api/resources/contacts/AsyncContactsClient.java b/src/main/java/com/intercom/api/resources/contacts/AsyncContactsClient.java index f2a70d1..c9a2880 100644 --- a/src/main/java/com/intercom/api/resources/contacts/AsyncContactsClient.java +++ b/src/main/java/com/intercom/api/resources/contacts/AsyncContactsClient.java @@ -9,6 +9,7 @@ import com.intercom.api.resources.companies.types.Company; import com.intercom.api.resources.contacts.requests.ArchiveContactRequest; import com.intercom.api.resources.contacts.requests.AttachSubscriptionToContactRequest; +import com.intercom.api.resources.contacts.requests.BlockContactRequest; import com.intercom.api.resources.contacts.requests.DeleteContactRequest; import com.intercom.api.resources.contacts.requests.DetachSubscriptionFromContactRequest; import com.intercom.api.resources.contacts.requests.FindContactRequest; @@ -18,11 +19,18 @@ import com.intercom.api.resources.contacts.requests.ListSegmentsAttachedToContactRequest; import com.intercom.api.resources.contacts.requests.ListTagsAttachedToContactRequest; import com.intercom.api.resources.contacts.requests.MergeContactsRequest; +import com.intercom.api.resources.contacts.requests.ShowContactByExternalIdRequest; import com.intercom.api.resources.contacts.requests.UnarchiveContactRequest; import com.intercom.api.resources.contacts.requests.UpdateContactRequest; import com.intercom.api.resources.contacts.types.Contact; +import com.intercom.api.resources.contacts.types.ContactsCreateResponse; +import com.intercom.api.resources.contacts.types.ContactsFindResponse; +import com.intercom.api.resources.contacts.types.ContactsMergeLeadInUserResponse; +import com.intercom.api.resources.contacts.types.ContactsUpdateResponse; +import com.intercom.api.resources.contacts.types.ShowContactByExternalIdResponse; import com.intercom.api.resources.subscriptiontypes.types.SubscriptionType; import com.intercom.api.types.ContactArchived; +import com.intercom.api.types.ContactBlocked; import com.intercom.api.types.ContactDeleted; import com.intercom.api.types.ContactSegments; import com.intercom.api.types.ContactUnarchived; @@ -156,28 +164,37 @@ public CompletableFuture listAttachedTags( /** * You can fetch the details of a single contact. */ - public CompletableFuture find(FindContactRequest request) { + public CompletableFuture find(FindContactRequest request) { return this.rawClient.find(request).thenApply(response -> response.body()); } /** * You can fetch the details of a single contact. */ - public CompletableFuture find(FindContactRequest request, RequestOptions requestOptions) { + public CompletableFuture find(FindContactRequest request, RequestOptions requestOptions) { return this.rawClient.find(request, requestOptions).thenApply(response -> response.body()); } /** * 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 %}

*/ - public CompletableFuture update(UpdateContactRequest request) { + public CompletableFuture update(UpdateContactRequest request) { return this.rawClient.update(request).thenApply(response -> response.body()); } /** * 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 %}

*/ - public CompletableFuture update(UpdateContactRequest request, RequestOptions requestOptions) { + public CompletableFuture update( + UpdateContactRequest request, RequestOptions requestOptions) { return this.rawClient.update(request, requestOptions).thenApply(response -> response.body()); } @@ -198,14 +215,22 @@ public CompletableFuture delete(DeleteContactRequest request, Re /** * You can merge a contact with a role of lead into a contact with a role of user. */ - public CompletableFuture mergeLeadInUser(MergeContactsRequest request) { + public CompletableFuture mergeLeadInUser() { + return this.rawClient.mergeLeadInUser().thenApply(response -> response.body()); + } + + /** + * You can merge a contact with a role of lead into a contact with a role of user. + */ + public CompletableFuture mergeLeadInUser(MergeContactsRequest request) { return this.rawClient.mergeLeadInUser(request).thenApply(response -> response.body()); } /** * You can merge a contact with a role of lead into a contact with a role of user. */ - public CompletableFuture mergeLeadInUser(MergeContactsRequest request, RequestOptions requestOptions) { + public CompletableFuture mergeLeadInUser( + MergeContactsRequest request, RequestOptions requestOptions) { return this.rawClient.mergeLeadInUser(request, requestOptions).thenApply(response -> response.body()); } @@ -430,17 +455,34 @@ public CompletableFuture> list( /** * You can create a new contact (ie. user or lead). */ - public CompletableFuture create(CreateContactRequest request) { + public CompletableFuture create(CreateContactRequest request) { return this.rawClient.create(request).thenApply(response -> response.body()); } /** * You can create a new contact (ie. user or lead). */ - public CompletableFuture create(CreateContactRequest request, RequestOptions requestOptions) { + public CompletableFuture create( + CreateContactRequest request, RequestOptions requestOptions) { return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); } + /** + * You can fetch the details of a single contact by external ID. Note that this endpoint only supports users and not leads. + */ + public CompletableFuture showContactByExternalId( + ShowContactByExternalIdRequest request) { + return this.rawClient.showContactByExternalId(request).thenApply(response -> response.body()); + } + + /** + * You can fetch the details of a single contact by external ID. Note that this endpoint only supports users and not leads. + */ + public CompletableFuture showContactByExternalId( + ShowContactByExternalIdRequest request, RequestOptions requestOptions) { + return this.rawClient.showContactByExternalId(request, requestOptions).thenApply(response -> response.body()); + } + /** * You can archive a single contact. */ @@ -469,4 +511,18 @@ public CompletableFuture unarchive( UnarchiveContactRequest request, RequestOptions requestOptions) { return this.rawClient.unarchive(request, requestOptions).thenApply(response -> response.body()); } + + /** + * Block a single contact.<br>Note: conversations of the contact will also be archived during the process.<br>More details in FAQ How do I block Inbox spam? + */ + public CompletableFuture blockContact(BlockContactRequest request) { + return this.rawClient.blockContact(request).thenApply(response -> response.body()); + } + + /** + * Block a single contact.<br>Note: conversations of the contact will also be archived during the process.<br>More details in FAQ How do I block Inbox spam? + */ + public CompletableFuture blockContact(BlockContactRequest request, RequestOptions requestOptions) { + return this.rawClient.blockContact(request, requestOptions).thenApply(response -> response.body()); + } } diff --git a/src/main/java/com/intercom/api/resources/contacts/AsyncRawContactsClient.java b/src/main/java/com/intercom/api/resources/contacts/AsyncRawContactsClient.java index 28dc93a..bf12db7 100644 --- a/src/main/java/com/intercom/api/resources/contacts/AsyncRawContactsClient.java +++ b/src/main/java/com/intercom/api/resources/contacts/AsyncRawContactsClient.java @@ -18,6 +18,7 @@ import com.intercom.api.resources.companies.types.Company; import com.intercom.api.resources.contacts.requests.ArchiveContactRequest; import com.intercom.api.resources.contacts.requests.AttachSubscriptionToContactRequest; +import com.intercom.api.resources.contacts.requests.BlockContactRequest; import com.intercom.api.resources.contacts.requests.DeleteContactRequest; import com.intercom.api.resources.contacts.requests.DetachSubscriptionFromContactRequest; import com.intercom.api.resources.contacts.requests.FindContactRequest; @@ -27,12 +28,19 @@ import com.intercom.api.resources.contacts.requests.ListSegmentsAttachedToContactRequest; import com.intercom.api.resources.contacts.requests.ListTagsAttachedToContactRequest; import com.intercom.api.resources.contacts.requests.MergeContactsRequest; +import com.intercom.api.resources.contacts.requests.ShowContactByExternalIdRequest; import com.intercom.api.resources.contacts.requests.UnarchiveContactRequest; import com.intercom.api.resources.contacts.requests.UpdateContactRequest; import com.intercom.api.resources.contacts.types.Contact; +import com.intercom.api.resources.contacts.types.ContactsCreateResponse; +import com.intercom.api.resources.contacts.types.ContactsFindResponse; +import com.intercom.api.resources.contacts.types.ContactsMergeLeadInUserResponse; +import com.intercom.api.resources.contacts.types.ContactsUpdateResponse; +import com.intercom.api.resources.contacts.types.ShowContactByExternalIdResponse; import com.intercom.api.resources.subscriptiontypes.types.SubscriptionType; import com.intercom.api.types.ContactArchived; import com.intercom.api.types.ContactAttachedCompanies; +import com.intercom.api.types.ContactBlocked; import com.intercom.api.types.ContactDeleted; import com.intercom.api.types.ContactList; import com.intercom.api.types.ContactSegments; @@ -45,6 +53,7 @@ import com.intercom.api.types.SubscriptionTypeList; import com.intercom.api.types.TagList; import java.io.IOException; +import java.util.Collections; import java.util.List; import java.util.Optional; import java.util.concurrent.CompletableFuture; @@ -118,7 +127,7 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO .from(request) .page(newPageNumber) .build(); - List result = parsedResponse.getCompanies(); + List result = parsedResponse.getCompanies().orElse(Collections.emptyList()); future.complete(new IntercomHttpResponse<>( new SyncPagingIterable(true, result, () -> { try { @@ -576,14 +585,14 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { /** * You can fetch the details of a single contact. */ - public CompletableFuture> find(FindContactRequest request) { + public CompletableFuture> find(FindContactRequest request) { return find(request, null); } /** * You can fetch the details of a single contact. */ - public CompletableFuture> find( + public CompletableFuture> find( FindContactRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -601,14 +610,15 @@ public CompletableFuture> find( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } - CompletableFuture> future = new CompletableFuture<>(); + CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Contact.class), response)); + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ContactsFindResponse.class), + response)); return; } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -642,15 +652,23 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { /** * 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 %}

*/ - public CompletableFuture> update(UpdateContactRequest request) { + public CompletableFuture> update(UpdateContactRequest request) { return update(request, null); } /** * 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 %}

*/ - public CompletableFuture> update( + public CompletableFuture> update( UpdateContactRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -675,14 +693,16 @@ public CompletableFuture> update( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } - CompletableFuture> future = new CompletableFuture<>(); + CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Contact.class), response)); + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ContactsUpdateResponse.class), + response)); return; } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -785,14 +805,22 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { /** * You can merge a contact with a role of lead into a contact with a role of user. */ - public CompletableFuture> mergeLeadInUser(MergeContactsRequest request) { + public CompletableFuture> mergeLeadInUser() { + return mergeLeadInUser(MergeContactsRequest.builder().build()); + } + + /** + * You can merge a contact with a role of lead into a contact with a role of user. + */ + public CompletableFuture> mergeLeadInUser( + MergeContactsRequest request) { return mergeLeadInUser(request, null); } /** * You can merge a contact with a role of lead into a contact with a role of user. */ - public CompletableFuture> mergeLeadInUser( + public CompletableFuture> mergeLeadInUser( MergeContactsRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -816,14 +844,16 @@ public CompletableFuture> mergeLeadInUser( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } - CompletableFuture> future = new CompletableFuture<>(); + CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Contact.class), response)); + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ContactsMergeLeadInUserResponse.class), + response)); return; } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1080,7 +1110,7 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO .from(request) .pagination(pagination) .build(); - List result = parsedResponse.getData(); + List result = parsedResponse.getData().orElse(Collections.emptyList()); future.complete(new IntercomHttpResponse<>( new SyncPagingIterable(startingAfter.isPresent(), result, () -> { try { @@ -1196,7 +1226,7 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO .from(request) .startingAfter(startingAfter) .build(); - List result = parsedResponse.getData(); + List result = parsedResponse.getData().orElse(Collections.emptyList()); future.complete(new IntercomHttpResponse<>( new SyncPagingIterable(startingAfter.isPresent(), result, () -> { try { @@ -1242,14 +1272,14 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { /** * You can create a new contact (ie. user or lead). */ - public CompletableFuture> create(CreateContactRequest request) { + public CompletableFuture> create(CreateContactRequest request) { return create(request, null); } /** * You can create a new contact (ie. user or lead). */ - public CompletableFuture> create( + public CompletableFuture> create( CreateContactRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -1273,14 +1303,86 @@ public CompletableFuture> create( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } - CompletableFuture> future = new CompletableFuture<>(); + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ContactsCreateResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can fetch the details of a single contact by external ID. Note that this endpoint only supports users and not leads. + */ + public CompletableFuture> showContactByExternalId( + ShowContactByExternalIdRequest request) { + return showContactByExternalId(request, null); + } + + /** + * You can fetch the details of a single contact by external ID. Note that this endpoint only supports users and not leads. + */ + public CompletableFuture> showContactByExternalId( + ShowContactByExternalIdRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts/find_by_external_id") + .addPathSegment(request.getExternalId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Contact.class), response)); + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ShowContactByExternalIdResponse.class), + response)); return; } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1431,4 +1533,64 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { }); return future; } + + /** + * Block a single contact.<br>Note: conversations of the contact will also be archived during the process.<br>More details in FAQ How do I block Inbox spam? + */ + public CompletableFuture> blockContact(BlockContactRequest request) { + return blockContact(request, null); + } + + /** + * Block a single contact.<br>Note: conversations of the contact will also be archived during the process.<br>More details in FAQ How do I block Inbox spam? + */ + public CompletableFuture> blockContact( + BlockContactRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getContactId()) + .addPathSegments("block") + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("POST", RequestBody.create("", null)) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ContactBlocked.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } } diff --git a/src/main/java/com/intercom/api/resources/contacts/ContactsClient.java b/src/main/java/com/intercom/api/resources/contacts/ContactsClient.java index dd7ed73..3c5cbf7 100644 --- a/src/main/java/com/intercom/api/resources/contacts/ContactsClient.java +++ b/src/main/java/com/intercom/api/resources/contacts/ContactsClient.java @@ -9,6 +9,7 @@ import com.intercom.api.resources.companies.types.Company; import com.intercom.api.resources.contacts.requests.ArchiveContactRequest; import com.intercom.api.resources.contacts.requests.AttachSubscriptionToContactRequest; +import com.intercom.api.resources.contacts.requests.BlockContactRequest; import com.intercom.api.resources.contacts.requests.DeleteContactRequest; import com.intercom.api.resources.contacts.requests.DetachSubscriptionFromContactRequest; import com.intercom.api.resources.contacts.requests.FindContactRequest; @@ -18,11 +19,18 @@ import com.intercom.api.resources.contacts.requests.ListSegmentsAttachedToContactRequest; import com.intercom.api.resources.contacts.requests.ListTagsAttachedToContactRequest; import com.intercom.api.resources.contacts.requests.MergeContactsRequest; +import com.intercom.api.resources.contacts.requests.ShowContactByExternalIdRequest; import com.intercom.api.resources.contacts.requests.UnarchiveContactRequest; import com.intercom.api.resources.contacts.requests.UpdateContactRequest; import com.intercom.api.resources.contacts.types.Contact; +import com.intercom.api.resources.contacts.types.ContactsCreateResponse; +import com.intercom.api.resources.contacts.types.ContactsFindResponse; +import com.intercom.api.resources.contacts.types.ContactsMergeLeadInUserResponse; +import com.intercom.api.resources.contacts.types.ContactsUpdateResponse; +import com.intercom.api.resources.contacts.types.ShowContactByExternalIdResponse; import com.intercom.api.resources.subscriptiontypes.types.SubscriptionType; import com.intercom.api.types.ContactArchived; +import com.intercom.api.types.ContactBlocked; import com.intercom.api.types.ContactDeleted; import com.intercom.api.types.ContactSegments; import com.intercom.api.types.ContactUnarchived; @@ -154,28 +162,36 @@ public TagList listAttachedTags(ListTagsAttachedToContactRequest request, Reques /** * You can fetch the details of a single contact. */ - public Contact find(FindContactRequest request) { + public ContactsFindResponse find(FindContactRequest request) { return this.rawClient.find(request).body(); } /** * You can fetch the details of a single contact. */ - public Contact find(FindContactRequest request, RequestOptions requestOptions) { + public ContactsFindResponse find(FindContactRequest request, RequestOptions requestOptions) { return this.rawClient.find(request, requestOptions).body(); } /** * 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 %}

*/ - public Contact update(UpdateContactRequest request) { + public ContactsUpdateResponse update(UpdateContactRequest request) { return this.rawClient.update(request).body(); } /** * 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 %}

*/ - public Contact update(UpdateContactRequest request, RequestOptions requestOptions) { + public ContactsUpdateResponse update(UpdateContactRequest request, RequestOptions requestOptions) { return this.rawClient.update(request, requestOptions).body(); } @@ -196,14 +212,22 @@ public ContactDeleted delete(DeleteContactRequest request, RequestOptions reques /** * You can merge a contact with a role of lead into a contact with a role of user. */ - public Contact mergeLeadInUser(MergeContactsRequest request) { + public ContactsMergeLeadInUserResponse mergeLeadInUser() { + return this.rawClient.mergeLeadInUser().body(); + } + + /** + * You can merge a contact with a role of lead into a contact with a role of user. + */ + public ContactsMergeLeadInUserResponse mergeLeadInUser(MergeContactsRequest request) { return this.rawClient.mergeLeadInUser(request).body(); } /** * You can merge a contact with a role of lead into a contact with a role of user. */ - public Contact mergeLeadInUser(MergeContactsRequest request, RequestOptions requestOptions) { + public ContactsMergeLeadInUserResponse mergeLeadInUser( + MergeContactsRequest request, RequestOptions requestOptions) { return this.rawClient.mergeLeadInUser(request, requestOptions).body(); } @@ -427,17 +451,32 @@ public SyncPagingIterable list(ListContactsRequest request, RequestOpti /** * You can create a new contact (ie. user or lead). */ - public Contact create(CreateContactRequest request) { + public ContactsCreateResponse create(CreateContactRequest request) { return this.rawClient.create(request).body(); } /** * You can create a new contact (ie. user or lead). */ - public Contact create(CreateContactRequest request, RequestOptions requestOptions) { + public ContactsCreateResponse create(CreateContactRequest request, RequestOptions requestOptions) { return this.rawClient.create(request, requestOptions).body(); } + /** + * You can fetch the details of a single contact by external ID. Note that this endpoint only supports users and not leads. + */ + public ShowContactByExternalIdResponse showContactByExternalId(ShowContactByExternalIdRequest request) { + return this.rawClient.showContactByExternalId(request).body(); + } + + /** + * You can fetch the details of a single contact by external ID. Note that this endpoint only supports users and not leads. + */ + public ShowContactByExternalIdResponse showContactByExternalId( + ShowContactByExternalIdRequest request, RequestOptions requestOptions) { + return this.rawClient.showContactByExternalId(request, requestOptions).body(); + } + /** * You can archive a single contact. */ @@ -465,4 +504,18 @@ public ContactUnarchived unarchive(UnarchiveContactRequest request) { public ContactUnarchived unarchive(UnarchiveContactRequest request, RequestOptions requestOptions) { return this.rawClient.unarchive(request, requestOptions).body(); } + + /** + * Block a single contact.<br>Note: conversations of the contact will also be archived during the process.<br>More details in FAQ How do I block Inbox spam? + */ + public ContactBlocked blockContact(BlockContactRequest request) { + return this.rawClient.blockContact(request).body(); + } + + /** + * Block a single contact.<br>Note: conversations of the contact will also be archived during the process.<br>More details in FAQ How do I block Inbox spam? + */ + public ContactBlocked blockContact(BlockContactRequest request, RequestOptions requestOptions) { + return this.rawClient.blockContact(request, requestOptions).body(); + } } diff --git a/src/main/java/com/intercom/api/resources/contacts/RawContactsClient.java b/src/main/java/com/intercom/api/resources/contacts/RawContactsClient.java index e9000a9..9bfb42a 100644 --- a/src/main/java/com/intercom/api/resources/contacts/RawContactsClient.java +++ b/src/main/java/com/intercom/api/resources/contacts/RawContactsClient.java @@ -18,6 +18,7 @@ import com.intercom.api.resources.companies.types.Company; import com.intercom.api.resources.contacts.requests.ArchiveContactRequest; import com.intercom.api.resources.contacts.requests.AttachSubscriptionToContactRequest; +import com.intercom.api.resources.contacts.requests.BlockContactRequest; import com.intercom.api.resources.contacts.requests.DeleteContactRequest; import com.intercom.api.resources.contacts.requests.DetachSubscriptionFromContactRequest; import com.intercom.api.resources.contacts.requests.FindContactRequest; @@ -27,12 +28,19 @@ import com.intercom.api.resources.contacts.requests.ListSegmentsAttachedToContactRequest; import com.intercom.api.resources.contacts.requests.ListTagsAttachedToContactRequest; import com.intercom.api.resources.contacts.requests.MergeContactsRequest; +import com.intercom.api.resources.contacts.requests.ShowContactByExternalIdRequest; import com.intercom.api.resources.contacts.requests.UnarchiveContactRequest; import com.intercom.api.resources.contacts.requests.UpdateContactRequest; import com.intercom.api.resources.contacts.types.Contact; +import com.intercom.api.resources.contacts.types.ContactsCreateResponse; +import com.intercom.api.resources.contacts.types.ContactsFindResponse; +import com.intercom.api.resources.contacts.types.ContactsMergeLeadInUserResponse; +import com.intercom.api.resources.contacts.types.ContactsUpdateResponse; +import com.intercom.api.resources.contacts.types.ShowContactByExternalIdResponse; import com.intercom.api.resources.subscriptiontypes.types.SubscriptionType; import com.intercom.api.types.ContactArchived; import com.intercom.api.types.ContactAttachedCompanies; +import com.intercom.api.types.ContactBlocked; import com.intercom.api.types.ContactDeleted; import com.intercom.api.types.ContactList; import com.intercom.api.types.ContactSegments; @@ -45,6 +53,7 @@ import com.intercom.api.types.SubscriptionTypeList; import com.intercom.api.types.TagList; import java.io.IOException; +import java.util.Collections; import java.util.List; import java.util.Optional; import okhttp3.Headers; @@ -109,7 +118,7 @@ public IntercomHttpResponse> listAttachedCompanies( .from(request) .page(newPageNumber) .build(); - List result = parsedResponse.getCompanies(); + List result = parsedResponse.getCompanies().orElse(Collections.emptyList()); return new IntercomHttpResponse<>( new SyncPagingIterable( true, result, () -> listAttachedCompanies(nextRequest, requestOptions) @@ -456,14 +465,14 @@ public IntercomHttpResponse listAttachedTags( /** * You can fetch the details of a single contact. */ - public IntercomHttpResponse find(FindContactRequest request) { + public IntercomHttpResponse find(FindContactRequest request) { return find(request, null); } /** * You can fetch the details of a single contact. */ - public IntercomHttpResponse find(FindContactRequest request, RequestOptions requestOptions) { + public IntercomHttpResponse find(FindContactRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("contacts") @@ -484,7 +493,8 @@ public IntercomHttpResponse find(FindContactRequest request, RequestOpt ResponseBody responseBody = response.body(); if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Contact.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ContactsFindResponse.class), + response); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { @@ -507,15 +517,24 @@ public IntercomHttpResponse find(FindContactRequest request, RequestOpt /** * 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 %}

*/ - public IntercomHttpResponse update(UpdateContactRequest request) { + public IntercomHttpResponse update(UpdateContactRequest request) { return update(request, null); } /** * 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 %}

*/ - public IntercomHttpResponse update(UpdateContactRequest request, RequestOptions requestOptions) { + public IntercomHttpResponse update( + UpdateContactRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("contacts") @@ -543,7 +562,8 @@ public IntercomHttpResponse update(UpdateContactRequest request, Reques ResponseBody responseBody = response.body(); if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Contact.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ContactsUpdateResponse.class), + response); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { @@ -619,14 +639,22 @@ public IntercomHttpResponse delete(DeleteContactRequest request, /** * You can merge a contact with a role of lead into a contact with a role of user. */ - public IntercomHttpResponse mergeLeadInUser(MergeContactsRequest request) { + public IntercomHttpResponse mergeLeadInUser() { + return mergeLeadInUser(MergeContactsRequest.builder().build()); + } + + /** + * You can merge a contact with a role of lead into a contact with a role of user. + */ + public IntercomHttpResponse mergeLeadInUser(MergeContactsRequest request) { return mergeLeadInUser(request, null); } /** * You can merge a contact with a role of lead into a contact with a role of user. */ - public IntercomHttpResponse mergeLeadInUser(MergeContactsRequest request, RequestOptions requestOptions) { + public IntercomHttpResponse mergeLeadInUser( + MergeContactsRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("contacts/merge") @@ -653,7 +681,9 @@ public IntercomHttpResponse mergeLeadInUser(MergeContactsRequest reques ResponseBody responseBody = response.body(); if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Contact.class), response); + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ContactsMergeLeadInUserResponse.class), + response); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { @@ -896,7 +926,7 @@ public IntercomHttpResponse> search( .from(request) .pagination(pagination) .build(); - List result = parsedResponse.getData(); + List result = parsedResponse.getData().orElse(Collections.emptyList()); return new IntercomHttpResponse<>( new SyncPagingIterable( startingAfter.isPresent(), result, () -> search(nextRequest, requestOptions) @@ -992,7 +1022,7 @@ public IntercomHttpResponse> list( .from(request) .startingAfter(startingAfter) .build(); - List result = parsedResponse.getData(); + List result = parsedResponse.getData().orElse(Collections.emptyList()); return new IntercomHttpResponse<>( new SyncPagingIterable( startingAfter.isPresent(), result, () -> list(nextRequest, requestOptions) @@ -1021,14 +1051,15 @@ public IntercomHttpResponse> list( /** * You can create a new contact (ie. user or lead). */ - public IntercomHttpResponse create(CreateContactRequest request) { + public IntercomHttpResponse create(CreateContactRequest request) { return create(request, null); } /** * You can create a new contact (ie. user or lead). */ - public IntercomHttpResponse create(CreateContactRequest request, RequestOptions requestOptions) { + public IntercomHttpResponse create( + CreateContactRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("contacts") @@ -1055,7 +1086,64 @@ public IntercomHttpResponse create(CreateContactRequest request, Reques ResponseBody responseBody = response.body(); if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Contact.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ContactsCreateResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can fetch the details of a single contact by external ID. Note that this endpoint only supports users and not leads. + */ + public IntercomHttpResponse showContactByExternalId( + ShowContactByExternalIdRequest request) { + return showContactByExternalId(request, null); + } + + /** + * You can fetch the details of a single contact by external ID. Note that this endpoint only supports users and not leads. + */ + public IntercomHttpResponse showContactByExternalId( + ShowContactByExternalIdRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts/find_by_external_id") + .addPathSegment(request.getExternalId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ShowContactByExternalIdResponse.class), + response); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { @@ -1166,4 +1254,50 @@ public IntercomHttpResponse unarchive( throw new IntercomException("Network error executing HTTP request", e); } } + + /** + * Block a single contact.<br>Note: conversations of the contact will also be archived during the process.<br>More details in FAQ How do I block Inbox spam? + */ + public IntercomHttpResponse blockContact(BlockContactRequest request) { + return blockContact(request, null); + } + + /** + * Block a single contact.<br>Note: conversations of the contact will also be archived during the process.<br>More details in FAQ How do I block Inbox spam? + */ + public IntercomHttpResponse blockContact( + BlockContactRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getContactId()) + .addPathSegments("block") + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("POST", RequestBody.create("", null)) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ContactBlocked.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } } diff --git a/src/main/java/com/intercom/api/resources/contacts/requests/ArchiveContactRequest.java b/src/main/java/com/intercom/api/resources/contacts/requests/ArchiveContactRequest.java index a1c5637..574b616 100644 --- a/src/main/java/com/intercom/api/resources/contacts/requests/ArchiveContactRequest.java +++ b/src/main/java/com/intercom/api/resources/contacts/requests/ArchiveContactRequest.java @@ -29,7 +29,7 @@ private ArchiveContactRequest(String contactId, Map additionalPr } /** - * @return id + * @return contact_id */ @JsonProperty("contact_id") public String getContactId() { @@ -67,7 +67,7 @@ public static ContactIdStage builder() { public interface ContactIdStage { /** - * id + * contact_id */ _FinalStage contactId(@NotNull String contactId); @@ -94,7 +94,7 @@ public Builder from(ArchiveContactRequest other) { } /** - * id

id

+ * contact_id

contact_id

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/contacts/requests/BlockContactRequest.java b/src/main/java/com/intercom/api/resources/contacts/requests/BlockContactRequest.java new file mode 100644 index 0000000..deb70ec --- /dev/null +++ b/src/main/java/com/intercom/api/resources/contacts/requests/BlockContactRequest.java @@ -0,0 +1,112 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.contacts.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = BlockContactRequest.Builder.class) +public final class BlockContactRequest { + private final String contactId; + + private final Map additionalProperties; + + private BlockContactRequest(String contactId, Map additionalProperties) { + this.contactId = contactId; + this.additionalProperties = additionalProperties; + } + + /** + * @return contact_id + */ + @JsonProperty("contact_id") + public String getContactId() { + return contactId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof BlockContactRequest && equalTo((BlockContactRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(BlockContactRequest other) { + return contactId.equals(other.contactId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.contactId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ContactIdStage builder() { + return new Builder(); + } + + public interface ContactIdStage { + /** + * contact_id + */ + _FinalStage contactId(@NotNull String contactId); + + Builder from(BlockContactRequest other); + } + + public interface _FinalStage { + BlockContactRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ContactIdStage, _FinalStage { + private String contactId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(BlockContactRequest other) { + contactId(other.getContactId()); + return this; + } + + /** + * contact_id

contact_id

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("contact_id") + public _FinalStage contactId(@NotNull String contactId) { + this.contactId = Objects.requireNonNull(contactId, "contactId must not be null"); + return this; + } + + @java.lang.Override + public BlockContactRequest build() { + return new BlockContactRequest(contactId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/contacts/requests/DeleteContactRequest.java b/src/main/java/com/intercom/api/resources/contacts/requests/DeleteContactRequest.java index 82c4d68..a30e816 100644 --- a/src/main/java/com/intercom/api/resources/contacts/requests/DeleteContactRequest.java +++ b/src/main/java/com/intercom/api/resources/contacts/requests/DeleteContactRequest.java @@ -29,7 +29,7 @@ private DeleteContactRequest(String contactId, Map additionalPro } /** - * @return id + * @return contact_id */ @JsonProperty("contact_id") public String getContactId() { @@ -67,7 +67,7 @@ public static ContactIdStage builder() { public interface ContactIdStage { /** - * id + * contact_id */ _FinalStage contactId(@NotNull String contactId); @@ -94,7 +94,7 @@ public Builder from(DeleteContactRequest other) { } /** - * id

id

+ * contact_id

contact_id

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/contacts/requests/FindContactRequest.java b/src/main/java/com/intercom/api/resources/contacts/requests/FindContactRequest.java index 28fdb9e..c6a5a20 100644 --- a/src/main/java/com/intercom/api/resources/contacts/requests/FindContactRequest.java +++ b/src/main/java/com/intercom/api/resources/contacts/requests/FindContactRequest.java @@ -29,7 +29,7 @@ private FindContactRequest(String contactId, Map additionalPrope } /** - * @return id + * @return contact_id */ @JsonProperty("contact_id") public String getContactId() { @@ -67,7 +67,7 @@ public static ContactIdStage builder() { public interface ContactIdStage { /** - * id + * contact_id */ _FinalStage contactId(@NotNull String contactId); @@ -94,7 +94,7 @@ public Builder from(FindContactRequest other) { } /** - * id

id

+ * contact_id

contact_id

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/contacts/requests/MergeContactsRequest.java b/src/main/java/com/intercom/api/resources/contacts/requests/MergeContactsRequest.java index 600f2ea..987743b 100644 --- a/src/main/java/com/intercom/api/resources/contacts/requests/MergeContactsRequest.java +++ b/src/main/java/com/intercom/api/resources/contacts/requests/MergeContactsRequest.java @@ -9,23 +9,25 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.intercom.api.core.ObjectMappers; import java.util.HashMap; import java.util.Map; import java.util.Objects; -import org.jetbrains.annotations.NotNull; +import java.util.Optional; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = MergeContactsRequest.Builder.class) public final class MergeContactsRequest { - private final String leadId; + private final Optional leadId; - private final String contactId; + private final Optional contactId; private final Map additionalProperties; - private MergeContactsRequest(String leadId, String contactId, Map additionalProperties) { + private MergeContactsRequest( + Optional leadId, Optional contactId, Map additionalProperties) { this.leadId = leadId; this.contactId = contactId; this.additionalProperties = additionalProperties; @@ -35,7 +37,7 @@ private MergeContactsRequest(String leadId, String contactId, Map getLeadId() { return leadId; } @@ -43,7 +45,7 @@ public String getLeadId() { * @return The unique identifier for the contact to merge into. Must be a user. */ @JsonProperty("into") - public String getContactId() { + public Optional getContactId() { return contactId; } @@ -72,42 +74,21 @@ public String toString() { return ObjectMappers.stringify(this); } - public static LeadIdStage builder() { + public static Builder builder() { return new Builder(); } - public interface LeadIdStage { - /** - * The unique identifier for the contact to merge away from. Must be a lead. - */ - ContactIdStage leadId(@NotNull String leadId); - - Builder from(MergeContactsRequest other); - } - - public interface ContactIdStage { - /** - * The unique identifier for the contact to merge into. Must be a user. - */ - _FinalStage contactId(@NotNull String contactId); - } - - public interface _FinalStage { - MergeContactsRequest build(); - } - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements LeadIdStage, ContactIdStage, _FinalStage { - private String leadId; + public static final class Builder { + private Optional leadId = Optional.empty(); - private String contactId; + private Optional contactId = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} - @java.lang.Override public Builder from(MergeContactsRequest other) { leadId(other.getLeadId()); contactId(other.getContactId()); @@ -115,28 +96,33 @@ public Builder from(MergeContactsRequest other) { } /** - * The unique identifier for the contact to merge away from. Must be a lead.

The unique identifier for the contact to merge away from. Must be a lead.

- * @return Reference to {@code this} so that method calls can be chained together. + *

The unique identifier for the contact to merge away from. Must be a lead.

*/ - @java.lang.Override - @JsonSetter("from") - public ContactIdStage leadId(@NotNull String leadId) { - this.leadId = Objects.requireNonNull(leadId, "leadId must not be null"); + @JsonSetter(value = "from", nulls = Nulls.SKIP) + public Builder leadId(Optional leadId) { + this.leadId = leadId; + return this; + } + + public Builder leadId(String leadId) { + this.leadId = Optional.ofNullable(leadId); return this; } /** - * The unique identifier for the contact to merge into. Must be a user.

The unique identifier for the contact to merge into. Must be a user.

- * @return Reference to {@code this} so that method calls can be chained together. + *

The unique identifier for the contact to merge into. Must be a user.

*/ - @java.lang.Override - @JsonSetter("into") - public _FinalStage contactId(@NotNull String contactId) { - this.contactId = Objects.requireNonNull(contactId, "contactId must not be null"); + @JsonSetter(value = "into", nulls = Nulls.SKIP) + public Builder contactId(Optional contactId) { + this.contactId = contactId; + return this; + } + + public Builder contactId(String contactId) { + this.contactId = Optional.ofNullable(contactId); return this; } - @java.lang.Override public MergeContactsRequest build() { return new MergeContactsRequest(leadId, contactId, additionalProperties); } diff --git a/src/main/java/com/intercom/api/resources/contacts/requests/ShowContactByExternalIdRequest.java b/src/main/java/com/intercom/api/resources/contacts/requests/ShowContactByExternalIdRequest.java new file mode 100644 index 0000000..1f15bd8 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/contacts/requests/ShowContactByExternalIdRequest.java @@ -0,0 +1,112 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.contacts.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ShowContactByExternalIdRequest.Builder.class) +public final class ShowContactByExternalIdRequest { + private final String externalId; + + private final Map additionalProperties; + + private ShowContactByExternalIdRequest(String externalId, Map additionalProperties) { + this.externalId = externalId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The external ID of the user that you want to retrieve + */ + @JsonProperty("external_id") + public String getExternalId() { + return externalId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ShowContactByExternalIdRequest && equalTo((ShowContactByExternalIdRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ShowContactByExternalIdRequest other) { + return externalId.equals(other.externalId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.externalId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ExternalIdStage builder() { + return new Builder(); + } + + public interface ExternalIdStage { + /** + * The external ID of the user that you want to retrieve + */ + _FinalStage externalId(@NotNull String externalId); + + Builder from(ShowContactByExternalIdRequest other); + } + + public interface _FinalStage { + ShowContactByExternalIdRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ExternalIdStage, _FinalStage { + private String externalId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ShowContactByExternalIdRequest other) { + externalId(other.getExternalId()); + return this; + } + + /** + * The external ID of the user that you want to retrieve

The external ID of the user that you want to retrieve

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("external_id") + public _FinalStage externalId(@NotNull String externalId) { + this.externalId = Objects.requireNonNull(externalId, "externalId must not be null"); + return this; + } + + @java.lang.Override + public ShowContactByExternalIdRequest build() { + return new ShowContactByExternalIdRequest(externalId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/contacts/requests/UnarchiveContactRequest.java b/src/main/java/com/intercom/api/resources/contacts/requests/UnarchiveContactRequest.java index b232367..59e6bd8 100644 --- a/src/main/java/com/intercom/api/resources/contacts/requests/UnarchiveContactRequest.java +++ b/src/main/java/com/intercom/api/resources/contacts/requests/UnarchiveContactRequest.java @@ -29,7 +29,7 @@ private UnarchiveContactRequest(String contactId, Map additional } /** - * @return id + * @return contact_id */ @JsonProperty("contact_id") public String getContactId() { @@ -67,7 +67,7 @@ public static ContactIdStage builder() { public interface ContactIdStage { /** - * id + * contact_id */ _FinalStage contactId(@NotNull String contactId); @@ -94,7 +94,7 @@ public Builder from(UnarchiveContactRequest other) { } /** - * id

id

+ * contact_id

contact_id

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/contacts/types/Contact.java b/src/main/java/com/intercom/api/resources/contacts/types/Contact.java index 3dba6ae..28332c8 100644 --- a/src/main/java/com/intercom/api/resources/contacts/types/Contact.java +++ b/src/main/java/com/intercom/api/resources/contacts/types/Contact.java @@ -21,20 +21,19 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; -import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = Contact.Builder.class) -public final class Contact { +public final class Contact implements IContact { private final Optional type; - private final String id; + private final Optional id; private final Optional externalId; - private final String workspaceId; + private final Optional workspaceId; - private final String role; + private final Optional role; private final Optional email; @@ -42,21 +41,19 @@ public final class Contact { private final Optional phone; - private final Optional formattedPhone; - private final Optional name; private final Optional ownerId; - private final boolean hasHardBounced; + private final Optional hasHardBounced; - private final boolean markedEmailAsSpam; + private final Optional markedEmailAsSpam; - private final boolean unsubscribedFromEmails; + private final Optional unsubscribedFromEmails; - private final int createdAt; + private final Optional createdAt; - private final int updatedAt; + private final Optional updatedAt; private final Optional signedUpAt; @@ -114,29 +111,28 @@ public final class Contact { private final Optional companies; - private final ContactLocation location; + private final Optional location; - private final ContactSocialProfiles socialProfiles; + private final Optional socialProfiles; private final Map additionalProperties; private Contact( Optional type, - String id, + Optional id, Optional externalId, - String workspaceId, - String role, + Optional workspaceId, + Optional role, Optional email, Optional emailDomain, Optional phone, - Optional formattedPhone, Optional name, Optional ownerId, - boolean hasHardBounced, - boolean markedEmailAsSpam, - boolean unsubscribedFromEmails, - int createdAt, - int updatedAt, + Optional hasHardBounced, + Optional markedEmailAsSpam, + Optional unsubscribedFromEmails, + Optional createdAt, + Optional updatedAt, Optional signedUpAt, Optional lastSeenAt, Optional lastRepliedAt, @@ -165,8 +161,8 @@ private Contact( Optional tags, Optional notes, Optional companies, - ContactLocation location, - ContactSocialProfiles socialProfiles, + Optional location, + Optional socialProfiles, Map additionalProperties) { this.type = type; this.id = id; @@ -176,7 +172,6 @@ private Contact( this.email = email; this.emailDomain = emailDomain; this.phone = phone; - this.formattedPhone = formattedPhone; this.name = name; this.ownerId = ownerId; this.hasHardBounced = hasHardBounced; @@ -229,7 +224,7 @@ public Optional getType() { * @return The unique identifier for the contact which is given by Intercom. */ @JsonProperty("id") - public String getId() { + public Optional getId() { return id; } @@ -245,7 +240,7 @@ public Optional getExternalId() { * @return The id of the workspace which the contact belongs to. */ @JsonProperty("workspace_id") - public String getWorkspaceId() { + public Optional getWorkspaceId() { return workspaceId; } @@ -253,7 +248,7 @@ public String getWorkspaceId() { * @return The role of the contact. */ @JsonProperty("role") - public String getRole() { + public Optional getRole() { return role; } @@ -281,14 +276,6 @@ public Optional getPhone() { return phone; } - /** - * @return The contacts phone number normalized to the E164 format - */ - @JsonProperty("formatted_phone") - public Optional getFormattedPhone() { - return formattedPhone; - } - /** * @return The contacts name. */ @@ -309,7 +296,7 @@ public Optional getOwnerId() { * @return Whether the contact has had an email sent to them hard bounce. */ @JsonProperty("has_hard_bounced") - public boolean getHasHardBounced() { + public Optional getHasHardBounced() { return hasHardBounced; } @@ -317,7 +304,7 @@ public boolean getHasHardBounced() { * @return Whether the contact has marked an email sent to them as spam. */ @JsonProperty("marked_email_as_spam") - public boolean getMarkedEmailAsSpam() { + public Optional getMarkedEmailAsSpam() { return markedEmailAsSpam; } @@ -325,7 +312,7 @@ public boolean getMarkedEmailAsSpam() { * @return Whether the contact is unsubscribed from emails. */ @JsonProperty("unsubscribed_from_emails") - public boolean getUnsubscribedFromEmails() { + public Optional getUnsubscribedFromEmails() { return unsubscribedFromEmails; } @@ -333,7 +320,7 @@ public boolean getUnsubscribedFromEmails() { * @return (UNIX timestamp) The time when the contact was created. */ @JsonProperty("created_at") - public int getCreatedAt() { + public Optional getCreatedAt() { return createdAt; } @@ -341,7 +328,7 @@ public int getCreatedAt() { * @return (UNIX timestamp) The time when the contact was last updated. */ @JsonProperty("updated_at") - public int getUpdatedAt() { + public Optional getUpdatedAt() { return updatedAt; } @@ -561,12 +548,12 @@ public Optional getCompanies() { } @JsonProperty("location") - public ContactLocation getLocation() { + public Optional getLocation() { return location; } @JsonProperty("social_profiles") - public ContactSocialProfiles getSocialProfiles() { + public Optional getSocialProfiles() { return socialProfiles; } @@ -590,14 +577,13 @@ private boolean equalTo(Contact other) { && email.equals(other.email) && emailDomain.equals(other.emailDomain) && phone.equals(other.phone) - && formattedPhone.equals(other.formattedPhone) && name.equals(other.name) && ownerId.equals(other.ownerId) - && hasHardBounced == other.hasHardBounced - && markedEmailAsSpam == other.markedEmailAsSpam - && unsubscribedFromEmails == other.unsubscribedFromEmails - && createdAt == other.createdAt - && updatedAt == other.updatedAt + && hasHardBounced.equals(other.hasHardBounced) + && markedEmailAsSpam.equals(other.markedEmailAsSpam) + && unsubscribedFromEmails.equals(other.unsubscribedFromEmails) + && createdAt.equals(other.createdAt) + && updatedAt.equals(other.updatedAt) && signedUpAt.equals(other.signedUpAt) && lastSeenAt.equals(other.lastSeenAt) && lastRepliedAt.equals(other.lastRepliedAt) @@ -641,7 +627,6 @@ public int hashCode() { this.email, this.emailDomain, this.phone, - this.formattedPhone, this.name, this.ownerId, this.hasHardBounced, @@ -686,1286 +671,771 @@ public String toString() { return ObjectMappers.stringify(this); } - public static IdStage builder() { + public static Builder builder() { return new Builder(); } - public interface IdStage { - /** - * The unique identifier for the contact which is given by Intercom. - */ - WorkspaceIdStage id(@NotNull String id); + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); - Builder from(Contact other); - } + private Optional id = Optional.empty(); - public interface WorkspaceIdStage { - /** - * The id of the workspace which the contact belongs to. - */ - RoleStage workspaceId(@NotNull String workspaceId); - } + private Optional externalId = Optional.empty(); - public interface RoleStage { - /** - * The role of the contact. - */ - HasHardBouncedStage role(@NotNull String role); - } + private Optional workspaceId = Optional.empty(); - public interface HasHardBouncedStage { - /** - * Whether the contact has had an email sent to them hard bounce. - */ - MarkedEmailAsSpamStage hasHardBounced(boolean hasHardBounced); - } + private Optional role = Optional.empty(); - public interface MarkedEmailAsSpamStage { - /** - * Whether the contact has marked an email sent to them as spam. - */ - UnsubscribedFromEmailsStage markedEmailAsSpam(boolean markedEmailAsSpam); - } + private Optional email = Optional.empty(); - public interface UnsubscribedFromEmailsStage { - /** - * Whether the contact is unsubscribed from emails. - */ - CreatedAtStage unsubscribedFromEmails(boolean unsubscribedFromEmails); - } + private Optional emailDomain = Optional.empty(); - public interface CreatedAtStage { - /** - * (UNIX timestamp) The time when the contact was created. - */ - UpdatedAtStage createdAt(int createdAt); - } + private Optional phone = Optional.empty(); - public interface UpdatedAtStage { - /** - * (UNIX timestamp) The time when the contact was last updated. - */ - LocationStage updatedAt(int updatedAt); - } + private Optional name = Optional.empty(); - public interface LocationStage { - SocialProfilesStage location(@NotNull ContactLocation location); - } + private Optional ownerId = Optional.empty(); - public interface SocialProfilesStage { - _FinalStage socialProfiles(@NotNull ContactSocialProfiles socialProfiles); - } + private Optional hasHardBounced = Optional.empty(); - public interface _FinalStage { - Contact build(); + private Optional markedEmailAsSpam = Optional.empty(); - /** - *

The type of object.

- */ - _FinalStage type(Optional type); + private Optional unsubscribedFromEmails = Optional.empty(); - _FinalStage type(String type); + private Optional createdAt = Optional.empty(); - /** - *

The unique identifier for the contact which is provided by the Client.

- */ - _FinalStage externalId(Optional externalId); + private Optional updatedAt = Optional.empty(); - _FinalStage externalId(String externalId); + private Optional signedUpAt = Optional.empty(); - /** - *

The contact's email.

- */ - _FinalStage email(Optional email); + private Optional lastSeenAt = Optional.empty(); - _FinalStage email(String email); + private Optional lastRepliedAt = Optional.empty(); - /** - *

The contact's email domain.

- */ - _FinalStage emailDomain(Optional emailDomain); + private Optional lastContactedAt = Optional.empty(); - _FinalStage emailDomain(String emailDomain); + private Optional lastEmailOpenedAt = Optional.empty(); - /** - *

The contacts phone.

- */ - _FinalStage phone(Optional phone); + private Optional lastEmailClickedAt = Optional.empty(); - _FinalStage phone(String phone); + private Optional languageOverride = Optional.empty(); - /** - *

The contacts phone number normalized to the E164 format

- */ - _FinalStage formattedPhone(Optional formattedPhone); + private Optional browser = Optional.empty(); - _FinalStage formattedPhone(String formattedPhone); + private Optional browserVersion = Optional.empty(); - /** - *

The contacts name.

- */ - _FinalStage name(Optional name); + private Optional browserLanguage = Optional.empty(); - _FinalStage name(String name); + private Optional os = Optional.empty(); - /** - *

The id of an admin that has been assigned account ownership of the contact.

- */ - _FinalStage ownerId(Optional ownerId); + private Optional androidAppName = Optional.empty(); - _FinalStage ownerId(Integer ownerId); + private Optional androidAppVersion = Optional.empty(); - /** - *

(UNIX timestamp) The time specified for when a contact signed up.

- */ - _FinalStage signedUpAt(Optional signedUpAt); + private Optional androidDevice = Optional.empty(); - _FinalStage signedUpAt(Integer signedUpAt); + private Optional androidOsVersion = Optional.empty(); - /** - *

(UNIX timestamp) The time when the contact was last seen (either where the Intercom Messenger was installed or when specified manually).

- */ - _FinalStage lastSeenAt(Optional lastSeenAt); + private Optional androidSdkVersion = Optional.empty(); - _FinalStage lastSeenAt(Integer lastSeenAt); + private Optional androidLastSeenAt = Optional.empty(); - /** - *

(UNIX timestamp) The time when the contact last messaged in.

- */ - _FinalStage lastRepliedAt(Optional lastRepliedAt); + private Optional iosAppName = Optional.empty(); - _FinalStage lastRepliedAt(Integer lastRepliedAt); + private Optional iosAppVersion = Optional.empty(); - /** - *

(UNIX timestamp) The time when the contact was last messaged.

- */ - _FinalStage lastContactedAt(Optional lastContactedAt); + private Optional iosDevice = Optional.empty(); - _FinalStage lastContactedAt(Integer lastContactedAt); + private Optional iosOsVersion = Optional.empty(); - /** - *

(UNIX timestamp) The time when the contact last opened an email.

- */ - _FinalStage lastEmailOpenedAt(Optional lastEmailOpenedAt); + private Optional iosSdkVersion = Optional.empty(); - _FinalStage lastEmailOpenedAt(Integer lastEmailOpenedAt); + private Optional iosLastSeenAt = Optional.empty(); - /** - *

(UNIX timestamp) The time when the contact last clicked a link in an email.

- */ - _FinalStage lastEmailClickedAt(Optional lastEmailClickedAt); + private Optional> customAttributes = Optional.empty(); - _FinalStage lastEmailClickedAt(Integer lastEmailClickedAt); + private Optional avatar = Optional.empty(); - /** - *

A preferred language setting for the contact, used by the Intercom Messenger even if their browser settings change.

- */ - _FinalStage languageOverride(Optional languageOverride); + private Optional tags = Optional.empty(); - _FinalStage languageOverride(String languageOverride); + private Optional notes = Optional.empty(); - /** - *

The name of the browser which the contact is using.

- */ - _FinalStage browser(Optional browser); + private Optional companies = Optional.empty(); - _FinalStage browser(String browser); + private Optional location = Optional.empty(); - /** - *

The version of the browser which the contact is using.

- */ - _FinalStage browserVersion(Optional browserVersion); + private Optional socialProfiles = Optional.empty(); - _FinalStage browserVersion(String browserVersion); + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); - /** - *

The language set by the browser which the contact is using.

- */ - _FinalStage browserLanguage(Optional browserLanguage); + private Builder() {} - _FinalStage browserLanguage(String browserLanguage); + public Builder from(Contact other) { + type(other.getType()); + id(other.getId()); + externalId(other.getExternalId()); + workspaceId(other.getWorkspaceId()); + role(other.getRole()); + email(other.getEmail()); + emailDomain(other.getEmailDomain()); + phone(other.getPhone()); + name(other.getName()); + ownerId(other.getOwnerId()); + hasHardBounced(other.getHasHardBounced()); + markedEmailAsSpam(other.getMarkedEmailAsSpam()); + unsubscribedFromEmails(other.getUnsubscribedFromEmails()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + signedUpAt(other.getSignedUpAt()); + lastSeenAt(other.getLastSeenAt()); + lastRepliedAt(other.getLastRepliedAt()); + lastContactedAt(other.getLastContactedAt()); + lastEmailOpenedAt(other.getLastEmailOpenedAt()); + lastEmailClickedAt(other.getLastEmailClickedAt()); + languageOverride(other.getLanguageOverride()); + browser(other.getBrowser()); + browserVersion(other.getBrowserVersion()); + browserLanguage(other.getBrowserLanguage()); + os(other.getOs()); + androidAppName(other.getAndroidAppName()); + androidAppVersion(other.getAndroidAppVersion()); + androidDevice(other.getAndroidDevice()); + androidOsVersion(other.getAndroidOsVersion()); + androidSdkVersion(other.getAndroidSdkVersion()); + androidLastSeenAt(other.getAndroidLastSeenAt()); + iosAppName(other.getIosAppName()); + iosAppVersion(other.getIosAppVersion()); + iosDevice(other.getIosDevice()); + iosOsVersion(other.getIosOsVersion()); + iosSdkVersion(other.getIosSdkVersion()); + iosLastSeenAt(other.getIosLastSeenAt()); + customAttributes(other.getCustomAttributes()); + avatar(other.getAvatar()); + tags(other.getTags()); + notes(other.getNotes()); + companies(other.getCompanies()); + location(other.getLocation()); + socialProfiles(other.getSocialProfiles()); + return this; + } /** - *

The operating system which the contact is using.

+ *

The type of object.

*/ - _FinalStage os(Optional os); + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } - _FinalStage os(String os); + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } /** - *

The name of the Android app which the contact is using.

+ *

The unique identifier for the contact which is given by Intercom.

*/ - _FinalStage androidAppName(Optional androidAppName); + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } - _FinalStage androidAppName(String androidAppName); + public Builder id(String id) { + this.id = Optional.ofNullable(id); + return this; + } /** - *

The version of the Android app which the contact is using.

+ *

The unique identifier for the contact which is provided by the Client.

*/ - _FinalStage androidAppVersion(Optional androidAppVersion); + @JsonSetter(value = "external_id", nulls = Nulls.SKIP) + public Builder externalId(Optional externalId) { + this.externalId = externalId; + return this; + } - _FinalStage androidAppVersion(String androidAppVersion); + public Builder externalId(String externalId) { + this.externalId = Optional.ofNullable(externalId); + return this; + } /** - *

The Android device which the contact is using.

+ *

The id of the workspace which the contact belongs to.

*/ - _FinalStage androidDevice(Optional androidDevice); + @JsonSetter(value = "workspace_id", nulls = Nulls.SKIP) + public Builder workspaceId(Optional workspaceId) { + this.workspaceId = workspaceId; + return this; + } - _FinalStage androidDevice(String androidDevice); + public Builder workspaceId(String workspaceId) { + this.workspaceId = Optional.ofNullable(workspaceId); + return this; + } /** - *

The version of the Android OS which the contact is using.

+ *

The role of the contact.

*/ - _FinalStage androidOsVersion(Optional androidOsVersion); + @JsonSetter(value = "role", nulls = Nulls.SKIP) + public Builder role(Optional role) { + this.role = role; + return this; + } - _FinalStage androidOsVersion(String androidOsVersion); + public Builder role(String role) { + this.role = Optional.ofNullable(role); + return this; + } /** - *

The version of the Android SDK which the contact is using.

+ *

The contact's email.

*/ - _FinalStage androidSdkVersion(Optional androidSdkVersion); + @JsonSetter(value = "email", nulls = Nulls.SKIP) + public Builder email(Optional email) { + this.email = email; + return this; + } - _FinalStage androidSdkVersion(String androidSdkVersion); + public Builder email(String email) { + this.email = Optional.ofNullable(email); + return this; + } /** - *

(UNIX timestamp) The time when the contact was last seen on an Android device.

+ *

The contact's email domain.

*/ - _FinalStage androidLastSeenAt(Optional androidLastSeenAt); + @JsonSetter(value = "email_domain", nulls = Nulls.SKIP) + public Builder emailDomain(Optional emailDomain) { + this.emailDomain = emailDomain; + return this; + } - _FinalStage androidLastSeenAt(Integer androidLastSeenAt); + public Builder emailDomain(String emailDomain) { + this.emailDomain = Optional.ofNullable(emailDomain); + return this; + } /** - *

The name of the iOS app which the contact is using.

+ *

The contacts phone.

*/ - _FinalStage iosAppName(Optional iosAppName); + @JsonSetter(value = "phone", nulls = Nulls.SKIP) + public Builder phone(Optional phone) { + this.phone = phone; + return this; + } - _FinalStage iosAppName(String iosAppName); + public Builder phone(String phone) { + this.phone = Optional.ofNullable(phone); + return this; + } /** - *

The version of the iOS app which the contact is using.

+ *

The contacts name.

*/ - _FinalStage iosAppVersion(Optional iosAppVersion); + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public Builder name(Optional name) { + this.name = name; + return this; + } - _FinalStage iosAppVersion(String iosAppVersion); + public Builder name(String name) { + this.name = Optional.ofNullable(name); + return this; + } /** - *

The iOS device which the contact is using.

+ *

The id of an admin that has been assigned account ownership of the contact.

*/ - _FinalStage iosDevice(Optional iosDevice); + @JsonSetter(value = "owner_id", nulls = Nulls.SKIP) + public Builder ownerId(Optional ownerId) { + this.ownerId = ownerId; + return this; + } - _FinalStage iosDevice(String iosDevice); + public Builder ownerId(Integer ownerId) { + this.ownerId = Optional.ofNullable(ownerId); + return this; + } /** - *

The version of iOS which the contact is using.

+ *

Whether the contact has had an email sent to them hard bounce.

*/ - _FinalStage iosOsVersion(Optional iosOsVersion); + @JsonSetter(value = "has_hard_bounced", nulls = Nulls.SKIP) + public Builder hasHardBounced(Optional hasHardBounced) { + this.hasHardBounced = hasHardBounced; + return this; + } - _FinalStage iosOsVersion(String iosOsVersion); + public Builder hasHardBounced(Boolean hasHardBounced) { + this.hasHardBounced = Optional.ofNullable(hasHardBounced); + return this; + } /** - *

The version of the iOS SDK which the contact is using.

+ *

Whether the contact has marked an email sent to them as spam.

*/ - _FinalStage iosSdkVersion(Optional iosSdkVersion); - - _FinalStage iosSdkVersion(String iosSdkVersion); - - /** - *

(UNIX timestamp) The last time the contact used the iOS app.

- */ - _FinalStage iosLastSeenAt(Optional iosLastSeenAt); - - _FinalStage iosLastSeenAt(Integer iosLastSeenAt); - - /** - *

The custom attributes which are set for the contact.

- */ - _FinalStage customAttributes(Optional> customAttributes); - - _FinalStage customAttributes(Map customAttributes); - - /** - *

An image URL containing the avatar of a contact.

- */ - _FinalStage avatar(Optional avatar); - - _FinalStage avatar(String avatar); - - _FinalStage tags(Optional tags); - - _FinalStage tags(ContactTags tags); - - _FinalStage notes(Optional notes); - - _FinalStage notes(ContactNotes notes); - - _FinalStage companies(Optional companies); - - _FinalStage companies(ContactCompanies companies); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder - implements IdStage, - WorkspaceIdStage, - RoleStage, - HasHardBouncedStage, - MarkedEmailAsSpamStage, - UnsubscribedFromEmailsStage, - CreatedAtStage, - UpdatedAtStage, - LocationStage, - SocialProfilesStage, - _FinalStage { - private String id; - - private String workspaceId; - - private String role; - - private boolean hasHardBounced; - - private boolean markedEmailAsSpam; - - private boolean unsubscribedFromEmails; - - private int createdAt; - - private int updatedAt; - - private ContactLocation location; - - private ContactSocialProfiles socialProfiles; - - private Optional companies = Optional.empty(); - - private Optional notes = Optional.empty(); - - private Optional tags = Optional.empty(); - - private Optional avatar = Optional.empty(); - - private Optional> customAttributes = Optional.empty(); - - private Optional iosLastSeenAt = Optional.empty(); - - private Optional iosSdkVersion = Optional.empty(); - - private Optional iosOsVersion = Optional.empty(); - - private Optional iosDevice = Optional.empty(); - - private Optional iosAppVersion = Optional.empty(); - - private Optional iosAppName = Optional.empty(); - - private Optional androidLastSeenAt = Optional.empty(); - - private Optional androidSdkVersion = Optional.empty(); - - private Optional androidOsVersion = Optional.empty(); - - private Optional androidDevice = Optional.empty(); - - private Optional androidAppVersion = Optional.empty(); - - private Optional androidAppName = Optional.empty(); - - private Optional os = Optional.empty(); - - private Optional browserLanguage = Optional.empty(); - - private Optional browserVersion = Optional.empty(); - - private Optional browser = Optional.empty(); - - private Optional languageOverride = Optional.empty(); - - private Optional lastEmailClickedAt = Optional.empty(); - - private Optional lastEmailOpenedAt = Optional.empty(); - - private Optional lastContactedAt = Optional.empty(); - - private Optional lastRepliedAt = Optional.empty(); - - private Optional lastSeenAt = Optional.empty(); - - private Optional signedUpAt = Optional.empty(); - - private Optional ownerId = Optional.empty(); - - private Optional name = Optional.empty(); - - private Optional formattedPhone = Optional.empty(); - - private Optional phone = Optional.empty(); - - private Optional emailDomain = Optional.empty(); - - private Optional email = Optional.empty(); - - private Optional externalId = Optional.empty(); - - private Optional type = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(Contact other) { - type(other.getType()); - id(other.getId()); - externalId(other.getExternalId()); - workspaceId(other.getWorkspaceId()); - role(other.getRole()); - email(other.getEmail()); - emailDomain(other.getEmailDomain()); - phone(other.getPhone()); - formattedPhone(other.getFormattedPhone()); - name(other.getName()); - ownerId(other.getOwnerId()); - hasHardBounced(other.getHasHardBounced()); - markedEmailAsSpam(other.getMarkedEmailAsSpam()); - unsubscribedFromEmails(other.getUnsubscribedFromEmails()); - createdAt(other.getCreatedAt()); - updatedAt(other.getUpdatedAt()); - signedUpAt(other.getSignedUpAt()); - lastSeenAt(other.getLastSeenAt()); - lastRepliedAt(other.getLastRepliedAt()); - lastContactedAt(other.getLastContactedAt()); - lastEmailOpenedAt(other.getLastEmailOpenedAt()); - lastEmailClickedAt(other.getLastEmailClickedAt()); - languageOverride(other.getLanguageOverride()); - browser(other.getBrowser()); - browserVersion(other.getBrowserVersion()); - browserLanguage(other.getBrowserLanguage()); - os(other.getOs()); - androidAppName(other.getAndroidAppName()); - androidAppVersion(other.getAndroidAppVersion()); - androidDevice(other.getAndroidDevice()); - androidOsVersion(other.getAndroidOsVersion()); - androidSdkVersion(other.getAndroidSdkVersion()); - androidLastSeenAt(other.getAndroidLastSeenAt()); - iosAppName(other.getIosAppName()); - iosAppVersion(other.getIosAppVersion()); - iosDevice(other.getIosDevice()); - iosOsVersion(other.getIosOsVersion()); - iosSdkVersion(other.getIosSdkVersion()); - iosLastSeenAt(other.getIosLastSeenAt()); - customAttributes(other.getCustomAttributes()); - avatar(other.getAvatar()); - tags(other.getTags()); - notes(other.getNotes()); - companies(other.getCompanies()); - location(other.getLocation()); - socialProfiles(other.getSocialProfiles()); - return this; - } - - /** - * The unique identifier for the contact which is given by Intercom.

The unique identifier for the contact which is given by Intercom.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("id") - public WorkspaceIdStage id(@NotNull String id) { - this.id = Objects.requireNonNull(id, "id must not be null"); - return this; - } - - /** - * The id of the workspace which the contact belongs to.

The id of the workspace which the contact belongs to.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("workspace_id") - public RoleStage workspaceId(@NotNull String workspaceId) { - this.workspaceId = Objects.requireNonNull(workspaceId, "workspaceId must not be null"); - return this; - } - - /** - * The role of the contact.

The role of the contact.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("role") - public HasHardBouncedStage role(@NotNull String role) { - this.role = Objects.requireNonNull(role, "role must not be null"); - return this; - } - - /** - * Whether the contact has had an email sent to them hard bounce.

Whether the contact has had an email sent to them hard bounce.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("has_hard_bounced") - public MarkedEmailAsSpamStage hasHardBounced(boolean hasHardBounced) { - this.hasHardBounced = hasHardBounced; - return this; - } - - /** - * Whether the contact has marked an email sent to them as spam.

Whether the contact has marked an email sent to them as spam.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("marked_email_as_spam") - public UnsubscribedFromEmailsStage markedEmailAsSpam(boolean markedEmailAsSpam) { + @JsonSetter(value = "marked_email_as_spam", nulls = Nulls.SKIP) + public Builder markedEmailAsSpam(Optional markedEmailAsSpam) { this.markedEmailAsSpam = markedEmailAsSpam; return this; } - /** - * Whether the contact is unsubscribed from emails.

Whether the contact is unsubscribed from emails.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("unsubscribed_from_emails") - public CreatedAtStage unsubscribedFromEmails(boolean unsubscribedFromEmails) { - this.unsubscribedFromEmails = unsubscribedFromEmails; - return this; - } - - /** - * (UNIX timestamp) The time when the contact was created.

(UNIX timestamp) The time when the contact was created.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("created_at") - public UpdatedAtStage createdAt(int createdAt) { - this.createdAt = createdAt; - return this; - } - - /** - * (UNIX timestamp) The time when the contact was last updated.

(UNIX timestamp) The time when the contact was last updated.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("updated_at") - public LocationStage updatedAt(int updatedAt) { - this.updatedAt = updatedAt; - return this; - } - - @java.lang.Override - @JsonSetter("location") - public SocialProfilesStage location(@NotNull ContactLocation location) { - this.location = Objects.requireNonNull(location, "location must not be null"); - return this; - } - - @java.lang.Override - @JsonSetter("social_profiles") - public _FinalStage socialProfiles(@NotNull ContactSocialProfiles socialProfiles) { - this.socialProfiles = Objects.requireNonNull(socialProfiles, "socialProfiles must not be null"); - return this; - } - - @java.lang.Override - public _FinalStage companies(ContactCompanies companies) { - this.companies = Optional.ofNullable(companies); - return this; - } - - @java.lang.Override - @JsonSetter(value = "companies", nulls = Nulls.SKIP) - public _FinalStage companies(Optional companies) { - this.companies = companies; - return this; - } - - @java.lang.Override - public _FinalStage notes(ContactNotes notes) { - this.notes = Optional.ofNullable(notes); - return this; - } - - @java.lang.Override - @JsonSetter(value = "notes", nulls = Nulls.SKIP) - public _FinalStage notes(Optional notes) { - this.notes = notes; - return this; - } - - @java.lang.Override - public _FinalStage tags(ContactTags tags) { - this.tags = Optional.ofNullable(tags); - return this; - } - - @java.lang.Override - @JsonSetter(value = "tags", nulls = Nulls.SKIP) - public _FinalStage tags(Optional tags) { - this.tags = tags; + public Builder markedEmailAsSpam(Boolean markedEmailAsSpam) { + this.markedEmailAsSpam = Optional.ofNullable(markedEmailAsSpam); return this; } /** - *

An image URL containing the avatar of a contact.

- * @return Reference to {@code this} so that method calls can be chained together. + *

Whether the contact is unsubscribed from emails.

*/ - @java.lang.Override - public _FinalStage avatar(String avatar) { - this.avatar = Optional.ofNullable(avatar); + @JsonSetter(value = "unsubscribed_from_emails", nulls = Nulls.SKIP) + public Builder unsubscribedFromEmails(Optional unsubscribedFromEmails) { + this.unsubscribedFromEmails = unsubscribedFromEmails; return this; } - /** - *

An image URL containing the avatar of a contact.

- */ - @java.lang.Override - @JsonSetter(value = "avatar", nulls = Nulls.SKIP) - public _FinalStage avatar(Optional avatar) { - this.avatar = avatar; + public Builder unsubscribedFromEmails(Boolean unsubscribedFromEmails) { + this.unsubscribedFromEmails = Optional.ofNullable(unsubscribedFromEmails); return this; } /** - *

The custom attributes which are set for the contact.

- * @return Reference to {@code this} so that method calls can be chained together. + *

(UNIX timestamp) The time when the contact was created.

*/ - @java.lang.Override - public _FinalStage customAttributes(Map customAttributes) { - this.customAttributes = Optional.ofNullable(customAttributes); - return this; - } - - /** - *

The custom attributes which are set for the contact.

- */ - @java.lang.Override - @JsonSetter(value = "custom_attributes", nulls = Nulls.SKIP) - public _FinalStage customAttributes(Optional> customAttributes) { - this.customAttributes = customAttributes; + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public Builder createdAt(Optional createdAt) { + this.createdAt = createdAt; return this; } - /** - *

(UNIX timestamp) The last time the contact used the iOS app.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage iosLastSeenAt(Integer iosLastSeenAt) { - this.iosLastSeenAt = Optional.ofNullable(iosLastSeenAt); + public Builder createdAt(Integer createdAt) { + this.createdAt = Optional.ofNullable(createdAt); return this; } /** - *

(UNIX timestamp) The last time the contact used the iOS app.

+ *

(UNIX timestamp) The time when the contact was last updated.

*/ - @java.lang.Override - @JsonSetter(value = "ios_last_seen_at", nulls = Nulls.SKIP) - public _FinalStage iosLastSeenAt(Optional iosLastSeenAt) { - this.iosLastSeenAt = iosLastSeenAt; + @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) + public Builder updatedAt(Optional updatedAt) { + this.updatedAt = updatedAt; return this; } - /** - *

The version of the iOS SDK which the contact is using.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage iosSdkVersion(String iosSdkVersion) { - this.iosSdkVersion = Optional.ofNullable(iosSdkVersion); + public Builder updatedAt(Integer updatedAt) { + this.updatedAt = Optional.ofNullable(updatedAt); return this; } /** - *

The version of the iOS SDK which the contact is using.

+ *

(UNIX timestamp) The time specified for when a contact signed up.

*/ - @java.lang.Override - @JsonSetter(value = "ios_sdk_version", nulls = Nulls.SKIP) - public _FinalStage iosSdkVersion(Optional iosSdkVersion) { - this.iosSdkVersion = iosSdkVersion; + @JsonSetter(value = "signed_up_at", nulls = Nulls.SKIP) + public Builder signedUpAt(Optional signedUpAt) { + this.signedUpAt = signedUpAt; return this; } - /** - *

The version of iOS which the contact is using.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage iosOsVersion(String iosOsVersion) { - this.iosOsVersion = Optional.ofNullable(iosOsVersion); + public Builder signedUpAt(Integer signedUpAt) { + this.signedUpAt = Optional.ofNullable(signedUpAt); return this; } /** - *

The version of iOS which the contact is using.

+ *

(UNIX timestamp) The time when the contact was last seen (either where the Intercom Messenger was installed or when specified manually).

*/ - @java.lang.Override - @JsonSetter(value = "ios_os_version", nulls = Nulls.SKIP) - public _FinalStage iosOsVersion(Optional iosOsVersion) { - this.iosOsVersion = iosOsVersion; + @JsonSetter(value = "last_seen_at", nulls = Nulls.SKIP) + public Builder lastSeenAt(Optional lastSeenAt) { + this.lastSeenAt = lastSeenAt; return this; } - /** - *

The iOS device which the contact is using.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage iosDevice(String iosDevice) { - this.iosDevice = Optional.ofNullable(iosDevice); + public Builder lastSeenAt(Integer lastSeenAt) { + this.lastSeenAt = Optional.ofNullable(lastSeenAt); return this; } /** - *

The iOS device which the contact is using.

+ *

(UNIX timestamp) The time when the contact last messaged in.

*/ - @java.lang.Override - @JsonSetter(value = "ios_device", nulls = Nulls.SKIP) - public _FinalStage iosDevice(Optional iosDevice) { - this.iosDevice = iosDevice; + @JsonSetter(value = "last_replied_at", nulls = Nulls.SKIP) + public Builder lastRepliedAt(Optional lastRepliedAt) { + this.lastRepliedAt = lastRepliedAt; return this; } - /** - *

The version of the iOS app which the contact is using.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage iosAppVersion(String iosAppVersion) { - this.iosAppVersion = Optional.ofNullable(iosAppVersion); + public Builder lastRepliedAt(Integer lastRepliedAt) { + this.lastRepliedAt = Optional.ofNullable(lastRepliedAt); return this; } /** - *

The version of the iOS app which the contact is using.

+ *

(UNIX timestamp) The time when the contact was last messaged.

*/ - @java.lang.Override - @JsonSetter(value = "ios_app_version", nulls = Nulls.SKIP) - public _FinalStage iosAppVersion(Optional iosAppVersion) { - this.iosAppVersion = iosAppVersion; + @JsonSetter(value = "last_contacted_at", nulls = Nulls.SKIP) + public Builder lastContactedAt(Optional lastContactedAt) { + this.lastContactedAt = lastContactedAt; return this; } - /** - *

The name of the iOS app which the contact is using.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage iosAppName(String iosAppName) { - this.iosAppName = Optional.ofNullable(iosAppName); + public Builder lastContactedAt(Integer lastContactedAt) { + this.lastContactedAt = Optional.ofNullable(lastContactedAt); return this; } /** - *

The name of the iOS app which the contact is using.

+ *

(UNIX timestamp) The time when the contact last opened an email.

*/ - @java.lang.Override - @JsonSetter(value = "ios_app_name", nulls = Nulls.SKIP) - public _FinalStage iosAppName(Optional iosAppName) { - this.iosAppName = iosAppName; + @JsonSetter(value = "last_email_opened_at", nulls = Nulls.SKIP) + public Builder lastEmailOpenedAt(Optional lastEmailOpenedAt) { + this.lastEmailOpenedAt = lastEmailOpenedAt; return this; } - /** - *

(UNIX timestamp) The time when the contact was last seen on an Android device.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage androidLastSeenAt(Integer androidLastSeenAt) { - this.androidLastSeenAt = Optional.ofNullable(androidLastSeenAt); + public Builder lastEmailOpenedAt(Integer lastEmailOpenedAt) { + this.lastEmailOpenedAt = Optional.ofNullable(lastEmailOpenedAt); return this; } /** - *

(UNIX timestamp) The time when the contact was last seen on an Android device.

+ *

(UNIX timestamp) The time when the contact last clicked a link in an email.

*/ - @java.lang.Override - @JsonSetter(value = "android_last_seen_at", nulls = Nulls.SKIP) - public _FinalStage androidLastSeenAt(Optional androidLastSeenAt) { - this.androidLastSeenAt = androidLastSeenAt; + @JsonSetter(value = "last_email_clicked_at", nulls = Nulls.SKIP) + public Builder lastEmailClickedAt(Optional lastEmailClickedAt) { + this.lastEmailClickedAt = lastEmailClickedAt; return this; } - /** - *

The version of the Android SDK which the contact is using.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage androidSdkVersion(String androidSdkVersion) { - this.androidSdkVersion = Optional.ofNullable(androidSdkVersion); + public Builder lastEmailClickedAt(Integer lastEmailClickedAt) { + this.lastEmailClickedAt = Optional.ofNullable(lastEmailClickedAt); return this; } /** - *

The version of the Android SDK which the contact is using.

+ *

A preferred language setting for the contact, used by the Intercom Messenger even if their browser settings change.

*/ - @java.lang.Override - @JsonSetter(value = "android_sdk_version", nulls = Nulls.SKIP) - public _FinalStage androidSdkVersion(Optional androidSdkVersion) { - this.androidSdkVersion = androidSdkVersion; + @JsonSetter(value = "language_override", nulls = Nulls.SKIP) + public Builder languageOverride(Optional languageOverride) { + this.languageOverride = languageOverride; return this; } - /** - *

The version of the Android OS which the contact is using.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage androidOsVersion(String androidOsVersion) { - this.androidOsVersion = Optional.ofNullable(androidOsVersion); + public Builder languageOverride(String languageOverride) { + this.languageOverride = Optional.ofNullable(languageOverride); return this; } /** - *

The version of the Android OS which the contact is using.

+ *

The name of the browser which the contact is using.

*/ - @java.lang.Override - @JsonSetter(value = "android_os_version", nulls = Nulls.SKIP) - public _FinalStage androidOsVersion(Optional androidOsVersion) { - this.androidOsVersion = androidOsVersion; + @JsonSetter(value = "browser", nulls = Nulls.SKIP) + public Builder browser(Optional browser) { + this.browser = browser; return this; } - /** - *

The Android device which the contact is using.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage androidDevice(String androidDevice) { - this.androidDevice = Optional.ofNullable(androidDevice); + public Builder browser(String browser) { + this.browser = Optional.ofNullable(browser); return this; } /** - *

The Android device which the contact is using.

+ *

The version of the browser which the contact is using.

*/ - @java.lang.Override - @JsonSetter(value = "android_device", nulls = Nulls.SKIP) - public _FinalStage androidDevice(Optional androidDevice) { - this.androidDevice = androidDevice; + @JsonSetter(value = "browser_version", nulls = Nulls.SKIP) + public Builder browserVersion(Optional browserVersion) { + this.browserVersion = browserVersion; return this; } - /** - *

The version of the Android app which the contact is using.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage androidAppVersion(String androidAppVersion) { - this.androidAppVersion = Optional.ofNullable(androidAppVersion); + public Builder browserVersion(String browserVersion) { + this.browserVersion = Optional.ofNullable(browserVersion); return this; } /** - *

The version of the Android app which the contact is using.

+ *

The language set by the browser which the contact is using.

*/ - @java.lang.Override - @JsonSetter(value = "android_app_version", nulls = Nulls.SKIP) - public _FinalStage androidAppVersion(Optional androidAppVersion) { - this.androidAppVersion = androidAppVersion; + @JsonSetter(value = "browser_language", nulls = Nulls.SKIP) + public Builder browserLanguage(Optional browserLanguage) { + this.browserLanguage = browserLanguage; return this; } - /** - *

The name of the Android app which the contact is using.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage androidAppName(String androidAppName) { - this.androidAppName = Optional.ofNullable(androidAppName); + public Builder browserLanguage(String browserLanguage) { + this.browserLanguage = Optional.ofNullable(browserLanguage); return this; } /** - *

The name of the Android app which the contact is using.

+ *

The operating system which the contact is using.

*/ - @java.lang.Override - @JsonSetter(value = "android_app_name", nulls = Nulls.SKIP) - public _FinalStage androidAppName(Optional androidAppName) { - this.androidAppName = androidAppName; + @JsonSetter(value = "os", nulls = Nulls.SKIP) + public Builder os(Optional os) { + this.os = os; return this; } - /** - *

The operating system which the contact is using.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage os(String os) { + public Builder os(String os) { this.os = Optional.ofNullable(os); return this; } /** - *

The operating system which the contact is using.

+ *

The name of the Android app which the contact is using.

*/ - @java.lang.Override - @JsonSetter(value = "os", nulls = Nulls.SKIP) - public _FinalStage os(Optional os) { - this.os = os; + @JsonSetter(value = "android_app_name", nulls = Nulls.SKIP) + public Builder androidAppName(Optional androidAppName) { + this.androidAppName = androidAppName; return this; } - /** - *

The language set by the browser which the contact is using.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage browserLanguage(String browserLanguage) { - this.browserLanguage = Optional.ofNullable(browserLanguage); + public Builder androidAppName(String androidAppName) { + this.androidAppName = Optional.ofNullable(androidAppName); return this; } /** - *

The language set by the browser which the contact is using.

+ *

The version of the Android app which the contact is using.

*/ - @java.lang.Override - @JsonSetter(value = "browser_language", nulls = Nulls.SKIP) - public _FinalStage browserLanguage(Optional browserLanguage) { - this.browserLanguage = browserLanguage; + @JsonSetter(value = "android_app_version", nulls = Nulls.SKIP) + public Builder androidAppVersion(Optional androidAppVersion) { + this.androidAppVersion = androidAppVersion; return this; } - /** - *

The version of the browser which the contact is using.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage browserVersion(String browserVersion) { - this.browserVersion = Optional.ofNullable(browserVersion); + public Builder androidAppVersion(String androidAppVersion) { + this.androidAppVersion = Optional.ofNullable(androidAppVersion); return this; } /** - *

The version of the browser which the contact is using.

+ *

The Android device which the contact is using.

*/ - @java.lang.Override - @JsonSetter(value = "browser_version", nulls = Nulls.SKIP) - public _FinalStage browserVersion(Optional browserVersion) { - this.browserVersion = browserVersion; + @JsonSetter(value = "android_device", nulls = Nulls.SKIP) + public Builder androidDevice(Optional androidDevice) { + this.androidDevice = androidDevice; return this; } - /** - *

The name of the browser which the contact is using.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage browser(String browser) { - this.browser = Optional.ofNullable(browser); + public Builder androidDevice(String androidDevice) { + this.androidDevice = Optional.ofNullable(androidDevice); return this; } /** - *

The name of the browser which the contact is using.

+ *

The version of the Android OS which the contact is using.

*/ - @java.lang.Override - @JsonSetter(value = "browser", nulls = Nulls.SKIP) - public _FinalStage browser(Optional browser) { - this.browser = browser; + @JsonSetter(value = "android_os_version", nulls = Nulls.SKIP) + public Builder androidOsVersion(Optional androidOsVersion) { + this.androidOsVersion = androidOsVersion; return this; } - /** - *

A preferred language setting for the contact, used by the Intercom Messenger even if their browser settings change.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage languageOverride(String languageOverride) { - this.languageOverride = Optional.ofNullable(languageOverride); + public Builder androidOsVersion(String androidOsVersion) { + this.androidOsVersion = Optional.ofNullable(androidOsVersion); return this; } /** - *

A preferred language setting for the contact, used by the Intercom Messenger even if their browser settings change.

+ *

The version of the Android SDK which the contact is using.

*/ - @java.lang.Override - @JsonSetter(value = "language_override", nulls = Nulls.SKIP) - public _FinalStage languageOverride(Optional languageOverride) { - this.languageOverride = languageOverride; + @JsonSetter(value = "android_sdk_version", nulls = Nulls.SKIP) + public Builder androidSdkVersion(Optional androidSdkVersion) { + this.androidSdkVersion = androidSdkVersion; return this; } - /** - *

(UNIX timestamp) The time when the contact last clicked a link in an email.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage lastEmailClickedAt(Integer lastEmailClickedAt) { - this.lastEmailClickedAt = Optional.ofNullable(lastEmailClickedAt); + public Builder androidSdkVersion(String androidSdkVersion) { + this.androidSdkVersion = Optional.ofNullable(androidSdkVersion); return this; } /** - *

(UNIX timestamp) The time when the contact last clicked a link in an email.

+ *

(UNIX timestamp) The time when the contact was last seen on an Android device.

*/ - @java.lang.Override - @JsonSetter(value = "last_email_clicked_at", nulls = Nulls.SKIP) - public _FinalStage lastEmailClickedAt(Optional lastEmailClickedAt) { - this.lastEmailClickedAt = lastEmailClickedAt; + @JsonSetter(value = "android_last_seen_at", nulls = Nulls.SKIP) + public Builder androidLastSeenAt(Optional androidLastSeenAt) { + this.androidLastSeenAt = androidLastSeenAt; return this; } - /** - *

(UNIX timestamp) The time when the contact last opened an email.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage lastEmailOpenedAt(Integer lastEmailOpenedAt) { - this.lastEmailOpenedAt = Optional.ofNullable(lastEmailOpenedAt); + public Builder androidLastSeenAt(Integer androidLastSeenAt) { + this.androidLastSeenAt = Optional.ofNullable(androidLastSeenAt); return this; } /** - *

(UNIX timestamp) The time when the contact last opened an email.

+ *

The name of the iOS app which the contact is using.

*/ - @java.lang.Override - @JsonSetter(value = "last_email_opened_at", nulls = Nulls.SKIP) - public _FinalStage lastEmailOpenedAt(Optional lastEmailOpenedAt) { - this.lastEmailOpenedAt = lastEmailOpenedAt; + @JsonSetter(value = "ios_app_name", nulls = Nulls.SKIP) + public Builder iosAppName(Optional iosAppName) { + this.iosAppName = iosAppName; return this; } - /** - *

(UNIX timestamp) The time when the contact was last messaged.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage lastContactedAt(Integer lastContactedAt) { - this.lastContactedAt = Optional.ofNullable(lastContactedAt); + public Builder iosAppName(String iosAppName) { + this.iosAppName = Optional.ofNullable(iosAppName); return this; } /** - *

(UNIX timestamp) The time when the contact was last messaged.

+ *

The version of the iOS app which the contact is using.

*/ - @java.lang.Override - @JsonSetter(value = "last_contacted_at", nulls = Nulls.SKIP) - public _FinalStage lastContactedAt(Optional lastContactedAt) { - this.lastContactedAt = lastContactedAt; + @JsonSetter(value = "ios_app_version", nulls = Nulls.SKIP) + public Builder iosAppVersion(Optional iosAppVersion) { + this.iosAppVersion = iosAppVersion; return this; } - /** - *

(UNIX timestamp) The time when the contact last messaged in.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage lastRepliedAt(Integer lastRepliedAt) { - this.lastRepliedAt = Optional.ofNullable(lastRepliedAt); + public Builder iosAppVersion(String iosAppVersion) { + this.iosAppVersion = Optional.ofNullable(iosAppVersion); return this; } /** - *

(UNIX timestamp) The time when the contact last messaged in.

+ *

The iOS device which the contact is using.

*/ - @java.lang.Override - @JsonSetter(value = "last_replied_at", nulls = Nulls.SKIP) - public _FinalStage lastRepliedAt(Optional lastRepliedAt) { - this.lastRepliedAt = lastRepliedAt; + @JsonSetter(value = "ios_device", nulls = Nulls.SKIP) + public Builder iosDevice(Optional iosDevice) { + this.iosDevice = iosDevice; return this; } - /** - *

(UNIX timestamp) The time when the contact was last seen (either where the Intercom Messenger was installed or when specified manually).

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage lastSeenAt(Integer lastSeenAt) { - this.lastSeenAt = Optional.ofNullable(lastSeenAt); + public Builder iosDevice(String iosDevice) { + this.iosDevice = Optional.ofNullable(iosDevice); return this; } /** - *

(UNIX timestamp) The time when the contact was last seen (either where the Intercom Messenger was installed or when specified manually).

+ *

The version of iOS which the contact is using.

*/ - @java.lang.Override - @JsonSetter(value = "last_seen_at", nulls = Nulls.SKIP) - public _FinalStage lastSeenAt(Optional lastSeenAt) { - this.lastSeenAt = lastSeenAt; + @JsonSetter(value = "ios_os_version", nulls = Nulls.SKIP) + public Builder iosOsVersion(Optional iosOsVersion) { + this.iosOsVersion = iosOsVersion; return this; } - /** - *

(UNIX timestamp) The time specified for when a contact signed up.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage signedUpAt(Integer signedUpAt) { - this.signedUpAt = Optional.ofNullable(signedUpAt); + public Builder iosOsVersion(String iosOsVersion) { + this.iosOsVersion = Optional.ofNullable(iosOsVersion); return this; } /** - *

(UNIX timestamp) The time specified for when a contact signed up.

+ *

The version of the iOS SDK which the contact is using.

*/ - @java.lang.Override - @JsonSetter(value = "signed_up_at", nulls = Nulls.SKIP) - public _FinalStage signedUpAt(Optional signedUpAt) { - this.signedUpAt = signedUpAt; + @JsonSetter(value = "ios_sdk_version", nulls = Nulls.SKIP) + public Builder iosSdkVersion(Optional iosSdkVersion) { + this.iosSdkVersion = iosSdkVersion; return this; } - /** - *

The id of an admin that has been assigned account ownership of the contact.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage ownerId(Integer ownerId) { - this.ownerId = Optional.ofNullable(ownerId); + public Builder iosSdkVersion(String iosSdkVersion) { + this.iosSdkVersion = Optional.ofNullable(iosSdkVersion); return this; } /** - *

The id of an admin that has been assigned account ownership of the contact.

+ *

(UNIX timestamp) The last time the contact used the iOS app.

*/ - @java.lang.Override - @JsonSetter(value = "owner_id", nulls = Nulls.SKIP) - public _FinalStage ownerId(Optional ownerId) { - this.ownerId = ownerId; + @JsonSetter(value = "ios_last_seen_at", nulls = Nulls.SKIP) + public Builder iosLastSeenAt(Optional iosLastSeenAt) { + this.iosLastSeenAt = iosLastSeenAt; return this; } - /** - *

The contacts name.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage name(String name) { - this.name = Optional.ofNullable(name); + public Builder iosLastSeenAt(Integer iosLastSeenAt) { + this.iosLastSeenAt = Optional.ofNullable(iosLastSeenAt); return this; } /** - *

The contacts name.

+ *

The custom attributes which are set for the contact.

*/ - @java.lang.Override - @JsonSetter(value = "name", nulls = Nulls.SKIP) - public _FinalStage name(Optional name) { - this.name = name; + @JsonSetter(value = "custom_attributes", nulls = Nulls.SKIP) + public Builder customAttributes(Optional> customAttributes) { + this.customAttributes = customAttributes; return this; } - /** - *

The contacts phone number normalized to the E164 format

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage formattedPhone(String formattedPhone) { - this.formattedPhone = Optional.ofNullable(formattedPhone); + public Builder customAttributes(Map customAttributes) { + this.customAttributes = Optional.ofNullable(customAttributes); return this; } /** - *

The contacts phone number normalized to the E164 format

+ *

An image URL containing the avatar of a contact.

*/ - @java.lang.Override - @JsonSetter(value = "formatted_phone", nulls = Nulls.SKIP) - public _FinalStage formattedPhone(Optional formattedPhone) { - this.formattedPhone = formattedPhone; + @JsonSetter(value = "avatar", nulls = Nulls.SKIP) + public Builder avatar(Optional avatar) { + this.avatar = avatar; return this; } - /** - *

The contacts phone.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage phone(String phone) { - this.phone = Optional.ofNullable(phone); + public Builder avatar(String avatar) { + this.avatar = Optional.ofNullable(avatar); return this; } - /** - *

The contacts phone.

- */ - @java.lang.Override - @JsonSetter(value = "phone", nulls = Nulls.SKIP) - public _FinalStage phone(Optional phone) { - this.phone = phone; + @JsonSetter(value = "tags", nulls = Nulls.SKIP) + public Builder tags(Optional tags) { + this.tags = tags; return this; } - /** - *

The contact's email domain.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage emailDomain(String emailDomain) { - this.emailDomain = Optional.ofNullable(emailDomain); + public Builder tags(ContactTags tags) { + this.tags = Optional.ofNullable(tags); return this; } - /** - *

The contact's email domain.

- */ - @java.lang.Override - @JsonSetter(value = "email_domain", nulls = Nulls.SKIP) - public _FinalStage emailDomain(Optional emailDomain) { - this.emailDomain = emailDomain; + @JsonSetter(value = "notes", nulls = Nulls.SKIP) + public Builder notes(Optional notes) { + this.notes = notes; return this; } - /** - *

The contact's email.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage email(String email) { - this.email = Optional.ofNullable(email); + public Builder notes(ContactNotes notes) { + this.notes = Optional.ofNullable(notes); return this; } - /** - *

The contact's email.

- */ - @java.lang.Override - @JsonSetter(value = "email", nulls = Nulls.SKIP) - public _FinalStage email(Optional email) { - this.email = email; + @JsonSetter(value = "companies", nulls = Nulls.SKIP) + public Builder companies(Optional companies) { + this.companies = companies; return this; } - /** - *

The unique identifier for the contact which is provided by the Client.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage externalId(String externalId) { - this.externalId = Optional.ofNullable(externalId); + public Builder companies(ContactCompanies companies) { + this.companies = Optional.ofNullable(companies); return this; } - /** - *

The unique identifier for the contact which is provided by the Client.

- */ - @java.lang.Override - @JsonSetter(value = "external_id", nulls = Nulls.SKIP) - public _FinalStage externalId(Optional externalId) { - this.externalId = externalId; + @JsonSetter(value = "location", nulls = Nulls.SKIP) + public Builder location(Optional location) { + this.location = location; return this; } - /** - *

The type of object.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage type(String type) { - this.type = Optional.ofNullable(type); + public Builder location(ContactLocation location) { + this.location = Optional.ofNullable(location); return this; } - /** - *

The type of object.

- */ - @java.lang.Override - @JsonSetter(value = "type", nulls = Nulls.SKIP) - public _FinalStage type(Optional type) { - this.type = type; + @JsonSetter(value = "social_profiles", nulls = Nulls.SKIP) + public Builder socialProfiles(Optional socialProfiles) { + this.socialProfiles = socialProfiles; + return this; + } + + public Builder socialProfiles(ContactSocialProfiles socialProfiles) { + this.socialProfiles = Optional.ofNullable(socialProfiles); return this; } - @java.lang.Override public Contact build() { return new Contact( type, @@ -1976,7 +1446,6 @@ public Contact build() { email, emailDomain, phone, - formattedPhone, name, ownerId, hasHardBounced, diff --git a/src/main/java/com/intercom/api/resources/contacts/types/ContactsCreateResponse.java b/src/main/java/com/intercom/api/resources/contacts/types/ContactsCreateResponse.java new file mode 100644 index 0000000..27130d1 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/contacts/types/ContactsCreateResponse.java @@ -0,0 +1,1521 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.contacts.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.types.ContactCompanies; +import com.intercom.api.types.ContactLocation; +import com.intercom.api.types.ContactNotes; +import com.intercom.api.types.ContactSocialProfiles; +import com.intercom.api.types.ContactTags; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ContactsCreateResponse.Builder.class) +public final class ContactsCreateResponse implements IContact { + private final Optional type; + + private final Optional id; + + private final Optional externalId; + + private final Optional workspaceId; + + private final Optional role; + + private final Optional email; + + private final Optional emailDomain; + + private final Optional phone; + + private final Optional name; + + private final Optional ownerId; + + private final Optional hasHardBounced; + + private final Optional markedEmailAsSpam; + + private final Optional unsubscribedFromEmails; + + private final Optional createdAt; + + private final Optional updatedAt; + + private final Optional signedUpAt; + + private final Optional lastSeenAt; + + private final Optional lastRepliedAt; + + private final Optional lastContactedAt; + + private final Optional lastEmailOpenedAt; + + private final Optional lastEmailClickedAt; + + private final Optional languageOverride; + + private final Optional browser; + + private final Optional browserVersion; + + private final Optional browserLanguage; + + private final Optional os; + + private final Optional androidAppName; + + private final Optional androidAppVersion; + + private final Optional androidDevice; + + private final Optional androidOsVersion; + + private final Optional androidSdkVersion; + + private final Optional androidLastSeenAt; + + private final Optional iosAppName; + + private final Optional iosAppVersion; + + private final Optional iosDevice; + + private final Optional iosOsVersion; + + private final Optional iosSdkVersion; + + private final Optional iosLastSeenAt; + + private final Optional> customAttributes; + + private final Optional avatar; + + private final Optional tags; + + private final Optional notes; + + private final Optional companies; + + private final Optional location; + + private final Optional socialProfiles; + + private final Optional enabledPushMessaging; + + private final Map additionalProperties; + + private ContactsCreateResponse( + Optional type, + Optional id, + Optional externalId, + Optional workspaceId, + Optional role, + Optional email, + Optional emailDomain, + Optional phone, + Optional name, + Optional ownerId, + Optional hasHardBounced, + Optional markedEmailAsSpam, + Optional unsubscribedFromEmails, + Optional createdAt, + Optional updatedAt, + Optional signedUpAt, + Optional lastSeenAt, + Optional lastRepliedAt, + Optional lastContactedAt, + Optional lastEmailOpenedAt, + Optional lastEmailClickedAt, + Optional languageOverride, + Optional browser, + Optional browserVersion, + Optional browserLanguage, + Optional os, + Optional androidAppName, + Optional androidAppVersion, + Optional androidDevice, + Optional androidOsVersion, + Optional androidSdkVersion, + Optional androidLastSeenAt, + Optional iosAppName, + Optional iosAppVersion, + Optional iosDevice, + Optional iosOsVersion, + Optional iosSdkVersion, + Optional iosLastSeenAt, + Optional> customAttributes, + Optional avatar, + Optional tags, + Optional notes, + Optional companies, + Optional location, + Optional socialProfiles, + Optional enabledPushMessaging, + Map additionalProperties) { + this.type = type; + this.id = id; + this.externalId = externalId; + this.workspaceId = workspaceId; + this.role = role; + this.email = email; + this.emailDomain = emailDomain; + this.phone = phone; + this.name = name; + this.ownerId = ownerId; + this.hasHardBounced = hasHardBounced; + this.markedEmailAsSpam = markedEmailAsSpam; + this.unsubscribedFromEmails = unsubscribedFromEmails; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.signedUpAt = signedUpAt; + this.lastSeenAt = lastSeenAt; + this.lastRepliedAt = lastRepliedAt; + this.lastContactedAt = lastContactedAt; + this.lastEmailOpenedAt = lastEmailOpenedAt; + this.lastEmailClickedAt = lastEmailClickedAt; + this.languageOverride = languageOverride; + this.browser = browser; + this.browserVersion = browserVersion; + this.browserLanguage = browserLanguage; + this.os = os; + this.androidAppName = androidAppName; + this.androidAppVersion = androidAppVersion; + this.androidDevice = androidDevice; + this.androidOsVersion = androidOsVersion; + this.androidSdkVersion = androidSdkVersion; + this.androidLastSeenAt = androidLastSeenAt; + this.iosAppName = iosAppName; + this.iosAppVersion = iosAppVersion; + this.iosDevice = iosDevice; + this.iosOsVersion = iosOsVersion; + this.iosSdkVersion = iosSdkVersion; + this.iosLastSeenAt = iosLastSeenAt; + this.customAttributes = customAttributes; + this.avatar = avatar; + this.tags = tags; + this.notes = notes; + this.companies = companies; + this.location = location; + this.socialProfiles = socialProfiles; + this.enabledPushMessaging = enabledPushMessaging; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of object. + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return The unique identifier for the contact which is given by Intercom. + */ + @JsonProperty("id") + public Optional getId() { + return id; + } + + /** + * @return The unique identifier for the contact which is provided by the Client. + */ + @JsonProperty("external_id") + public Optional getExternalId() { + return externalId; + } + + /** + * @return The id of the workspace which the contact belongs to. + */ + @JsonProperty("workspace_id") + public Optional getWorkspaceId() { + return workspaceId; + } + + /** + * @return The role of the contact. + */ + @JsonProperty("role") + public Optional getRole() { + return role; + } + + /** + * @return The contact's email. + */ + @JsonProperty("email") + public Optional getEmail() { + return email; + } + + /** + * @return The contact's email domain. + */ + @JsonProperty("email_domain") + public Optional getEmailDomain() { + return emailDomain; + } + + /** + * @return The contacts phone. + */ + @JsonProperty("phone") + public Optional getPhone() { + return phone; + } + + /** + * @return The contacts name. + */ + @JsonProperty("name") + public Optional getName() { + return name; + } + + /** + * @return The id of an admin that has been assigned account ownership of the contact. + */ + @JsonProperty("owner_id") + public Optional getOwnerId() { + return ownerId; + } + + /** + * @return Whether the contact has had an email sent to them hard bounce. + */ + @JsonProperty("has_hard_bounced") + public Optional getHasHardBounced() { + return hasHardBounced; + } + + /** + * @return Whether the contact has marked an email sent to them as spam. + */ + @JsonProperty("marked_email_as_spam") + public Optional getMarkedEmailAsSpam() { + return markedEmailAsSpam; + } + + /** + * @return Whether the contact is unsubscribed from emails. + */ + @JsonProperty("unsubscribed_from_emails") + public Optional getUnsubscribedFromEmails() { + return unsubscribedFromEmails; + } + + /** + * @return (UNIX timestamp) The time when the contact was created. + */ + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + /** + * @return (UNIX timestamp) The time when the contact was last updated. + */ + @JsonProperty("updated_at") + public Optional getUpdatedAt() { + return updatedAt; + } + + /** + * @return (UNIX timestamp) The time specified for when a contact signed up. + */ + @JsonProperty("signed_up_at") + public Optional getSignedUpAt() { + return signedUpAt; + } + + /** + * @return (UNIX timestamp) The time when the contact was last seen (either where the Intercom Messenger was installed or when specified manually). + */ + @JsonProperty("last_seen_at") + public Optional getLastSeenAt() { + return lastSeenAt; + } + + /** + * @return (UNIX timestamp) The time when the contact last messaged in. + */ + @JsonProperty("last_replied_at") + public Optional getLastRepliedAt() { + return lastRepliedAt; + } + + /** + * @return (UNIX timestamp) The time when the contact was last messaged. + */ + @JsonProperty("last_contacted_at") + public Optional getLastContactedAt() { + return lastContactedAt; + } + + /** + * @return (UNIX timestamp) The time when the contact last opened an email. + */ + @JsonProperty("last_email_opened_at") + public Optional getLastEmailOpenedAt() { + return lastEmailOpenedAt; + } + + /** + * @return (UNIX timestamp) The time when the contact last clicked a link in an email. + */ + @JsonProperty("last_email_clicked_at") + public Optional getLastEmailClickedAt() { + return lastEmailClickedAt; + } + + /** + * @return A preferred language setting for the contact, used by the Intercom Messenger even if their browser settings change. + */ + @JsonProperty("language_override") + public Optional getLanguageOverride() { + return languageOverride; + } + + /** + * @return The name of the browser which the contact is using. + */ + @JsonProperty("browser") + public Optional getBrowser() { + return browser; + } + + /** + * @return The version of the browser which the contact is using. + */ + @JsonProperty("browser_version") + public Optional getBrowserVersion() { + return browserVersion; + } + + /** + * @return The language set by the browser which the contact is using. + */ + @JsonProperty("browser_language") + public Optional getBrowserLanguage() { + return browserLanguage; + } + + /** + * @return The operating system which the contact is using. + */ + @JsonProperty("os") + public Optional getOs() { + return os; + } + + /** + * @return The name of the Android app which the contact is using. + */ + @JsonProperty("android_app_name") + public Optional getAndroidAppName() { + return androidAppName; + } + + /** + * @return The version of the Android app which the contact is using. + */ + @JsonProperty("android_app_version") + public Optional getAndroidAppVersion() { + return androidAppVersion; + } + + /** + * @return The Android device which the contact is using. + */ + @JsonProperty("android_device") + public Optional getAndroidDevice() { + return androidDevice; + } + + /** + * @return The version of the Android OS which the contact is using. + */ + @JsonProperty("android_os_version") + public Optional getAndroidOsVersion() { + return androidOsVersion; + } + + /** + * @return The version of the Android SDK which the contact is using. + */ + @JsonProperty("android_sdk_version") + public Optional getAndroidSdkVersion() { + return androidSdkVersion; + } + + /** + * @return (UNIX timestamp) The time when the contact was last seen on an Android device. + */ + @JsonProperty("android_last_seen_at") + public Optional getAndroidLastSeenAt() { + return androidLastSeenAt; + } + + /** + * @return The name of the iOS app which the contact is using. + */ + @JsonProperty("ios_app_name") + public Optional getIosAppName() { + return iosAppName; + } + + /** + * @return The version of the iOS app which the contact is using. + */ + @JsonProperty("ios_app_version") + public Optional getIosAppVersion() { + return iosAppVersion; + } + + /** + * @return The iOS device which the contact is using. + */ + @JsonProperty("ios_device") + public Optional getIosDevice() { + return iosDevice; + } + + /** + * @return The version of iOS which the contact is using. + */ + @JsonProperty("ios_os_version") + public Optional getIosOsVersion() { + return iosOsVersion; + } + + /** + * @return The version of the iOS SDK which the contact is using. + */ + @JsonProperty("ios_sdk_version") + public Optional getIosSdkVersion() { + return iosSdkVersion; + } + + /** + * @return (UNIX timestamp) The last time the contact used the iOS app. + */ + @JsonProperty("ios_last_seen_at") + public Optional getIosLastSeenAt() { + return iosLastSeenAt; + } + + /** + * @return The custom attributes which are set for the contact. + */ + @JsonProperty("custom_attributes") + public Optional> getCustomAttributes() { + return customAttributes; + } + + /** + * @return An image URL containing the avatar of a contact. + */ + @JsonProperty("avatar") + public Optional getAvatar() { + return avatar; + } + + @JsonProperty("tags") + public Optional getTags() { + return tags; + } + + @JsonProperty("notes") + public Optional getNotes() { + return notes; + } + + @JsonProperty("companies") + public Optional getCompanies() { + return companies; + } + + @JsonProperty("location") + public Optional getLocation() { + return location; + } + + @JsonProperty("social_profiles") + public Optional getSocialProfiles() { + return socialProfiles; + } + + /** + * @return If the user has enabled push messaging. + */ + @JsonProperty("enabled_push_messaging") + public Optional getEnabledPushMessaging() { + return enabledPushMessaging; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ContactsCreateResponse && equalTo((ContactsCreateResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ContactsCreateResponse other) { + return type.equals(other.type) + && id.equals(other.id) + && externalId.equals(other.externalId) + && workspaceId.equals(other.workspaceId) + && role.equals(other.role) + && email.equals(other.email) + && emailDomain.equals(other.emailDomain) + && phone.equals(other.phone) + && name.equals(other.name) + && ownerId.equals(other.ownerId) + && hasHardBounced.equals(other.hasHardBounced) + && markedEmailAsSpam.equals(other.markedEmailAsSpam) + && unsubscribedFromEmails.equals(other.unsubscribedFromEmails) + && createdAt.equals(other.createdAt) + && updatedAt.equals(other.updatedAt) + && signedUpAt.equals(other.signedUpAt) + && lastSeenAt.equals(other.lastSeenAt) + && lastRepliedAt.equals(other.lastRepliedAt) + && lastContactedAt.equals(other.lastContactedAt) + && lastEmailOpenedAt.equals(other.lastEmailOpenedAt) + && lastEmailClickedAt.equals(other.lastEmailClickedAt) + && languageOverride.equals(other.languageOverride) + && browser.equals(other.browser) + && browserVersion.equals(other.browserVersion) + && browserLanguage.equals(other.browserLanguage) + && os.equals(other.os) + && androidAppName.equals(other.androidAppName) + && androidAppVersion.equals(other.androidAppVersion) + && androidDevice.equals(other.androidDevice) + && androidOsVersion.equals(other.androidOsVersion) + && androidSdkVersion.equals(other.androidSdkVersion) + && androidLastSeenAt.equals(other.androidLastSeenAt) + && iosAppName.equals(other.iosAppName) + && iosAppVersion.equals(other.iosAppVersion) + && iosDevice.equals(other.iosDevice) + && iosOsVersion.equals(other.iosOsVersion) + && iosSdkVersion.equals(other.iosSdkVersion) + && iosLastSeenAt.equals(other.iosLastSeenAt) + && customAttributes.equals(other.customAttributes) + && avatar.equals(other.avatar) + && tags.equals(other.tags) + && notes.equals(other.notes) + && companies.equals(other.companies) + && location.equals(other.location) + && socialProfiles.equals(other.socialProfiles) + && enabledPushMessaging.equals(other.enabledPushMessaging); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.type, + this.id, + this.externalId, + this.workspaceId, + this.role, + this.email, + this.emailDomain, + this.phone, + this.name, + this.ownerId, + this.hasHardBounced, + this.markedEmailAsSpam, + this.unsubscribedFromEmails, + this.createdAt, + this.updatedAt, + this.signedUpAt, + this.lastSeenAt, + this.lastRepliedAt, + this.lastContactedAt, + this.lastEmailOpenedAt, + this.lastEmailClickedAt, + this.languageOverride, + this.browser, + this.browserVersion, + this.browserLanguage, + this.os, + this.androidAppName, + this.androidAppVersion, + this.androidDevice, + this.androidOsVersion, + this.androidSdkVersion, + this.androidLastSeenAt, + this.iosAppName, + this.iosAppVersion, + this.iosDevice, + this.iosOsVersion, + this.iosSdkVersion, + this.iosLastSeenAt, + this.customAttributes, + this.avatar, + this.tags, + this.notes, + this.companies, + this.location, + this.socialProfiles, + this.enabledPushMessaging); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); + + private Optional id = Optional.empty(); + + private Optional externalId = Optional.empty(); + + private Optional workspaceId = Optional.empty(); + + private Optional role = Optional.empty(); + + private Optional email = Optional.empty(); + + private Optional emailDomain = Optional.empty(); + + private Optional phone = Optional.empty(); + + private Optional name = Optional.empty(); + + private Optional ownerId = Optional.empty(); + + private Optional hasHardBounced = Optional.empty(); + + private Optional markedEmailAsSpam = Optional.empty(); + + private Optional unsubscribedFromEmails = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + private Optional updatedAt = Optional.empty(); + + private Optional signedUpAt = Optional.empty(); + + private Optional lastSeenAt = Optional.empty(); + + private Optional lastRepliedAt = Optional.empty(); + + private Optional lastContactedAt = Optional.empty(); + + private Optional lastEmailOpenedAt = Optional.empty(); + + private Optional lastEmailClickedAt = Optional.empty(); + + private Optional languageOverride = Optional.empty(); + + private Optional browser = Optional.empty(); + + private Optional browserVersion = Optional.empty(); + + private Optional browserLanguage = Optional.empty(); + + private Optional os = Optional.empty(); + + private Optional androidAppName = Optional.empty(); + + private Optional androidAppVersion = Optional.empty(); + + private Optional androidDevice = Optional.empty(); + + private Optional androidOsVersion = Optional.empty(); + + private Optional androidSdkVersion = Optional.empty(); + + private Optional androidLastSeenAt = Optional.empty(); + + private Optional iosAppName = Optional.empty(); + + private Optional iosAppVersion = Optional.empty(); + + private Optional iosDevice = Optional.empty(); + + private Optional iosOsVersion = Optional.empty(); + + private Optional iosSdkVersion = Optional.empty(); + + private Optional iosLastSeenAt = Optional.empty(); + + private Optional> customAttributes = Optional.empty(); + + private Optional avatar = Optional.empty(); + + private Optional tags = Optional.empty(); + + private Optional notes = Optional.empty(); + + private Optional companies = Optional.empty(); + + private Optional location = Optional.empty(); + + private Optional socialProfiles = Optional.empty(); + + private Optional enabledPushMessaging = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ContactsCreateResponse other) { + type(other.getType()); + id(other.getId()); + externalId(other.getExternalId()); + workspaceId(other.getWorkspaceId()); + role(other.getRole()); + email(other.getEmail()); + emailDomain(other.getEmailDomain()); + phone(other.getPhone()); + name(other.getName()); + ownerId(other.getOwnerId()); + hasHardBounced(other.getHasHardBounced()); + markedEmailAsSpam(other.getMarkedEmailAsSpam()); + unsubscribedFromEmails(other.getUnsubscribedFromEmails()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + signedUpAt(other.getSignedUpAt()); + lastSeenAt(other.getLastSeenAt()); + lastRepliedAt(other.getLastRepliedAt()); + lastContactedAt(other.getLastContactedAt()); + lastEmailOpenedAt(other.getLastEmailOpenedAt()); + lastEmailClickedAt(other.getLastEmailClickedAt()); + languageOverride(other.getLanguageOverride()); + browser(other.getBrowser()); + browserVersion(other.getBrowserVersion()); + browserLanguage(other.getBrowserLanguage()); + os(other.getOs()); + androidAppName(other.getAndroidAppName()); + androidAppVersion(other.getAndroidAppVersion()); + androidDevice(other.getAndroidDevice()); + androidOsVersion(other.getAndroidOsVersion()); + androidSdkVersion(other.getAndroidSdkVersion()); + androidLastSeenAt(other.getAndroidLastSeenAt()); + iosAppName(other.getIosAppName()); + iosAppVersion(other.getIosAppVersion()); + iosDevice(other.getIosDevice()); + iosOsVersion(other.getIosOsVersion()); + iosSdkVersion(other.getIosSdkVersion()); + iosLastSeenAt(other.getIosLastSeenAt()); + customAttributes(other.getCustomAttributes()); + avatar(other.getAvatar()); + tags(other.getTags()); + notes(other.getNotes()); + companies(other.getCompanies()); + location(other.getLocation()); + socialProfiles(other.getSocialProfiles()); + enabledPushMessaging(other.getEnabledPushMessaging()); + return this; + } + + /** + *

The type of object.

+ */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + /** + *

The unique identifier for the contact which is given by Intercom.

+ */ + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.ofNullable(id); + return this; + } + + /** + *

The unique identifier for the contact which is provided by the Client.

+ */ + @JsonSetter(value = "external_id", nulls = Nulls.SKIP) + public Builder externalId(Optional externalId) { + this.externalId = externalId; + return this; + } + + public Builder externalId(String externalId) { + this.externalId = Optional.ofNullable(externalId); + return this; + } + + /** + *

The id of the workspace which the contact belongs to.

+ */ + @JsonSetter(value = "workspace_id", nulls = Nulls.SKIP) + public Builder workspaceId(Optional workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + public Builder workspaceId(String workspaceId) { + this.workspaceId = Optional.ofNullable(workspaceId); + return this; + } + + /** + *

The role of the contact.

+ */ + @JsonSetter(value = "role", nulls = Nulls.SKIP) + public Builder role(Optional role) { + this.role = role; + return this; + } + + public Builder role(String role) { + this.role = Optional.ofNullable(role); + return this; + } + + /** + *

The contact's email.

+ */ + @JsonSetter(value = "email", nulls = Nulls.SKIP) + public Builder email(Optional email) { + this.email = email; + return this; + } + + public Builder email(String email) { + this.email = Optional.ofNullable(email); + return this; + } + + /** + *

The contact's email domain.

+ */ + @JsonSetter(value = "email_domain", nulls = Nulls.SKIP) + public Builder emailDomain(Optional emailDomain) { + this.emailDomain = emailDomain; + return this; + } + + public Builder emailDomain(String emailDomain) { + this.emailDomain = Optional.ofNullable(emailDomain); + return this; + } + + /** + *

The contacts phone.

+ */ + @JsonSetter(value = "phone", nulls = Nulls.SKIP) + public Builder phone(Optional phone) { + this.phone = phone; + return this; + } + + public Builder phone(String phone) { + this.phone = Optional.ofNullable(phone); + return this; + } + + /** + *

The contacts name.

+ */ + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public Builder name(Optional name) { + this.name = name; + return this; + } + + public Builder name(String name) { + this.name = Optional.ofNullable(name); + return this; + } + + /** + *

The id of an admin that has been assigned account ownership of the contact.

+ */ + @JsonSetter(value = "owner_id", nulls = Nulls.SKIP) + public Builder ownerId(Optional ownerId) { + this.ownerId = ownerId; + return this; + } + + public Builder ownerId(Integer ownerId) { + this.ownerId = Optional.ofNullable(ownerId); + return this; + } + + /** + *

Whether the contact has had an email sent to them hard bounce.

+ */ + @JsonSetter(value = "has_hard_bounced", nulls = Nulls.SKIP) + public Builder hasHardBounced(Optional hasHardBounced) { + this.hasHardBounced = hasHardBounced; + return this; + } + + public Builder hasHardBounced(Boolean hasHardBounced) { + this.hasHardBounced = Optional.ofNullable(hasHardBounced); + return this; + } + + /** + *

Whether the contact has marked an email sent to them as spam.

+ */ + @JsonSetter(value = "marked_email_as_spam", nulls = Nulls.SKIP) + public Builder markedEmailAsSpam(Optional markedEmailAsSpam) { + this.markedEmailAsSpam = markedEmailAsSpam; + return this; + } + + public Builder markedEmailAsSpam(Boolean markedEmailAsSpam) { + this.markedEmailAsSpam = Optional.ofNullable(markedEmailAsSpam); + return this; + } + + /** + *

Whether the contact is unsubscribed from emails.

+ */ + @JsonSetter(value = "unsubscribed_from_emails", nulls = Nulls.SKIP) + public Builder unsubscribedFromEmails(Optional unsubscribedFromEmails) { + this.unsubscribedFromEmails = unsubscribedFromEmails; + return this; + } + + public Builder unsubscribedFromEmails(Boolean unsubscribedFromEmails) { + this.unsubscribedFromEmails = Optional.ofNullable(unsubscribedFromEmails); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact was created.

+ */ + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public Builder createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + public Builder createdAt(Integer createdAt) { + this.createdAt = Optional.ofNullable(createdAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact was last updated.

+ */ + @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) + public Builder updatedAt(Optional updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + public Builder updatedAt(Integer updatedAt) { + this.updatedAt = Optional.ofNullable(updatedAt); + return this; + } + + /** + *

(UNIX timestamp) The time specified for when a contact signed up.

+ */ + @JsonSetter(value = "signed_up_at", nulls = Nulls.SKIP) + public Builder signedUpAt(Optional signedUpAt) { + this.signedUpAt = signedUpAt; + return this; + } + + public Builder signedUpAt(Integer signedUpAt) { + this.signedUpAt = Optional.ofNullable(signedUpAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact was last seen (either where the Intercom Messenger was installed or when specified manually).

+ */ + @JsonSetter(value = "last_seen_at", nulls = Nulls.SKIP) + public Builder lastSeenAt(Optional lastSeenAt) { + this.lastSeenAt = lastSeenAt; + return this; + } + + public Builder lastSeenAt(Integer lastSeenAt) { + this.lastSeenAt = Optional.ofNullable(lastSeenAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact last messaged in.

+ */ + @JsonSetter(value = "last_replied_at", nulls = Nulls.SKIP) + public Builder lastRepliedAt(Optional lastRepliedAt) { + this.lastRepliedAt = lastRepliedAt; + return this; + } + + public Builder lastRepliedAt(Integer lastRepliedAt) { + this.lastRepliedAt = Optional.ofNullable(lastRepliedAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact was last messaged.

+ */ + @JsonSetter(value = "last_contacted_at", nulls = Nulls.SKIP) + public Builder lastContactedAt(Optional lastContactedAt) { + this.lastContactedAt = lastContactedAt; + return this; + } + + public Builder lastContactedAt(Integer lastContactedAt) { + this.lastContactedAt = Optional.ofNullable(lastContactedAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact last opened an email.

+ */ + @JsonSetter(value = "last_email_opened_at", nulls = Nulls.SKIP) + public Builder lastEmailOpenedAt(Optional lastEmailOpenedAt) { + this.lastEmailOpenedAt = lastEmailOpenedAt; + return this; + } + + public Builder lastEmailOpenedAt(Integer lastEmailOpenedAt) { + this.lastEmailOpenedAt = Optional.ofNullable(lastEmailOpenedAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact last clicked a link in an email.

+ */ + @JsonSetter(value = "last_email_clicked_at", nulls = Nulls.SKIP) + public Builder lastEmailClickedAt(Optional lastEmailClickedAt) { + this.lastEmailClickedAt = lastEmailClickedAt; + return this; + } + + public Builder lastEmailClickedAt(Integer lastEmailClickedAt) { + this.lastEmailClickedAt = Optional.ofNullable(lastEmailClickedAt); + return this; + } + + /** + *

A preferred language setting for the contact, used by the Intercom Messenger even if their browser settings change.

+ */ + @JsonSetter(value = "language_override", nulls = Nulls.SKIP) + public Builder languageOverride(Optional languageOverride) { + this.languageOverride = languageOverride; + return this; + } + + public Builder languageOverride(String languageOverride) { + this.languageOverride = Optional.ofNullable(languageOverride); + return this; + } + + /** + *

The name of the browser which the contact is using.

+ */ + @JsonSetter(value = "browser", nulls = Nulls.SKIP) + public Builder browser(Optional browser) { + this.browser = browser; + return this; + } + + public Builder browser(String browser) { + this.browser = Optional.ofNullable(browser); + return this; + } + + /** + *

The version of the browser which the contact is using.

+ */ + @JsonSetter(value = "browser_version", nulls = Nulls.SKIP) + public Builder browserVersion(Optional browserVersion) { + this.browserVersion = browserVersion; + return this; + } + + public Builder browserVersion(String browserVersion) { + this.browserVersion = Optional.ofNullable(browserVersion); + return this; + } + + /** + *

The language set by the browser which the contact is using.

+ */ + @JsonSetter(value = "browser_language", nulls = Nulls.SKIP) + public Builder browserLanguage(Optional browserLanguage) { + this.browserLanguage = browserLanguage; + return this; + } + + public Builder browserLanguage(String browserLanguage) { + this.browserLanguage = Optional.ofNullable(browserLanguage); + return this; + } + + /** + *

The operating system which the contact is using.

+ */ + @JsonSetter(value = "os", nulls = Nulls.SKIP) + public Builder os(Optional os) { + this.os = os; + return this; + } + + public Builder os(String os) { + this.os = Optional.ofNullable(os); + return this; + } + + /** + *

The name of the Android app which the contact is using.

+ */ + @JsonSetter(value = "android_app_name", nulls = Nulls.SKIP) + public Builder androidAppName(Optional androidAppName) { + this.androidAppName = androidAppName; + return this; + } + + public Builder androidAppName(String androidAppName) { + this.androidAppName = Optional.ofNullable(androidAppName); + return this; + } + + /** + *

The version of the Android app which the contact is using.

+ */ + @JsonSetter(value = "android_app_version", nulls = Nulls.SKIP) + public Builder androidAppVersion(Optional androidAppVersion) { + this.androidAppVersion = androidAppVersion; + return this; + } + + public Builder androidAppVersion(String androidAppVersion) { + this.androidAppVersion = Optional.ofNullable(androidAppVersion); + return this; + } + + /** + *

The Android device which the contact is using.

+ */ + @JsonSetter(value = "android_device", nulls = Nulls.SKIP) + public Builder androidDevice(Optional androidDevice) { + this.androidDevice = androidDevice; + return this; + } + + public Builder androidDevice(String androidDevice) { + this.androidDevice = Optional.ofNullable(androidDevice); + return this; + } + + /** + *

The version of the Android OS which the contact is using.

+ */ + @JsonSetter(value = "android_os_version", nulls = Nulls.SKIP) + public Builder androidOsVersion(Optional androidOsVersion) { + this.androidOsVersion = androidOsVersion; + return this; + } + + public Builder androidOsVersion(String androidOsVersion) { + this.androidOsVersion = Optional.ofNullable(androidOsVersion); + return this; + } + + /** + *

The version of the Android SDK which the contact is using.

+ */ + @JsonSetter(value = "android_sdk_version", nulls = Nulls.SKIP) + public Builder androidSdkVersion(Optional androidSdkVersion) { + this.androidSdkVersion = androidSdkVersion; + return this; + } + + public Builder androidSdkVersion(String androidSdkVersion) { + this.androidSdkVersion = Optional.ofNullable(androidSdkVersion); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact was last seen on an Android device.

+ */ + @JsonSetter(value = "android_last_seen_at", nulls = Nulls.SKIP) + public Builder androidLastSeenAt(Optional androidLastSeenAt) { + this.androidLastSeenAt = androidLastSeenAt; + return this; + } + + public Builder androidLastSeenAt(Integer androidLastSeenAt) { + this.androidLastSeenAt = Optional.ofNullable(androidLastSeenAt); + return this; + } + + /** + *

The name of the iOS app which the contact is using.

+ */ + @JsonSetter(value = "ios_app_name", nulls = Nulls.SKIP) + public Builder iosAppName(Optional iosAppName) { + this.iosAppName = iosAppName; + return this; + } + + public Builder iosAppName(String iosAppName) { + this.iosAppName = Optional.ofNullable(iosAppName); + return this; + } + + /** + *

The version of the iOS app which the contact is using.

+ */ + @JsonSetter(value = "ios_app_version", nulls = Nulls.SKIP) + public Builder iosAppVersion(Optional iosAppVersion) { + this.iosAppVersion = iosAppVersion; + return this; + } + + public Builder iosAppVersion(String iosAppVersion) { + this.iosAppVersion = Optional.ofNullable(iosAppVersion); + return this; + } + + /** + *

The iOS device which the contact is using.

+ */ + @JsonSetter(value = "ios_device", nulls = Nulls.SKIP) + public Builder iosDevice(Optional iosDevice) { + this.iosDevice = iosDevice; + return this; + } + + public Builder iosDevice(String iosDevice) { + this.iosDevice = Optional.ofNullable(iosDevice); + return this; + } + + /** + *

The version of iOS which the contact is using.

+ */ + @JsonSetter(value = "ios_os_version", nulls = Nulls.SKIP) + public Builder iosOsVersion(Optional iosOsVersion) { + this.iosOsVersion = iosOsVersion; + return this; + } + + public Builder iosOsVersion(String iosOsVersion) { + this.iosOsVersion = Optional.ofNullable(iosOsVersion); + return this; + } + + /** + *

The version of the iOS SDK which the contact is using.

+ */ + @JsonSetter(value = "ios_sdk_version", nulls = Nulls.SKIP) + public Builder iosSdkVersion(Optional iosSdkVersion) { + this.iosSdkVersion = iosSdkVersion; + return this; + } + + public Builder iosSdkVersion(String iosSdkVersion) { + this.iosSdkVersion = Optional.ofNullable(iosSdkVersion); + return this; + } + + /** + *

(UNIX timestamp) The last time the contact used the iOS app.

+ */ + @JsonSetter(value = "ios_last_seen_at", nulls = Nulls.SKIP) + public Builder iosLastSeenAt(Optional iosLastSeenAt) { + this.iosLastSeenAt = iosLastSeenAt; + return this; + } + + public Builder iosLastSeenAt(Integer iosLastSeenAt) { + this.iosLastSeenAt = Optional.ofNullable(iosLastSeenAt); + return this; + } + + /** + *

The custom attributes which are set for the contact.

+ */ + @JsonSetter(value = "custom_attributes", nulls = Nulls.SKIP) + public Builder customAttributes(Optional> customAttributes) { + this.customAttributes = customAttributes; + return this; + } + + public Builder customAttributes(Map customAttributes) { + this.customAttributes = Optional.ofNullable(customAttributes); + return this; + } + + /** + *

An image URL containing the avatar of a contact.

+ */ + @JsonSetter(value = "avatar", nulls = Nulls.SKIP) + public Builder avatar(Optional avatar) { + this.avatar = avatar; + return this; + } + + public Builder avatar(String avatar) { + this.avatar = Optional.ofNullable(avatar); + return this; + } + + @JsonSetter(value = "tags", nulls = Nulls.SKIP) + public Builder tags(Optional tags) { + this.tags = tags; + return this; + } + + public Builder tags(ContactTags tags) { + this.tags = Optional.ofNullable(tags); + return this; + } + + @JsonSetter(value = "notes", nulls = Nulls.SKIP) + public Builder notes(Optional notes) { + this.notes = notes; + return this; + } + + public Builder notes(ContactNotes notes) { + this.notes = Optional.ofNullable(notes); + return this; + } + + @JsonSetter(value = "companies", nulls = Nulls.SKIP) + public Builder companies(Optional companies) { + this.companies = companies; + return this; + } + + public Builder companies(ContactCompanies companies) { + this.companies = Optional.ofNullable(companies); + return this; + } + + @JsonSetter(value = "location", nulls = Nulls.SKIP) + public Builder location(Optional location) { + this.location = location; + return this; + } + + public Builder location(ContactLocation location) { + this.location = Optional.ofNullable(location); + return this; + } + + @JsonSetter(value = "social_profiles", nulls = Nulls.SKIP) + public Builder socialProfiles(Optional socialProfiles) { + this.socialProfiles = socialProfiles; + return this; + } + + public Builder socialProfiles(ContactSocialProfiles socialProfiles) { + this.socialProfiles = Optional.ofNullable(socialProfiles); + return this; + } + + /** + *

If the user has enabled push messaging.

+ */ + @JsonSetter(value = "enabled_push_messaging", nulls = Nulls.SKIP) + public Builder enabledPushMessaging(Optional enabledPushMessaging) { + this.enabledPushMessaging = enabledPushMessaging; + return this; + } + + public Builder enabledPushMessaging(Boolean enabledPushMessaging) { + this.enabledPushMessaging = Optional.ofNullable(enabledPushMessaging); + return this; + } + + public ContactsCreateResponse build() { + return new ContactsCreateResponse( + type, + id, + externalId, + workspaceId, + role, + email, + emailDomain, + phone, + name, + ownerId, + hasHardBounced, + markedEmailAsSpam, + unsubscribedFromEmails, + createdAt, + updatedAt, + signedUpAt, + lastSeenAt, + lastRepliedAt, + lastContactedAt, + lastEmailOpenedAt, + lastEmailClickedAt, + languageOverride, + browser, + browserVersion, + browserLanguage, + os, + androidAppName, + androidAppVersion, + androidDevice, + androidOsVersion, + androidSdkVersion, + androidLastSeenAt, + iosAppName, + iosAppVersion, + iosDevice, + iosOsVersion, + iosSdkVersion, + iosLastSeenAt, + customAttributes, + avatar, + tags, + notes, + companies, + location, + socialProfiles, + enabledPushMessaging, + additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/contacts/types/ContactsFindResponse.java b/src/main/java/com/intercom/api/resources/contacts/types/ContactsFindResponse.java new file mode 100644 index 0000000..3d95a6d --- /dev/null +++ b/src/main/java/com/intercom/api/resources/contacts/types/ContactsFindResponse.java @@ -0,0 +1,1521 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.contacts.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.types.ContactCompanies; +import com.intercom.api.types.ContactLocation; +import com.intercom.api.types.ContactNotes; +import com.intercom.api.types.ContactSocialProfiles; +import com.intercom.api.types.ContactTags; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ContactsFindResponse.Builder.class) +public final class ContactsFindResponse implements IContact { + private final Optional type; + + private final Optional id; + + private final Optional externalId; + + private final Optional workspaceId; + + private final Optional role; + + private final Optional email; + + private final Optional emailDomain; + + private final Optional phone; + + private final Optional name; + + private final Optional ownerId; + + private final Optional hasHardBounced; + + private final Optional markedEmailAsSpam; + + private final Optional unsubscribedFromEmails; + + private final Optional createdAt; + + private final Optional updatedAt; + + private final Optional signedUpAt; + + private final Optional lastSeenAt; + + private final Optional lastRepliedAt; + + private final Optional lastContactedAt; + + private final Optional lastEmailOpenedAt; + + private final Optional lastEmailClickedAt; + + private final Optional languageOverride; + + private final Optional browser; + + private final Optional browserVersion; + + private final Optional browserLanguage; + + private final Optional os; + + private final Optional androidAppName; + + private final Optional androidAppVersion; + + private final Optional androidDevice; + + private final Optional androidOsVersion; + + private final Optional androidSdkVersion; + + private final Optional androidLastSeenAt; + + private final Optional iosAppName; + + private final Optional iosAppVersion; + + private final Optional iosDevice; + + private final Optional iosOsVersion; + + private final Optional iosSdkVersion; + + private final Optional iosLastSeenAt; + + private final Optional> customAttributes; + + private final Optional avatar; + + private final Optional tags; + + private final Optional notes; + + private final Optional companies; + + private final Optional location; + + private final Optional socialProfiles; + + private final Optional enabledPushMessaging; + + private final Map additionalProperties; + + private ContactsFindResponse( + Optional type, + Optional id, + Optional externalId, + Optional workspaceId, + Optional role, + Optional email, + Optional emailDomain, + Optional phone, + Optional name, + Optional ownerId, + Optional hasHardBounced, + Optional markedEmailAsSpam, + Optional unsubscribedFromEmails, + Optional createdAt, + Optional updatedAt, + Optional signedUpAt, + Optional lastSeenAt, + Optional lastRepliedAt, + Optional lastContactedAt, + Optional lastEmailOpenedAt, + Optional lastEmailClickedAt, + Optional languageOverride, + Optional browser, + Optional browserVersion, + Optional browserLanguage, + Optional os, + Optional androidAppName, + Optional androidAppVersion, + Optional androidDevice, + Optional androidOsVersion, + Optional androidSdkVersion, + Optional androidLastSeenAt, + Optional iosAppName, + Optional iosAppVersion, + Optional iosDevice, + Optional iosOsVersion, + Optional iosSdkVersion, + Optional iosLastSeenAt, + Optional> customAttributes, + Optional avatar, + Optional tags, + Optional notes, + Optional companies, + Optional location, + Optional socialProfiles, + Optional enabledPushMessaging, + Map additionalProperties) { + this.type = type; + this.id = id; + this.externalId = externalId; + this.workspaceId = workspaceId; + this.role = role; + this.email = email; + this.emailDomain = emailDomain; + this.phone = phone; + this.name = name; + this.ownerId = ownerId; + this.hasHardBounced = hasHardBounced; + this.markedEmailAsSpam = markedEmailAsSpam; + this.unsubscribedFromEmails = unsubscribedFromEmails; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.signedUpAt = signedUpAt; + this.lastSeenAt = lastSeenAt; + this.lastRepliedAt = lastRepliedAt; + this.lastContactedAt = lastContactedAt; + this.lastEmailOpenedAt = lastEmailOpenedAt; + this.lastEmailClickedAt = lastEmailClickedAt; + this.languageOverride = languageOverride; + this.browser = browser; + this.browserVersion = browserVersion; + this.browserLanguage = browserLanguage; + this.os = os; + this.androidAppName = androidAppName; + this.androidAppVersion = androidAppVersion; + this.androidDevice = androidDevice; + this.androidOsVersion = androidOsVersion; + this.androidSdkVersion = androidSdkVersion; + this.androidLastSeenAt = androidLastSeenAt; + this.iosAppName = iosAppName; + this.iosAppVersion = iosAppVersion; + this.iosDevice = iosDevice; + this.iosOsVersion = iosOsVersion; + this.iosSdkVersion = iosSdkVersion; + this.iosLastSeenAt = iosLastSeenAt; + this.customAttributes = customAttributes; + this.avatar = avatar; + this.tags = tags; + this.notes = notes; + this.companies = companies; + this.location = location; + this.socialProfiles = socialProfiles; + this.enabledPushMessaging = enabledPushMessaging; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of object. + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return The unique identifier for the contact which is given by Intercom. + */ + @JsonProperty("id") + public Optional getId() { + return id; + } + + /** + * @return The unique identifier for the contact which is provided by the Client. + */ + @JsonProperty("external_id") + public Optional getExternalId() { + return externalId; + } + + /** + * @return The id of the workspace which the contact belongs to. + */ + @JsonProperty("workspace_id") + public Optional getWorkspaceId() { + return workspaceId; + } + + /** + * @return The role of the contact. + */ + @JsonProperty("role") + public Optional getRole() { + return role; + } + + /** + * @return The contact's email. + */ + @JsonProperty("email") + public Optional getEmail() { + return email; + } + + /** + * @return The contact's email domain. + */ + @JsonProperty("email_domain") + public Optional getEmailDomain() { + return emailDomain; + } + + /** + * @return The contacts phone. + */ + @JsonProperty("phone") + public Optional getPhone() { + return phone; + } + + /** + * @return The contacts name. + */ + @JsonProperty("name") + public Optional getName() { + return name; + } + + /** + * @return The id of an admin that has been assigned account ownership of the contact. + */ + @JsonProperty("owner_id") + public Optional getOwnerId() { + return ownerId; + } + + /** + * @return Whether the contact has had an email sent to them hard bounce. + */ + @JsonProperty("has_hard_bounced") + public Optional getHasHardBounced() { + return hasHardBounced; + } + + /** + * @return Whether the contact has marked an email sent to them as spam. + */ + @JsonProperty("marked_email_as_spam") + public Optional getMarkedEmailAsSpam() { + return markedEmailAsSpam; + } + + /** + * @return Whether the contact is unsubscribed from emails. + */ + @JsonProperty("unsubscribed_from_emails") + public Optional getUnsubscribedFromEmails() { + return unsubscribedFromEmails; + } + + /** + * @return (UNIX timestamp) The time when the contact was created. + */ + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + /** + * @return (UNIX timestamp) The time when the contact was last updated. + */ + @JsonProperty("updated_at") + public Optional getUpdatedAt() { + return updatedAt; + } + + /** + * @return (UNIX timestamp) The time specified for when a contact signed up. + */ + @JsonProperty("signed_up_at") + public Optional getSignedUpAt() { + return signedUpAt; + } + + /** + * @return (UNIX timestamp) The time when the contact was last seen (either where the Intercom Messenger was installed or when specified manually). + */ + @JsonProperty("last_seen_at") + public Optional getLastSeenAt() { + return lastSeenAt; + } + + /** + * @return (UNIX timestamp) The time when the contact last messaged in. + */ + @JsonProperty("last_replied_at") + public Optional getLastRepliedAt() { + return lastRepliedAt; + } + + /** + * @return (UNIX timestamp) The time when the contact was last messaged. + */ + @JsonProperty("last_contacted_at") + public Optional getLastContactedAt() { + return lastContactedAt; + } + + /** + * @return (UNIX timestamp) The time when the contact last opened an email. + */ + @JsonProperty("last_email_opened_at") + public Optional getLastEmailOpenedAt() { + return lastEmailOpenedAt; + } + + /** + * @return (UNIX timestamp) The time when the contact last clicked a link in an email. + */ + @JsonProperty("last_email_clicked_at") + public Optional getLastEmailClickedAt() { + return lastEmailClickedAt; + } + + /** + * @return A preferred language setting for the contact, used by the Intercom Messenger even if their browser settings change. + */ + @JsonProperty("language_override") + public Optional getLanguageOverride() { + return languageOverride; + } + + /** + * @return The name of the browser which the contact is using. + */ + @JsonProperty("browser") + public Optional getBrowser() { + return browser; + } + + /** + * @return The version of the browser which the contact is using. + */ + @JsonProperty("browser_version") + public Optional getBrowserVersion() { + return browserVersion; + } + + /** + * @return The language set by the browser which the contact is using. + */ + @JsonProperty("browser_language") + public Optional getBrowserLanguage() { + return browserLanguage; + } + + /** + * @return The operating system which the contact is using. + */ + @JsonProperty("os") + public Optional getOs() { + return os; + } + + /** + * @return The name of the Android app which the contact is using. + */ + @JsonProperty("android_app_name") + public Optional getAndroidAppName() { + return androidAppName; + } + + /** + * @return The version of the Android app which the contact is using. + */ + @JsonProperty("android_app_version") + public Optional getAndroidAppVersion() { + return androidAppVersion; + } + + /** + * @return The Android device which the contact is using. + */ + @JsonProperty("android_device") + public Optional getAndroidDevice() { + return androidDevice; + } + + /** + * @return The version of the Android OS which the contact is using. + */ + @JsonProperty("android_os_version") + public Optional getAndroidOsVersion() { + return androidOsVersion; + } + + /** + * @return The version of the Android SDK which the contact is using. + */ + @JsonProperty("android_sdk_version") + public Optional getAndroidSdkVersion() { + return androidSdkVersion; + } + + /** + * @return (UNIX timestamp) The time when the contact was last seen on an Android device. + */ + @JsonProperty("android_last_seen_at") + public Optional getAndroidLastSeenAt() { + return androidLastSeenAt; + } + + /** + * @return The name of the iOS app which the contact is using. + */ + @JsonProperty("ios_app_name") + public Optional getIosAppName() { + return iosAppName; + } + + /** + * @return The version of the iOS app which the contact is using. + */ + @JsonProperty("ios_app_version") + public Optional getIosAppVersion() { + return iosAppVersion; + } + + /** + * @return The iOS device which the contact is using. + */ + @JsonProperty("ios_device") + public Optional getIosDevice() { + return iosDevice; + } + + /** + * @return The version of iOS which the contact is using. + */ + @JsonProperty("ios_os_version") + public Optional getIosOsVersion() { + return iosOsVersion; + } + + /** + * @return The version of the iOS SDK which the contact is using. + */ + @JsonProperty("ios_sdk_version") + public Optional getIosSdkVersion() { + return iosSdkVersion; + } + + /** + * @return (UNIX timestamp) The last time the contact used the iOS app. + */ + @JsonProperty("ios_last_seen_at") + public Optional getIosLastSeenAt() { + return iosLastSeenAt; + } + + /** + * @return The custom attributes which are set for the contact. + */ + @JsonProperty("custom_attributes") + public Optional> getCustomAttributes() { + return customAttributes; + } + + /** + * @return An image URL containing the avatar of a contact. + */ + @JsonProperty("avatar") + public Optional getAvatar() { + return avatar; + } + + @JsonProperty("tags") + public Optional getTags() { + return tags; + } + + @JsonProperty("notes") + public Optional getNotes() { + return notes; + } + + @JsonProperty("companies") + public Optional getCompanies() { + return companies; + } + + @JsonProperty("location") + public Optional getLocation() { + return location; + } + + @JsonProperty("social_profiles") + public Optional getSocialProfiles() { + return socialProfiles; + } + + /** + * @return If the user has enabled push messaging. + */ + @JsonProperty("enabled_push_messaging") + public Optional getEnabledPushMessaging() { + return enabledPushMessaging; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ContactsFindResponse && equalTo((ContactsFindResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ContactsFindResponse other) { + return type.equals(other.type) + && id.equals(other.id) + && externalId.equals(other.externalId) + && workspaceId.equals(other.workspaceId) + && role.equals(other.role) + && email.equals(other.email) + && emailDomain.equals(other.emailDomain) + && phone.equals(other.phone) + && name.equals(other.name) + && ownerId.equals(other.ownerId) + && hasHardBounced.equals(other.hasHardBounced) + && markedEmailAsSpam.equals(other.markedEmailAsSpam) + && unsubscribedFromEmails.equals(other.unsubscribedFromEmails) + && createdAt.equals(other.createdAt) + && updatedAt.equals(other.updatedAt) + && signedUpAt.equals(other.signedUpAt) + && lastSeenAt.equals(other.lastSeenAt) + && lastRepliedAt.equals(other.lastRepliedAt) + && lastContactedAt.equals(other.lastContactedAt) + && lastEmailOpenedAt.equals(other.lastEmailOpenedAt) + && lastEmailClickedAt.equals(other.lastEmailClickedAt) + && languageOverride.equals(other.languageOverride) + && browser.equals(other.browser) + && browserVersion.equals(other.browserVersion) + && browserLanguage.equals(other.browserLanguage) + && os.equals(other.os) + && androidAppName.equals(other.androidAppName) + && androidAppVersion.equals(other.androidAppVersion) + && androidDevice.equals(other.androidDevice) + && androidOsVersion.equals(other.androidOsVersion) + && androidSdkVersion.equals(other.androidSdkVersion) + && androidLastSeenAt.equals(other.androidLastSeenAt) + && iosAppName.equals(other.iosAppName) + && iosAppVersion.equals(other.iosAppVersion) + && iosDevice.equals(other.iosDevice) + && iosOsVersion.equals(other.iosOsVersion) + && iosSdkVersion.equals(other.iosSdkVersion) + && iosLastSeenAt.equals(other.iosLastSeenAt) + && customAttributes.equals(other.customAttributes) + && avatar.equals(other.avatar) + && tags.equals(other.tags) + && notes.equals(other.notes) + && companies.equals(other.companies) + && location.equals(other.location) + && socialProfiles.equals(other.socialProfiles) + && enabledPushMessaging.equals(other.enabledPushMessaging); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.type, + this.id, + this.externalId, + this.workspaceId, + this.role, + this.email, + this.emailDomain, + this.phone, + this.name, + this.ownerId, + this.hasHardBounced, + this.markedEmailAsSpam, + this.unsubscribedFromEmails, + this.createdAt, + this.updatedAt, + this.signedUpAt, + this.lastSeenAt, + this.lastRepliedAt, + this.lastContactedAt, + this.lastEmailOpenedAt, + this.lastEmailClickedAt, + this.languageOverride, + this.browser, + this.browserVersion, + this.browserLanguage, + this.os, + this.androidAppName, + this.androidAppVersion, + this.androidDevice, + this.androidOsVersion, + this.androidSdkVersion, + this.androidLastSeenAt, + this.iosAppName, + this.iosAppVersion, + this.iosDevice, + this.iosOsVersion, + this.iosSdkVersion, + this.iosLastSeenAt, + this.customAttributes, + this.avatar, + this.tags, + this.notes, + this.companies, + this.location, + this.socialProfiles, + this.enabledPushMessaging); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); + + private Optional id = Optional.empty(); + + private Optional externalId = Optional.empty(); + + private Optional workspaceId = Optional.empty(); + + private Optional role = Optional.empty(); + + private Optional email = Optional.empty(); + + private Optional emailDomain = Optional.empty(); + + private Optional phone = Optional.empty(); + + private Optional name = Optional.empty(); + + private Optional ownerId = Optional.empty(); + + private Optional hasHardBounced = Optional.empty(); + + private Optional markedEmailAsSpam = Optional.empty(); + + private Optional unsubscribedFromEmails = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + private Optional updatedAt = Optional.empty(); + + private Optional signedUpAt = Optional.empty(); + + private Optional lastSeenAt = Optional.empty(); + + private Optional lastRepliedAt = Optional.empty(); + + private Optional lastContactedAt = Optional.empty(); + + private Optional lastEmailOpenedAt = Optional.empty(); + + private Optional lastEmailClickedAt = Optional.empty(); + + private Optional languageOverride = Optional.empty(); + + private Optional browser = Optional.empty(); + + private Optional browserVersion = Optional.empty(); + + private Optional browserLanguage = Optional.empty(); + + private Optional os = Optional.empty(); + + private Optional androidAppName = Optional.empty(); + + private Optional androidAppVersion = Optional.empty(); + + private Optional androidDevice = Optional.empty(); + + private Optional androidOsVersion = Optional.empty(); + + private Optional androidSdkVersion = Optional.empty(); + + private Optional androidLastSeenAt = Optional.empty(); + + private Optional iosAppName = Optional.empty(); + + private Optional iosAppVersion = Optional.empty(); + + private Optional iosDevice = Optional.empty(); + + private Optional iosOsVersion = Optional.empty(); + + private Optional iosSdkVersion = Optional.empty(); + + private Optional iosLastSeenAt = Optional.empty(); + + private Optional> customAttributes = Optional.empty(); + + private Optional avatar = Optional.empty(); + + private Optional tags = Optional.empty(); + + private Optional notes = Optional.empty(); + + private Optional companies = Optional.empty(); + + private Optional location = Optional.empty(); + + private Optional socialProfiles = Optional.empty(); + + private Optional enabledPushMessaging = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ContactsFindResponse other) { + type(other.getType()); + id(other.getId()); + externalId(other.getExternalId()); + workspaceId(other.getWorkspaceId()); + role(other.getRole()); + email(other.getEmail()); + emailDomain(other.getEmailDomain()); + phone(other.getPhone()); + name(other.getName()); + ownerId(other.getOwnerId()); + hasHardBounced(other.getHasHardBounced()); + markedEmailAsSpam(other.getMarkedEmailAsSpam()); + unsubscribedFromEmails(other.getUnsubscribedFromEmails()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + signedUpAt(other.getSignedUpAt()); + lastSeenAt(other.getLastSeenAt()); + lastRepliedAt(other.getLastRepliedAt()); + lastContactedAt(other.getLastContactedAt()); + lastEmailOpenedAt(other.getLastEmailOpenedAt()); + lastEmailClickedAt(other.getLastEmailClickedAt()); + languageOverride(other.getLanguageOverride()); + browser(other.getBrowser()); + browserVersion(other.getBrowserVersion()); + browserLanguage(other.getBrowserLanguage()); + os(other.getOs()); + androidAppName(other.getAndroidAppName()); + androidAppVersion(other.getAndroidAppVersion()); + androidDevice(other.getAndroidDevice()); + androidOsVersion(other.getAndroidOsVersion()); + androidSdkVersion(other.getAndroidSdkVersion()); + androidLastSeenAt(other.getAndroidLastSeenAt()); + iosAppName(other.getIosAppName()); + iosAppVersion(other.getIosAppVersion()); + iosDevice(other.getIosDevice()); + iosOsVersion(other.getIosOsVersion()); + iosSdkVersion(other.getIosSdkVersion()); + iosLastSeenAt(other.getIosLastSeenAt()); + customAttributes(other.getCustomAttributes()); + avatar(other.getAvatar()); + tags(other.getTags()); + notes(other.getNotes()); + companies(other.getCompanies()); + location(other.getLocation()); + socialProfiles(other.getSocialProfiles()); + enabledPushMessaging(other.getEnabledPushMessaging()); + return this; + } + + /** + *

The type of object.

+ */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + /** + *

The unique identifier for the contact which is given by Intercom.

+ */ + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.ofNullable(id); + return this; + } + + /** + *

The unique identifier for the contact which is provided by the Client.

+ */ + @JsonSetter(value = "external_id", nulls = Nulls.SKIP) + public Builder externalId(Optional externalId) { + this.externalId = externalId; + return this; + } + + public Builder externalId(String externalId) { + this.externalId = Optional.ofNullable(externalId); + return this; + } + + /** + *

The id of the workspace which the contact belongs to.

+ */ + @JsonSetter(value = "workspace_id", nulls = Nulls.SKIP) + public Builder workspaceId(Optional workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + public Builder workspaceId(String workspaceId) { + this.workspaceId = Optional.ofNullable(workspaceId); + return this; + } + + /** + *

The role of the contact.

+ */ + @JsonSetter(value = "role", nulls = Nulls.SKIP) + public Builder role(Optional role) { + this.role = role; + return this; + } + + public Builder role(String role) { + this.role = Optional.ofNullable(role); + return this; + } + + /** + *

The contact's email.

+ */ + @JsonSetter(value = "email", nulls = Nulls.SKIP) + public Builder email(Optional email) { + this.email = email; + return this; + } + + public Builder email(String email) { + this.email = Optional.ofNullable(email); + return this; + } + + /** + *

The contact's email domain.

+ */ + @JsonSetter(value = "email_domain", nulls = Nulls.SKIP) + public Builder emailDomain(Optional emailDomain) { + this.emailDomain = emailDomain; + return this; + } + + public Builder emailDomain(String emailDomain) { + this.emailDomain = Optional.ofNullable(emailDomain); + return this; + } + + /** + *

The contacts phone.

+ */ + @JsonSetter(value = "phone", nulls = Nulls.SKIP) + public Builder phone(Optional phone) { + this.phone = phone; + return this; + } + + public Builder phone(String phone) { + this.phone = Optional.ofNullable(phone); + return this; + } + + /** + *

The contacts name.

+ */ + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public Builder name(Optional name) { + this.name = name; + return this; + } + + public Builder name(String name) { + this.name = Optional.ofNullable(name); + return this; + } + + /** + *

The id of an admin that has been assigned account ownership of the contact.

+ */ + @JsonSetter(value = "owner_id", nulls = Nulls.SKIP) + public Builder ownerId(Optional ownerId) { + this.ownerId = ownerId; + return this; + } + + public Builder ownerId(Integer ownerId) { + this.ownerId = Optional.ofNullable(ownerId); + return this; + } + + /** + *

Whether the contact has had an email sent to them hard bounce.

+ */ + @JsonSetter(value = "has_hard_bounced", nulls = Nulls.SKIP) + public Builder hasHardBounced(Optional hasHardBounced) { + this.hasHardBounced = hasHardBounced; + return this; + } + + public Builder hasHardBounced(Boolean hasHardBounced) { + this.hasHardBounced = Optional.ofNullable(hasHardBounced); + return this; + } + + /** + *

Whether the contact has marked an email sent to them as spam.

+ */ + @JsonSetter(value = "marked_email_as_spam", nulls = Nulls.SKIP) + public Builder markedEmailAsSpam(Optional markedEmailAsSpam) { + this.markedEmailAsSpam = markedEmailAsSpam; + return this; + } + + public Builder markedEmailAsSpam(Boolean markedEmailAsSpam) { + this.markedEmailAsSpam = Optional.ofNullable(markedEmailAsSpam); + return this; + } + + /** + *

Whether the contact is unsubscribed from emails.

+ */ + @JsonSetter(value = "unsubscribed_from_emails", nulls = Nulls.SKIP) + public Builder unsubscribedFromEmails(Optional unsubscribedFromEmails) { + this.unsubscribedFromEmails = unsubscribedFromEmails; + return this; + } + + public Builder unsubscribedFromEmails(Boolean unsubscribedFromEmails) { + this.unsubscribedFromEmails = Optional.ofNullable(unsubscribedFromEmails); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact was created.

+ */ + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public Builder createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + public Builder createdAt(Integer createdAt) { + this.createdAt = Optional.ofNullable(createdAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact was last updated.

+ */ + @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) + public Builder updatedAt(Optional updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + public Builder updatedAt(Integer updatedAt) { + this.updatedAt = Optional.ofNullable(updatedAt); + return this; + } + + /** + *

(UNIX timestamp) The time specified for when a contact signed up.

+ */ + @JsonSetter(value = "signed_up_at", nulls = Nulls.SKIP) + public Builder signedUpAt(Optional signedUpAt) { + this.signedUpAt = signedUpAt; + return this; + } + + public Builder signedUpAt(Integer signedUpAt) { + this.signedUpAt = Optional.ofNullable(signedUpAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact was last seen (either where the Intercom Messenger was installed or when specified manually).

+ */ + @JsonSetter(value = "last_seen_at", nulls = Nulls.SKIP) + public Builder lastSeenAt(Optional lastSeenAt) { + this.lastSeenAt = lastSeenAt; + return this; + } + + public Builder lastSeenAt(Integer lastSeenAt) { + this.lastSeenAt = Optional.ofNullable(lastSeenAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact last messaged in.

+ */ + @JsonSetter(value = "last_replied_at", nulls = Nulls.SKIP) + public Builder lastRepliedAt(Optional lastRepliedAt) { + this.lastRepliedAt = lastRepliedAt; + return this; + } + + public Builder lastRepliedAt(Integer lastRepliedAt) { + this.lastRepliedAt = Optional.ofNullable(lastRepliedAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact was last messaged.

+ */ + @JsonSetter(value = "last_contacted_at", nulls = Nulls.SKIP) + public Builder lastContactedAt(Optional lastContactedAt) { + this.lastContactedAt = lastContactedAt; + return this; + } + + public Builder lastContactedAt(Integer lastContactedAt) { + this.lastContactedAt = Optional.ofNullable(lastContactedAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact last opened an email.

+ */ + @JsonSetter(value = "last_email_opened_at", nulls = Nulls.SKIP) + public Builder lastEmailOpenedAt(Optional lastEmailOpenedAt) { + this.lastEmailOpenedAt = lastEmailOpenedAt; + return this; + } + + public Builder lastEmailOpenedAt(Integer lastEmailOpenedAt) { + this.lastEmailOpenedAt = Optional.ofNullable(lastEmailOpenedAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact last clicked a link in an email.

+ */ + @JsonSetter(value = "last_email_clicked_at", nulls = Nulls.SKIP) + public Builder lastEmailClickedAt(Optional lastEmailClickedAt) { + this.lastEmailClickedAt = lastEmailClickedAt; + return this; + } + + public Builder lastEmailClickedAt(Integer lastEmailClickedAt) { + this.lastEmailClickedAt = Optional.ofNullable(lastEmailClickedAt); + return this; + } + + /** + *

A preferred language setting for the contact, used by the Intercom Messenger even if their browser settings change.

+ */ + @JsonSetter(value = "language_override", nulls = Nulls.SKIP) + public Builder languageOverride(Optional languageOverride) { + this.languageOverride = languageOverride; + return this; + } + + public Builder languageOverride(String languageOverride) { + this.languageOverride = Optional.ofNullable(languageOverride); + return this; + } + + /** + *

The name of the browser which the contact is using.

+ */ + @JsonSetter(value = "browser", nulls = Nulls.SKIP) + public Builder browser(Optional browser) { + this.browser = browser; + return this; + } + + public Builder browser(String browser) { + this.browser = Optional.ofNullable(browser); + return this; + } + + /** + *

The version of the browser which the contact is using.

+ */ + @JsonSetter(value = "browser_version", nulls = Nulls.SKIP) + public Builder browserVersion(Optional browserVersion) { + this.browserVersion = browserVersion; + return this; + } + + public Builder browserVersion(String browserVersion) { + this.browserVersion = Optional.ofNullable(browserVersion); + return this; + } + + /** + *

The language set by the browser which the contact is using.

+ */ + @JsonSetter(value = "browser_language", nulls = Nulls.SKIP) + public Builder browserLanguage(Optional browserLanguage) { + this.browserLanguage = browserLanguage; + return this; + } + + public Builder browserLanguage(String browserLanguage) { + this.browserLanguage = Optional.ofNullable(browserLanguage); + return this; + } + + /** + *

The operating system which the contact is using.

+ */ + @JsonSetter(value = "os", nulls = Nulls.SKIP) + public Builder os(Optional os) { + this.os = os; + return this; + } + + public Builder os(String os) { + this.os = Optional.ofNullable(os); + return this; + } + + /** + *

The name of the Android app which the contact is using.

+ */ + @JsonSetter(value = "android_app_name", nulls = Nulls.SKIP) + public Builder androidAppName(Optional androidAppName) { + this.androidAppName = androidAppName; + return this; + } + + public Builder androidAppName(String androidAppName) { + this.androidAppName = Optional.ofNullable(androidAppName); + return this; + } + + /** + *

The version of the Android app which the contact is using.

+ */ + @JsonSetter(value = "android_app_version", nulls = Nulls.SKIP) + public Builder androidAppVersion(Optional androidAppVersion) { + this.androidAppVersion = androidAppVersion; + return this; + } + + public Builder androidAppVersion(String androidAppVersion) { + this.androidAppVersion = Optional.ofNullable(androidAppVersion); + return this; + } + + /** + *

The Android device which the contact is using.

+ */ + @JsonSetter(value = "android_device", nulls = Nulls.SKIP) + public Builder androidDevice(Optional androidDevice) { + this.androidDevice = androidDevice; + return this; + } + + public Builder androidDevice(String androidDevice) { + this.androidDevice = Optional.ofNullable(androidDevice); + return this; + } + + /** + *

The version of the Android OS which the contact is using.

+ */ + @JsonSetter(value = "android_os_version", nulls = Nulls.SKIP) + public Builder androidOsVersion(Optional androidOsVersion) { + this.androidOsVersion = androidOsVersion; + return this; + } + + public Builder androidOsVersion(String androidOsVersion) { + this.androidOsVersion = Optional.ofNullable(androidOsVersion); + return this; + } + + /** + *

The version of the Android SDK which the contact is using.

+ */ + @JsonSetter(value = "android_sdk_version", nulls = Nulls.SKIP) + public Builder androidSdkVersion(Optional androidSdkVersion) { + this.androidSdkVersion = androidSdkVersion; + return this; + } + + public Builder androidSdkVersion(String androidSdkVersion) { + this.androidSdkVersion = Optional.ofNullable(androidSdkVersion); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact was last seen on an Android device.

+ */ + @JsonSetter(value = "android_last_seen_at", nulls = Nulls.SKIP) + public Builder androidLastSeenAt(Optional androidLastSeenAt) { + this.androidLastSeenAt = androidLastSeenAt; + return this; + } + + public Builder androidLastSeenAt(Integer androidLastSeenAt) { + this.androidLastSeenAt = Optional.ofNullable(androidLastSeenAt); + return this; + } + + /** + *

The name of the iOS app which the contact is using.

+ */ + @JsonSetter(value = "ios_app_name", nulls = Nulls.SKIP) + public Builder iosAppName(Optional iosAppName) { + this.iosAppName = iosAppName; + return this; + } + + public Builder iosAppName(String iosAppName) { + this.iosAppName = Optional.ofNullable(iosAppName); + return this; + } + + /** + *

The version of the iOS app which the contact is using.

+ */ + @JsonSetter(value = "ios_app_version", nulls = Nulls.SKIP) + public Builder iosAppVersion(Optional iosAppVersion) { + this.iosAppVersion = iosAppVersion; + return this; + } + + public Builder iosAppVersion(String iosAppVersion) { + this.iosAppVersion = Optional.ofNullable(iosAppVersion); + return this; + } + + /** + *

The iOS device which the contact is using.

+ */ + @JsonSetter(value = "ios_device", nulls = Nulls.SKIP) + public Builder iosDevice(Optional iosDevice) { + this.iosDevice = iosDevice; + return this; + } + + public Builder iosDevice(String iosDevice) { + this.iosDevice = Optional.ofNullable(iosDevice); + return this; + } + + /** + *

The version of iOS which the contact is using.

+ */ + @JsonSetter(value = "ios_os_version", nulls = Nulls.SKIP) + public Builder iosOsVersion(Optional iosOsVersion) { + this.iosOsVersion = iosOsVersion; + return this; + } + + public Builder iosOsVersion(String iosOsVersion) { + this.iosOsVersion = Optional.ofNullable(iosOsVersion); + return this; + } + + /** + *

The version of the iOS SDK which the contact is using.

+ */ + @JsonSetter(value = "ios_sdk_version", nulls = Nulls.SKIP) + public Builder iosSdkVersion(Optional iosSdkVersion) { + this.iosSdkVersion = iosSdkVersion; + return this; + } + + public Builder iosSdkVersion(String iosSdkVersion) { + this.iosSdkVersion = Optional.ofNullable(iosSdkVersion); + return this; + } + + /** + *

(UNIX timestamp) The last time the contact used the iOS app.

+ */ + @JsonSetter(value = "ios_last_seen_at", nulls = Nulls.SKIP) + public Builder iosLastSeenAt(Optional iosLastSeenAt) { + this.iosLastSeenAt = iosLastSeenAt; + return this; + } + + public Builder iosLastSeenAt(Integer iosLastSeenAt) { + this.iosLastSeenAt = Optional.ofNullable(iosLastSeenAt); + return this; + } + + /** + *

The custom attributes which are set for the contact.

+ */ + @JsonSetter(value = "custom_attributes", nulls = Nulls.SKIP) + public Builder customAttributes(Optional> customAttributes) { + this.customAttributes = customAttributes; + return this; + } + + public Builder customAttributes(Map customAttributes) { + this.customAttributes = Optional.ofNullable(customAttributes); + return this; + } + + /** + *

An image URL containing the avatar of a contact.

+ */ + @JsonSetter(value = "avatar", nulls = Nulls.SKIP) + public Builder avatar(Optional avatar) { + this.avatar = avatar; + return this; + } + + public Builder avatar(String avatar) { + this.avatar = Optional.ofNullable(avatar); + return this; + } + + @JsonSetter(value = "tags", nulls = Nulls.SKIP) + public Builder tags(Optional tags) { + this.tags = tags; + return this; + } + + public Builder tags(ContactTags tags) { + this.tags = Optional.ofNullable(tags); + return this; + } + + @JsonSetter(value = "notes", nulls = Nulls.SKIP) + public Builder notes(Optional notes) { + this.notes = notes; + return this; + } + + public Builder notes(ContactNotes notes) { + this.notes = Optional.ofNullable(notes); + return this; + } + + @JsonSetter(value = "companies", nulls = Nulls.SKIP) + public Builder companies(Optional companies) { + this.companies = companies; + return this; + } + + public Builder companies(ContactCompanies companies) { + this.companies = Optional.ofNullable(companies); + return this; + } + + @JsonSetter(value = "location", nulls = Nulls.SKIP) + public Builder location(Optional location) { + this.location = location; + return this; + } + + public Builder location(ContactLocation location) { + this.location = Optional.ofNullable(location); + return this; + } + + @JsonSetter(value = "social_profiles", nulls = Nulls.SKIP) + public Builder socialProfiles(Optional socialProfiles) { + this.socialProfiles = socialProfiles; + return this; + } + + public Builder socialProfiles(ContactSocialProfiles socialProfiles) { + this.socialProfiles = Optional.ofNullable(socialProfiles); + return this; + } + + /** + *

If the user has enabled push messaging.

+ */ + @JsonSetter(value = "enabled_push_messaging", nulls = Nulls.SKIP) + public Builder enabledPushMessaging(Optional enabledPushMessaging) { + this.enabledPushMessaging = enabledPushMessaging; + return this; + } + + public Builder enabledPushMessaging(Boolean enabledPushMessaging) { + this.enabledPushMessaging = Optional.ofNullable(enabledPushMessaging); + return this; + } + + public ContactsFindResponse build() { + return new ContactsFindResponse( + type, + id, + externalId, + workspaceId, + role, + email, + emailDomain, + phone, + name, + ownerId, + hasHardBounced, + markedEmailAsSpam, + unsubscribedFromEmails, + createdAt, + updatedAt, + signedUpAt, + lastSeenAt, + lastRepliedAt, + lastContactedAt, + lastEmailOpenedAt, + lastEmailClickedAt, + languageOverride, + browser, + browserVersion, + browserLanguage, + os, + androidAppName, + androidAppVersion, + androidDevice, + androidOsVersion, + androidSdkVersion, + androidLastSeenAt, + iosAppName, + iosAppVersion, + iosDevice, + iosOsVersion, + iosSdkVersion, + iosLastSeenAt, + customAttributes, + avatar, + tags, + notes, + companies, + location, + socialProfiles, + enabledPushMessaging, + additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/contacts/types/ContactsMergeLeadInUserResponse.java b/src/main/java/com/intercom/api/resources/contacts/types/ContactsMergeLeadInUserResponse.java new file mode 100644 index 0000000..a6c4783 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/contacts/types/ContactsMergeLeadInUserResponse.java @@ -0,0 +1,1521 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.contacts.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.types.ContactCompanies; +import com.intercom.api.types.ContactLocation; +import com.intercom.api.types.ContactNotes; +import com.intercom.api.types.ContactSocialProfiles; +import com.intercom.api.types.ContactTags; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ContactsMergeLeadInUserResponse.Builder.class) +public final class ContactsMergeLeadInUserResponse implements IContact { + private final Optional type; + + private final Optional id; + + private final Optional externalId; + + private final Optional workspaceId; + + private final Optional role; + + private final Optional email; + + private final Optional emailDomain; + + private final Optional phone; + + private final Optional name; + + private final Optional ownerId; + + private final Optional hasHardBounced; + + private final Optional markedEmailAsSpam; + + private final Optional unsubscribedFromEmails; + + private final Optional createdAt; + + private final Optional updatedAt; + + private final Optional signedUpAt; + + private final Optional lastSeenAt; + + private final Optional lastRepliedAt; + + private final Optional lastContactedAt; + + private final Optional lastEmailOpenedAt; + + private final Optional lastEmailClickedAt; + + private final Optional languageOverride; + + private final Optional browser; + + private final Optional browserVersion; + + private final Optional browserLanguage; + + private final Optional os; + + private final Optional androidAppName; + + private final Optional androidAppVersion; + + private final Optional androidDevice; + + private final Optional androidOsVersion; + + private final Optional androidSdkVersion; + + private final Optional androidLastSeenAt; + + private final Optional iosAppName; + + private final Optional iosAppVersion; + + private final Optional iosDevice; + + private final Optional iosOsVersion; + + private final Optional iosSdkVersion; + + private final Optional iosLastSeenAt; + + private final Optional> customAttributes; + + private final Optional avatar; + + private final Optional tags; + + private final Optional notes; + + private final Optional companies; + + private final Optional location; + + private final Optional socialProfiles; + + private final Optional enabledPushMessaging; + + private final Map additionalProperties; + + private ContactsMergeLeadInUserResponse( + Optional type, + Optional id, + Optional externalId, + Optional workspaceId, + Optional role, + Optional email, + Optional emailDomain, + Optional phone, + Optional name, + Optional ownerId, + Optional hasHardBounced, + Optional markedEmailAsSpam, + Optional unsubscribedFromEmails, + Optional createdAt, + Optional updatedAt, + Optional signedUpAt, + Optional lastSeenAt, + Optional lastRepliedAt, + Optional lastContactedAt, + Optional lastEmailOpenedAt, + Optional lastEmailClickedAt, + Optional languageOverride, + Optional browser, + Optional browserVersion, + Optional browserLanguage, + Optional os, + Optional androidAppName, + Optional androidAppVersion, + Optional androidDevice, + Optional androidOsVersion, + Optional androidSdkVersion, + Optional androidLastSeenAt, + Optional iosAppName, + Optional iosAppVersion, + Optional iosDevice, + Optional iosOsVersion, + Optional iosSdkVersion, + Optional iosLastSeenAt, + Optional> customAttributes, + Optional avatar, + Optional tags, + Optional notes, + Optional companies, + Optional location, + Optional socialProfiles, + Optional enabledPushMessaging, + Map additionalProperties) { + this.type = type; + this.id = id; + this.externalId = externalId; + this.workspaceId = workspaceId; + this.role = role; + this.email = email; + this.emailDomain = emailDomain; + this.phone = phone; + this.name = name; + this.ownerId = ownerId; + this.hasHardBounced = hasHardBounced; + this.markedEmailAsSpam = markedEmailAsSpam; + this.unsubscribedFromEmails = unsubscribedFromEmails; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.signedUpAt = signedUpAt; + this.lastSeenAt = lastSeenAt; + this.lastRepliedAt = lastRepliedAt; + this.lastContactedAt = lastContactedAt; + this.lastEmailOpenedAt = lastEmailOpenedAt; + this.lastEmailClickedAt = lastEmailClickedAt; + this.languageOverride = languageOverride; + this.browser = browser; + this.browserVersion = browserVersion; + this.browserLanguage = browserLanguage; + this.os = os; + this.androidAppName = androidAppName; + this.androidAppVersion = androidAppVersion; + this.androidDevice = androidDevice; + this.androidOsVersion = androidOsVersion; + this.androidSdkVersion = androidSdkVersion; + this.androidLastSeenAt = androidLastSeenAt; + this.iosAppName = iosAppName; + this.iosAppVersion = iosAppVersion; + this.iosDevice = iosDevice; + this.iosOsVersion = iosOsVersion; + this.iosSdkVersion = iosSdkVersion; + this.iosLastSeenAt = iosLastSeenAt; + this.customAttributes = customAttributes; + this.avatar = avatar; + this.tags = tags; + this.notes = notes; + this.companies = companies; + this.location = location; + this.socialProfiles = socialProfiles; + this.enabledPushMessaging = enabledPushMessaging; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of object. + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return The unique identifier for the contact which is given by Intercom. + */ + @JsonProperty("id") + public Optional getId() { + return id; + } + + /** + * @return The unique identifier for the contact which is provided by the Client. + */ + @JsonProperty("external_id") + public Optional getExternalId() { + return externalId; + } + + /** + * @return The id of the workspace which the contact belongs to. + */ + @JsonProperty("workspace_id") + public Optional getWorkspaceId() { + return workspaceId; + } + + /** + * @return The role of the contact. + */ + @JsonProperty("role") + public Optional getRole() { + return role; + } + + /** + * @return The contact's email. + */ + @JsonProperty("email") + public Optional getEmail() { + return email; + } + + /** + * @return The contact's email domain. + */ + @JsonProperty("email_domain") + public Optional getEmailDomain() { + return emailDomain; + } + + /** + * @return The contacts phone. + */ + @JsonProperty("phone") + public Optional getPhone() { + return phone; + } + + /** + * @return The contacts name. + */ + @JsonProperty("name") + public Optional getName() { + return name; + } + + /** + * @return The id of an admin that has been assigned account ownership of the contact. + */ + @JsonProperty("owner_id") + public Optional getOwnerId() { + return ownerId; + } + + /** + * @return Whether the contact has had an email sent to them hard bounce. + */ + @JsonProperty("has_hard_bounced") + public Optional getHasHardBounced() { + return hasHardBounced; + } + + /** + * @return Whether the contact has marked an email sent to them as spam. + */ + @JsonProperty("marked_email_as_spam") + public Optional getMarkedEmailAsSpam() { + return markedEmailAsSpam; + } + + /** + * @return Whether the contact is unsubscribed from emails. + */ + @JsonProperty("unsubscribed_from_emails") + public Optional getUnsubscribedFromEmails() { + return unsubscribedFromEmails; + } + + /** + * @return (UNIX timestamp) The time when the contact was created. + */ + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + /** + * @return (UNIX timestamp) The time when the contact was last updated. + */ + @JsonProperty("updated_at") + public Optional getUpdatedAt() { + return updatedAt; + } + + /** + * @return (UNIX timestamp) The time specified for when a contact signed up. + */ + @JsonProperty("signed_up_at") + public Optional getSignedUpAt() { + return signedUpAt; + } + + /** + * @return (UNIX timestamp) The time when the contact was last seen (either where the Intercom Messenger was installed or when specified manually). + */ + @JsonProperty("last_seen_at") + public Optional getLastSeenAt() { + return lastSeenAt; + } + + /** + * @return (UNIX timestamp) The time when the contact last messaged in. + */ + @JsonProperty("last_replied_at") + public Optional getLastRepliedAt() { + return lastRepliedAt; + } + + /** + * @return (UNIX timestamp) The time when the contact was last messaged. + */ + @JsonProperty("last_contacted_at") + public Optional getLastContactedAt() { + return lastContactedAt; + } + + /** + * @return (UNIX timestamp) The time when the contact last opened an email. + */ + @JsonProperty("last_email_opened_at") + public Optional getLastEmailOpenedAt() { + return lastEmailOpenedAt; + } + + /** + * @return (UNIX timestamp) The time when the contact last clicked a link in an email. + */ + @JsonProperty("last_email_clicked_at") + public Optional getLastEmailClickedAt() { + return lastEmailClickedAt; + } + + /** + * @return A preferred language setting for the contact, used by the Intercom Messenger even if their browser settings change. + */ + @JsonProperty("language_override") + public Optional getLanguageOverride() { + return languageOverride; + } + + /** + * @return The name of the browser which the contact is using. + */ + @JsonProperty("browser") + public Optional getBrowser() { + return browser; + } + + /** + * @return The version of the browser which the contact is using. + */ + @JsonProperty("browser_version") + public Optional getBrowserVersion() { + return browserVersion; + } + + /** + * @return The language set by the browser which the contact is using. + */ + @JsonProperty("browser_language") + public Optional getBrowserLanguage() { + return browserLanguage; + } + + /** + * @return The operating system which the contact is using. + */ + @JsonProperty("os") + public Optional getOs() { + return os; + } + + /** + * @return The name of the Android app which the contact is using. + */ + @JsonProperty("android_app_name") + public Optional getAndroidAppName() { + return androidAppName; + } + + /** + * @return The version of the Android app which the contact is using. + */ + @JsonProperty("android_app_version") + public Optional getAndroidAppVersion() { + return androidAppVersion; + } + + /** + * @return The Android device which the contact is using. + */ + @JsonProperty("android_device") + public Optional getAndroidDevice() { + return androidDevice; + } + + /** + * @return The version of the Android OS which the contact is using. + */ + @JsonProperty("android_os_version") + public Optional getAndroidOsVersion() { + return androidOsVersion; + } + + /** + * @return The version of the Android SDK which the contact is using. + */ + @JsonProperty("android_sdk_version") + public Optional getAndroidSdkVersion() { + return androidSdkVersion; + } + + /** + * @return (UNIX timestamp) The time when the contact was last seen on an Android device. + */ + @JsonProperty("android_last_seen_at") + public Optional getAndroidLastSeenAt() { + return androidLastSeenAt; + } + + /** + * @return The name of the iOS app which the contact is using. + */ + @JsonProperty("ios_app_name") + public Optional getIosAppName() { + return iosAppName; + } + + /** + * @return The version of the iOS app which the contact is using. + */ + @JsonProperty("ios_app_version") + public Optional getIosAppVersion() { + return iosAppVersion; + } + + /** + * @return The iOS device which the contact is using. + */ + @JsonProperty("ios_device") + public Optional getIosDevice() { + return iosDevice; + } + + /** + * @return The version of iOS which the contact is using. + */ + @JsonProperty("ios_os_version") + public Optional getIosOsVersion() { + return iosOsVersion; + } + + /** + * @return The version of the iOS SDK which the contact is using. + */ + @JsonProperty("ios_sdk_version") + public Optional getIosSdkVersion() { + return iosSdkVersion; + } + + /** + * @return (UNIX timestamp) The last time the contact used the iOS app. + */ + @JsonProperty("ios_last_seen_at") + public Optional getIosLastSeenAt() { + return iosLastSeenAt; + } + + /** + * @return The custom attributes which are set for the contact. + */ + @JsonProperty("custom_attributes") + public Optional> getCustomAttributes() { + return customAttributes; + } + + /** + * @return An image URL containing the avatar of a contact. + */ + @JsonProperty("avatar") + public Optional getAvatar() { + return avatar; + } + + @JsonProperty("tags") + public Optional getTags() { + return tags; + } + + @JsonProperty("notes") + public Optional getNotes() { + return notes; + } + + @JsonProperty("companies") + public Optional getCompanies() { + return companies; + } + + @JsonProperty("location") + public Optional getLocation() { + return location; + } + + @JsonProperty("social_profiles") + public Optional getSocialProfiles() { + return socialProfiles; + } + + /** + * @return If the user has enabled push messaging. + */ + @JsonProperty("enabled_push_messaging") + public Optional getEnabledPushMessaging() { + return enabledPushMessaging; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ContactsMergeLeadInUserResponse && equalTo((ContactsMergeLeadInUserResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ContactsMergeLeadInUserResponse other) { + return type.equals(other.type) + && id.equals(other.id) + && externalId.equals(other.externalId) + && workspaceId.equals(other.workspaceId) + && role.equals(other.role) + && email.equals(other.email) + && emailDomain.equals(other.emailDomain) + && phone.equals(other.phone) + && name.equals(other.name) + && ownerId.equals(other.ownerId) + && hasHardBounced.equals(other.hasHardBounced) + && markedEmailAsSpam.equals(other.markedEmailAsSpam) + && unsubscribedFromEmails.equals(other.unsubscribedFromEmails) + && createdAt.equals(other.createdAt) + && updatedAt.equals(other.updatedAt) + && signedUpAt.equals(other.signedUpAt) + && lastSeenAt.equals(other.lastSeenAt) + && lastRepliedAt.equals(other.lastRepliedAt) + && lastContactedAt.equals(other.lastContactedAt) + && lastEmailOpenedAt.equals(other.lastEmailOpenedAt) + && lastEmailClickedAt.equals(other.lastEmailClickedAt) + && languageOverride.equals(other.languageOverride) + && browser.equals(other.browser) + && browserVersion.equals(other.browserVersion) + && browserLanguage.equals(other.browserLanguage) + && os.equals(other.os) + && androidAppName.equals(other.androidAppName) + && androidAppVersion.equals(other.androidAppVersion) + && androidDevice.equals(other.androidDevice) + && androidOsVersion.equals(other.androidOsVersion) + && androidSdkVersion.equals(other.androidSdkVersion) + && androidLastSeenAt.equals(other.androidLastSeenAt) + && iosAppName.equals(other.iosAppName) + && iosAppVersion.equals(other.iosAppVersion) + && iosDevice.equals(other.iosDevice) + && iosOsVersion.equals(other.iosOsVersion) + && iosSdkVersion.equals(other.iosSdkVersion) + && iosLastSeenAt.equals(other.iosLastSeenAt) + && customAttributes.equals(other.customAttributes) + && avatar.equals(other.avatar) + && tags.equals(other.tags) + && notes.equals(other.notes) + && companies.equals(other.companies) + && location.equals(other.location) + && socialProfiles.equals(other.socialProfiles) + && enabledPushMessaging.equals(other.enabledPushMessaging); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.type, + this.id, + this.externalId, + this.workspaceId, + this.role, + this.email, + this.emailDomain, + this.phone, + this.name, + this.ownerId, + this.hasHardBounced, + this.markedEmailAsSpam, + this.unsubscribedFromEmails, + this.createdAt, + this.updatedAt, + this.signedUpAt, + this.lastSeenAt, + this.lastRepliedAt, + this.lastContactedAt, + this.lastEmailOpenedAt, + this.lastEmailClickedAt, + this.languageOverride, + this.browser, + this.browserVersion, + this.browserLanguage, + this.os, + this.androidAppName, + this.androidAppVersion, + this.androidDevice, + this.androidOsVersion, + this.androidSdkVersion, + this.androidLastSeenAt, + this.iosAppName, + this.iosAppVersion, + this.iosDevice, + this.iosOsVersion, + this.iosSdkVersion, + this.iosLastSeenAt, + this.customAttributes, + this.avatar, + this.tags, + this.notes, + this.companies, + this.location, + this.socialProfiles, + this.enabledPushMessaging); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); + + private Optional id = Optional.empty(); + + private Optional externalId = Optional.empty(); + + private Optional workspaceId = Optional.empty(); + + private Optional role = Optional.empty(); + + private Optional email = Optional.empty(); + + private Optional emailDomain = Optional.empty(); + + private Optional phone = Optional.empty(); + + private Optional name = Optional.empty(); + + private Optional ownerId = Optional.empty(); + + private Optional hasHardBounced = Optional.empty(); + + private Optional markedEmailAsSpam = Optional.empty(); + + private Optional unsubscribedFromEmails = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + private Optional updatedAt = Optional.empty(); + + private Optional signedUpAt = Optional.empty(); + + private Optional lastSeenAt = Optional.empty(); + + private Optional lastRepliedAt = Optional.empty(); + + private Optional lastContactedAt = Optional.empty(); + + private Optional lastEmailOpenedAt = Optional.empty(); + + private Optional lastEmailClickedAt = Optional.empty(); + + private Optional languageOverride = Optional.empty(); + + private Optional browser = Optional.empty(); + + private Optional browserVersion = Optional.empty(); + + private Optional browserLanguage = Optional.empty(); + + private Optional os = Optional.empty(); + + private Optional androidAppName = Optional.empty(); + + private Optional androidAppVersion = Optional.empty(); + + private Optional androidDevice = Optional.empty(); + + private Optional androidOsVersion = Optional.empty(); + + private Optional androidSdkVersion = Optional.empty(); + + private Optional androidLastSeenAt = Optional.empty(); + + private Optional iosAppName = Optional.empty(); + + private Optional iosAppVersion = Optional.empty(); + + private Optional iosDevice = Optional.empty(); + + private Optional iosOsVersion = Optional.empty(); + + private Optional iosSdkVersion = Optional.empty(); + + private Optional iosLastSeenAt = Optional.empty(); + + private Optional> customAttributes = Optional.empty(); + + private Optional avatar = Optional.empty(); + + private Optional tags = Optional.empty(); + + private Optional notes = Optional.empty(); + + private Optional companies = Optional.empty(); + + private Optional location = Optional.empty(); + + private Optional socialProfiles = Optional.empty(); + + private Optional enabledPushMessaging = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ContactsMergeLeadInUserResponse other) { + type(other.getType()); + id(other.getId()); + externalId(other.getExternalId()); + workspaceId(other.getWorkspaceId()); + role(other.getRole()); + email(other.getEmail()); + emailDomain(other.getEmailDomain()); + phone(other.getPhone()); + name(other.getName()); + ownerId(other.getOwnerId()); + hasHardBounced(other.getHasHardBounced()); + markedEmailAsSpam(other.getMarkedEmailAsSpam()); + unsubscribedFromEmails(other.getUnsubscribedFromEmails()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + signedUpAt(other.getSignedUpAt()); + lastSeenAt(other.getLastSeenAt()); + lastRepliedAt(other.getLastRepliedAt()); + lastContactedAt(other.getLastContactedAt()); + lastEmailOpenedAt(other.getLastEmailOpenedAt()); + lastEmailClickedAt(other.getLastEmailClickedAt()); + languageOverride(other.getLanguageOverride()); + browser(other.getBrowser()); + browserVersion(other.getBrowserVersion()); + browserLanguage(other.getBrowserLanguage()); + os(other.getOs()); + androidAppName(other.getAndroidAppName()); + androidAppVersion(other.getAndroidAppVersion()); + androidDevice(other.getAndroidDevice()); + androidOsVersion(other.getAndroidOsVersion()); + androidSdkVersion(other.getAndroidSdkVersion()); + androidLastSeenAt(other.getAndroidLastSeenAt()); + iosAppName(other.getIosAppName()); + iosAppVersion(other.getIosAppVersion()); + iosDevice(other.getIosDevice()); + iosOsVersion(other.getIosOsVersion()); + iosSdkVersion(other.getIosSdkVersion()); + iosLastSeenAt(other.getIosLastSeenAt()); + customAttributes(other.getCustomAttributes()); + avatar(other.getAvatar()); + tags(other.getTags()); + notes(other.getNotes()); + companies(other.getCompanies()); + location(other.getLocation()); + socialProfiles(other.getSocialProfiles()); + enabledPushMessaging(other.getEnabledPushMessaging()); + return this; + } + + /** + *

The type of object.

+ */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + /** + *

The unique identifier for the contact which is given by Intercom.

+ */ + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.ofNullable(id); + return this; + } + + /** + *

The unique identifier for the contact which is provided by the Client.

+ */ + @JsonSetter(value = "external_id", nulls = Nulls.SKIP) + public Builder externalId(Optional externalId) { + this.externalId = externalId; + return this; + } + + public Builder externalId(String externalId) { + this.externalId = Optional.ofNullable(externalId); + return this; + } + + /** + *

The id of the workspace which the contact belongs to.

+ */ + @JsonSetter(value = "workspace_id", nulls = Nulls.SKIP) + public Builder workspaceId(Optional workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + public Builder workspaceId(String workspaceId) { + this.workspaceId = Optional.ofNullable(workspaceId); + return this; + } + + /** + *

The role of the contact.

+ */ + @JsonSetter(value = "role", nulls = Nulls.SKIP) + public Builder role(Optional role) { + this.role = role; + return this; + } + + public Builder role(String role) { + this.role = Optional.ofNullable(role); + return this; + } + + /** + *

The contact's email.

+ */ + @JsonSetter(value = "email", nulls = Nulls.SKIP) + public Builder email(Optional email) { + this.email = email; + return this; + } + + public Builder email(String email) { + this.email = Optional.ofNullable(email); + return this; + } + + /** + *

The contact's email domain.

+ */ + @JsonSetter(value = "email_domain", nulls = Nulls.SKIP) + public Builder emailDomain(Optional emailDomain) { + this.emailDomain = emailDomain; + return this; + } + + public Builder emailDomain(String emailDomain) { + this.emailDomain = Optional.ofNullable(emailDomain); + return this; + } + + /** + *

The contacts phone.

+ */ + @JsonSetter(value = "phone", nulls = Nulls.SKIP) + public Builder phone(Optional phone) { + this.phone = phone; + return this; + } + + public Builder phone(String phone) { + this.phone = Optional.ofNullable(phone); + return this; + } + + /** + *

The contacts name.

+ */ + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public Builder name(Optional name) { + this.name = name; + return this; + } + + public Builder name(String name) { + this.name = Optional.ofNullable(name); + return this; + } + + /** + *

The id of an admin that has been assigned account ownership of the contact.

+ */ + @JsonSetter(value = "owner_id", nulls = Nulls.SKIP) + public Builder ownerId(Optional ownerId) { + this.ownerId = ownerId; + return this; + } + + public Builder ownerId(Integer ownerId) { + this.ownerId = Optional.ofNullable(ownerId); + return this; + } + + /** + *

Whether the contact has had an email sent to them hard bounce.

+ */ + @JsonSetter(value = "has_hard_bounced", nulls = Nulls.SKIP) + public Builder hasHardBounced(Optional hasHardBounced) { + this.hasHardBounced = hasHardBounced; + return this; + } + + public Builder hasHardBounced(Boolean hasHardBounced) { + this.hasHardBounced = Optional.ofNullable(hasHardBounced); + return this; + } + + /** + *

Whether the contact has marked an email sent to them as spam.

+ */ + @JsonSetter(value = "marked_email_as_spam", nulls = Nulls.SKIP) + public Builder markedEmailAsSpam(Optional markedEmailAsSpam) { + this.markedEmailAsSpam = markedEmailAsSpam; + return this; + } + + public Builder markedEmailAsSpam(Boolean markedEmailAsSpam) { + this.markedEmailAsSpam = Optional.ofNullable(markedEmailAsSpam); + return this; + } + + /** + *

Whether the contact is unsubscribed from emails.

+ */ + @JsonSetter(value = "unsubscribed_from_emails", nulls = Nulls.SKIP) + public Builder unsubscribedFromEmails(Optional unsubscribedFromEmails) { + this.unsubscribedFromEmails = unsubscribedFromEmails; + return this; + } + + public Builder unsubscribedFromEmails(Boolean unsubscribedFromEmails) { + this.unsubscribedFromEmails = Optional.ofNullable(unsubscribedFromEmails); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact was created.

+ */ + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public Builder createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + public Builder createdAt(Integer createdAt) { + this.createdAt = Optional.ofNullable(createdAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact was last updated.

+ */ + @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) + public Builder updatedAt(Optional updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + public Builder updatedAt(Integer updatedAt) { + this.updatedAt = Optional.ofNullable(updatedAt); + return this; + } + + /** + *

(UNIX timestamp) The time specified for when a contact signed up.

+ */ + @JsonSetter(value = "signed_up_at", nulls = Nulls.SKIP) + public Builder signedUpAt(Optional signedUpAt) { + this.signedUpAt = signedUpAt; + return this; + } + + public Builder signedUpAt(Integer signedUpAt) { + this.signedUpAt = Optional.ofNullable(signedUpAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact was last seen (either where the Intercom Messenger was installed or when specified manually).

+ */ + @JsonSetter(value = "last_seen_at", nulls = Nulls.SKIP) + public Builder lastSeenAt(Optional lastSeenAt) { + this.lastSeenAt = lastSeenAt; + return this; + } + + public Builder lastSeenAt(Integer lastSeenAt) { + this.lastSeenAt = Optional.ofNullable(lastSeenAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact last messaged in.

+ */ + @JsonSetter(value = "last_replied_at", nulls = Nulls.SKIP) + public Builder lastRepliedAt(Optional lastRepliedAt) { + this.lastRepliedAt = lastRepliedAt; + return this; + } + + public Builder lastRepliedAt(Integer lastRepliedAt) { + this.lastRepliedAt = Optional.ofNullable(lastRepliedAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact was last messaged.

+ */ + @JsonSetter(value = "last_contacted_at", nulls = Nulls.SKIP) + public Builder lastContactedAt(Optional lastContactedAt) { + this.lastContactedAt = lastContactedAt; + return this; + } + + public Builder lastContactedAt(Integer lastContactedAt) { + this.lastContactedAt = Optional.ofNullable(lastContactedAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact last opened an email.

+ */ + @JsonSetter(value = "last_email_opened_at", nulls = Nulls.SKIP) + public Builder lastEmailOpenedAt(Optional lastEmailOpenedAt) { + this.lastEmailOpenedAt = lastEmailOpenedAt; + return this; + } + + public Builder lastEmailOpenedAt(Integer lastEmailOpenedAt) { + this.lastEmailOpenedAt = Optional.ofNullable(lastEmailOpenedAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact last clicked a link in an email.

+ */ + @JsonSetter(value = "last_email_clicked_at", nulls = Nulls.SKIP) + public Builder lastEmailClickedAt(Optional lastEmailClickedAt) { + this.lastEmailClickedAt = lastEmailClickedAt; + return this; + } + + public Builder lastEmailClickedAt(Integer lastEmailClickedAt) { + this.lastEmailClickedAt = Optional.ofNullable(lastEmailClickedAt); + return this; + } + + /** + *

A preferred language setting for the contact, used by the Intercom Messenger even if their browser settings change.

+ */ + @JsonSetter(value = "language_override", nulls = Nulls.SKIP) + public Builder languageOverride(Optional languageOverride) { + this.languageOverride = languageOverride; + return this; + } + + public Builder languageOverride(String languageOverride) { + this.languageOverride = Optional.ofNullable(languageOverride); + return this; + } + + /** + *

The name of the browser which the contact is using.

+ */ + @JsonSetter(value = "browser", nulls = Nulls.SKIP) + public Builder browser(Optional browser) { + this.browser = browser; + return this; + } + + public Builder browser(String browser) { + this.browser = Optional.ofNullable(browser); + return this; + } + + /** + *

The version of the browser which the contact is using.

+ */ + @JsonSetter(value = "browser_version", nulls = Nulls.SKIP) + public Builder browserVersion(Optional browserVersion) { + this.browserVersion = browserVersion; + return this; + } + + public Builder browserVersion(String browserVersion) { + this.browserVersion = Optional.ofNullable(browserVersion); + return this; + } + + /** + *

The language set by the browser which the contact is using.

+ */ + @JsonSetter(value = "browser_language", nulls = Nulls.SKIP) + public Builder browserLanguage(Optional browserLanguage) { + this.browserLanguage = browserLanguage; + return this; + } + + public Builder browserLanguage(String browserLanguage) { + this.browserLanguage = Optional.ofNullable(browserLanguage); + return this; + } + + /** + *

The operating system which the contact is using.

+ */ + @JsonSetter(value = "os", nulls = Nulls.SKIP) + public Builder os(Optional os) { + this.os = os; + return this; + } + + public Builder os(String os) { + this.os = Optional.ofNullable(os); + return this; + } + + /** + *

The name of the Android app which the contact is using.

+ */ + @JsonSetter(value = "android_app_name", nulls = Nulls.SKIP) + public Builder androidAppName(Optional androidAppName) { + this.androidAppName = androidAppName; + return this; + } + + public Builder androidAppName(String androidAppName) { + this.androidAppName = Optional.ofNullable(androidAppName); + return this; + } + + /** + *

The version of the Android app which the contact is using.

+ */ + @JsonSetter(value = "android_app_version", nulls = Nulls.SKIP) + public Builder androidAppVersion(Optional androidAppVersion) { + this.androidAppVersion = androidAppVersion; + return this; + } + + public Builder androidAppVersion(String androidAppVersion) { + this.androidAppVersion = Optional.ofNullable(androidAppVersion); + return this; + } + + /** + *

The Android device which the contact is using.

+ */ + @JsonSetter(value = "android_device", nulls = Nulls.SKIP) + public Builder androidDevice(Optional androidDevice) { + this.androidDevice = androidDevice; + return this; + } + + public Builder androidDevice(String androidDevice) { + this.androidDevice = Optional.ofNullable(androidDevice); + return this; + } + + /** + *

The version of the Android OS which the contact is using.

+ */ + @JsonSetter(value = "android_os_version", nulls = Nulls.SKIP) + public Builder androidOsVersion(Optional androidOsVersion) { + this.androidOsVersion = androidOsVersion; + return this; + } + + public Builder androidOsVersion(String androidOsVersion) { + this.androidOsVersion = Optional.ofNullable(androidOsVersion); + return this; + } + + /** + *

The version of the Android SDK which the contact is using.

+ */ + @JsonSetter(value = "android_sdk_version", nulls = Nulls.SKIP) + public Builder androidSdkVersion(Optional androidSdkVersion) { + this.androidSdkVersion = androidSdkVersion; + return this; + } + + public Builder androidSdkVersion(String androidSdkVersion) { + this.androidSdkVersion = Optional.ofNullable(androidSdkVersion); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact was last seen on an Android device.

+ */ + @JsonSetter(value = "android_last_seen_at", nulls = Nulls.SKIP) + public Builder androidLastSeenAt(Optional androidLastSeenAt) { + this.androidLastSeenAt = androidLastSeenAt; + return this; + } + + public Builder androidLastSeenAt(Integer androidLastSeenAt) { + this.androidLastSeenAt = Optional.ofNullable(androidLastSeenAt); + return this; + } + + /** + *

The name of the iOS app which the contact is using.

+ */ + @JsonSetter(value = "ios_app_name", nulls = Nulls.SKIP) + public Builder iosAppName(Optional iosAppName) { + this.iosAppName = iosAppName; + return this; + } + + public Builder iosAppName(String iosAppName) { + this.iosAppName = Optional.ofNullable(iosAppName); + return this; + } + + /** + *

The version of the iOS app which the contact is using.

+ */ + @JsonSetter(value = "ios_app_version", nulls = Nulls.SKIP) + public Builder iosAppVersion(Optional iosAppVersion) { + this.iosAppVersion = iosAppVersion; + return this; + } + + public Builder iosAppVersion(String iosAppVersion) { + this.iosAppVersion = Optional.ofNullable(iosAppVersion); + return this; + } + + /** + *

The iOS device which the contact is using.

+ */ + @JsonSetter(value = "ios_device", nulls = Nulls.SKIP) + public Builder iosDevice(Optional iosDevice) { + this.iosDevice = iosDevice; + return this; + } + + public Builder iosDevice(String iosDevice) { + this.iosDevice = Optional.ofNullable(iosDevice); + return this; + } + + /** + *

The version of iOS which the contact is using.

+ */ + @JsonSetter(value = "ios_os_version", nulls = Nulls.SKIP) + public Builder iosOsVersion(Optional iosOsVersion) { + this.iosOsVersion = iosOsVersion; + return this; + } + + public Builder iosOsVersion(String iosOsVersion) { + this.iosOsVersion = Optional.ofNullable(iosOsVersion); + return this; + } + + /** + *

The version of the iOS SDK which the contact is using.

+ */ + @JsonSetter(value = "ios_sdk_version", nulls = Nulls.SKIP) + public Builder iosSdkVersion(Optional iosSdkVersion) { + this.iosSdkVersion = iosSdkVersion; + return this; + } + + public Builder iosSdkVersion(String iosSdkVersion) { + this.iosSdkVersion = Optional.ofNullable(iosSdkVersion); + return this; + } + + /** + *

(UNIX timestamp) The last time the contact used the iOS app.

+ */ + @JsonSetter(value = "ios_last_seen_at", nulls = Nulls.SKIP) + public Builder iosLastSeenAt(Optional iosLastSeenAt) { + this.iosLastSeenAt = iosLastSeenAt; + return this; + } + + public Builder iosLastSeenAt(Integer iosLastSeenAt) { + this.iosLastSeenAt = Optional.ofNullable(iosLastSeenAt); + return this; + } + + /** + *

The custom attributes which are set for the contact.

+ */ + @JsonSetter(value = "custom_attributes", nulls = Nulls.SKIP) + public Builder customAttributes(Optional> customAttributes) { + this.customAttributes = customAttributes; + return this; + } + + public Builder customAttributes(Map customAttributes) { + this.customAttributes = Optional.ofNullable(customAttributes); + return this; + } + + /** + *

An image URL containing the avatar of a contact.

+ */ + @JsonSetter(value = "avatar", nulls = Nulls.SKIP) + public Builder avatar(Optional avatar) { + this.avatar = avatar; + return this; + } + + public Builder avatar(String avatar) { + this.avatar = Optional.ofNullable(avatar); + return this; + } + + @JsonSetter(value = "tags", nulls = Nulls.SKIP) + public Builder tags(Optional tags) { + this.tags = tags; + return this; + } + + public Builder tags(ContactTags tags) { + this.tags = Optional.ofNullable(tags); + return this; + } + + @JsonSetter(value = "notes", nulls = Nulls.SKIP) + public Builder notes(Optional notes) { + this.notes = notes; + return this; + } + + public Builder notes(ContactNotes notes) { + this.notes = Optional.ofNullable(notes); + return this; + } + + @JsonSetter(value = "companies", nulls = Nulls.SKIP) + public Builder companies(Optional companies) { + this.companies = companies; + return this; + } + + public Builder companies(ContactCompanies companies) { + this.companies = Optional.ofNullable(companies); + return this; + } + + @JsonSetter(value = "location", nulls = Nulls.SKIP) + public Builder location(Optional location) { + this.location = location; + return this; + } + + public Builder location(ContactLocation location) { + this.location = Optional.ofNullable(location); + return this; + } + + @JsonSetter(value = "social_profiles", nulls = Nulls.SKIP) + public Builder socialProfiles(Optional socialProfiles) { + this.socialProfiles = socialProfiles; + return this; + } + + public Builder socialProfiles(ContactSocialProfiles socialProfiles) { + this.socialProfiles = Optional.ofNullable(socialProfiles); + return this; + } + + /** + *

If the user has enabled push messaging.

+ */ + @JsonSetter(value = "enabled_push_messaging", nulls = Nulls.SKIP) + public Builder enabledPushMessaging(Optional enabledPushMessaging) { + this.enabledPushMessaging = enabledPushMessaging; + return this; + } + + public Builder enabledPushMessaging(Boolean enabledPushMessaging) { + this.enabledPushMessaging = Optional.ofNullable(enabledPushMessaging); + return this; + } + + public ContactsMergeLeadInUserResponse build() { + return new ContactsMergeLeadInUserResponse( + type, + id, + externalId, + workspaceId, + role, + email, + emailDomain, + phone, + name, + ownerId, + hasHardBounced, + markedEmailAsSpam, + unsubscribedFromEmails, + createdAt, + updatedAt, + signedUpAt, + lastSeenAt, + lastRepliedAt, + lastContactedAt, + lastEmailOpenedAt, + lastEmailClickedAt, + languageOverride, + browser, + browserVersion, + browserLanguage, + os, + androidAppName, + androidAppVersion, + androidDevice, + androidOsVersion, + androidSdkVersion, + androidLastSeenAt, + iosAppName, + iosAppVersion, + iosDevice, + iosOsVersion, + iosSdkVersion, + iosLastSeenAt, + customAttributes, + avatar, + tags, + notes, + companies, + location, + socialProfiles, + enabledPushMessaging, + additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/contacts/types/ContactsUpdateResponse.java b/src/main/java/com/intercom/api/resources/contacts/types/ContactsUpdateResponse.java new file mode 100644 index 0000000..bb446f4 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/contacts/types/ContactsUpdateResponse.java @@ -0,0 +1,1521 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.contacts.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.types.ContactCompanies; +import com.intercom.api.types.ContactLocation; +import com.intercom.api.types.ContactNotes; +import com.intercom.api.types.ContactSocialProfiles; +import com.intercom.api.types.ContactTags; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ContactsUpdateResponse.Builder.class) +public final class ContactsUpdateResponse implements IContact { + private final Optional type; + + private final Optional id; + + private final Optional externalId; + + private final Optional workspaceId; + + private final Optional role; + + private final Optional email; + + private final Optional emailDomain; + + private final Optional phone; + + private final Optional name; + + private final Optional ownerId; + + private final Optional hasHardBounced; + + private final Optional markedEmailAsSpam; + + private final Optional unsubscribedFromEmails; + + private final Optional createdAt; + + private final Optional updatedAt; + + private final Optional signedUpAt; + + private final Optional lastSeenAt; + + private final Optional lastRepliedAt; + + private final Optional lastContactedAt; + + private final Optional lastEmailOpenedAt; + + private final Optional lastEmailClickedAt; + + private final Optional languageOverride; + + private final Optional browser; + + private final Optional browserVersion; + + private final Optional browserLanguage; + + private final Optional os; + + private final Optional androidAppName; + + private final Optional androidAppVersion; + + private final Optional androidDevice; + + private final Optional androidOsVersion; + + private final Optional androidSdkVersion; + + private final Optional androidLastSeenAt; + + private final Optional iosAppName; + + private final Optional iosAppVersion; + + private final Optional iosDevice; + + private final Optional iosOsVersion; + + private final Optional iosSdkVersion; + + private final Optional iosLastSeenAt; + + private final Optional> customAttributes; + + private final Optional avatar; + + private final Optional tags; + + private final Optional notes; + + private final Optional companies; + + private final Optional location; + + private final Optional socialProfiles; + + private final Optional enabledPushMessaging; + + private final Map additionalProperties; + + private ContactsUpdateResponse( + Optional type, + Optional id, + Optional externalId, + Optional workspaceId, + Optional role, + Optional email, + Optional emailDomain, + Optional phone, + Optional name, + Optional ownerId, + Optional hasHardBounced, + Optional markedEmailAsSpam, + Optional unsubscribedFromEmails, + Optional createdAt, + Optional updatedAt, + Optional signedUpAt, + Optional lastSeenAt, + Optional lastRepliedAt, + Optional lastContactedAt, + Optional lastEmailOpenedAt, + Optional lastEmailClickedAt, + Optional languageOverride, + Optional browser, + Optional browserVersion, + Optional browserLanguage, + Optional os, + Optional androidAppName, + Optional androidAppVersion, + Optional androidDevice, + Optional androidOsVersion, + Optional androidSdkVersion, + Optional androidLastSeenAt, + Optional iosAppName, + Optional iosAppVersion, + Optional iosDevice, + Optional iosOsVersion, + Optional iosSdkVersion, + Optional iosLastSeenAt, + Optional> customAttributes, + Optional avatar, + Optional tags, + Optional notes, + Optional companies, + Optional location, + Optional socialProfiles, + Optional enabledPushMessaging, + Map additionalProperties) { + this.type = type; + this.id = id; + this.externalId = externalId; + this.workspaceId = workspaceId; + this.role = role; + this.email = email; + this.emailDomain = emailDomain; + this.phone = phone; + this.name = name; + this.ownerId = ownerId; + this.hasHardBounced = hasHardBounced; + this.markedEmailAsSpam = markedEmailAsSpam; + this.unsubscribedFromEmails = unsubscribedFromEmails; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.signedUpAt = signedUpAt; + this.lastSeenAt = lastSeenAt; + this.lastRepliedAt = lastRepliedAt; + this.lastContactedAt = lastContactedAt; + this.lastEmailOpenedAt = lastEmailOpenedAt; + this.lastEmailClickedAt = lastEmailClickedAt; + this.languageOverride = languageOverride; + this.browser = browser; + this.browserVersion = browserVersion; + this.browserLanguage = browserLanguage; + this.os = os; + this.androidAppName = androidAppName; + this.androidAppVersion = androidAppVersion; + this.androidDevice = androidDevice; + this.androidOsVersion = androidOsVersion; + this.androidSdkVersion = androidSdkVersion; + this.androidLastSeenAt = androidLastSeenAt; + this.iosAppName = iosAppName; + this.iosAppVersion = iosAppVersion; + this.iosDevice = iosDevice; + this.iosOsVersion = iosOsVersion; + this.iosSdkVersion = iosSdkVersion; + this.iosLastSeenAt = iosLastSeenAt; + this.customAttributes = customAttributes; + this.avatar = avatar; + this.tags = tags; + this.notes = notes; + this.companies = companies; + this.location = location; + this.socialProfiles = socialProfiles; + this.enabledPushMessaging = enabledPushMessaging; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of object. + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return The unique identifier for the contact which is given by Intercom. + */ + @JsonProperty("id") + public Optional getId() { + return id; + } + + /** + * @return The unique identifier for the contact which is provided by the Client. + */ + @JsonProperty("external_id") + public Optional getExternalId() { + return externalId; + } + + /** + * @return The id of the workspace which the contact belongs to. + */ + @JsonProperty("workspace_id") + public Optional getWorkspaceId() { + return workspaceId; + } + + /** + * @return The role of the contact. + */ + @JsonProperty("role") + public Optional getRole() { + return role; + } + + /** + * @return The contact's email. + */ + @JsonProperty("email") + public Optional getEmail() { + return email; + } + + /** + * @return The contact's email domain. + */ + @JsonProperty("email_domain") + public Optional getEmailDomain() { + return emailDomain; + } + + /** + * @return The contacts phone. + */ + @JsonProperty("phone") + public Optional getPhone() { + return phone; + } + + /** + * @return The contacts name. + */ + @JsonProperty("name") + public Optional getName() { + return name; + } + + /** + * @return The id of an admin that has been assigned account ownership of the contact. + */ + @JsonProperty("owner_id") + public Optional getOwnerId() { + return ownerId; + } + + /** + * @return Whether the contact has had an email sent to them hard bounce. + */ + @JsonProperty("has_hard_bounced") + public Optional getHasHardBounced() { + return hasHardBounced; + } + + /** + * @return Whether the contact has marked an email sent to them as spam. + */ + @JsonProperty("marked_email_as_spam") + public Optional getMarkedEmailAsSpam() { + return markedEmailAsSpam; + } + + /** + * @return Whether the contact is unsubscribed from emails. + */ + @JsonProperty("unsubscribed_from_emails") + public Optional getUnsubscribedFromEmails() { + return unsubscribedFromEmails; + } + + /** + * @return (UNIX timestamp) The time when the contact was created. + */ + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + /** + * @return (UNIX timestamp) The time when the contact was last updated. + */ + @JsonProperty("updated_at") + public Optional getUpdatedAt() { + return updatedAt; + } + + /** + * @return (UNIX timestamp) The time specified for when a contact signed up. + */ + @JsonProperty("signed_up_at") + public Optional getSignedUpAt() { + return signedUpAt; + } + + /** + * @return (UNIX timestamp) The time when the contact was last seen (either where the Intercom Messenger was installed or when specified manually). + */ + @JsonProperty("last_seen_at") + public Optional getLastSeenAt() { + return lastSeenAt; + } + + /** + * @return (UNIX timestamp) The time when the contact last messaged in. + */ + @JsonProperty("last_replied_at") + public Optional getLastRepliedAt() { + return lastRepliedAt; + } + + /** + * @return (UNIX timestamp) The time when the contact was last messaged. + */ + @JsonProperty("last_contacted_at") + public Optional getLastContactedAt() { + return lastContactedAt; + } + + /** + * @return (UNIX timestamp) The time when the contact last opened an email. + */ + @JsonProperty("last_email_opened_at") + public Optional getLastEmailOpenedAt() { + return lastEmailOpenedAt; + } + + /** + * @return (UNIX timestamp) The time when the contact last clicked a link in an email. + */ + @JsonProperty("last_email_clicked_at") + public Optional getLastEmailClickedAt() { + return lastEmailClickedAt; + } + + /** + * @return A preferred language setting for the contact, used by the Intercom Messenger even if their browser settings change. + */ + @JsonProperty("language_override") + public Optional getLanguageOverride() { + return languageOverride; + } + + /** + * @return The name of the browser which the contact is using. + */ + @JsonProperty("browser") + public Optional getBrowser() { + return browser; + } + + /** + * @return The version of the browser which the contact is using. + */ + @JsonProperty("browser_version") + public Optional getBrowserVersion() { + return browserVersion; + } + + /** + * @return The language set by the browser which the contact is using. + */ + @JsonProperty("browser_language") + public Optional getBrowserLanguage() { + return browserLanguage; + } + + /** + * @return The operating system which the contact is using. + */ + @JsonProperty("os") + public Optional getOs() { + return os; + } + + /** + * @return The name of the Android app which the contact is using. + */ + @JsonProperty("android_app_name") + public Optional getAndroidAppName() { + return androidAppName; + } + + /** + * @return The version of the Android app which the contact is using. + */ + @JsonProperty("android_app_version") + public Optional getAndroidAppVersion() { + return androidAppVersion; + } + + /** + * @return The Android device which the contact is using. + */ + @JsonProperty("android_device") + public Optional getAndroidDevice() { + return androidDevice; + } + + /** + * @return The version of the Android OS which the contact is using. + */ + @JsonProperty("android_os_version") + public Optional getAndroidOsVersion() { + return androidOsVersion; + } + + /** + * @return The version of the Android SDK which the contact is using. + */ + @JsonProperty("android_sdk_version") + public Optional getAndroidSdkVersion() { + return androidSdkVersion; + } + + /** + * @return (UNIX timestamp) The time when the contact was last seen on an Android device. + */ + @JsonProperty("android_last_seen_at") + public Optional getAndroidLastSeenAt() { + return androidLastSeenAt; + } + + /** + * @return The name of the iOS app which the contact is using. + */ + @JsonProperty("ios_app_name") + public Optional getIosAppName() { + return iosAppName; + } + + /** + * @return The version of the iOS app which the contact is using. + */ + @JsonProperty("ios_app_version") + public Optional getIosAppVersion() { + return iosAppVersion; + } + + /** + * @return The iOS device which the contact is using. + */ + @JsonProperty("ios_device") + public Optional getIosDevice() { + return iosDevice; + } + + /** + * @return The version of iOS which the contact is using. + */ + @JsonProperty("ios_os_version") + public Optional getIosOsVersion() { + return iosOsVersion; + } + + /** + * @return The version of the iOS SDK which the contact is using. + */ + @JsonProperty("ios_sdk_version") + public Optional getIosSdkVersion() { + return iosSdkVersion; + } + + /** + * @return (UNIX timestamp) The last time the contact used the iOS app. + */ + @JsonProperty("ios_last_seen_at") + public Optional getIosLastSeenAt() { + return iosLastSeenAt; + } + + /** + * @return The custom attributes which are set for the contact. + */ + @JsonProperty("custom_attributes") + public Optional> getCustomAttributes() { + return customAttributes; + } + + /** + * @return An image URL containing the avatar of a contact. + */ + @JsonProperty("avatar") + public Optional getAvatar() { + return avatar; + } + + @JsonProperty("tags") + public Optional getTags() { + return tags; + } + + @JsonProperty("notes") + public Optional getNotes() { + return notes; + } + + @JsonProperty("companies") + public Optional getCompanies() { + return companies; + } + + @JsonProperty("location") + public Optional getLocation() { + return location; + } + + @JsonProperty("social_profiles") + public Optional getSocialProfiles() { + return socialProfiles; + } + + /** + * @return If the user has enabled push messaging. + */ + @JsonProperty("enabled_push_messaging") + public Optional getEnabledPushMessaging() { + return enabledPushMessaging; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ContactsUpdateResponse && equalTo((ContactsUpdateResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ContactsUpdateResponse other) { + return type.equals(other.type) + && id.equals(other.id) + && externalId.equals(other.externalId) + && workspaceId.equals(other.workspaceId) + && role.equals(other.role) + && email.equals(other.email) + && emailDomain.equals(other.emailDomain) + && phone.equals(other.phone) + && name.equals(other.name) + && ownerId.equals(other.ownerId) + && hasHardBounced.equals(other.hasHardBounced) + && markedEmailAsSpam.equals(other.markedEmailAsSpam) + && unsubscribedFromEmails.equals(other.unsubscribedFromEmails) + && createdAt.equals(other.createdAt) + && updatedAt.equals(other.updatedAt) + && signedUpAt.equals(other.signedUpAt) + && lastSeenAt.equals(other.lastSeenAt) + && lastRepliedAt.equals(other.lastRepliedAt) + && lastContactedAt.equals(other.lastContactedAt) + && lastEmailOpenedAt.equals(other.lastEmailOpenedAt) + && lastEmailClickedAt.equals(other.lastEmailClickedAt) + && languageOverride.equals(other.languageOverride) + && browser.equals(other.browser) + && browserVersion.equals(other.browserVersion) + && browserLanguage.equals(other.browserLanguage) + && os.equals(other.os) + && androidAppName.equals(other.androidAppName) + && androidAppVersion.equals(other.androidAppVersion) + && androidDevice.equals(other.androidDevice) + && androidOsVersion.equals(other.androidOsVersion) + && androidSdkVersion.equals(other.androidSdkVersion) + && androidLastSeenAt.equals(other.androidLastSeenAt) + && iosAppName.equals(other.iosAppName) + && iosAppVersion.equals(other.iosAppVersion) + && iosDevice.equals(other.iosDevice) + && iosOsVersion.equals(other.iosOsVersion) + && iosSdkVersion.equals(other.iosSdkVersion) + && iosLastSeenAt.equals(other.iosLastSeenAt) + && customAttributes.equals(other.customAttributes) + && avatar.equals(other.avatar) + && tags.equals(other.tags) + && notes.equals(other.notes) + && companies.equals(other.companies) + && location.equals(other.location) + && socialProfiles.equals(other.socialProfiles) + && enabledPushMessaging.equals(other.enabledPushMessaging); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.type, + this.id, + this.externalId, + this.workspaceId, + this.role, + this.email, + this.emailDomain, + this.phone, + this.name, + this.ownerId, + this.hasHardBounced, + this.markedEmailAsSpam, + this.unsubscribedFromEmails, + this.createdAt, + this.updatedAt, + this.signedUpAt, + this.lastSeenAt, + this.lastRepliedAt, + this.lastContactedAt, + this.lastEmailOpenedAt, + this.lastEmailClickedAt, + this.languageOverride, + this.browser, + this.browserVersion, + this.browserLanguage, + this.os, + this.androidAppName, + this.androidAppVersion, + this.androidDevice, + this.androidOsVersion, + this.androidSdkVersion, + this.androidLastSeenAt, + this.iosAppName, + this.iosAppVersion, + this.iosDevice, + this.iosOsVersion, + this.iosSdkVersion, + this.iosLastSeenAt, + this.customAttributes, + this.avatar, + this.tags, + this.notes, + this.companies, + this.location, + this.socialProfiles, + this.enabledPushMessaging); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); + + private Optional id = Optional.empty(); + + private Optional externalId = Optional.empty(); + + private Optional workspaceId = Optional.empty(); + + private Optional role = Optional.empty(); + + private Optional email = Optional.empty(); + + private Optional emailDomain = Optional.empty(); + + private Optional phone = Optional.empty(); + + private Optional name = Optional.empty(); + + private Optional ownerId = Optional.empty(); + + private Optional hasHardBounced = Optional.empty(); + + private Optional markedEmailAsSpam = Optional.empty(); + + private Optional unsubscribedFromEmails = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + private Optional updatedAt = Optional.empty(); + + private Optional signedUpAt = Optional.empty(); + + private Optional lastSeenAt = Optional.empty(); + + private Optional lastRepliedAt = Optional.empty(); + + private Optional lastContactedAt = Optional.empty(); + + private Optional lastEmailOpenedAt = Optional.empty(); + + private Optional lastEmailClickedAt = Optional.empty(); + + private Optional languageOverride = Optional.empty(); + + private Optional browser = Optional.empty(); + + private Optional browserVersion = Optional.empty(); + + private Optional browserLanguage = Optional.empty(); + + private Optional os = Optional.empty(); + + private Optional androidAppName = Optional.empty(); + + private Optional androidAppVersion = Optional.empty(); + + private Optional androidDevice = Optional.empty(); + + private Optional androidOsVersion = Optional.empty(); + + private Optional androidSdkVersion = Optional.empty(); + + private Optional androidLastSeenAt = Optional.empty(); + + private Optional iosAppName = Optional.empty(); + + private Optional iosAppVersion = Optional.empty(); + + private Optional iosDevice = Optional.empty(); + + private Optional iosOsVersion = Optional.empty(); + + private Optional iosSdkVersion = Optional.empty(); + + private Optional iosLastSeenAt = Optional.empty(); + + private Optional> customAttributes = Optional.empty(); + + private Optional avatar = Optional.empty(); + + private Optional tags = Optional.empty(); + + private Optional notes = Optional.empty(); + + private Optional companies = Optional.empty(); + + private Optional location = Optional.empty(); + + private Optional socialProfiles = Optional.empty(); + + private Optional enabledPushMessaging = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ContactsUpdateResponse other) { + type(other.getType()); + id(other.getId()); + externalId(other.getExternalId()); + workspaceId(other.getWorkspaceId()); + role(other.getRole()); + email(other.getEmail()); + emailDomain(other.getEmailDomain()); + phone(other.getPhone()); + name(other.getName()); + ownerId(other.getOwnerId()); + hasHardBounced(other.getHasHardBounced()); + markedEmailAsSpam(other.getMarkedEmailAsSpam()); + unsubscribedFromEmails(other.getUnsubscribedFromEmails()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + signedUpAt(other.getSignedUpAt()); + lastSeenAt(other.getLastSeenAt()); + lastRepliedAt(other.getLastRepliedAt()); + lastContactedAt(other.getLastContactedAt()); + lastEmailOpenedAt(other.getLastEmailOpenedAt()); + lastEmailClickedAt(other.getLastEmailClickedAt()); + languageOverride(other.getLanguageOverride()); + browser(other.getBrowser()); + browserVersion(other.getBrowserVersion()); + browserLanguage(other.getBrowserLanguage()); + os(other.getOs()); + androidAppName(other.getAndroidAppName()); + androidAppVersion(other.getAndroidAppVersion()); + androidDevice(other.getAndroidDevice()); + androidOsVersion(other.getAndroidOsVersion()); + androidSdkVersion(other.getAndroidSdkVersion()); + androidLastSeenAt(other.getAndroidLastSeenAt()); + iosAppName(other.getIosAppName()); + iosAppVersion(other.getIosAppVersion()); + iosDevice(other.getIosDevice()); + iosOsVersion(other.getIosOsVersion()); + iosSdkVersion(other.getIosSdkVersion()); + iosLastSeenAt(other.getIosLastSeenAt()); + customAttributes(other.getCustomAttributes()); + avatar(other.getAvatar()); + tags(other.getTags()); + notes(other.getNotes()); + companies(other.getCompanies()); + location(other.getLocation()); + socialProfiles(other.getSocialProfiles()); + enabledPushMessaging(other.getEnabledPushMessaging()); + return this; + } + + /** + *

The type of object.

+ */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + /** + *

The unique identifier for the contact which is given by Intercom.

+ */ + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.ofNullable(id); + return this; + } + + /** + *

The unique identifier for the contact which is provided by the Client.

+ */ + @JsonSetter(value = "external_id", nulls = Nulls.SKIP) + public Builder externalId(Optional externalId) { + this.externalId = externalId; + return this; + } + + public Builder externalId(String externalId) { + this.externalId = Optional.ofNullable(externalId); + return this; + } + + /** + *

The id of the workspace which the contact belongs to.

+ */ + @JsonSetter(value = "workspace_id", nulls = Nulls.SKIP) + public Builder workspaceId(Optional workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + public Builder workspaceId(String workspaceId) { + this.workspaceId = Optional.ofNullable(workspaceId); + return this; + } + + /** + *

The role of the contact.

+ */ + @JsonSetter(value = "role", nulls = Nulls.SKIP) + public Builder role(Optional role) { + this.role = role; + return this; + } + + public Builder role(String role) { + this.role = Optional.ofNullable(role); + return this; + } + + /** + *

The contact's email.

+ */ + @JsonSetter(value = "email", nulls = Nulls.SKIP) + public Builder email(Optional email) { + this.email = email; + return this; + } + + public Builder email(String email) { + this.email = Optional.ofNullable(email); + return this; + } + + /** + *

The contact's email domain.

+ */ + @JsonSetter(value = "email_domain", nulls = Nulls.SKIP) + public Builder emailDomain(Optional emailDomain) { + this.emailDomain = emailDomain; + return this; + } + + public Builder emailDomain(String emailDomain) { + this.emailDomain = Optional.ofNullable(emailDomain); + return this; + } + + /** + *

The contacts phone.

+ */ + @JsonSetter(value = "phone", nulls = Nulls.SKIP) + public Builder phone(Optional phone) { + this.phone = phone; + return this; + } + + public Builder phone(String phone) { + this.phone = Optional.ofNullable(phone); + return this; + } + + /** + *

The contacts name.

+ */ + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public Builder name(Optional name) { + this.name = name; + return this; + } + + public Builder name(String name) { + this.name = Optional.ofNullable(name); + return this; + } + + /** + *

The id of an admin that has been assigned account ownership of the contact.

+ */ + @JsonSetter(value = "owner_id", nulls = Nulls.SKIP) + public Builder ownerId(Optional ownerId) { + this.ownerId = ownerId; + return this; + } + + public Builder ownerId(Integer ownerId) { + this.ownerId = Optional.ofNullable(ownerId); + return this; + } + + /** + *

Whether the contact has had an email sent to them hard bounce.

+ */ + @JsonSetter(value = "has_hard_bounced", nulls = Nulls.SKIP) + public Builder hasHardBounced(Optional hasHardBounced) { + this.hasHardBounced = hasHardBounced; + return this; + } + + public Builder hasHardBounced(Boolean hasHardBounced) { + this.hasHardBounced = Optional.ofNullable(hasHardBounced); + return this; + } + + /** + *

Whether the contact has marked an email sent to them as spam.

+ */ + @JsonSetter(value = "marked_email_as_spam", nulls = Nulls.SKIP) + public Builder markedEmailAsSpam(Optional markedEmailAsSpam) { + this.markedEmailAsSpam = markedEmailAsSpam; + return this; + } + + public Builder markedEmailAsSpam(Boolean markedEmailAsSpam) { + this.markedEmailAsSpam = Optional.ofNullable(markedEmailAsSpam); + return this; + } + + /** + *

Whether the contact is unsubscribed from emails.

+ */ + @JsonSetter(value = "unsubscribed_from_emails", nulls = Nulls.SKIP) + public Builder unsubscribedFromEmails(Optional unsubscribedFromEmails) { + this.unsubscribedFromEmails = unsubscribedFromEmails; + return this; + } + + public Builder unsubscribedFromEmails(Boolean unsubscribedFromEmails) { + this.unsubscribedFromEmails = Optional.ofNullable(unsubscribedFromEmails); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact was created.

+ */ + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public Builder createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + public Builder createdAt(Integer createdAt) { + this.createdAt = Optional.ofNullable(createdAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact was last updated.

+ */ + @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) + public Builder updatedAt(Optional updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + public Builder updatedAt(Integer updatedAt) { + this.updatedAt = Optional.ofNullable(updatedAt); + return this; + } + + /** + *

(UNIX timestamp) The time specified for when a contact signed up.

+ */ + @JsonSetter(value = "signed_up_at", nulls = Nulls.SKIP) + public Builder signedUpAt(Optional signedUpAt) { + this.signedUpAt = signedUpAt; + return this; + } + + public Builder signedUpAt(Integer signedUpAt) { + this.signedUpAt = Optional.ofNullable(signedUpAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact was last seen (either where the Intercom Messenger was installed or when specified manually).

+ */ + @JsonSetter(value = "last_seen_at", nulls = Nulls.SKIP) + public Builder lastSeenAt(Optional lastSeenAt) { + this.lastSeenAt = lastSeenAt; + return this; + } + + public Builder lastSeenAt(Integer lastSeenAt) { + this.lastSeenAt = Optional.ofNullable(lastSeenAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact last messaged in.

+ */ + @JsonSetter(value = "last_replied_at", nulls = Nulls.SKIP) + public Builder lastRepliedAt(Optional lastRepliedAt) { + this.lastRepliedAt = lastRepliedAt; + return this; + } + + public Builder lastRepliedAt(Integer lastRepliedAt) { + this.lastRepliedAt = Optional.ofNullable(lastRepliedAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact was last messaged.

+ */ + @JsonSetter(value = "last_contacted_at", nulls = Nulls.SKIP) + public Builder lastContactedAt(Optional lastContactedAt) { + this.lastContactedAt = lastContactedAt; + return this; + } + + public Builder lastContactedAt(Integer lastContactedAt) { + this.lastContactedAt = Optional.ofNullable(lastContactedAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact last opened an email.

+ */ + @JsonSetter(value = "last_email_opened_at", nulls = Nulls.SKIP) + public Builder lastEmailOpenedAt(Optional lastEmailOpenedAt) { + this.lastEmailOpenedAt = lastEmailOpenedAt; + return this; + } + + public Builder lastEmailOpenedAt(Integer lastEmailOpenedAt) { + this.lastEmailOpenedAt = Optional.ofNullable(lastEmailOpenedAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact last clicked a link in an email.

+ */ + @JsonSetter(value = "last_email_clicked_at", nulls = Nulls.SKIP) + public Builder lastEmailClickedAt(Optional lastEmailClickedAt) { + this.lastEmailClickedAt = lastEmailClickedAt; + return this; + } + + public Builder lastEmailClickedAt(Integer lastEmailClickedAt) { + this.lastEmailClickedAt = Optional.ofNullable(lastEmailClickedAt); + return this; + } + + /** + *

A preferred language setting for the contact, used by the Intercom Messenger even if their browser settings change.

+ */ + @JsonSetter(value = "language_override", nulls = Nulls.SKIP) + public Builder languageOverride(Optional languageOverride) { + this.languageOverride = languageOverride; + return this; + } + + public Builder languageOverride(String languageOverride) { + this.languageOverride = Optional.ofNullable(languageOverride); + return this; + } + + /** + *

The name of the browser which the contact is using.

+ */ + @JsonSetter(value = "browser", nulls = Nulls.SKIP) + public Builder browser(Optional browser) { + this.browser = browser; + return this; + } + + public Builder browser(String browser) { + this.browser = Optional.ofNullable(browser); + return this; + } + + /** + *

The version of the browser which the contact is using.

+ */ + @JsonSetter(value = "browser_version", nulls = Nulls.SKIP) + public Builder browserVersion(Optional browserVersion) { + this.browserVersion = browserVersion; + return this; + } + + public Builder browserVersion(String browserVersion) { + this.browserVersion = Optional.ofNullable(browserVersion); + return this; + } + + /** + *

The language set by the browser which the contact is using.

+ */ + @JsonSetter(value = "browser_language", nulls = Nulls.SKIP) + public Builder browserLanguage(Optional browserLanguage) { + this.browserLanguage = browserLanguage; + return this; + } + + public Builder browserLanguage(String browserLanguage) { + this.browserLanguage = Optional.ofNullable(browserLanguage); + return this; + } + + /** + *

The operating system which the contact is using.

+ */ + @JsonSetter(value = "os", nulls = Nulls.SKIP) + public Builder os(Optional os) { + this.os = os; + return this; + } + + public Builder os(String os) { + this.os = Optional.ofNullable(os); + return this; + } + + /** + *

The name of the Android app which the contact is using.

+ */ + @JsonSetter(value = "android_app_name", nulls = Nulls.SKIP) + public Builder androidAppName(Optional androidAppName) { + this.androidAppName = androidAppName; + return this; + } + + public Builder androidAppName(String androidAppName) { + this.androidAppName = Optional.ofNullable(androidAppName); + return this; + } + + /** + *

The version of the Android app which the contact is using.

+ */ + @JsonSetter(value = "android_app_version", nulls = Nulls.SKIP) + public Builder androidAppVersion(Optional androidAppVersion) { + this.androidAppVersion = androidAppVersion; + return this; + } + + public Builder androidAppVersion(String androidAppVersion) { + this.androidAppVersion = Optional.ofNullable(androidAppVersion); + return this; + } + + /** + *

The Android device which the contact is using.

+ */ + @JsonSetter(value = "android_device", nulls = Nulls.SKIP) + public Builder androidDevice(Optional androidDevice) { + this.androidDevice = androidDevice; + return this; + } + + public Builder androidDevice(String androidDevice) { + this.androidDevice = Optional.ofNullable(androidDevice); + return this; + } + + /** + *

The version of the Android OS which the contact is using.

+ */ + @JsonSetter(value = "android_os_version", nulls = Nulls.SKIP) + public Builder androidOsVersion(Optional androidOsVersion) { + this.androidOsVersion = androidOsVersion; + return this; + } + + public Builder androidOsVersion(String androidOsVersion) { + this.androidOsVersion = Optional.ofNullable(androidOsVersion); + return this; + } + + /** + *

The version of the Android SDK which the contact is using.

+ */ + @JsonSetter(value = "android_sdk_version", nulls = Nulls.SKIP) + public Builder androidSdkVersion(Optional androidSdkVersion) { + this.androidSdkVersion = androidSdkVersion; + return this; + } + + public Builder androidSdkVersion(String androidSdkVersion) { + this.androidSdkVersion = Optional.ofNullable(androidSdkVersion); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact was last seen on an Android device.

+ */ + @JsonSetter(value = "android_last_seen_at", nulls = Nulls.SKIP) + public Builder androidLastSeenAt(Optional androidLastSeenAt) { + this.androidLastSeenAt = androidLastSeenAt; + return this; + } + + public Builder androidLastSeenAt(Integer androidLastSeenAt) { + this.androidLastSeenAt = Optional.ofNullable(androidLastSeenAt); + return this; + } + + /** + *

The name of the iOS app which the contact is using.

+ */ + @JsonSetter(value = "ios_app_name", nulls = Nulls.SKIP) + public Builder iosAppName(Optional iosAppName) { + this.iosAppName = iosAppName; + return this; + } + + public Builder iosAppName(String iosAppName) { + this.iosAppName = Optional.ofNullable(iosAppName); + return this; + } + + /** + *

The version of the iOS app which the contact is using.

+ */ + @JsonSetter(value = "ios_app_version", nulls = Nulls.SKIP) + public Builder iosAppVersion(Optional iosAppVersion) { + this.iosAppVersion = iosAppVersion; + return this; + } + + public Builder iosAppVersion(String iosAppVersion) { + this.iosAppVersion = Optional.ofNullable(iosAppVersion); + return this; + } + + /** + *

The iOS device which the contact is using.

+ */ + @JsonSetter(value = "ios_device", nulls = Nulls.SKIP) + public Builder iosDevice(Optional iosDevice) { + this.iosDevice = iosDevice; + return this; + } + + public Builder iosDevice(String iosDevice) { + this.iosDevice = Optional.ofNullable(iosDevice); + return this; + } + + /** + *

The version of iOS which the contact is using.

+ */ + @JsonSetter(value = "ios_os_version", nulls = Nulls.SKIP) + public Builder iosOsVersion(Optional iosOsVersion) { + this.iosOsVersion = iosOsVersion; + return this; + } + + public Builder iosOsVersion(String iosOsVersion) { + this.iosOsVersion = Optional.ofNullable(iosOsVersion); + return this; + } + + /** + *

The version of the iOS SDK which the contact is using.

+ */ + @JsonSetter(value = "ios_sdk_version", nulls = Nulls.SKIP) + public Builder iosSdkVersion(Optional iosSdkVersion) { + this.iosSdkVersion = iosSdkVersion; + return this; + } + + public Builder iosSdkVersion(String iosSdkVersion) { + this.iosSdkVersion = Optional.ofNullable(iosSdkVersion); + return this; + } + + /** + *

(UNIX timestamp) The last time the contact used the iOS app.

+ */ + @JsonSetter(value = "ios_last_seen_at", nulls = Nulls.SKIP) + public Builder iosLastSeenAt(Optional iosLastSeenAt) { + this.iosLastSeenAt = iosLastSeenAt; + return this; + } + + public Builder iosLastSeenAt(Integer iosLastSeenAt) { + this.iosLastSeenAt = Optional.ofNullable(iosLastSeenAt); + return this; + } + + /** + *

The custom attributes which are set for the contact.

+ */ + @JsonSetter(value = "custom_attributes", nulls = Nulls.SKIP) + public Builder customAttributes(Optional> customAttributes) { + this.customAttributes = customAttributes; + return this; + } + + public Builder customAttributes(Map customAttributes) { + this.customAttributes = Optional.ofNullable(customAttributes); + return this; + } + + /** + *

An image URL containing the avatar of a contact.

+ */ + @JsonSetter(value = "avatar", nulls = Nulls.SKIP) + public Builder avatar(Optional avatar) { + this.avatar = avatar; + return this; + } + + public Builder avatar(String avatar) { + this.avatar = Optional.ofNullable(avatar); + return this; + } + + @JsonSetter(value = "tags", nulls = Nulls.SKIP) + public Builder tags(Optional tags) { + this.tags = tags; + return this; + } + + public Builder tags(ContactTags tags) { + this.tags = Optional.ofNullable(tags); + return this; + } + + @JsonSetter(value = "notes", nulls = Nulls.SKIP) + public Builder notes(Optional notes) { + this.notes = notes; + return this; + } + + public Builder notes(ContactNotes notes) { + this.notes = Optional.ofNullable(notes); + return this; + } + + @JsonSetter(value = "companies", nulls = Nulls.SKIP) + public Builder companies(Optional companies) { + this.companies = companies; + return this; + } + + public Builder companies(ContactCompanies companies) { + this.companies = Optional.ofNullable(companies); + return this; + } + + @JsonSetter(value = "location", nulls = Nulls.SKIP) + public Builder location(Optional location) { + this.location = location; + return this; + } + + public Builder location(ContactLocation location) { + this.location = Optional.ofNullable(location); + return this; + } + + @JsonSetter(value = "social_profiles", nulls = Nulls.SKIP) + public Builder socialProfiles(Optional socialProfiles) { + this.socialProfiles = socialProfiles; + return this; + } + + public Builder socialProfiles(ContactSocialProfiles socialProfiles) { + this.socialProfiles = Optional.ofNullable(socialProfiles); + return this; + } + + /** + *

If the user has enabled push messaging.

+ */ + @JsonSetter(value = "enabled_push_messaging", nulls = Nulls.SKIP) + public Builder enabledPushMessaging(Optional enabledPushMessaging) { + this.enabledPushMessaging = enabledPushMessaging; + return this; + } + + public Builder enabledPushMessaging(Boolean enabledPushMessaging) { + this.enabledPushMessaging = Optional.ofNullable(enabledPushMessaging); + return this; + } + + public ContactsUpdateResponse build() { + return new ContactsUpdateResponse( + type, + id, + externalId, + workspaceId, + role, + email, + emailDomain, + phone, + name, + ownerId, + hasHardBounced, + markedEmailAsSpam, + unsubscribedFromEmails, + createdAt, + updatedAt, + signedUpAt, + lastSeenAt, + lastRepliedAt, + lastContactedAt, + lastEmailOpenedAt, + lastEmailClickedAt, + languageOverride, + browser, + browserVersion, + browserLanguage, + os, + androidAppName, + androidAppVersion, + androidDevice, + androidOsVersion, + androidSdkVersion, + androidLastSeenAt, + iosAppName, + iosAppVersion, + iosDevice, + iosOsVersion, + iosSdkVersion, + iosLastSeenAt, + customAttributes, + avatar, + tags, + notes, + companies, + location, + socialProfiles, + enabledPushMessaging, + additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/contacts/types/IContact.java b/src/main/java/com/intercom/api/resources/contacts/types/IContact.java new file mode 100644 index 0000000..faa1acb --- /dev/null +++ b/src/main/java/com/intercom/api/resources/contacts/types/IContact.java @@ -0,0 +1,104 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.contacts.types; + +import com.intercom.api.types.ContactCompanies; +import com.intercom.api.types.ContactLocation; +import com.intercom.api.types.ContactNotes; +import com.intercom.api.types.ContactSocialProfiles; +import com.intercom.api.types.ContactTags; +import java.util.Map; +import java.util.Optional; + +public interface IContact { + Optional getType(); + + Optional getId(); + + Optional getExternalId(); + + Optional getWorkspaceId(); + + Optional getRole(); + + Optional getEmail(); + + Optional getEmailDomain(); + + Optional getPhone(); + + Optional getName(); + + Optional getOwnerId(); + + Optional getHasHardBounced(); + + Optional getMarkedEmailAsSpam(); + + Optional getUnsubscribedFromEmails(); + + Optional getCreatedAt(); + + Optional getUpdatedAt(); + + Optional getSignedUpAt(); + + Optional getLastSeenAt(); + + Optional getLastRepliedAt(); + + Optional getLastContactedAt(); + + Optional getLastEmailOpenedAt(); + + Optional getLastEmailClickedAt(); + + Optional getLanguageOverride(); + + Optional getBrowser(); + + Optional getBrowserVersion(); + + Optional getBrowserLanguage(); + + Optional getOs(); + + Optional getAndroidAppName(); + + Optional getAndroidAppVersion(); + + Optional getAndroidDevice(); + + Optional getAndroidOsVersion(); + + Optional getAndroidSdkVersion(); + + Optional getAndroidLastSeenAt(); + + Optional getIosAppName(); + + Optional getIosAppVersion(); + + Optional getIosDevice(); + + Optional getIosOsVersion(); + + Optional getIosSdkVersion(); + + Optional getIosLastSeenAt(); + + Optional> getCustomAttributes(); + + Optional getAvatar(); + + Optional getTags(); + + Optional getNotes(); + + Optional getCompanies(); + + Optional getLocation(); + + Optional getSocialProfiles(); +} diff --git a/src/main/java/com/intercom/api/resources/contacts/types/ShowContactByExternalIdResponse.java b/src/main/java/com/intercom/api/resources/contacts/types/ShowContactByExternalIdResponse.java new file mode 100644 index 0000000..c48d03a --- /dev/null +++ b/src/main/java/com/intercom/api/resources/contacts/types/ShowContactByExternalIdResponse.java @@ -0,0 +1,1521 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.contacts.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.types.ContactCompanies; +import com.intercom.api.types.ContactLocation; +import com.intercom.api.types.ContactNotes; +import com.intercom.api.types.ContactSocialProfiles; +import com.intercom.api.types.ContactTags; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ShowContactByExternalIdResponse.Builder.class) +public final class ShowContactByExternalIdResponse implements IContact { + private final Optional type; + + private final Optional id; + + private final Optional externalId; + + private final Optional workspaceId; + + private final Optional role; + + private final Optional email; + + private final Optional emailDomain; + + private final Optional phone; + + private final Optional name; + + private final Optional ownerId; + + private final Optional hasHardBounced; + + private final Optional markedEmailAsSpam; + + private final Optional unsubscribedFromEmails; + + private final Optional createdAt; + + private final Optional updatedAt; + + private final Optional signedUpAt; + + private final Optional lastSeenAt; + + private final Optional lastRepliedAt; + + private final Optional lastContactedAt; + + private final Optional lastEmailOpenedAt; + + private final Optional lastEmailClickedAt; + + private final Optional languageOverride; + + private final Optional browser; + + private final Optional browserVersion; + + private final Optional browserLanguage; + + private final Optional os; + + private final Optional androidAppName; + + private final Optional androidAppVersion; + + private final Optional androidDevice; + + private final Optional androidOsVersion; + + private final Optional androidSdkVersion; + + private final Optional androidLastSeenAt; + + private final Optional iosAppName; + + private final Optional iosAppVersion; + + private final Optional iosDevice; + + private final Optional iosOsVersion; + + private final Optional iosSdkVersion; + + private final Optional iosLastSeenAt; + + private final Optional> customAttributes; + + private final Optional avatar; + + private final Optional tags; + + private final Optional notes; + + private final Optional companies; + + private final Optional location; + + private final Optional socialProfiles; + + private final Optional enabledPushMessaging; + + private final Map additionalProperties; + + private ShowContactByExternalIdResponse( + Optional type, + Optional id, + Optional externalId, + Optional workspaceId, + Optional role, + Optional email, + Optional emailDomain, + Optional phone, + Optional name, + Optional ownerId, + Optional hasHardBounced, + Optional markedEmailAsSpam, + Optional unsubscribedFromEmails, + Optional createdAt, + Optional updatedAt, + Optional signedUpAt, + Optional lastSeenAt, + Optional lastRepliedAt, + Optional lastContactedAt, + Optional lastEmailOpenedAt, + Optional lastEmailClickedAt, + Optional languageOverride, + Optional browser, + Optional browserVersion, + Optional browserLanguage, + Optional os, + Optional androidAppName, + Optional androidAppVersion, + Optional androidDevice, + Optional androidOsVersion, + Optional androidSdkVersion, + Optional androidLastSeenAt, + Optional iosAppName, + Optional iosAppVersion, + Optional iosDevice, + Optional iosOsVersion, + Optional iosSdkVersion, + Optional iosLastSeenAt, + Optional> customAttributes, + Optional avatar, + Optional tags, + Optional notes, + Optional companies, + Optional location, + Optional socialProfiles, + Optional enabledPushMessaging, + Map additionalProperties) { + this.type = type; + this.id = id; + this.externalId = externalId; + this.workspaceId = workspaceId; + this.role = role; + this.email = email; + this.emailDomain = emailDomain; + this.phone = phone; + this.name = name; + this.ownerId = ownerId; + this.hasHardBounced = hasHardBounced; + this.markedEmailAsSpam = markedEmailAsSpam; + this.unsubscribedFromEmails = unsubscribedFromEmails; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.signedUpAt = signedUpAt; + this.lastSeenAt = lastSeenAt; + this.lastRepliedAt = lastRepliedAt; + this.lastContactedAt = lastContactedAt; + this.lastEmailOpenedAt = lastEmailOpenedAt; + this.lastEmailClickedAt = lastEmailClickedAt; + this.languageOverride = languageOverride; + this.browser = browser; + this.browserVersion = browserVersion; + this.browserLanguage = browserLanguage; + this.os = os; + this.androidAppName = androidAppName; + this.androidAppVersion = androidAppVersion; + this.androidDevice = androidDevice; + this.androidOsVersion = androidOsVersion; + this.androidSdkVersion = androidSdkVersion; + this.androidLastSeenAt = androidLastSeenAt; + this.iosAppName = iosAppName; + this.iosAppVersion = iosAppVersion; + this.iosDevice = iosDevice; + this.iosOsVersion = iosOsVersion; + this.iosSdkVersion = iosSdkVersion; + this.iosLastSeenAt = iosLastSeenAt; + this.customAttributes = customAttributes; + this.avatar = avatar; + this.tags = tags; + this.notes = notes; + this.companies = companies; + this.location = location; + this.socialProfiles = socialProfiles; + this.enabledPushMessaging = enabledPushMessaging; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of object. + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return The unique identifier for the contact which is given by Intercom. + */ + @JsonProperty("id") + public Optional getId() { + return id; + } + + /** + * @return The unique identifier for the contact which is provided by the Client. + */ + @JsonProperty("external_id") + public Optional getExternalId() { + return externalId; + } + + /** + * @return The id of the workspace which the contact belongs to. + */ + @JsonProperty("workspace_id") + public Optional getWorkspaceId() { + return workspaceId; + } + + /** + * @return The role of the contact. + */ + @JsonProperty("role") + public Optional getRole() { + return role; + } + + /** + * @return The contact's email. + */ + @JsonProperty("email") + public Optional getEmail() { + return email; + } + + /** + * @return The contact's email domain. + */ + @JsonProperty("email_domain") + public Optional getEmailDomain() { + return emailDomain; + } + + /** + * @return The contacts phone. + */ + @JsonProperty("phone") + public Optional getPhone() { + return phone; + } + + /** + * @return The contacts name. + */ + @JsonProperty("name") + public Optional getName() { + return name; + } + + /** + * @return The id of an admin that has been assigned account ownership of the contact. + */ + @JsonProperty("owner_id") + public Optional getOwnerId() { + return ownerId; + } + + /** + * @return Whether the contact has had an email sent to them hard bounce. + */ + @JsonProperty("has_hard_bounced") + public Optional getHasHardBounced() { + return hasHardBounced; + } + + /** + * @return Whether the contact has marked an email sent to them as spam. + */ + @JsonProperty("marked_email_as_spam") + public Optional getMarkedEmailAsSpam() { + return markedEmailAsSpam; + } + + /** + * @return Whether the contact is unsubscribed from emails. + */ + @JsonProperty("unsubscribed_from_emails") + public Optional getUnsubscribedFromEmails() { + return unsubscribedFromEmails; + } + + /** + * @return (UNIX timestamp) The time when the contact was created. + */ + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + /** + * @return (UNIX timestamp) The time when the contact was last updated. + */ + @JsonProperty("updated_at") + public Optional getUpdatedAt() { + return updatedAt; + } + + /** + * @return (UNIX timestamp) The time specified for when a contact signed up. + */ + @JsonProperty("signed_up_at") + public Optional getSignedUpAt() { + return signedUpAt; + } + + /** + * @return (UNIX timestamp) The time when the contact was last seen (either where the Intercom Messenger was installed or when specified manually). + */ + @JsonProperty("last_seen_at") + public Optional getLastSeenAt() { + return lastSeenAt; + } + + /** + * @return (UNIX timestamp) The time when the contact last messaged in. + */ + @JsonProperty("last_replied_at") + public Optional getLastRepliedAt() { + return lastRepliedAt; + } + + /** + * @return (UNIX timestamp) The time when the contact was last messaged. + */ + @JsonProperty("last_contacted_at") + public Optional getLastContactedAt() { + return lastContactedAt; + } + + /** + * @return (UNIX timestamp) The time when the contact last opened an email. + */ + @JsonProperty("last_email_opened_at") + public Optional getLastEmailOpenedAt() { + return lastEmailOpenedAt; + } + + /** + * @return (UNIX timestamp) The time when the contact last clicked a link in an email. + */ + @JsonProperty("last_email_clicked_at") + public Optional getLastEmailClickedAt() { + return lastEmailClickedAt; + } + + /** + * @return A preferred language setting for the contact, used by the Intercom Messenger even if their browser settings change. + */ + @JsonProperty("language_override") + public Optional getLanguageOverride() { + return languageOverride; + } + + /** + * @return The name of the browser which the contact is using. + */ + @JsonProperty("browser") + public Optional getBrowser() { + return browser; + } + + /** + * @return The version of the browser which the contact is using. + */ + @JsonProperty("browser_version") + public Optional getBrowserVersion() { + return browserVersion; + } + + /** + * @return The language set by the browser which the contact is using. + */ + @JsonProperty("browser_language") + public Optional getBrowserLanguage() { + return browserLanguage; + } + + /** + * @return The operating system which the contact is using. + */ + @JsonProperty("os") + public Optional getOs() { + return os; + } + + /** + * @return The name of the Android app which the contact is using. + */ + @JsonProperty("android_app_name") + public Optional getAndroidAppName() { + return androidAppName; + } + + /** + * @return The version of the Android app which the contact is using. + */ + @JsonProperty("android_app_version") + public Optional getAndroidAppVersion() { + return androidAppVersion; + } + + /** + * @return The Android device which the contact is using. + */ + @JsonProperty("android_device") + public Optional getAndroidDevice() { + return androidDevice; + } + + /** + * @return The version of the Android OS which the contact is using. + */ + @JsonProperty("android_os_version") + public Optional getAndroidOsVersion() { + return androidOsVersion; + } + + /** + * @return The version of the Android SDK which the contact is using. + */ + @JsonProperty("android_sdk_version") + public Optional getAndroidSdkVersion() { + return androidSdkVersion; + } + + /** + * @return (UNIX timestamp) The time when the contact was last seen on an Android device. + */ + @JsonProperty("android_last_seen_at") + public Optional getAndroidLastSeenAt() { + return androidLastSeenAt; + } + + /** + * @return The name of the iOS app which the contact is using. + */ + @JsonProperty("ios_app_name") + public Optional getIosAppName() { + return iosAppName; + } + + /** + * @return The version of the iOS app which the contact is using. + */ + @JsonProperty("ios_app_version") + public Optional getIosAppVersion() { + return iosAppVersion; + } + + /** + * @return The iOS device which the contact is using. + */ + @JsonProperty("ios_device") + public Optional getIosDevice() { + return iosDevice; + } + + /** + * @return The version of iOS which the contact is using. + */ + @JsonProperty("ios_os_version") + public Optional getIosOsVersion() { + return iosOsVersion; + } + + /** + * @return The version of the iOS SDK which the contact is using. + */ + @JsonProperty("ios_sdk_version") + public Optional getIosSdkVersion() { + return iosSdkVersion; + } + + /** + * @return (UNIX timestamp) The last time the contact used the iOS app. + */ + @JsonProperty("ios_last_seen_at") + public Optional getIosLastSeenAt() { + return iosLastSeenAt; + } + + /** + * @return The custom attributes which are set for the contact. + */ + @JsonProperty("custom_attributes") + public Optional> getCustomAttributes() { + return customAttributes; + } + + /** + * @return An image URL containing the avatar of a contact. + */ + @JsonProperty("avatar") + public Optional getAvatar() { + return avatar; + } + + @JsonProperty("tags") + public Optional getTags() { + return tags; + } + + @JsonProperty("notes") + public Optional getNotes() { + return notes; + } + + @JsonProperty("companies") + public Optional getCompanies() { + return companies; + } + + @JsonProperty("location") + public Optional getLocation() { + return location; + } + + @JsonProperty("social_profiles") + public Optional getSocialProfiles() { + return socialProfiles; + } + + /** + * @return If the user has enabled push messaging. + */ + @JsonProperty("enabled_push_messaging") + public Optional getEnabledPushMessaging() { + return enabledPushMessaging; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ShowContactByExternalIdResponse && equalTo((ShowContactByExternalIdResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ShowContactByExternalIdResponse other) { + return type.equals(other.type) + && id.equals(other.id) + && externalId.equals(other.externalId) + && workspaceId.equals(other.workspaceId) + && role.equals(other.role) + && email.equals(other.email) + && emailDomain.equals(other.emailDomain) + && phone.equals(other.phone) + && name.equals(other.name) + && ownerId.equals(other.ownerId) + && hasHardBounced.equals(other.hasHardBounced) + && markedEmailAsSpam.equals(other.markedEmailAsSpam) + && unsubscribedFromEmails.equals(other.unsubscribedFromEmails) + && createdAt.equals(other.createdAt) + && updatedAt.equals(other.updatedAt) + && signedUpAt.equals(other.signedUpAt) + && lastSeenAt.equals(other.lastSeenAt) + && lastRepliedAt.equals(other.lastRepliedAt) + && lastContactedAt.equals(other.lastContactedAt) + && lastEmailOpenedAt.equals(other.lastEmailOpenedAt) + && lastEmailClickedAt.equals(other.lastEmailClickedAt) + && languageOverride.equals(other.languageOverride) + && browser.equals(other.browser) + && browserVersion.equals(other.browserVersion) + && browserLanguage.equals(other.browserLanguage) + && os.equals(other.os) + && androidAppName.equals(other.androidAppName) + && androidAppVersion.equals(other.androidAppVersion) + && androidDevice.equals(other.androidDevice) + && androidOsVersion.equals(other.androidOsVersion) + && androidSdkVersion.equals(other.androidSdkVersion) + && androidLastSeenAt.equals(other.androidLastSeenAt) + && iosAppName.equals(other.iosAppName) + && iosAppVersion.equals(other.iosAppVersion) + && iosDevice.equals(other.iosDevice) + && iosOsVersion.equals(other.iosOsVersion) + && iosSdkVersion.equals(other.iosSdkVersion) + && iosLastSeenAt.equals(other.iosLastSeenAt) + && customAttributes.equals(other.customAttributes) + && avatar.equals(other.avatar) + && tags.equals(other.tags) + && notes.equals(other.notes) + && companies.equals(other.companies) + && location.equals(other.location) + && socialProfiles.equals(other.socialProfiles) + && enabledPushMessaging.equals(other.enabledPushMessaging); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.type, + this.id, + this.externalId, + this.workspaceId, + this.role, + this.email, + this.emailDomain, + this.phone, + this.name, + this.ownerId, + this.hasHardBounced, + this.markedEmailAsSpam, + this.unsubscribedFromEmails, + this.createdAt, + this.updatedAt, + this.signedUpAt, + this.lastSeenAt, + this.lastRepliedAt, + this.lastContactedAt, + this.lastEmailOpenedAt, + this.lastEmailClickedAt, + this.languageOverride, + this.browser, + this.browserVersion, + this.browserLanguage, + this.os, + this.androidAppName, + this.androidAppVersion, + this.androidDevice, + this.androidOsVersion, + this.androidSdkVersion, + this.androidLastSeenAt, + this.iosAppName, + this.iosAppVersion, + this.iosDevice, + this.iosOsVersion, + this.iosSdkVersion, + this.iosLastSeenAt, + this.customAttributes, + this.avatar, + this.tags, + this.notes, + this.companies, + this.location, + this.socialProfiles, + this.enabledPushMessaging); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); + + private Optional id = Optional.empty(); + + private Optional externalId = Optional.empty(); + + private Optional workspaceId = Optional.empty(); + + private Optional role = Optional.empty(); + + private Optional email = Optional.empty(); + + private Optional emailDomain = Optional.empty(); + + private Optional phone = Optional.empty(); + + private Optional name = Optional.empty(); + + private Optional ownerId = Optional.empty(); + + private Optional hasHardBounced = Optional.empty(); + + private Optional markedEmailAsSpam = Optional.empty(); + + private Optional unsubscribedFromEmails = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + private Optional updatedAt = Optional.empty(); + + private Optional signedUpAt = Optional.empty(); + + private Optional lastSeenAt = Optional.empty(); + + private Optional lastRepliedAt = Optional.empty(); + + private Optional lastContactedAt = Optional.empty(); + + private Optional lastEmailOpenedAt = Optional.empty(); + + private Optional lastEmailClickedAt = Optional.empty(); + + private Optional languageOverride = Optional.empty(); + + private Optional browser = Optional.empty(); + + private Optional browserVersion = Optional.empty(); + + private Optional browserLanguage = Optional.empty(); + + private Optional os = Optional.empty(); + + private Optional androidAppName = Optional.empty(); + + private Optional androidAppVersion = Optional.empty(); + + private Optional androidDevice = Optional.empty(); + + private Optional androidOsVersion = Optional.empty(); + + private Optional androidSdkVersion = Optional.empty(); + + private Optional androidLastSeenAt = Optional.empty(); + + private Optional iosAppName = Optional.empty(); + + private Optional iosAppVersion = Optional.empty(); + + private Optional iosDevice = Optional.empty(); + + private Optional iosOsVersion = Optional.empty(); + + private Optional iosSdkVersion = Optional.empty(); + + private Optional iosLastSeenAt = Optional.empty(); + + private Optional> customAttributes = Optional.empty(); + + private Optional avatar = Optional.empty(); + + private Optional tags = Optional.empty(); + + private Optional notes = Optional.empty(); + + private Optional companies = Optional.empty(); + + private Optional location = Optional.empty(); + + private Optional socialProfiles = Optional.empty(); + + private Optional enabledPushMessaging = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ShowContactByExternalIdResponse other) { + type(other.getType()); + id(other.getId()); + externalId(other.getExternalId()); + workspaceId(other.getWorkspaceId()); + role(other.getRole()); + email(other.getEmail()); + emailDomain(other.getEmailDomain()); + phone(other.getPhone()); + name(other.getName()); + ownerId(other.getOwnerId()); + hasHardBounced(other.getHasHardBounced()); + markedEmailAsSpam(other.getMarkedEmailAsSpam()); + unsubscribedFromEmails(other.getUnsubscribedFromEmails()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + signedUpAt(other.getSignedUpAt()); + lastSeenAt(other.getLastSeenAt()); + lastRepliedAt(other.getLastRepliedAt()); + lastContactedAt(other.getLastContactedAt()); + lastEmailOpenedAt(other.getLastEmailOpenedAt()); + lastEmailClickedAt(other.getLastEmailClickedAt()); + languageOverride(other.getLanguageOverride()); + browser(other.getBrowser()); + browserVersion(other.getBrowserVersion()); + browserLanguage(other.getBrowserLanguage()); + os(other.getOs()); + androidAppName(other.getAndroidAppName()); + androidAppVersion(other.getAndroidAppVersion()); + androidDevice(other.getAndroidDevice()); + androidOsVersion(other.getAndroidOsVersion()); + androidSdkVersion(other.getAndroidSdkVersion()); + androidLastSeenAt(other.getAndroidLastSeenAt()); + iosAppName(other.getIosAppName()); + iosAppVersion(other.getIosAppVersion()); + iosDevice(other.getIosDevice()); + iosOsVersion(other.getIosOsVersion()); + iosSdkVersion(other.getIosSdkVersion()); + iosLastSeenAt(other.getIosLastSeenAt()); + customAttributes(other.getCustomAttributes()); + avatar(other.getAvatar()); + tags(other.getTags()); + notes(other.getNotes()); + companies(other.getCompanies()); + location(other.getLocation()); + socialProfiles(other.getSocialProfiles()); + enabledPushMessaging(other.getEnabledPushMessaging()); + return this; + } + + /** + *

The type of object.

+ */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + /** + *

The unique identifier for the contact which is given by Intercom.

+ */ + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.ofNullable(id); + return this; + } + + /** + *

The unique identifier for the contact which is provided by the Client.

+ */ + @JsonSetter(value = "external_id", nulls = Nulls.SKIP) + public Builder externalId(Optional externalId) { + this.externalId = externalId; + return this; + } + + public Builder externalId(String externalId) { + this.externalId = Optional.ofNullable(externalId); + return this; + } + + /** + *

The id of the workspace which the contact belongs to.

+ */ + @JsonSetter(value = "workspace_id", nulls = Nulls.SKIP) + public Builder workspaceId(Optional workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + public Builder workspaceId(String workspaceId) { + this.workspaceId = Optional.ofNullable(workspaceId); + return this; + } + + /** + *

The role of the contact.

+ */ + @JsonSetter(value = "role", nulls = Nulls.SKIP) + public Builder role(Optional role) { + this.role = role; + return this; + } + + public Builder role(String role) { + this.role = Optional.ofNullable(role); + return this; + } + + /** + *

The contact's email.

+ */ + @JsonSetter(value = "email", nulls = Nulls.SKIP) + public Builder email(Optional email) { + this.email = email; + return this; + } + + public Builder email(String email) { + this.email = Optional.ofNullable(email); + return this; + } + + /** + *

The contact's email domain.

+ */ + @JsonSetter(value = "email_domain", nulls = Nulls.SKIP) + public Builder emailDomain(Optional emailDomain) { + this.emailDomain = emailDomain; + return this; + } + + public Builder emailDomain(String emailDomain) { + this.emailDomain = Optional.ofNullable(emailDomain); + return this; + } + + /** + *

The contacts phone.

+ */ + @JsonSetter(value = "phone", nulls = Nulls.SKIP) + public Builder phone(Optional phone) { + this.phone = phone; + return this; + } + + public Builder phone(String phone) { + this.phone = Optional.ofNullable(phone); + return this; + } + + /** + *

The contacts name.

+ */ + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public Builder name(Optional name) { + this.name = name; + return this; + } + + public Builder name(String name) { + this.name = Optional.ofNullable(name); + return this; + } + + /** + *

The id of an admin that has been assigned account ownership of the contact.

+ */ + @JsonSetter(value = "owner_id", nulls = Nulls.SKIP) + public Builder ownerId(Optional ownerId) { + this.ownerId = ownerId; + return this; + } + + public Builder ownerId(Integer ownerId) { + this.ownerId = Optional.ofNullable(ownerId); + return this; + } + + /** + *

Whether the contact has had an email sent to them hard bounce.

+ */ + @JsonSetter(value = "has_hard_bounced", nulls = Nulls.SKIP) + public Builder hasHardBounced(Optional hasHardBounced) { + this.hasHardBounced = hasHardBounced; + return this; + } + + public Builder hasHardBounced(Boolean hasHardBounced) { + this.hasHardBounced = Optional.ofNullable(hasHardBounced); + return this; + } + + /** + *

Whether the contact has marked an email sent to them as spam.

+ */ + @JsonSetter(value = "marked_email_as_spam", nulls = Nulls.SKIP) + public Builder markedEmailAsSpam(Optional markedEmailAsSpam) { + this.markedEmailAsSpam = markedEmailAsSpam; + return this; + } + + public Builder markedEmailAsSpam(Boolean markedEmailAsSpam) { + this.markedEmailAsSpam = Optional.ofNullable(markedEmailAsSpam); + return this; + } + + /** + *

Whether the contact is unsubscribed from emails.

+ */ + @JsonSetter(value = "unsubscribed_from_emails", nulls = Nulls.SKIP) + public Builder unsubscribedFromEmails(Optional unsubscribedFromEmails) { + this.unsubscribedFromEmails = unsubscribedFromEmails; + return this; + } + + public Builder unsubscribedFromEmails(Boolean unsubscribedFromEmails) { + this.unsubscribedFromEmails = Optional.ofNullable(unsubscribedFromEmails); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact was created.

+ */ + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public Builder createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + public Builder createdAt(Integer createdAt) { + this.createdAt = Optional.ofNullable(createdAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact was last updated.

+ */ + @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) + public Builder updatedAt(Optional updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + public Builder updatedAt(Integer updatedAt) { + this.updatedAt = Optional.ofNullable(updatedAt); + return this; + } + + /** + *

(UNIX timestamp) The time specified for when a contact signed up.

+ */ + @JsonSetter(value = "signed_up_at", nulls = Nulls.SKIP) + public Builder signedUpAt(Optional signedUpAt) { + this.signedUpAt = signedUpAt; + return this; + } + + public Builder signedUpAt(Integer signedUpAt) { + this.signedUpAt = Optional.ofNullable(signedUpAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact was last seen (either where the Intercom Messenger was installed or when specified manually).

+ */ + @JsonSetter(value = "last_seen_at", nulls = Nulls.SKIP) + public Builder lastSeenAt(Optional lastSeenAt) { + this.lastSeenAt = lastSeenAt; + return this; + } + + public Builder lastSeenAt(Integer lastSeenAt) { + this.lastSeenAt = Optional.ofNullable(lastSeenAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact last messaged in.

+ */ + @JsonSetter(value = "last_replied_at", nulls = Nulls.SKIP) + public Builder lastRepliedAt(Optional lastRepliedAt) { + this.lastRepliedAt = lastRepliedAt; + return this; + } + + public Builder lastRepliedAt(Integer lastRepliedAt) { + this.lastRepliedAt = Optional.ofNullable(lastRepliedAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact was last messaged.

+ */ + @JsonSetter(value = "last_contacted_at", nulls = Nulls.SKIP) + public Builder lastContactedAt(Optional lastContactedAt) { + this.lastContactedAt = lastContactedAt; + return this; + } + + public Builder lastContactedAt(Integer lastContactedAt) { + this.lastContactedAt = Optional.ofNullable(lastContactedAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact last opened an email.

+ */ + @JsonSetter(value = "last_email_opened_at", nulls = Nulls.SKIP) + public Builder lastEmailOpenedAt(Optional lastEmailOpenedAt) { + this.lastEmailOpenedAt = lastEmailOpenedAt; + return this; + } + + public Builder lastEmailOpenedAt(Integer lastEmailOpenedAt) { + this.lastEmailOpenedAt = Optional.ofNullable(lastEmailOpenedAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact last clicked a link in an email.

+ */ + @JsonSetter(value = "last_email_clicked_at", nulls = Nulls.SKIP) + public Builder lastEmailClickedAt(Optional lastEmailClickedAt) { + this.lastEmailClickedAt = lastEmailClickedAt; + return this; + } + + public Builder lastEmailClickedAt(Integer lastEmailClickedAt) { + this.lastEmailClickedAt = Optional.ofNullable(lastEmailClickedAt); + return this; + } + + /** + *

A preferred language setting for the contact, used by the Intercom Messenger even if their browser settings change.

+ */ + @JsonSetter(value = "language_override", nulls = Nulls.SKIP) + public Builder languageOverride(Optional languageOverride) { + this.languageOverride = languageOverride; + return this; + } + + public Builder languageOverride(String languageOverride) { + this.languageOverride = Optional.ofNullable(languageOverride); + return this; + } + + /** + *

The name of the browser which the contact is using.

+ */ + @JsonSetter(value = "browser", nulls = Nulls.SKIP) + public Builder browser(Optional browser) { + this.browser = browser; + return this; + } + + public Builder browser(String browser) { + this.browser = Optional.ofNullable(browser); + return this; + } + + /** + *

The version of the browser which the contact is using.

+ */ + @JsonSetter(value = "browser_version", nulls = Nulls.SKIP) + public Builder browserVersion(Optional browserVersion) { + this.browserVersion = browserVersion; + return this; + } + + public Builder browserVersion(String browserVersion) { + this.browserVersion = Optional.ofNullable(browserVersion); + return this; + } + + /** + *

The language set by the browser which the contact is using.

+ */ + @JsonSetter(value = "browser_language", nulls = Nulls.SKIP) + public Builder browserLanguage(Optional browserLanguage) { + this.browserLanguage = browserLanguage; + return this; + } + + public Builder browserLanguage(String browserLanguage) { + this.browserLanguage = Optional.ofNullable(browserLanguage); + return this; + } + + /** + *

The operating system which the contact is using.

+ */ + @JsonSetter(value = "os", nulls = Nulls.SKIP) + public Builder os(Optional os) { + this.os = os; + return this; + } + + public Builder os(String os) { + this.os = Optional.ofNullable(os); + return this; + } + + /** + *

The name of the Android app which the contact is using.

+ */ + @JsonSetter(value = "android_app_name", nulls = Nulls.SKIP) + public Builder androidAppName(Optional androidAppName) { + this.androidAppName = androidAppName; + return this; + } + + public Builder androidAppName(String androidAppName) { + this.androidAppName = Optional.ofNullable(androidAppName); + return this; + } + + /** + *

The version of the Android app which the contact is using.

+ */ + @JsonSetter(value = "android_app_version", nulls = Nulls.SKIP) + public Builder androidAppVersion(Optional androidAppVersion) { + this.androidAppVersion = androidAppVersion; + return this; + } + + public Builder androidAppVersion(String androidAppVersion) { + this.androidAppVersion = Optional.ofNullable(androidAppVersion); + return this; + } + + /** + *

The Android device which the contact is using.

+ */ + @JsonSetter(value = "android_device", nulls = Nulls.SKIP) + public Builder androidDevice(Optional androidDevice) { + this.androidDevice = androidDevice; + return this; + } + + public Builder androidDevice(String androidDevice) { + this.androidDevice = Optional.ofNullable(androidDevice); + return this; + } + + /** + *

The version of the Android OS which the contact is using.

+ */ + @JsonSetter(value = "android_os_version", nulls = Nulls.SKIP) + public Builder androidOsVersion(Optional androidOsVersion) { + this.androidOsVersion = androidOsVersion; + return this; + } + + public Builder androidOsVersion(String androidOsVersion) { + this.androidOsVersion = Optional.ofNullable(androidOsVersion); + return this; + } + + /** + *

The version of the Android SDK which the contact is using.

+ */ + @JsonSetter(value = "android_sdk_version", nulls = Nulls.SKIP) + public Builder androidSdkVersion(Optional androidSdkVersion) { + this.androidSdkVersion = androidSdkVersion; + return this; + } + + public Builder androidSdkVersion(String androidSdkVersion) { + this.androidSdkVersion = Optional.ofNullable(androidSdkVersion); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact was last seen on an Android device.

+ */ + @JsonSetter(value = "android_last_seen_at", nulls = Nulls.SKIP) + public Builder androidLastSeenAt(Optional androidLastSeenAt) { + this.androidLastSeenAt = androidLastSeenAt; + return this; + } + + public Builder androidLastSeenAt(Integer androidLastSeenAt) { + this.androidLastSeenAt = Optional.ofNullable(androidLastSeenAt); + return this; + } + + /** + *

The name of the iOS app which the contact is using.

+ */ + @JsonSetter(value = "ios_app_name", nulls = Nulls.SKIP) + public Builder iosAppName(Optional iosAppName) { + this.iosAppName = iosAppName; + return this; + } + + public Builder iosAppName(String iosAppName) { + this.iosAppName = Optional.ofNullable(iosAppName); + return this; + } + + /** + *

The version of the iOS app which the contact is using.

+ */ + @JsonSetter(value = "ios_app_version", nulls = Nulls.SKIP) + public Builder iosAppVersion(Optional iosAppVersion) { + this.iosAppVersion = iosAppVersion; + return this; + } + + public Builder iosAppVersion(String iosAppVersion) { + this.iosAppVersion = Optional.ofNullable(iosAppVersion); + return this; + } + + /** + *

The iOS device which the contact is using.

+ */ + @JsonSetter(value = "ios_device", nulls = Nulls.SKIP) + public Builder iosDevice(Optional iosDevice) { + this.iosDevice = iosDevice; + return this; + } + + public Builder iosDevice(String iosDevice) { + this.iosDevice = Optional.ofNullable(iosDevice); + return this; + } + + /** + *

The version of iOS which the contact is using.

+ */ + @JsonSetter(value = "ios_os_version", nulls = Nulls.SKIP) + public Builder iosOsVersion(Optional iosOsVersion) { + this.iosOsVersion = iosOsVersion; + return this; + } + + public Builder iosOsVersion(String iosOsVersion) { + this.iosOsVersion = Optional.ofNullable(iosOsVersion); + return this; + } + + /** + *

The version of the iOS SDK which the contact is using.

+ */ + @JsonSetter(value = "ios_sdk_version", nulls = Nulls.SKIP) + public Builder iosSdkVersion(Optional iosSdkVersion) { + this.iosSdkVersion = iosSdkVersion; + return this; + } + + public Builder iosSdkVersion(String iosSdkVersion) { + this.iosSdkVersion = Optional.ofNullable(iosSdkVersion); + return this; + } + + /** + *

(UNIX timestamp) The last time the contact used the iOS app.

+ */ + @JsonSetter(value = "ios_last_seen_at", nulls = Nulls.SKIP) + public Builder iosLastSeenAt(Optional iosLastSeenAt) { + this.iosLastSeenAt = iosLastSeenAt; + return this; + } + + public Builder iosLastSeenAt(Integer iosLastSeenAt) { + this.iosLastSeenAt = Optional.ofNullable(iosLastSeenAt); + return this; + } + + /** + *

The custom attributes which are set for the contact.

+ */ + @JsonSetter(value = "custom_attributes", nulls = Nulls.SKIP) + public Builder customAttributes(Optional> customAttributes) { + this.customAttributes = customAttributes; + return this; + } + + public Builder customAttributes(Map customAttributes) { + this.customAttributes = Optional.ofNullable(customAttributes); + return this; + } + + /** + *

An image URL containing the avatar of a contact.

+ */ + @JsonSetter(value = "avatar", nulls = Nulls.SKIP) + public Builder avatar(Optional avatar) { + this.avatar = avatar; + return this; + } + + public Builder avatar(String avatar) { + this.avatar = Optional.ofNullable(avatar); + return this; + } + + @JsonSetter(value = "tags", nulls = Nulls.SKIP) + public Builder tags(Optional tags) { + this.tags = tags; + return this; + } + + public Builder tags(ContactTags tags) { + this.tags = Optional.ofNullable(tags); + return this; + } + + @JsonSetter(value = "notes", nulls = Nulls.SKIP) + public Builder notes(Optional notes) { + this.notes = notes; + return this; + } + + public Builder notes(ContactNotes notes) { + this.notes = Optional.ofNullable(notes); + return this; + } + + @JsonSetter(value = "companies", nulls = Nulls.SKIP) + public Builder companies(Optional companies) { + this.companies = companies; + return this; + } + + public Builder companies(ContactCompanies companies) { + this.companies = Optional.ofNullable(companies); + return this; + } + + @JsonSetter(value = "location", nulls = Nulls.SKIP) + public Builder location(Optional location) { + this.location = location; + return this; + } + + public Builder location(ContactLocation location) { + this.location = Optional.ofNullable(location); + return this; + } + + @JsonSetter(value = "social_profiles", nulls = Nulls.SKIP) + public Builder socialProfiles(Optional socialProfiles) { + this.socialProfiles = socialProfiles; + return this; + } + + public Builder socialProfiles(ContactSocialProfiles socialProfiles) { + this.socialProfiles = Optional.ofNullable(socialProfiles); + return this; + } + + /** + *

If the user has enabled push messaging.

+ */ + @JsonSetter(value = "enabled_push_messaging", nulls = Nulls.SKIP) + public Builder enabledPushMessaging(Optional enabledPushMessaging) { + this.enabledPushMessaging = enabledPushMessaging; + return this; + } + + public Builder enabledPushMessaging(Boolean enabledPushMessaging) { + this.enabledPushMessaging = Optional.ofNullable(enabledPushMessaging); + return this; + } + + public ShowContactByExternalIdResponse build() { + return new ShowContactByExternalIdResponse( + type, + id, + externalId, + workspaceId, + role, + email, + emailDomain, + phone, + name, + ownerId, + hasHardBounced, + markedEmailAsSpam, + unsubscribedFromEmails, + createdAt, + updatedAt, + signedUpAt, + lastSeenAt, + lastRepliedAt, + lastContactedAt, + lastEmailOpenedAt, + lastEmailClickedAt, + languageOverride, + browser, + browserVersion, + browserLanguage, + os, + androidAppName, + androidAppVersion, + androidDevice, + androidOsVersion, + androidSdkVersion, + androidLastSeenAt, + iosAppName, + iosAppVersion, + iosDevice, + iosOsVersion, + iosSdkVersion, + iosLastSeenAt, + customAttributes, + avatar, + tags, + notes, + companies, + location, + socialProfiles, + enabledPushMessaging, + additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/conversations/AsyncConversationsClient.java b/src/main/java/com/intercom/api/resources/conversations/AsyncConversationsClient.java index 034671b..cf0e6c9 100644 --- a/src/main/java/com/intercom/api/resources/conversations/AsyncConversationsClient.java +++ b/src/main/java/com/intercom/api/resources/conversations/AsyncConversationsClient.java @@ -10,6 +10,7 @@ import com.intercom.api.resources.conversations.requests.AutoAssignConversationRequest; import com.intercom.api.resources.conversations.requests.ConvertConversationToTicketRequest; import com.intercom.api.resources.conversations.requests.CreateConversationRequest; +import com.intercom.api.resources.conversations.requests.DeleteConversationRequest; import com.intercom.api.resources.conversations.requests.DetachContactFromConversationRequest; import com.intercom.api.resources.conversations.requests.FindConversationRequest; import com.intercom.api.resources.conversations.requests.ListConversationsRequest; @@ -19,8 +20,10 @@ import com.intercom.api.resources.conversations.types.Conversation; import com.intercom.api.resources.messages.types.Message; import com.intercom.api.resources.tickets.types.Ticket; +import com.intercom.api.types.ConversationDeleted; import com.intercom.api.types.RedactConversationRequest; import com.intercom.api.types.SearchRequest; +import java.util.Optional; import java.util.concurrent.CompletableFuture; public class AsyncConversationsClient { @@ -132,6 +135,10 @@ public CompletableFuture find(FindConversationRequest request, Req *

{% 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 %}

*/ public CompletableFuture update(UpdateConversationRequest request) { return this.rawClient.update(request).thenApply(response -> response.body()); @@ -142,11 +149,30 @@ public CompletableFuture update(UpdateConversationRequest request) *

{% 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 %}

*/ public CompletableFuture update(UpdateConversationRequest request, RequestOptions requestOptions) { return this.rawClient.update(request, requestOptions).thenApply(response -> response.body()); } + /** + * You can delete a single conversation. + */ + public CompletableFuture deleteConversation(DeleteConversationRequest request) { + return this.rawClient.deleteConversation(request).thenApply(response -> response.body()); + } + + /** + * You can delete a single conversation. + */ + public CompletableFuture deleteConversation( + DeleteConversationRequest request, RequestOptions requestOptions) { + return this.rawClient.deleteConversation(request, requestOptions).thenApply(response -> response.body()); + } + /** * 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.

@@ -165,7 +191,7 @@ public CompletableFuture update(UpdateConversationRequest request, *
  • There's a limit of max 15 filters for each AND or OR group
  • * *

    Accepted Fields

    - *

    Most keys listed as part of the The conversation model is searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as created_at accepts a date, the value cannot be a string such as "foorbar"). + *

    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 | * | :---------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------- | @@ -262,7 +288,7 @@ public CompletableFuture> search(SearchRequest *

  • There's a limit of max 15 filters for each AND or OR group
  • * *

    Accepted Fields

    - *

    Most keys listed as part of the The conversation model is searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as created_at accepts a date, the value cannot be a string such as "foorbar"). + *

    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 | * | :---------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------- | @@ -383,33 +409,6 @@ public CompletableFuture manage( return this.rawClient.manage(request, requestOptions).thenApply(response -> response.body()); } - /** - * {% admonition type="danger" name="Deprecation of Run Assignment Rules" %} - * Run assignment rules is now deprecated in version 2.12 and future versions and will be permanently removed on December 31, 2026. After this date, any requests made to this endpoint will fail. - * {% /admonition %} - * You can let a conversation be automatically assigned following assignment rules. - * {% admonition type="warning" name="When using workflows" %} - * It is not possible to use this endpoint with Workflows. - * {% /admonition %} - */ - public CompletableFuture runAssignmentRules(AutoAssignConversationRequest request) { - return this.rawClient.runAssignmentRules(request).thenApply(response -> response.body()); - } - - /** - * {% admonition type="danger" name="Deprecation of Run Assignment Rules" %} - * Run assignment rules is now deprecated in version 2.12 and future versions and will be permanently removed on December 31, 2026. After this date, any requests made to this endpoint will fail. - * {% /admonition %} - * You can let a conversation be automatically assigned following assignment rules. - * {% admonition type="warning" name="When using workflows" %} - * It is not possible to use this endpoint with Workflows. - * {% /admonition %} - */ - public CompletableFuture runAssignmentRules( - AutoAssignConversationRequest request, RequestOptions requestOptions) { - return this.rawClient.runAssignmentRules(request, requestOptions).thenApply(response -> response.body()); - } - /** * 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" %} @@ -476,15 +475,24 @@ public CompletableFuture redactConversationPart( /** * You can convert a conversation to a ticket. */ - public CompletableFuture convertToTicket(ConvertConversationToTicketRequest request) { + public CompletableFuture> convertToTicket(ConvertConversationToTicketRequest request) { return this.rawClient.convertToTicket(request).thenApply(response -> response.body()); } /** * You can convert a conversation to a ticket. */ - public CompletableFuture convertToTicket( + public CompletableFuture> convertToTicket( ConvertConversationToTicketRequest request, RequestOptions requestOptions) { return this.rawClient.convertToTicket(request, requestOptions).thenApply(response -> response.body()); } + + public CompletableFuture runAssignmentRules(AutoAssignConversationRequest request) { + return this.rawClient.runAssignmentRules(request).thenApply(response -> response.body()); + } + + public CompletableFuture runAssignmentRules( + AutoAssignConversationRequest request, RequestOptions requestOptions) { + return this.rawClient.runAssignmentRules(request, requestOptions).thenApply(response -> response.body()); + } } diff --git a/src/main/java/com/intercom/api/resources/conversations/AsyncRawConversationsClient.java b/src/main/java/com/intercom/api/resources/conversations/AsyncRawConversationsClient.java index 436f2a3..637ef6c 100644 --- a/src/main/java/com/intercom/api/resources/conversations/AsyncRawConversationsClient.java +++ b/src/main/java/com/intercom/api/resources/conversations/AsyncRawConversationsClient.java @@ -4,6 +4,7 @@ package com.intercom.api.resources.conversations; import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; import com.intercom.api.core.ClientOptions; import com.intercom.api.core.IntercomApiException; import com.intercom.api.core.IntercomException; @@ -22,6 +23,7 @@ import com.intercom.api.resources.conversations.requests.AutoAssignConversationRequest; import com.intercom.api.resources.conversations.requests.ConvertConversationToTicketRequest; import com.intercom.api.resources.conversations.requests.CreateConversationRequest; +import com.intercom.api.resources.conversations.requests.DeleteConversationRequest; import com.intercom.api.resources.conversations.requests.DetachContactFromConversationRequest; import com.intercom.api.resources.conversations.requests.FindConversationRequest; import com.intercom.api.resources.conversations.requests.ListConversationsRequest; @@ -31,13 +33,15 @@ import com.intercom.api.resources.conversations.types.Conversation; import com.intercom.api.resources.messages.types.Message; import com.intercom.api.resources.tickets.types.Ticket; +import com.intercom.api.types.ConversationDeleted; +import com.intercom.api.types.ConversationList; import com.intercom.api.types.CursorPages; import com.intercom.api.types.Error; -import com.intercom.api.types.PaginatedConversationResponse; import com.intercom.api.types.RedactConversationRequest; import com.intercom.api.types.SearchRequest; import com.intercom.api.types.StartingAfterPaging; import java.io.IOException; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -125,8 +129,8 @@ public CompletableFuture>> public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { if (response.isSuccessful()) { - PaginatedConversationResponse parsedResponse = ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), PaginatedConversationResponse.class); + ConversationList parsedResponse = + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ConversationList.class); Optional startingAfter = parsedResponse .getPages() .flatMap(CursorPages::getNext) @@ -135,7 +139,8 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO .from(request) .startingAfter(startingAfter) .build(); - List result = parsedResponse.getConversations(); + List result = + parsedResponse.getConversations().orElse(Collections.emptyList()); future.complete(new IntercomHttpResponse<>( new SyncPagingIterable(startingAfter.isPresent(), result, () -> { try { @@ -307,11 +312,18 @@ public CompletableFuture> find( HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("conversations") - .addPathSegment(request.getConversationId()); + .addPathSegment(Integer.toString(request.getConversationId())); if (request.getDisplayAs().isPresent()) { QueryStringMapper.addQueryParameter( httpUrl, "display_as", request.getDisplayAs().get(), false); } + if (request.getIncludeTranslations().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_translations", + request.getIncludeTranslations().get().toString(), + false); + } Request.Builder _requestBuilder = new Request.Builder() .url(httpUrl.build()) .method("GET", null) @@ -380,6 +392,10 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { *

    {% 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 %}

    */ public CompletableFuture> update(UpdateConversationRequest request) { return update(request, null); @@ -390,13 +406,17 @@ public CompletableFuture> update(UpdateConver *

    {% 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 %}

    */ public CompletableFuture> update( UpdateConversationRequest request, RequestOptions requestOptions) { HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("conversations") - .addPathSegment(request.getConversationId()); + .addPathSegment(Integer.toString(request.getConversationId())); if (request.getDisplayAs().isPresent()) { QueryStringMapper.addQueryParameter( httpUrl, "display_as", request.getDisplayAs().get(), false); @@ -405,9 +425,15 @@ public CompletableFuture> update( if (request.getRead().isPresent()) { properties.put("read", request.getRead()); } + if (request.getTitle().isPresent()) { + properties.put("title", request.getTitle()); + } if (request.getCustomAttributes().isPresent()) { properties.put("custom_attributes", request.getCustomAttributes()); } + if (request.getCompanyId().isPresent()) { + properties.put("company_id", request.getCompanyId()); + } RequestBody body; try { body = RequestBody.create( @@ -478,6 +504,82 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { return future; } + /** + * You can delete a single conversation. + */ + public CompletableFuture> deleteConversation( + DeleteConversationRequest request) { + return deleteConversation(request, null); + } + + /** + * You can delete a single conversation. + */ + public CompletableFuture> deleteConversation( + DeleteConversationRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations") + .addPathSegment(Integer.toString(request.getConversationId())) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ConversationDeleted.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + /** * 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.

    @@ -496,7 +598,7 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { *
  • There's a limit of max 15 filters for each AND or OR group
  • * *

    Accepted Fields

    - *

    Most keys listed as part of the The conversation model is searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as created_at accepts a date, the value cannot be a string such as "foorbar"). + *

    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 | * | :---------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------- | @@ -593,7 +695,7 @@ public CompletableFuture>> *

  • There's a limit of max 15 filters for each AND or OR group
  • * *

    Accepted Fields

    - *

    Most keys listed as part of the The conversation model is searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as created_at accepts a date, the value cannot be a string such as "foorbar"). + *

    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 | * | :---------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------- | @@ -698,8 +800,8 @@ public CompletableFuture>> public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { if (response.isSuccessful()) { - PaginatedConversationResponse parsedResponse = ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), PaginatedConversationResponse.class); + ConversationList parsedResponse = + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ConversationList.class); Optional startingAfter = parsedResponse .getPages() .flatMap(CursorPages::getNext) @@ -713,7 +815,8 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO .from(request) .pagination(pagination) .build(); - List result = parsedResponse.getConversations(); + List result = + parsedResponse.getConversations().orElse(Collections.emptyList()); future.complete(new IntercomHttpResponse<>( new SyncPagingIterable(startingAfter.isPresent(), result, () -> { try { @@ -935,100 +1038,6 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { return future; } - /** - * {% admonition type="danger" name="Deprecation of Run Assignment Rules" %} - * Run assignment rules is now deprecated in version 2.12 and future versions and will be permanently removed on December 31, 2026. After this date, any requests made to this endpoint will fail. - * {% /admonition %} - * You can let a conversation be automatically assigned following assignment rules. - * {% admonition type="warning" name="When using workflows" %} - * It is not possible to use this endpoint with Workflows. - * {% /admonition %} - */ - public CompletableFuture> runAssignmentRules( - AutoAssignConversationRequest request) { - return runAssignmentRules(request, null); - } - - /** - * {% admonition type="danger" name="Deprecation of Run Assignment Rules" %} - * Run assignment rules is now deprecated in version 2.12 and future versions and will be permanently removed on December 31, 2026. After this date, any requests made to this endpoint will fail. - * {% /admonition %} - * You can let a conversation be automatically assigned following assignment rules. - * {% admonition type="warning" name="When using workflows" %} - * It is not possible to use this endpoint with Workflows. - * {% /admonition %} - */ - public CompletableFuture> runAssignmentRules( - AutoAssignConversationRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("conversations") - .addPathSegment(request.getConversationId()) - .addPathSegments("run_assignment_rules") - .build(); - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl) - .method("POST", RequestBody.create("", null)) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - CompletableFuture> future = new CompletableFuture<>(); - client.newCall(okhttpRequest).enqueue(new Callback() { - @Override - public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { - try (ResponseBody responseBody = response.body()) { - if (response.isSuccessful()) { - future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Conversation.class), - response)); - return; - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 401: - future.completeExceptionally(new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), - response)); - return; - case 403: - future.completeExceptionally(new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), - response)); - return; - case 404: - future.completeExceptionally(new NotFoundError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); - return; - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); - return; - } catch (IOException e) { - future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); - } - } - - @Override - public void onFailure(@NotNull Call call, @NotNull IOException e) { - future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); - } - }); - return future; - } - /** * 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" %} @@ -1316,19 +1325,20 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { /** * You can convert a conversation to a ticket. */ - public CompletableFuture> convertToTicket(ConvertConversationToTicketRequest request) { + public CompletableFuture>> convertToTicket( + ConvertConversationToTicketRequest request) { return convertToTicket(request, null); } /** * You can convert a conversation to a ticket. */ - public CompletableFuture> convertToTicket( + public CompletableFuture>> convertToTicket( ConvertConversationToTicketRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("conversations") - .addPathSegment(request.getConversationId()) + .addPathSegment(Integer.toString(request.getConversationId())) .addPathSegments("convert") .build(); RequestBody body; @@ -1349,14 +1359,16 @@ public CompletableFuture> convertToTicket( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } - CompletableFuture> future = new CompletableFuture<>(); + CompletableFuture>> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Ticket.class), response)); + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response)); return; } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1387,4 +1399,54 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { }); return future; } + + public CompletableFuture> runAssignmentRules(AutoAssignConversationRequest request) { + return runAssignmentRules(request, null); + } + + public CompletableFuture> runAssignmentRules( + AutoAssignConversationRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations") + .addPathSegment(request.getConversationId()) + .addPathSegments("run_assignment_rules") + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("POST", RequestBody.create("", null)) + .headers(Headers.of(clientOptions.headers(requestOptions))); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>(null, response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } } diff --git a/src/main/java/com/intercom/api/resources/conversations/ConversationsClient.java b/src/main/java/com/intercom/api/resources/conversations/ConversationsClient.java index df1b33f..d13aa07 100644 --- a/src/main/java/com/intercom/api/resources/conversations/ConversationsClient.java +++ b/src/main/java/com/intercom/api/resources/conversations/ConversationsClient.java @@ -10,6 +10,7 @@ import com.intercom.api.resources.conversations.requests.AutoAssignConversationRequest; import com.intercom.api.resources.conversations.requests.ConvertConversationToTicketRequest; import com.intercom.api.resources.conversations.requests.CreateConversationRequest; +import com.intercom.api.resources.conversations.requests.DeleteConversationRequest; import com.intercom.api.resources.conversations.requests.DetachContactFromConversationRequest; import com.intercom.api.resources.conversations.requests.FindConversationRequest; import com.intercom.api.resources.conversations.requests.ListConversationsRequest; @@ -19,8 +20,10 @@ import com.intercom.api.resources.conversations.types.Conversation; import com.intercom.api.resources.messages.types.Message; import com.intercom.api.resources.tickets.types.Ticket; +import com.intercom.api.types.ConversationDeleted; import com.intercom.api.types.RedactConversationRequest; import com.intercom.api.types.SearchRequest; +import java.util.Optional; public class ConversationsClient { protected final ClientOptions clientOptions; @@ -130,6 +133,10 @@ public Conversation find(FindConversationRequest request, RequestOptions request *

    {% 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 %}

    */ public Conversation update(UpdateConversationRequest request) { return this.rawClient.update(request).body(); @@ -140,11 +147,29 @@ public Conversation update(UpdateConversationRequest request) { *

    {% 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 %}

    */ public Conversation update(UpdateConversationRequest request, RequestOptions requestOptions) { return this.rawClient.update(request, requestOptions).body(); } + /** + * You can delete a single conversation. + */ + public ConversationDeleted deleteConversation(DeleteConversationRequest request) { + return this.rawClient.deleteConversation(request).body(); + } + + /** + * You can delete a single conversation. + */ + public ConversationDeleted deleteConversation(DeleteConversationRequest request, RequestOptions requestOptions) { + return this.rawClient.deleteConversation(request, requestOptions).body(); + } + /** * 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.

    @@ -163,7 +188,7 @@ public Conversation update(UpdateConversationRequest request, RequestOptions req *
  • There's a limit of max 15 filters for each AND or OR group
  • * *

    Accepted Fields

    - *

    Most keys listed as part of the The conversation model is searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as created_at accepts a date, the value cannot be a string such as "foorbar"). + *

    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 | * | :---------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------- | @@ -260,7 +285,7 @@ public SyncPagingIterable search(SearchRequest request) { *

  • There's a limit of max 15 filters for each AND or OR group
  • * *

    Accepted Fields

    - *

    Most keys listed as part of the The conversation model is searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as created_at accepts a date, the value cannot be a string such as "foorbar"). + *

    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 | * | :---------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------- | @@ -379,32 +404,6 @@ public Conversation manage(ManageConversationPartsRequest request, RequestOption return this.rawClient.manage(request, requestOptions).body(); } - /** - * {% admonition type="danger" name="Deprecation of Run Assignment Rules" %} - * Run assignment rules is now deprecated in version 2.12 and future versions and will be permanently removed on December 31, 2026. After this date, any requests made to this endpoint will fail. - * {% /admonition %} - * You can let a conversation be automatically assigned following assignment rules. - * {% admonition type="warning" name="When using workflows" %} - * It is not possible to use this endpoint with Workflows. - * {% /admonition %} - */ - public Conversation runAssignmentRules(AutoAssignConversationRequest request) { - return this.rawClient.runAssignmentRules(request).body(); - } - - /** - * {% admonition type="danger" name="Deprecation of Run Assignment Rules" %} - * Run assignment rules is now deprecated in version 2.12 and future versions and will be permanently removed on December 31, 2026. After this date, any requests made to this endpoint will fail. - * {% /admonition %} - * You can let a conversation be automatically assigned following assignment rules. - * {% admonition type="warning" name="When using workflows" %} - * It is not possible to use this endpoint with Workflows. - * {% /admonition %} - */ - public Conversation runAssignmentRules(AutoAssignConversationRequest request, RequestOptions requestOptions) { - return this.rawClient.runAssignmentRules(request, requestOptions).body(); - } - /** * 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" %} @@ -470,14 +469,22 @@ public Conversation redactConversationPart(RedactConversationRequest request, Re /** * You can convert a conversation to a ticket. */ - public Ticket convertToTicket(ConvertConversationToTicketRequest request) { + public Optional convertToTicket(ConvertConversationToTicketRequest request) { return this.rawClient.convertToTicket(request).body(); } /** * You can convert a conversation to a ticket. */ - public Ticket convertToTicket(ConvertConversationToTicketRequest request, RequestOptions requestOptions) { + public Optional convertToTicket(ConvertConversationToTicketRequest request, RequestOptions requestOptions) { return this.rawClient.convertToTicket(request, requestOptions).body(); } + + public void runAssignmentRules(AutoAssignConversationRequest request) { + this.rawClient.runAssignmentRules(request).body(); + } + + public void runAssignmentRules(AutoAssignConversationRequest request, RequestOptions requestOptions) { + this.rawClient.runAssignmentRules(request, requestOptions).body(); + } } diff --git a/src/main/java/com/intercom/api/resources/conversations/RawConversationsClient.java b/src/main/java/com/intercom/api/resources/conversations/RawConversationsClient.java index 5016dba..12a33b0 100644 --- a/src/main/java/com/intercom/api/resources/conversations/RawConversationsClient.java +++ b/src/main/java/com/intercom/api/resources/conversations/RawConversationsClient.java @@ -4,6 +4,7 @@ package com.intercom.api.resources.conversations; import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; import com.intercom.api.core.ClientOptions; import com.intercom.api.core.IntercomApiException; import com.intercom.api.core.IntercomException; @@ -22,6 +23,7 @@ import com.intercom.api.resources.conversations.requests.AutoAssignConversationRequest; import com.intercom.api.resources.conversations.requests.ConvertConversationToTicketRequest; import com.intercom.api.resources.conversations.requests.CreateConversationRequest; +import com.intercom.api.resources.conversations.requests.DeleteConversationRequest; import com.intercom.api.resources.conversations.requests.DetachContactFromConversationRequest; import com.intercom.api.resources.conversations.requests.FindConversationRequest; import com.intercom.api.resources.conversations.requests.ListConversationsRequest; @@ -31,13 +33,15 @@ import com.intercom.api.resources.conversations.types.Conversation; import com.intercom.api.resources.messages.types.Message; import com.intercom.api.resources.tickets.types.Ticket; +import com.intercom.api.types.ConversationDeleted; +import com.intercom.api.types.ConversationList; import com.intercom.api.types.CursorPages; import com.intercom.api.types.Error; -import com.intercom.api.types.PaginatedConversationResponse; import com.intercom.api.types.RedactConversationRequest; import com.intercom.api.types.SearchRequest; import com.intercom.api.types.StartingAfterPaging; import java.io.IOException; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -116,8 +120,8 @@ public IntercomHttpResponse> list( try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); if (response.isSuccessful()) { - PaginatedConversationResponse parsedResponse = - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedConversationResponse.class); + ConversationList parsedResponse = + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ConversationList.class); Optional startingAfter = parsedResponse .getPages() .flatMap(CursorPages::getNext) @@ -126,7 +130,7 @@ public IntercomHttpResponse> list( .from(request) .startingAfter(startingAfter) .build(); - List result = parsedResponse.getConversations(); + List result = parsedResponse.getConversations().orElse(Collections.emptyList()); return new IntercomHttpResponse<>( new SyncPagingIterable( startingAfter.isPresent(), result, () -> list(nextRequest, requestOptions) @@ -257,11 +261,18 @@ public IntercomHttpResponse find(FindConversationRequest request, HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("conversations") - .addPathSegment(request.getConversationId()); + .addPathSegment(Integer.toString(request.getConversationId())); if (request.getDisplayAs().isPresent()) { QueryStringMapper.addQueryParameter( httpUrl, "display_as", request.getDisplayAs().get(), false); } + if (request.getIncludeTranslations().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_translations", + request.getIncludeTranslations().get().toString(), + false); + } Request.Builder _requestBuilder = new Request.Builder() .url(httpUrl.build()) .method("GET", null) @@ -310,6 +321,10 @@ public IntercomHttpResponse find(FindConversationRequest request, *

    {% 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 %}

    */ public IntercomHttpResponse update(UpdateConversationRequest request) { return update(request, null); @@ -320,12 +335,16 @@ public IntercomHttpResponse update(UpdateConversationRequest reque *

    {% 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 %}

    */ public IntercomHttpResponse update(UpdateConversationRequest request, RequestOptions requestOptions) { HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("conversations") - .addPathSegment(request.getConversationId()); + .addPathSegment(Integer.toString(request.getConversationId())); if (request.getDisplayAs().isPresent()) { QueryStringMapper.addQueryParameter( httpUrl, "display_as", request.getDisplayAs().get(), false); @@ -334,9 +353,15 @@ public IntercomHttpResponse update(UpdateConversationRequest reque if (request.getRead().isPresent()) { properties.put("read", request.getRead()); } + if (request.getTitle().isPresent()) { + properties.put("title", request.getTitle()); + } if (request.getCustomAttributes().isPresent()) { properties.put("custom_attributes", request.getCustomAttributes()); } + if (request.getCompanyId().isPresent()) { + properties.put("company_id", request.getCompanyId()); + } RequestBody body; try { body = RequestBody.create( @@ -387,6 +412,64 @@ public IntercomHttpResponse update(UpdateConversationRequest reque } } + /** + * You can delete a single conversation. + */ + public IntercomHttpResponse deleteConversation(DeleteConversationRequest request) { + return deleteConversation(request, null); + } + + /** + * You can delete a single conversation. + */ + public IntercomHttpResponse deleteConversation( + DeleteConversationRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations") + .addPathSegment(Integer.toString(request.getConversationId())) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ConversationDeleted.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + /** * 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.

    @@ -405,7 +488,7 @@ public IntercomHttpResponse update(UpdateConversationRequest reque *
  • There's a limit of max 15 filters for each AND or OR group
  • * *

    Accepted Fields

    - *

    Most keys listed as part of the The conversation model is searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as created_at accepts a date, the value cannot be a string such as "foorbar"). + *

    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 | * | :---------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------- | @@ -502,7 +585,7 @@ public IntercomHttpResponse> search(SearchReque *

  • There's a limit of max 15 filters for each AND or OR group
  • * *

    Accepted Fields

    - *

    Most keys listed as part of the The conversation model is searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as created_at accepts a date, the value cannot be a string such as "foorbar"). + *

    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 | * | :---------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------- | @@ -604,8 +687,8 @@ public IntercomHttpResponse> search( try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); if (response.isSuccessful()) { - PaginatedConversationResponse parsedResponse = - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedConversationResponse.class); + ConversationList parsedResponse = + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ConversationList.class); Optional startingAfter = parsedResponse .getPages() .flatMap(CursorPages::getNext) @@ -619,7 +702,7 @@ public IntercomHttpResponse> search( .from(request) .pagination(pagination) .build(); - List result = parsedResponse.getConversations(); + List result = parsedResponse.getConversations().orElse(Collections.emptyList()); return new IntercomHttpResponse<>( new SyncPagingIterable( startingAfter.isPresent(), result, () -> search(nextRequest, requestOptions) @@ -784,79 +867,6 @@ public IntercomHttpResponse manage( } } - /** - * {% admonition type="danger" name="Deprecation of Run Assignment Rules" %} - * Run assignment rules is now deprecated in version 2.12 and future versions and will be permanently removed on December 31, 2026. After this date, any requests made to this endpoint will fail. - * {% /admonition %} - * You can let a conversation be automatically assigned following assignment rules. - * {% admonition type="warning" name="When using workflows" %} - * It is not possible to use this endpoint with Workflows. - * {% /admonition %} - */ - public IntercomHttpResponse runAssignmentRules(AutoAssignConversationRequest request) { - return runAssignmentRules(request, null); - } - - /** - * {% admonition type="danger" name="Deprecation of Run Assignment Rules" %} - * Run assignment rules is now deprecated in version 2.12 and future versions and will be permanently removed on December 31, 2026. After this date, any requests made to this endpoint will fail. - * {% /admonition %} - * You can let a conversation be automatically assigned following assignment rules. - * {% admonition type="warning" name="When using workflows" %} - * It is not possible to use this endpoint with Workflows. - * {% /admonition %} - */ - public IntercomHttpResponse runAssignmentRules( - AutoAssignConversationRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("conversations") - .addPathSegment(request.getConversationId()) - .addPathSegments("run_assignment_rules") - .build(); - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl) - .method("POST", RequestBody.create("", null)) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Conversation.class), response); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); - case 404: - throw new NotFoundError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); - } catch (IOException e) { - throw new IntercomException("Network error executing HTTP request", e); - } - } - /** * 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" %} @@ -1081,19 +1091,19 @@ public IntercomHttpResponse redactConversationPart( /** * You can convert a conversation to a ticket. */ - public IntercomHttpResponse convertToTicket(ConvertConversationToTicketRequest request) { + public IntercomHttpResponse> convertToTicket(ConvertConversationToTicketRequest request) { return convertToTicket(request, null); } /** * You can convert a conversation to a ticket. */ - public IntercomHttpResponse convertToTicket( + public IntercomHttpResponse> convertToTicket( ConvertConversationToTicketRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("conversations") - .addPathSegment(request.getConversationId()) + .addPathSegment(Integer.toString(request.getConversationId())) .addPathSegments("convert") .build(); RequestBody body; @@ -1118,7 +1128,9 @@ public IntercomHttpResponse convertToTicket( ResponseBody responseBody = response.body(); if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Ticket.class), response); + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { @@ -1138,4 +1150,41 @@ public IntercomHttpResponse convertToTicket( throw new IntercomException("Network error executing HTTP request", e); } } + + public IntercomHttpResponse runAssignmentRules(AutoAssignConversationRequest request) { + return runAssignmentRules(request, null); + } + + public IntercomHttpResponse runAssignmentRules( + AutoAssignConversationRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations") + .addPathSegment(request.getConversationId()) + .addPathSegments("run_assignment_rules") + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("POST", RequestBody.create("", null)) + .headers(Headers.of(clientOptions.headers(requestOptions))); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>(null, response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } } diff --git a/src/main/java/com/intercom/api/resources/conversations/requests/AutoAssignConversationRequest.java b/src/main/java/com/intercom/api/resources/conversations/requests/AutoAssignConversationRequest.java index 8225e4c..35d7fb9 100644 --- a/src/main/java/com/intercom/api/resources/conversations/requests/AutoAssignConversationRequest.java +++ b/src/main/java/com/intercom/api/resources/conversations/requests/AutoAssignConversationRequest.java @@ -28,9 +28,6 @@ private AutoAssignConversationRequest(String conversationId, Map this.additionalProperties = additionalProperties; } - /** - * @return The identifier for the conversation as given by Intercom. - */ @JsonProperty("conversation_id") public String getConversationId() { return conversationId; @@ -66,9 +63,6 @@ public static ConversationIdStage builder() { } public interface ConversationIdStage { - /** - * The identifier for the conversation as given by Intercom. - */ _FinalStage conversationId(@NotNull String conversationId); Builder from(AutoAssignConversationRequest other); @@ -93,10 +87,6 @@ public Builder from(AutoAssignConversationRequest other) { return this; } - /** - * The identifier for the conversation as given by Intercom.

    The identifier for the conversation as given by Intercom.

    - * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override @JsonSetter("conversation_id") public _FinalStage conversationId(@NotNull String conversationId) { diff --git a/src/main/java/com/intercom/api/resources/conversations/requests/ConvertConversationToTicketRequest.java b/src/main/java/com/intercom/api/resources/conversations/requests/ConvertConversationToTicketRequest.java index 2affc19..e771a80 100644 --- a/src/main/java/com/intercom/api/resources/conversations/requests/ConvertConversationToTicketRequest.java +++ b/src/main/java/com/intercom/api/resources/conversations/requests/ConvertConversationToTicketRequest.java @@ -21,7 +21,7 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ConvertConversationToTicketRequest.Builder.class) public final class ConvertConversationToTicketRequest { - private final String conversationId; + private final int conversationId; private final String ticketTypeId; @@ -30,7 +30,7 @@ public final class ConvertConversationToTicketRequest { private final Map additionalProperties; private ConvertConversationToTicketRequest( - String conversationId, + int conversationId, String ticketTypeId, Optional> attributes, Map additionalProperties) { @@ -44,7 +44,7 @@ private ConvertConversationToTicketRequest( * @return The id of the conversation to target */ @JsonProperty("conversation_id") - public String getConversationId() { + public int getConversationId() { return conversationId; } @@ -74,7 +74,7 @@ public Map getAdditionalProperties() { } private boolean equalTo(ConvertConversationToTicketRequest other) { - return conversationId.equals(other.conversationId) + return conversationId == other.conversationId && ticketTypeId.equals(other.ticketTypeId) && attributes.equals(other.attributes); } @@ -97,7 +97,7 @@ public interface ConversationIdStage { /** * The id of the conversation to target */ - TicketTypeIdStage conversationId(@NotNull String conversationId); + TicketTypeIdStage conversationId(int conversationId); Builder from(ConvertConversationToTicketRequest other); } @@ -119,7 +119,7 @@ public interface _FinalStage { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements ConversationIdStage, TicketTypeIdStage, _FinalStage { - private String conversationId; + private int conversationId; private String ticketTypeId; @@ -144,8 +144,8 @@ public Builder from(ConvertConversationToTicketRequest other) { */ @java.lang.Override @JsonSetter("conversation_id") - public TicketTypeIdStage conversationId(@NotNull String conversationId) { - this.conversationId = Objects.requireNonNull(conversationId, "conversationId must not be null"); + public TicketTypeIdStage conversationId(int conversationId) { + this.conversationId = conversationId; return this; } diff --git a/src/main/java/com/intercom/api/resources/conversations/requests/DeleteConversationRequest.java b/src/main/java/com/intercom/api/resources/conversations/requests/DeleteConversationRequest.java new file mode 100644 index 0000000..ad2163f --- /dev/null +++ b/src/main/java/com/intercom/api/resources/conversations/requests/DeleteConversationRequest.java @@ -0,0 +1,111 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.conversations.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = DeleteConversationRequest.Builder.class) +public final class DeleteConversationRequest { + private final int conversationId; + + private final Map additionalProperties; + + private DeleteConversationRequest(int conversationId, Map additionalProperties) { + this.conversationId = conversationId; + this.additionalProperties = additionalProperties; + } + + /** + * @return id + */ + @JsonProperty("conversation_id") + public int getConversationId() { + return conversationId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeleteConversationRequest && equalTo((DeleteConversationRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeleteConversationRequest other) { + return conversationId == other.conversationId; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.conversationId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ConversationIdStage builder() { + return new Builder(); + } + + public interface ConversationIdStage { + /** + * id + */ + _FinalStage conversationId(int conversationId); + + Builder from(DeleteConversationRequest other); + } + + public interface _FinalStage { + DeleteConversationRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ConversationIdStage, _FinalStage { + private int conversationId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DeleteConversationRequest other) { + conversationId(other.getConversationId()); + return this; + } + + /** + * id

    id

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("conversation_id") + public _FinalStage conversationId(int conversationId) { + this.conversationId = conversationId; + return this; + } + + @java.lang.Override + public DeleteConversationRequest build() { + return new DeleteConversationRequest(conversationId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/conversations/requests/FindConversationRequest.java b/src/main/java/com/intercom/api/resources/conversations/requests/FindConversationRequest.java index dd75ae6..5a3dfa4 100644 --- a/src/main/java/com/intercom/api/resources/conversations/requests/FindConversationRequest.java +++ b/src/main/java/com/intercom/api/resources/conversations/requests/FindConversationRequest.java @@ -16,21 +16,26 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; -import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = FindConversationRequest.Builder.class) public final class FindConversationRequest { - private final String conversationId; + private final int conversationId; private final Optional displayAs; + private final Optional includeTranslations; + private final Map additionalProperties; private FindConversationRequest( - String conversationId, Optional displayAs, Map additionalProperties) { + int conversationId, + Optional displayAs, + Optional includeTranslations, + Map additionalProperties) { this.conversationId = conversationId; this.displayAs = displayAs; + this.includeTranslations = includeTranslations; this.additionalProperties = additionalProperties; } @@ -38,7 +43,7 @@ private FindConversationRequest( * @return The id of the conversation to target */ @JsonProperty("conversation_id") - public String getConversationId() { + public int getConversationId() { return conversationId; } @@ -50,6 +55,14 @@ public Optional getDisplayAs() { return displayAs; } + /** + * @return If set to true, conversation parts will be translated to the detected language of the conversation. + */ + @JsonProperty("include_translations") + public Optional getIncludeTranslations() { + return includeTranslations; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -62,12 +75,14 @@ public Map getAdditionalProperties() { } private boolean equalTo(FindConversationRequest other) { - return conversationId.equals(other.conversationId) && displayAs.equals(other.displayAs); + return conversationId == other.conversationId + && displayAs.equals(other.displayAs) + && includeTranslations.equals(other.includeTranslations); } @java.lang.Override public int hashCode() { - return Objects.hash(this.conversationId, this.displayAs); + return Objects.hash(this.conversationId, this.displayAs, this.includeTranslations); } @java.lang.Override @@ -83,7 +98,7 @@ public interface ConversationIdStage { /** * The id of the conversation to target */ - _FinalStage conversationId(@NotNull String conversationId); + _FinalStage conversationId(int conversationId); Builder from(FindConversationRequest other); } @@ -97,11 +112,20 @@ public interface _FinalStage { _FinalStage displayAs(Optional displayAs); _FinalStage displayAs(String displayAs); + + /** + *

    If set to true, conversation parts will be translated to the detected language of the conversation.

    + */ + _FinalStage includeTranslations(Optional includeTranslations); + + _FinalStage includeTranslations(Boolean includeTranslations); } @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements ConversationIdStage, _FinalStage { - private String conversationId; + private int conversationId; + + private Optional includeTranslations = Optional.empty(); private Optional displayAs = Optional.empty(); @@ -114,6 +138,7 @@ private Builder() {} public Builder from(FindConversationRequest other) { conversationId(other.getConversationId()); displayAs(other.getDisplayAs()); + includeTranslations(other.getIncludeTranslations()); return this; } @@ -123,8 +148,28 @@ public Builder from(FindConversationRequest other) { */ @java.lang.Override @JsonSetter("conversation_id") - public _FinalStage conversationId(@NotNull String conversationId) { - this.conversationId = Objects.requireNonNull(conversationId, "conversationId must not be null"); + public _FinalStage conversationId(int conversationId) { + this.conversationId = conversationId; + return this; + } + + /** + *

    If set to true, conversation parts will be translated to the detected language of the conversation.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage includeTranslations(Boolean includeTranslations) { + this.includeTranslations = Optional.ofNullable(includeTranslations); + return this; + } + + /** + *

    If set to true, conversation parts will be translated to the detected language of the conversation.

    + */ + @java.lang.Override + @JsonSetter(value = "include_translations", nulls = Nulls.SKIP) + public _FinalStage includeTranslations(Optional includeTranslations) { + this.includeTranslations = includeTranslations; return this; } @@ -150,7 +195,7 @@ public _FinalStage displayAs(Optional displayAs) { @java.lang.Override public FindConversationRequest build() { - return new FindConversationRequest(conversationId, displayAs, additionalProperties); + return new FindConversationRequest(conversationId, displayAs, includeTranslations, additionalProperties); } } } diff --git a/src/main/java/com/intercom/api/resources/conversations/requests/UpdateConversationRequest.java b/src/main/java/com/intercom/api/resources/conversations/requests/UpdateConversationRequest.java index 76ad55d..a3171c8 100644 --- a/src/main/java/com/intercom/api/resources/conversations/requests/UpdateConversationRequest.java +++ b/src/main/java/com/intercom/api/resources/conversations/requests/UpdateConversationRequest.java @@ -9,38 +9,53 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.JsonValue; import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; import com.intercom.api.core.ObjectMappers; +import com.intercom.api.types.CustomObjectInstanceList; +import com.intercom.api.types.Datetime; +import java.io.IOException; import java.util.HashMap; import java.util.Map; import java.util.Objects; import java.util.Optional; -import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = UpdateConversationRequest.Builder.class) public final class UpdateConversationRequest { - private final String conversationId; + private final int conversationId; private final Optional displayAs; private final Optional read; - private final Optional> customAttributes; + private final Optional title; + + private final Optional> customAttributes; + + private final Optional companyId; private final Map additionalProperties; private UpdateConversationRequest( - String conversationId, + int conversationId, Optional displayAs, Optional read, - Optional> customAttributes, + Optional title, + Optional> customAttributes, + Optional companyId, Map additionalProperties) { this.conversationId = conversationId; this.displayAs = displayAs; this.read = read; + this.title = title; this.customAttributes = customAttributes; + this.companyId = companyId; this.additionalProperties = additionalProperties; } @@ -48,7 +63,7 @@ private UpdateConversationRequest( * @return The id of the conversation to target */ @JsonProperty("conversation_id") - public String getConversationId() { + public int getConversationId() { return conversationId; } @@ -68,11 +83,27 @@ public Optional getRead() { return read; } + /** + * @return The title given to the conversation + */ + @JsonProperty("title") + public Optional getTitle() { + return title; + } + @JsonProperty("custom_attributes") - public Optional> getCustomAttributes() { + public Optional> getCustomAttributes() { return customAttributes; } + /** + * @return 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. + */ + @JsonProperty("company_id") + public Optional getCompanyId() { + return companyId; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -85,15 +116,18 @@ public Map getAdditionalProperties() { } private boolean equalTo(UpdateConversationRequest other) { - return conversationId.equals(other.conversationId) + return conversationId == other.conversationId && displayAs.equals(other.displayAs) && read.equals(other.read) - && customAttributes.equals(other.customAttributes); + && title.equals(other.title) + && customAttributes.equals(other.customAttributes) + && companyId.equals(other.companyId); } @java.lang.Override public int hashCode() { - return Objects.hash(this.conversationId, this.displayAs, this.read, this.customAttributes); + return Objects.hash( + this.conversationId, this.displayAs, this.read, this.title, this.customAttributes, this.companyId); } @java.lang.Override @@ -109,7 +143,7 @@ public interface ConversationIdStage { /** * The id of the conversation to target */ - _FinalStage conversationId(@NotNull String conversationId); + _FinalStage conversationId(int conversationId); Builder from(UpdateConversationRequest other); } @@ -131,16 +165,34 @@ public interface _FinalStage { _FinalStage read(Boolean read); - _FinalStage customAttributes(Optional> customAttributes); + /** + *

    The title given to the conversation

    + */ + _FinalStage title(Optional title); + + _FinalStage title(String title); + + _FinalStage customAttributes(Optional> customAttributes); + + _FinalStage customAttributes(Map 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.

    + */ + _FinalStage companyId(Optional companyId); - _FinalStage customAttributes(Map customAttributes); + _FinalStage companyId(String companyId); } @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements ConversationIdStage, _FinalStage { - private String conversationId; + private int conversationId; + + private Optional companyId = Optional.empty(); - private Optional> customAttributes = Optional.empty(); + private Optional> customAttributes = Optional.empty(); + + private Optional title = Optional.empty(); private Optional read = Optional.empty(); @@ -156,7 +208,9 @@ public Builder from(UpdateConversationRequest other) { conversationId(other.getConversationId()); displayAs(other.getDisplayAs()); read(other.getRead()); + title(other.getTitle()); customAttributes(other.getCustomAttributes()); + companyId(other.getCompanyId()); return this; } @@ -166,24 +220,64 @@ public Builder from(UpdateConversationRequest other) { */ @java.lang.Override @JsonSetter("conversation_id") - public _FinalStage conversationId(@NotNull String conversationId) { - this.conversationId = Objects.requireNonNull(conversationId, "conversationId must not be null"); + public _FinalStage conversationId(int conversationId) { + this.conversationId = conversationId; + return this; + } + + /** + *

    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.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage companyId(String companyId) { + this.companyId = Optional.ofNullable(companyId); + return this; + } + + /** + *

    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.

    + */ + @java.lang.Override + @JsonSetter(value = "company_id", nulls = Nulls.SKIP) + public _FinalStage companyId(Optional companyId) { + this.companyId = companyId; return this; } @java.lang.Override - public _FinalStage customAttributes(Map customAttributes) { + public _FinalStage customAttributes(Map customAttributes) { this.customAttributes = Optional.ofNullable(customAttributes); return this; } @java.lang.Override @JsonSetter(value = "custom_attributes", nulls = Nulls.SKIP) - public _FinalStage customAttributes(Optional> customAttributes) { + public _FinalStage customAttributes(Optional> customAttributes) { this.customAttributes = customAttributes; return this; } + /** + *

    The title given to the conversation

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage title(String title) { + this.title = Optional.ofNullable(title); + return this; + } + + /** + *

    The title given to the conversation

    + */ + @java.lang.Override + @JsonSetter(value = "title", nulls = Nulls.SKIP) + public _FinalStage title(Optional title) { + this.title = title; + return this; + } + /** *

    Mark a conversation as read within Intercom.

    * @return Reference to {@code this} so that method calls can be chained together. @@ -227,7 +321,111 @@ public _FinalStage displayAs(Optional displayAs) { @java.lang.Override public UpdateConversationRequest build() { return new UpdateConversationRequest( - conversationId, displayAs, read, customAttributes, additionalProperties); + conversationId, displayAs, read, title, customAttributes, companyId, additionalProperties); + } + } + + @JsonDeserialize(using = CustomAttributesValue.Deserializer.class) + public static final class CustomAttributesValue { + private final Object value; + + private final int type; + + private CustomAttributesValue(Object value, int type) { + this.value = value; + this.type = type; + } + + @JsonValue + public Object get() { + return this.value; + } + + @SuppressWarnings("unchecked") + public T visit(Visitor visitor) { + if (this.type == 0) { + return visitor.visit((String) this.value); + } else if (this.type == 1) { + return visitor.visit((int) this.value); + } else if (this.type == 2) { + return visitor.visit((Datetime) this.value); + } else if (this.type == 3) { + return visitor.visit((CustomObjectInstanceList) this.value); + } + throw new IllegalStateException("Failed to visit value. This should never happen."); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CustomAttributesValue && equalTo((CustomAttributesValue) other); + } + + private boolean equalTo(CustomAttributesValue other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return this.value.toString(); + } + + public static CustomAttributesValue of(String value) { + return new CustomAttributesValue(value, 0); + } + + public static CustomAttributesValue of(int value) { + return new CustomAttributesValue(value, 1); + } + + public static CustomAttributesValue of(Datetime value) { + return new CustomAttributesValue(value, 2); + } + + public static CustomAttributesValue of(CustomObjectInstanceList value) { + return new CustomAttributesValue(value, 3); + } + + public interface Visitor { + T visit(String value); + + T visit(int value); + + T visit(Datetime value); + + T visit(CustomObjectInstanceList value); + } + + static final class Deserializer extends StdDeserializer { + Deserializer() { + super(CustomAttributesValue.class); + } + + @java.lang.Override + public CustomAttributesValue deserialize(JsonParser p, DeserializationContext context) throws IOException { + Object value = p.readValueAs(Object.class); + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); + } catch (IllegalArgumentException e) { + } + if (value instanceof Integer) { + return of((Integer) value); + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, Datetime.class)); + } catch (IllegalArgumentException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, CustomObjectInstanceList.class)); + } catch (IllegalArgumentException e) { + } + throw new JsonParseException(p, "Failed to deserialize"); + } } } } diff --git a/src/main/java/com/intercom/api/resources/conversations/types/Conversation.java b/src/main/java/com/intercom/api/resources/conversations/types/Conversation.java index 8b01a01..b11603a 100644 --- a/src/main/java/com/intercom/api/resources/conversations/types/Conversation.java +++ b/src/main/java/com/intercom/api/resources/conversations/types/Conversation.java @@ -12,7 +12,11 @@ import com.fasterxml.jackson.annotation.JsonSetter; import com.fasterxml.jackson.annotation.JsonValue; import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; import com.intercom.api.core.ObjectMappers; import com.intercom.api.resources.aiagent.types.AiAgent; import com.intercom.api.types.ConversationContacts; @@ -22,38 +26,39 @@ import com.intercom.api.types.ConversationSource; import com.intercom.api.types.ConversationStatistics; import com.intercom.api.types.ConversationTeammates; +import com.intercom.api.types.CustomObjectInstanceList; +import com.intercom.api.types.Datetime; import com.intercom.api.types.LinkedObjectList; import com.intercom.api.types.SlaApplied; import com.intercom.api.types.Tags; +import java.io.IOException; import java.util.HashMap; -import java.util.LinkedHashMap; import java.util.Map; import java.util.Objects; import java.util.Optional; -import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = Conversation.Builder.class) public final class Conversation { private final Optional type; - private final String id; + private final Optional id; private final Optional title; - private final int createdAt; + private final Optional createdAt; - private final int updatedAt; + private final Optional updatedAt; private final Optional waitingSince; private final Optional snoozedUntil; - private final boolean open; + private final Optional open; - private final State state; + private final Optional state; - private final boolean read; + private final Optional read; private final Optional priority; @@ -61,17 +66,19 @@ public final class Conversation { private final Optional teamAssigneeId; + private final Optional companyId; + private final Optional tags; private final Optional conversationRating; - private final ConversationSource source; + private final Optional source; - private final ConversationContacts contacts; + private final Optional contacts; - private final ConversationTeammates teammates; + private final Optional teammates; - private final Map customAttributes; + private final Optional> customAttributes; private final Optional firstContactReply; @@ -91,24 +98,25 @@ public final class Conversation { private Conversation( Optional type, - String id, + Optional id, Optional title, - int createdAt, - int updatedAt, + Optional createdAt, + Optional updatedAt, Optional waitingSince, Optional snoozedUntil, - boolean open, - State state, - boolean read, + Optional open, + Optional state, + Optional read, Optional priority, Optional adminAssigneeId, Optional teamAssigneeId, + Optional companyId, Optional tags, Optional conversationRating, - ConversationSource source, - ConversationContacts contacts, - ConversationTeammates teammates, - Map customAttributes, + Optional source, + Optional contacts, + Optional teammates, + Optional> customAttributes, Optional firstContactReply, Optional slaApplied, Optional statistics, @@ -130,6 +138,7 @@ private Conversation( this.priority = priority; this.adminAssigneeId = adminAssigneeId; this.teamAssigneeId = teamAssigneeId; + this.companyId = companyId; this.tags = tags; this.conversationRating = conversationRating; this.source = source; @@ -158,7 +167,7 @@ public Optional getType() { * @return The id representing the conversation. */ @JsonProperty("id") - public String getId() { + public Optional getId() { return id; } @@ -174,7 +183,7 @@ public Optional getTitle() { * @return The time the conversation was created. */ @JsonProperty("created_at") - public int getCreatedAt() { + public Optional getCreatedAt() { return createdAt; } @@ -182,7 +191,7 @@ public int getCreatedAt() { * @return The last time the conversation was updated. */ @JsonProperty("updated_at") - public int getUpdatedAt() { + public Optional getUpdatedAt() { return updatedAt; } @@ -206,7 +215,7 @@ public Optional getSnoozedUntil() { * @return Indicates whether a conversation is open (true) or closed (false). */ @JsonProperty("open") - public boolean getOpen() { + public Optional getOpen() { return open; } @@ -214,7 +223,7 @@ public boolean getOpen() { * @return Can be set to "open", "closed" or "snoozed". */ @JsonProperty("state") - public State getState() { + public Optional getState() { return state; } @@ -222,7 +231,7 @@ public State getState() { * @return Indicates whether a conversation has been read. */ @JsonProperty("read") - public boolean getRead() { + public Optional getRead() { return read; } @@ -250,6 +259,14 @@ public Optional getTeamAssigneeId() { return teamAssigneeId; } + /** + * @return The ID of the company that the conversation is associated with. The unique identifier for the company which is given by Intercom. + */ + @JsonProperty("company_id") + public Optional getCompanyId() { + return companyId; + } + @JsonProperty("tags") public Optional getTags() { return tags; @@ -261,22 +278,22 @@ public Optional getConversationRating() { } @JsonProperty("source") - public ConversationSource getSource() { + public Optional getSource() { return source; } @JsonProperty("contacts") - public ConversationContacts getContacts() { + public Optional getContacts() { return contacts; } @JsonProperty("teammates") - public ConversationTeammates getTeammates() { + public Optional getTeammates() { return teammates; } @JsonProperty("custom_attributes") - public Map getCustomAttributes() { + public Optional> getCustomAttributes() { return customAttributes; } @@ -333,16 +350,17 @@ private boolean equalTo(Conversation other) { return type.equals(other.type) && id.equals(other.id) && title.equals(other.title) - && createdAt == other.createdAt - && updatedAt == other.updatedAt + && createdAt.equals(other.createdAt) + && updatedAt.equals(other.updatedAt) && waitingSince.equals(other.waitingSince) && snoozedUntil.equals(other.snoozedUntil) - && open == other.open + && open.equals(other.open) && state.equals(other.state) - && read == other.read + && read.equals(other.read) && priority.equals(other.priority) && adminAssigneeId.equals(other.adminAssigneeId) && teamAssigneeId.equals(other.teamAssigneeId) + && companyId.equals(other.companyId) && tags.equals(other.tags) && conversationRating.equals(other.conversationRating) && source.equals(other.source) @@ -374,6 +392,7 @@ public int hashCode() { this.priority, this.adminAssigneeId, this.teamAssigneeId, + this.companyId, this.tags, this.conversationRating, this.source, @@ -394,234 +413,71 @@ public String toString() { return ObjectMappers.stringify(this); } - public static IdStage builder() { + public static Builder builder() { return new Builder(); } - public interface IdStage { - /** - * The id representing the conversation. - */ - CreatedAtStage id(@NotNull String id); - - Builder from(Conversation other); - } - - public interface CreatedAtStage { - /** - * The time the conversation was created. - */ - UpdatedAtStage createdAt(int createdAt); - } - - public interface UpdatedAtStage { - /** - * The last time the conversation was updated. - */ - OpenStage updatedAt(int updatedAt); - } - - public interface OpenStage { - /** - * Indicates whether a conversation is open (true) or closed (false). - */ - StateStage open(boolean open); - } - - public interface StateStage { - /** - * Can be set to "open", "closed" or "snoozed". - */ - ReadStage state(@NotNull State state); - } - - public interface ReadStage { - /** - * Indicates whether a conversation has been read. - */ - SourceStage read(boolean read); - } - - public interface SourceStage { - ContactsStage source(@NotNull ConversationSource source); - } - - public interface ContactsStage { - TeammatesStage contacts(@NotNull ConversationContacts contacts); - } - - public interface TeammatesStage { - _FinalStage teammates(@NotNull ConversationTeammates teammates); - } - - public interface _FinalStage { - Conversation build(); - - /** - *

    Always conversation.

    - */ - _FinalStage type(Optional type); - - _FinalStage type(String type); - - /** - *

    The title given to the conversation.

    - */ - _FinalStage title(Optional title); - - _FinalStage title(String title); - - /** - *

    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.

    - */ - _FinalStage waitingSince(Optional waitingSince); - - _FinalStage waitingSince(Integer waitingSince); - - /** - *

    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.

    - */ - _FinalStage snoozedUntil(Optional snoozedUntil); - - _FinalStage snoozedUntil(Integer snoozedUntil); - - /** - *

    If marked as priority, it will return priority or else not_priority.

    - */ - _FinalStage priority(Optional priority); - - _FinalStage priority(Priority priority); - - /** - *

    The id of the admin assigned to the conversation. If it's not assigned to an admin it will return null.

    - */ - _FinalStage adminAssigneeId(Optional adminAssigneeId); - - _FinalStage adminAssigneeId(Integer adminAssigneeId); - - /** - *

    The id of the team assigned to the conversation. If it's not assigned to a team it will return null.

    - */ - _FinalStage teamAssigneeId(Optional teamAssigneeId); - - _FinalStage teamAssigneeId(String teamAssigneeId); - - _FinalStage tags(Optional tags); - - _FinalStage tags(Tags tags); - - _FinalStage conversationRating(Optional conversationRating); - - _FinalStage conversationRating(ConversationRating conversationRating); - - _FinalStage customAttributes(Map customAttributes); - - _FinalStage putAllCustomAttributes(Map customAttributes); - - _FinalStage customAttributes(String key, Object value); - - _FinalStage firstContactReply(Optional firstContactReply); - - _FinalStage firstContactReply(ConversationFirstContactReply firstContactReply); - - _FinalStage slaApplied(Optional slaApplied); - - _FinalStage slaApplied(SlaApplied slaApplied); - - _FinalStage statistics(Optional statistics); - - _FinalStage statistics(ConversationStatistics statistics); - - _FinalStage conversationParts(Optional conversationParts); - - _FinalStage conversationParts(ConversationParts conversationParts); - - _FinalStage linkedObjects(Optional linkedObjects); - - _FinalStage linkedObjects(LinkedObjectList linkedObjects); + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); - /** - *

    Indicates whether the AI Agent participated in the conversation.

    - */ - _FinalStage aiAgentParticipated(Optional aiAgentParticipated); + private Optional id = Optional.empty(); - _FinalStage aiAgentParticipated(Boolean aiAgentParticipated); + private Optional title = Optional.empty(); - _FinalStage aiAgent(Optional aiAgent); + private Optional createdAt = Optional.empty(); - _FinalStage aiAgent(AiAgent aiAgent); - } + private Optional updatedAt = Optional.empty(); - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder - implements IdStage, - CreatedAtStage, - UpdatedAtStage, - OpenStage, - StateStage, - ReadStage, - SourceStage, - ContactsStage, - TeammatesStage, - _FinalStage { - private String id; + private Optional waitingSince = Optional.empty(); - private int createdAt; + private Optional snoozedUntil = Optional.empty(); - private int updatedAt; + private Optional open = Optional.empty(); - private boolean open; + private Optional state = Optional.empty(); - private State state; + private Optional read = Optional.empty(); - private boolean read; + private Optional priority = Optional.empty(); - private ConversationSource source; + private Optional adminAssigneeId = Optional.empty(); - private ConversationContacts contacts; + private Optional teamAssigneeId = Optional.empty(); - private ConversationTeammates teammates; + private Optional companyId = Optional.empty(); - private Optional aiAgent = Optional.empty(); + private Optional tags = Optional.empty(); - private Optional aiAgentParticipated = Optional.empty(); + private Optional conversationRating = Optional.empty(); - private Optional linkedObjects = Optional.empty(); + private Optional source = Optional.empty(); - private Optional conversationParts = Optional.empty(); + private Optional contacts = Optional.empty(); - private Optional statistics = Optional.empty(); + private Optional teammates = Optional.empty(); - private Optional slaApplied = Optional.empty(); + private Optional> customAttributes = Optional.empty(); private Optional firstContactReply = Optional.empty(); - private Map customAttributes = new LinkedHashMap<>(); - - private Optional conversationRating = Optional.empty(); - - private Optional tags = Optional.empty(); - - private Optional teamAssigneeId = Optional.empty(); - - private Optional adminAssigneeId = Optional.empty(); + private Optional slaApplied = Optional.empty(); - private Optional priority = Optional.empty(); + private Optional statistics = Optional.empty(); - private Optional snoozedUntil = Optional.empty(); + private Optional conversationParts = Optional.empty(); - private Optional waitingSince = Optional.empty(); + private Optional linkedObjects = Optional.empty(); - private Optional title = Optional.empty(); + private Optional aiAgentParticipated = Optional.empty(); - private Optional type = Optional.empty(); + private Optional aiAgent = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} - @java.lang.Override public Builder from(Conversation other) { type(other.getType()); id(other.getId()); @@ -636,6 +492,7 @@ public Builder from(Conversation other) { priority(other.getPriority()); adminAssigneeId(other.getAdminAssigneeId()); teamAssigneeId(other.getTeamAssigneeId()); + companyId(other.getCompanyId()); tags(other.getTags()); conversationRating(other.getConversationRating()); source(other.getSource()); @@ -653,377 +510,347 @@ public Builder from(Conversation other) { } /** - * The id representing the conversation.

    The id representing the conversation.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    Always conversation.

    + */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + /** + *

    The id representing the conversation.

    */ - @java.lang.Override - @JsonSetter("id") - public CreatedAtStage id(@NotNull String id) { - this.id = Objects.requireNonNull(id, "id must not be null"); + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.ofNullable(id); return this; } /** - * The time the conversation was created.

    The time the conversation was created.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The title given to the conversation.

    */ - @java.lang.Override - @JsonSetter("created_at") - public UpdatedAtStage createdAt(int createdAt) { + @JsonSetter(value = "title", nulls = Nulls.SKIP) + public Builder title(Optional title) { + this.title = title; + return this; + } + + public Builder title(String title) { + this.title = Optional.ofNullable(title); + return this; + } + + /** + *

    The time the conversation was created.

    + */ + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public Builder createdAt(Optional createdAt) { this.createdAt = createdAt; return this; } + public Builder createdAt(Integer createdAt) { + this.createdAt = Optional.ofNullable(createdAt); + return this; + } + /** - * The last time the conversation was updated.

    The last time the conversation was updated.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The last time the conversation was updated.

    */ - @java.lang.Override - @JsonSetter("updated_at") - public OpenStage updatedAt(int updatedAt) { + @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) + public Builder updatedAt(Optional updatedAt) { this.updatedAt = updatedAt; return this; } + public Builder updatedAt(Integer updatedAt) { + this.updatedAt = Optional.ofNullable(updatedAt); + return this; + } + /** - * Indicates whether a conversation is open (true) or closed (false).

    Indicates whether a conversation is open (true) or closed (false).

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    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.

    */ - @java.lang.Override - @JsonSetter("open") - public StateStage open(boolean open) { - this.open = open; + @JsonSetter(value = "waiting_since", nulls = Nulls.SKIP) + public Builder waitingSince(Optional waitingSince) { + this.waitingSince = waitingSince; + return this; + } + + public Builder waitingSince(Integer waitingSince) { + this.waitingSince = Optional.ofNullable(waitingSince); return this; } /** - * Can be set to "open", "closed" or "snoozed".

    Can be set to "open", "closed" or "snoozed".

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    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.

    */ - @java.lang.Override - @JsonSetter("state") - public ReadStage state(@NotNull State state) { - this.state = Objects.requireNonNull(state, "state must not be null"); + @JsonSetter(value = "snoozed_until", nulls = Nulls.SKIP) + public Builder snoozedUntil(Optional snoozedUntil) { + this.snoozedUntil = snoozedUntil; + return this; + } + + public Builder snoozedUntil(Integer snoozedUntil) { + this.snoozedUntil = Optional.ofNullable(snoozedUntil); return this; } /** - * Indicates whether a conversation has been read.

    Indicates whether a conversation has been read.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    Indicates whether a conversation is open (true) or closed (false).

    */ - @java.lang.Override - @JsonSetter("read") - public SourceStage read(boolean read) { - this.read = read; + @JsonSetter(value = "open", nulls = Nulls.SKIP) + public Builder open(Optional open) { + this.open = open; return this; } - @java.lang.Override - @JsonSetter("source") - public ContactsStage source(@NotNull ConversationSource source) { - this.source = Objects.requireNonNull(source, "source must not be null"); + public Builder open(Boolean open) { + this.open = Optional.ofNullable(open); return this; } - @java.lang.Override - @JsonSetter("contacts") - public TeammatesStage contacts(@NotNull ConversationContacts contacts) { - this.contacts = Objects.requireNonNull(contacts, "contacts must not be null"); + /** + *

    Can be set to "open", "closed" or "snoozed".

    + */ + @JsonSetter(value = "state", nulls = Nulls.SKIP) + public Builder state(Optional state) { + this.state = state; return this; } - @java.lang.Override - @JsonSetter("teammates") - public _FinalStage teammates(@NotNull ConversationTeammates teammates) { - this.teammates = Objects.requireNonNull(teammates, "teammates must not be null"); + public Builder state(State state) { + this.state = Optional.ofNullable(state); return this; } - @java.lang.Override - public _FinalStage aiAgent(AiAgent aiAgent) { - this.aiAgent = Optional.ofNullable(aiAgent); + /** + *

    Indicates whether a conversation has been read.

    + */ + @JsonSetter(value = "read", nulls = Nulls.SKIP) + public Builder read(Optional read) { + this.read = read; return this; } - @java.lang.Override - @JsonSetter(value = "ai_agent", nulls = Nulls.SKIP) - public _FinalStage aiAgent(Optional aiAgent) { - this.aiAgent = aiAgent; + public Builder read(Boolean read) { + this.read = Optional.ofNullable(read); return this; } /** - *

    Indicates whether the AI Agent participated in the conversation.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    If marked as priority, it will return priority or else not_priority.

    */ - @java.lang.Override - public _FinalStage aiAgentParticipated(Boolean aiAgentParticipated) { - this.aiAgentParticipated = Optional.ofNullable(aiAgentParticipated); + @JsonSetter(value = "priority", nulls = Nulls.SKIP) + public Builder priority(Optional priority) { + this.priority = priority; + return this; + } + + public Builder priority(Priority priority) { + this.priority = Optional.ofNullable(priority); return this; } /** - *

    Indicates whether the AI Agent participated in the conversation.

    + *

    The id of the admin assigned to the conversation. If it's not assigned to an admin it will return null.

    */ - @java.lang.Override - @JsonSetter(value = "ai_agent_participated", nulls = Nulls.SKIP) - public _FinalStage aiAgentParticipated(Optional aiAgentParticipated) { - this.aiAgentParticipated = aiAgentParticipated; + @JsonSetter(value = "admin_assignee_id", nulls = Nulls.SKIP) + public Builder adminAssigneeId(Optional adminAssigneeId) { + this.adminAssigneeId = adminAssigneeId; return this; } - @java.lang.Override - public _FinalStage linkedObjects(LinkedObjectList linkedObjects) { - this.linkedObjects = Optional.ofNullable(linkedObjects); + public Builder adminAssigneeId(Integer adminAssigneeId) { + this.adminAssigneeId = Optional.ofNullable(adminAssigneeId); return this; } - @java.lang.Override - @JsonSetter(value = "linked_objects", nulls = Nulls.SKIP) - public _FinalStage linkedObjects(Optional linkedObjects) { - this.linkedObjects = linkedObjects; + /** + *

    The id of the team assigned to the conversation. If it's not assigned to a team it will return null.

    + */ + @JsonSetter(value = "team_assignee_id", nulls = Nulls.SKIP) + public Builder teamAssigneeId(Optional teamAssigneeId) { + this.teamAssigneeId = teamAssigneeId; return this; } - @java.lang.Override - public _FinalStage conversationParts(ConversationParts conversationParts) { - this.conversationParts = Optional.ofNullable(conversationParts); + public Builder teamAssigneeId(String teamAssigneeId) { + this.teamAssigneeId = Optional.ofNullable(teamAssigneeId); return this; } - @java.lang.Override - @JsonSetter(value = "conversation_parts", nulls = Nulls.SKIP) - public _FinalStage conversationParts(Optional conversationParts) { - this.conversationParts = conversationParts; + /** + *

    The ID of the company that the conversation is associated with. The unique identifier for the company which is given by Intercom.

    + */ + @JsonSetter(value = "company_id", nulls = Nulls.SKIP) + public Builder companyId(Optional companyId) { + this.companyId = companyId; return this; } - @java.lang.Override - public _FinalStage statistics(ConversationStatistics statistics) { - this.statistics = Optional.ofNullable(statistics); + public Builder companyId(String companyId) { + this.companyId = Optional.ofNullable(companyId); return this; } - @java.lang.Override - @JsonSetter(value = "statistics", nulls = Nulls.SKIP) - public _FinalStage statistics(Optional statistics) { - this.statistics = statistics; + @JsonSetter(value = "tags", nulls = Nulls.SKIP) + public Builder tags(Optional tags) { + this.tags = tags; return this; } - @java.lang.Override - public _FinalStage slaApplied(SlaApplied slaApplied) { - this.slaApplied = Optional.ofNullable(slaApplied); + public Builder tags(Tags tags) { + this.tags = Optional.ofNullable(tags); return this; } - @java.lang.Override - @JsonSetter(value = "sla_applied", nulls = Nulls.SKIP) - public _FinalStage slaApplied(Optional slaApplied) { - this.slaApplied = slaApplied; + @JsonSetter(value = "conversation_rating", nulls = Nulls.SKIP) + public Builder conversationRating(Optional conversationRating) { + this.conversationRating = conversationRating; return this; } - @java.lang.Override - public _FinalStage firstContactReply(ConversationFirstContactReply firstContactReply) { - this.firstContactReply = Optional.ofNullable(firstContactReply); + public Builder conversationRating(ConversationRating conversationRating) { + this.conversationRating = Optional.ofNullable(conversationRating); return this; } - @java.lang.Override - @JsonSetter(value = "first_contact_reply", nulls = Nulls.SKIP) - public _FinalStage firstContactReply(Optional firstContactReply) { - this.firstContactReply = firstContactReply; + @JsonSetter(value = "source", nulls = Nulls.SKIP) + public Builder source(Optional source) { + this.source = source; return this; } - @java.lang.Override - public _FinalStage customAttributes(String key, Object value) { - this.customAttributes.put(key, value); + public Builder source(ConversationSource source) { + this.source = Optional.ofNullable(source); return this; } - @java.lang.Override - public _FinalStage putAllCustomAttributes(Map customAttributes) { - this.customAttributes.putAll(customAttributes); + @JsonSetter(value = "contacts", nulls = Nulls.SKIP) + public Builder contacts(Optional contacts) { + this.contacts = contacts; return this; } - @java.lang.Override - @JsonSetter(value = "custom_attributes", nulls = Nulls.SKIP) - public _FinalStage customAttributes(Map customAttributes) { - this.customAttributes.clear(); - this.customAttributes.putAll(customAttributes); + public Builder contacts(ConversationContacts contacts) { + this.contacts = Optional.ofNullable(contacts); return this; } - @java.lang.Override - public _FinalStage conversationRating(ConversationRating conversationRating) { - this.conversationRating = Optional.ofNullable(conversationRating); + @JsonSetter(value = "teammates", nulls = Nulls.SKIP) + public Builder teammates(Optional teammates) { + this.teammates = teammates; return this; } - @java.lang.Override - @JsonSetter(value = "conversation_rating", nulls = Nulls.SKIP) - public _FinalStage conversationRating(Optional conversationRating) { - this.conversationRating = conversationRating; + public Builder teammates(ConversationTeammates teammates) { + this.teammates = Optional.ofNullable(teammates); return this; } - @java.lang.Override - public _FinalStage tags(Tags tags) { - this.tags = Optional.ofNullable(tags); + @JsonSetter(value = "custom_attributes", nulls = Nulls.SKIP) + public Builder customAttributes(Optional> customAttributes) { + this.customAttributes = customAttributes; return this; } - @java.lang.Override - @JsonSetter(value = "tags", nulls = Nulls.SKIP) - public _FinalStage tags(Optional tags) { - this.tags = tags; + public Builder customAttributes(Map customAttributes) { + this.customAttributes = Optional.ofNullable(customAttributes); return this; } - /** - *

    The id of the team assigned to the conversation. If it's not assigned to a team it will return null.

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage teamAssigneeId(String teamAssigneeId) { - this.teamAssigneeId = Optional.ofNullable(teamAssigneeId); + @JsonSetter(value = "first_contact_reply", nulls = Nulls.SKIP) + public Builder firstContactReply(Optional firstContactReply) { + this.firstContactReply = firstContactReply; return this; } - /** - *

    The id of the team assigned to the conversation. If it's not assigned to a team it will return null.

    - */ - @java.lang.Override - @JsonSetter(value = "team_assignee_id", nulls = Nulls.SKIP) - public _FinalStage teamAssigneeId(Optional teamAssigneeId) { - this.teamAssigneeId = teamAssigneeId; + public Builder firstContactReply(ConversationFirstContactReply firstContactReply) { + this.firstContactReply = Optional.ofNullable(firstContactReply); return this; } - /** - *

    The id of the admin assigned to the conversation. If it's not assigned to an admin it will return null.

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage adminAssigneeId(Integer adminAssigneeId) { - this.adminAssigneeId = Optional.ofNullable(adminAssigneeId); + @JsonSetter(value = "sla_applied", nulls = Nulls.SKIP) + public Builder slaApplied(Optional slaApplied) { + this.slaApplied = slaApplied; return this; } - /** - *

    The id of the admin assigned to the conversation. If it's not assigned to an admin it will return null.

    - */ - @java.lang.Override - @JsonSetter(value = "admin_assignee_id", nulls = Nulls.SKIP) - public _FinalStage adminAssigneeId(Optional adminAssigneeId) { - this.adminAssigneeId = adminAssigneeId; + public Builder slaApplied(SlaApplied slaApplied) { + this.slaApplied = Optional.ofNullable(slaApplied); return this; } - /** - *

    If marked as priority, it will return priority or else not_priority.

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage priority(Priority priority) { - this.priority = Optional.ofNullable(priority); + @JsonSetter(value = "statistics", nulls = Nulls.SKIP) + public Builder statistics(Optional statistics) { + this.statistics = statistics; return this; } - /** - *

    If marked as priority, it will return priority or else not_priority.

    - */ - @java.lang.Override - @JsonSetter(value = "priority", nulls = Nulls.SKIP) - public _FinalStage priority(Optional priority) { - this.priority = priority; + public Builder statistics(ConversationStatistics statistics) { + this.statistics = Optional.ofNullable(statistics); return this; } - /** - *

    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.

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage snoozedUntil(Integer snoozedUntil) { - this.snoozedUntil = Optional.ofNullable(snoozedUntil); + @JsonSetter(value = "conversation_parts", nulls = Nulls.SKIP) + public Builder conversationParts(Optional conversationParts) { + this.conversationParts = conversationParts; return this; } - /** - *

    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.

    - */ - @java.lang.Override - @JsonSetter(value = "snoozed_until", nulls = Nulls.SKIP) - public _FinalStage snoozedUntil(Optional snoozedUntil) { - this.snoozedUntil = snoozedUntil; + public Builder conversationParts(ConversationParts conversationParts) { + this.conversationParts = Optional.ofNullable(conversationParts); return this; } - /** - *

    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.

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage waitingSince(Integer waitingSince) { - this.waitingSince = Optional.ofNullable(waitingSince); + @JsonSetter(value = "linked_objects", nulls = Nulls.SKIP) + public Builder linkedObjects(Optional linkedObjects) { + this.linkedObjects = linkedObjects; return this; } - /** - *

    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.

    - */ - @java.lang.Override - @JsonSetter(value = "waiting_since", nulls = Nulls.SKIP) - public _FinalStage waitingSince(Optional waitingSince) { - this.waitingSince = waitingSince; + public Builder linkedObjects(LinkedObjectList linkedObjects) { + this.linkedObjects = Optional.ofNullable(linkedObjects); return this; } /** - *

    The title given to the conversation.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    Indicates whether the AI Agent participated in the conversation.

    */ - @java.lang.Override - public _FinalStage title(String title) { - this.title = Optional.ofNullable(title); + @JsonSetter(value = "ai_agent_participated", nulls = Nulls.SKIP) + public Builder aiAgentParticipated(Optional aiAgentParticipated) { + this.aiAgentParticipated = aiAgentParticipated; return this; } - /** - *

    The title given to the conversation.

    - */ - @java.lang.Override - @JsonSetter(value = "title", nulls = Nulls.SKIP) - public _FinalStage title(Optional title) { - this.title = title; + public Builder aiAgentParticipated(Boolean aiAgentParticipated) { + this.aiAgentParticipated = Optional.ofNullable(aiAgentParticipated); return this; } - /** - *

    Always conversation.

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage type(String type) { - this.type = Optional.ofNullable(type); + @JsonSetter(value = "ai_agent", nulls = Nulls.SKIP) + public Builder aiAgent(Optional aiAgent) { + this.aiAgent = aiAgent; return this; } - /** - *

    Always conversation.

    - */ - @java.lang.Override - @JsonSetter(value = "type", nulls = Nulls.SKIP) - public _FinalStage type(Optional type) { - this.type = type; + public Builder aiAgent(AiAgent aiAgent) { + this.aiAgent = Optional.ofNullable(aiAgent); return this; } - @java.lang.Override public Conversation build() { return new Conversation( type, @@ -1039,6 +866,7 @@ public Conversation build() { priority, adminAssigneeId, teamAssigneeId, + companyId, tags, conversationRating, source, @@ -1215,4 +1043,108 @@ public interface Visitor { T visitUnknown(String unknownType); } } + + @JsonDeserialize(using = CustomAttributesValue.Deserializer.class) + public static final class CustomAttributesValue { + private final Object value; + + private final int type; + + private CustomAttributesValue(Object value, int type) { + this.value = value; + this.type = type; + } + + @JsonValue + public Object get() { + return this.value; + } + + @SuppressWarnings("unchecked") + public T visit(Visitor visitor) { + if (this.type == 0) { + return visitor.visit((String) this.value); + } else if (this.type == 1) { + return visitor.visit((int) this.value); + } else if (this.type == 2) { + return visitor.visit((Datetime) this.value); + } else if (this.type == 3) { + return visitor.visit((CustomObjectInstanceList) this.value); + } + throw new IllegalStateException("Failed to visit value. This should never happen."); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CustomAttributesValue && equalTo((CustomAttributesValue) other); + } + + private boolean equalTo(CustomAttributesValue other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return this.value.toString(); + } + + public static CustomAttributesValue of(String value) { + return new CustomAttributesValue(value, 0); + } + + public static CustomAttributesValue of(int value) { + return new CustomAttributesValue(value, 1); + } + + public static CustomAttributesValue of(Datetime value) { + return new CustomAttributesValue(value, 2); + } + + public static CustomAttributesValue of(CustomObjectInstanceList value) { + return new CustomAttributesValue(value, 3); + } + + public interface Visitor { + T visit(String value); + + T visit(int value); + + T visit(Datetime value); + + T visit(CustomObjectInstanceList value); + } + + static final class Deserializer extends StdDeserializer { + Deserializer() { + super(CustomAttributesValue.class); + } + + @java.lang.Override + public CustomAttributesValue deserialize(JsonParser p, DeserializationContext context) throws IOException { + Object value = p.readValueAs(Object.class); + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); + } catch (IllegalArgumentException e) { + } + if (value instanceof Integer) { + return of((Integer) value); + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, Datetime.class)); + } catch (IllegalArgumentException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, CustomObjectInstanceList.class)); + } catch (IllegalArgumentException e) { + } + throw new JsonParseException(p, "Failed to deserialize"); + } + } + } } diff --git a/src/main/java/com/intercom/api/resources/customchannelevents/AsyncCustomChannelEventsClient.java b/src/main/java/com/intercom/api/resources/customchannelevents/AsyncCustomChannelEventsClient.java new file mode 100644 index 0000000..c007d7c --- /dev/null +++ b/src/main/java/com/intercom/api/resources/customchannelevents/AsyncCustomChannelEventsClient.java @@ -0,0 +1,117 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.customchannelevents; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.customchannelevents.requests.NotifyAttributeCollectedRequest; +import com.intercom.api.resources.customchannelevents.requests.NotifyNewMessageRequest; +import com.intercom.api.resources.customchannelevents.requests.NotifyQuickReplySelectedRequest; +import com.intercom.api.types.CustomChannelBaseEvent; +import com.intercom.api.types.CustomChannelNotificationResponse; +import java.util.concurrent.CompletableFuture; + +public class AsyncCustomChannelEventsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawCustomChannelEventsClient rawClient; + + public AsyncCustomChannelEventsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawCustomChannelEventsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawCustomChannelEventsClient withRawResponse() { + return this.rawClient; + } + + /** + * 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.

    + *
    + */ + public CompletableFuture notifyNewConversation(CustomChannelBaseEvent request) { + return this.rawClient.notifyNewConversation(request).thenApply(response -> response.body()); + } + + /** + * 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.

    + *
    + */ + public CompletableFuture notifyNewConversation( + CustomChannelBaseEvent request, RequestOptions requestOptions) { + return this.rawClient.notifyNewConversation(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * 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.

    + *
    + */ + public CompletableFuture notifyNewMessage(NotifyNewMessageRequest request) { + return this.rawClient.notifyNewMessage(request).thenApply(response -> response.body()); + } + + /** + * 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.

    + *
    + */ + public CompletableFuture notifyNewMessage( + NotifyNewMessageRequest request, RequestOptions requestOptions) { + return this.rawClient.notifyNewMessage(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * 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.

    + *
    + */ + public CompletableFuture notifyQuickReplySelected( + NotifyQuickReplySelectedRequest request) { + return this.rawClient.notifyQuickReplySelected(request).thenApply(response -> response.body()); + } + + /** + * 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.

    + *
    + */ + public CompletableFuture notifyQuickReplySelected( + NotifyQuickReplySelectedRequest request, RequestOptions requestOptions) { + return this.rawClient.notifyQuickReplySelected(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * 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.

    + *
    + */ + public CompletableFuture notifyAttributeCollected( + NotifyAttributeCollectedRequest request) { + return this.rawClient.notifyAttributeCollected(request).thenApply(response -> response.body()); + } + + /** + * 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.

    + *
    + */ + public CompletableFuture notifyAttributeCollected( + NotifyAttributeCollectedRequest request, RequestOptions requestOptions) { + return this.rawClient.notifyAttributeCollected(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/intercom/api/resources/customchannelevents/AsyncRawCustomChannelEventsClient.java b/src/main/java/com/intercom/api/resources/customchannelevents/AsyncRawCustomChannelEventsClient.java new file mode 100644 index 0000000..313fc66 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/customchannelevents/AsyncRawCustomChannelEventsClient.java @@ -0,0 +1,439 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.customchannelevents; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.errors.BadRequestError; +import com.intercom.api.errors.NotFoundError; +import com.intercom.api.errors.UnauthorizedError; +import com.intercom.api.errors.UnprocessableEntityError; +import com.intercom.api.resources.customchannelevents.requests.NotifyAttributeCollectedRequest; +import com.intercom.api.resources.customchannelevents.requests.NotifyNewMessageRequest; +import com.intercom.api.resources.customchannelevents.requests.NotifyQuickReplySelectedRequest; +import com.intercom.api.types.CustomChannelBaseEvent; +import com.intercom.api.types.CustomChannelNotificationResponse; +import com.intercom.api.types.Error; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawCustomChannelEventsClient { + protected final ClientOptions clientOptions; + + public AsyncRawCustomChannelEventsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * 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.

    + *
    + */ + public CompletableFuture> notifyNewConversation( + CustomChannelBaseEvent request) { + return notifyNewConversation(request, null); + } + + /** + * 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.

    + *
    + */ + public CompletableFuture> notifyNewConversation( + CustomChannelBaseEvent request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("custom_channel_events/notify_new_conversation") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CustomChannelNotificationResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + case 422: + future.completeExceptionally(new UnprocessableEntityError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * 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.

    + *
    + */ + public CompletableFuture> notifyNewMessage( + NotifyNewMessageRequest request) { + return notifyNewMessage(request, null); + } + + /** + * 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.

    + *
    + */ + public CompletableFuture> notifyNewMessage( + NotifyNewMessageRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("custom_channel_events/notify_new_message") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CustomChannelNotificationResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + case 422: + future.completeExceptionally(new UnprocessableEntityError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * 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.

    + *
    + */ + public CompletableFuture> notifyQuickReplySelected( + NotifyQuickReplySelectedRequest request) { + return notifyQuickReplySelected(request, null); + } + + /** + * 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.

    + *
    + */ + public CompletableFuture> notifyQuickReplySelected( + NotifyQuickReplySelectedRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("custom_channel_events/notify_quick_reply_selected") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CustomChannelNotificationResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + case 422: + future.completeExceptionally(new UnprocessableEntityError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * 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.

    + *
    + */ + public CompletableFuture> notifyAttributeCollected( + NotifyAttributeCollectedRequest request) { + return notifyAttributeCollected(request, null); + } + + /** + * 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.

    + *
    + */ + public CompletableFuture> notifyAttributeCollected( + NotifyAttributeCollectedRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("custom_channel_events/notify_attribute_collected") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CustomChannelNotificationResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + case 422: + future.completeExceptionally(new UnprocessableEntityError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/intercom/api/resources/customchannelevents/CustomChannelEventsClient.java b/src/main/java/com/intercom/api/resources/customchannelevents/CustomChannelEventsClient.java new file mode 100644 index 0000000..8728305 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/customchannelevents/CustomChannelEventsClient.java @@ -0,0 +1,114 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.customchannelevents; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.customchannelevents.requests.NotifyAttributeCollectedRequest; +import com.intercom.api.resources.customchannelevents.requests.NotifyNewMessageRequest; +import com.intercom.api.resources.customchannelevents.requests.NotifyQuickReplySelectedRequest; +import com.intercom.api.types.CustomChannelBaseEvent; +import com.intercom.api.types.CustomChannelNotificationResponse; + +public class CustomChannelEventsClient { + protected final ClientOptions clientOptions; + + private final RawCustomChannelEventsClient rawClient; + + public CustomChannelEventsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawCustomChannelEventsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawCustomChannelEventsClient withRawResponse() { + return this.rawClient; + } + + /** + * 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.

    + *
    + */ + public CustomChannelNotificationResponse notifyNewConversation(CustomChannelBaseEvent request) { + return this.rawClient.notifyNewConversation(request).body(); + } + + /** + * 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.

    + *
    + */ + public CustomChannelNotificationResponse notifyNewConversation( + CustomChannelBaseEvent request, RequestOptions requestOptions) { + return this.rawClient.notifyNewConversation(request, requestOptions).body(); + } + + /** + * 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.

    + *
    + */ + public CustomChannelNotificationResponse notifyNewMessage(NotifyNewMessageRequest request) { + return this.rawClient.notifyNewMessage(request).body(); + } + + /** + * 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.

    + *
    + */ + public CustomChannelNotificationResponse notifyNewMessage( + NotifyNewMessageRequest request, RequestOptions requestOptions) { + return this.rawClient.notifyNewMessage(request, requestOptions).body(); + } + + /** + * 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.

    + *
    + */ + public CustomChannelNotificationResponse notifyQuickReplySelected(NotifyQuickReplySelectedRequest request) { + return this.rawClient.notifyQuickReplySelected(request).body(); + } + + /** + * 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.

    + *
    + */ + public CustomChannelNotificationResponse notifyQuickReplySelected( + NotifyQuickReplySelectedRequest request, RequestOptions requestOptions) { + return this.rawClient.notifyQuickReplySelected(request, requestOptions).body(); + } + + /** + * 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.

    + *
    + */ + public CustomChannelNotificationResponse notifyAttributeCollected(NotifyAttributeCollectedRequest request) { + return this.rawClient.notifyAttributeCollected(request).body(); + } + + /** + * 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.

    + *
    + */ + public CustomChannelNotificationResponse notifyAttributeCollected( + NotifyAttributeCollectedRequest request, RequestOptions requestOptions) { + return this.rawClient.notifyAttributeCollected(request, requestOptions).body(); + } +} diff --git a/src/main/java/com/intercom/api/resources/customchannelevents/RawCustomChannelEventsClient.java b/src/main/java/com/intercom/api/resources/customchannelevents/RawCustomChannelEventsClient.java new file mode 100644 index 0000000..dc8df96 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/customchannelevents/RawCustomChannelEventsClient.java @@ -0,0 +1,350 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.customchannelevents; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.errors.BadRequestError; +import com.intercom.api.errors.NotFoundError; +import com.intercom.api.errors.UnauthorizedError; +import com.intercom.api.errors.UnprocessableEntityError; +import com.intercom.api.resources.customchannelevents.requests.NotifyAttributeCollectedRequest; +import com.intercom.api.resources.customchannelevents.requests.NotifyNewMessageRequest; +import com.intercom.api.resources.customchannelevents.requests.NotifyQuickReplySelectedRequest; +import com.intercom.api.types.CustomChannelBaseEvent; +import com.intercom.api.types.CustomChannelNotificationResponse; +import com.intercom.api.types.Error; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawCustomChannelEventsClient { + protected final ClientOptions clientOptions; + + public RawCustomChannelEventsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * 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.

    + *
    + */ + public IntercomHttpResponse notifyNewConversation( + CustomChannelBaseEvent request) { + return notifyNewConversation(request, null); + } + + /** + * 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.

    + *
    + */ + public IntercomHttpResponse notifyNewConversation( + CustomChannelBaseEvent request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("custom_channel_events/notify_new_conversation") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CustomChannelNotificationResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + case 422: + throw new UnprocessableEntityError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * 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.

    + *
    + */ + public IntercomHttpResponse notifyNewMessage(NotifyNewMessageRequest request) { + return notifyNewMessage(request, null); + } + + /** + * 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.

    + *
    + */ + public IntercomHttpResponse notifyNewMessage( + NotifyNewMessageRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("custom_channel_events/notify_new_message") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CustomChannelNotificationResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + case 422: + throw new UnprocessableEntityError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * 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.

    + *
    + */ + public IntercomHttpResponse notifyQuickReplySelected( + NotifyQuickReplySelectedRequest request) { + return notifyQuickReplySelected(request, null); + } + + /** + * 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.

    + *
    + */ + public IntercomHttpResponse notifyQuickReplySelected( + NotifyQuickReplySelectedRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("custom_channel_events/notify_quick_reply_selected") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CustomChannelNotificationResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + case 422: + throw new UnprocessableEntityError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * 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.

    + *
    + */ + public IntercomHttpResponse notifyAttributeCollected( + NotifyAttributeCollectedRequest request) { + return notifyAttributeCollected(request, null); + } + + /** + * 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.

    + *
    + */ + public IntercomHttpResponse notifyAttributeCollected( + NotifyAttributeCollectedRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("custom_channel_events/notify_attribute_collected") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CustomChannelNotificationResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + case 422: + throw new UnprocessableEntityError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/customchannelevents/requests/NotifyAttributeCollectedRequest.java b/src/main/java/com/intercom/api/resources/customchannelevents/requests/NotifyAttributeCollectedRequest.java new file mode 100644 index 0000000..02f4b5c --- /dev/null +++ b/src/main/java/com/intercom/api/resources/customchannelevents/requests/NotifyAttributeCollectedRequest.java @@ -0,0 +1,202 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.customchannelevents.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.types.CustomChannelAttribute; +import com.intercom.api.types.CustomChannelContact; +import com.intercom.api.types.ICustomChannelBaseEvent; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = NotifyAttributeCollectedRequest.Builder.class) +public final class NotifyAttributeCollectedRequest implements ICustomChannelBaseEvent { + private final String eventId; + + private final String externalConversationId; + + private final CustomChannelContact contact; + + private final CustomChannelAttribute attribute; + + private final Map additionalProperties; + + private NotifyAttributeCollectedRequest( + String eventId, + String externalConversationId, + CustomChannelContact contact, + CustomChannelAttribute attribute, + Map additionalProperties) { + this.eventId = eventId; + this.externalConversationId = externalConversationId; + this.contact = contact; + this.attribute = attribute; + this.additionalProperties = additionalProperties; + } + + /** + * @return Unique identifier for the event. + */ + @JsonProperty("event_id") + public String getEventId() { + return eventId; + } + + /** + * @return Identifier for the conversation in your application. + */ + @JsonProperty("external_conversation_id") + public String getExternalConversationId() { + return externalConversationId; + } + + @JsonProperty("contact") + public CustomChannelContact getContact() { + return contact; + } + + @JsonProperty("attribute") + public CustomChannelAttribute getAttribute() { + return attribute; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof NotifyAttributeCollectedRequest && equalTo((NotifyAttributeCollectedRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(NotifyAttributeCollectedRequest other) { + return eventId.equals(other.eventId) + && externalConversationId.equals(other.externalConversationId) + && contact.equals(other.contact) + && attribute.equals(other.attribute); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.eventId, this.externalConversationId, this.contact, this.attribute); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static EventIdStage builder() { + return new Builder(); + } + + public interface EventIdStage { + /** + * Unique identifier for the event. + */ + ExternalConversationIdStage eventId(@NotNull String eventId); + + Builder from(NotifyAttributeCollectedRequest other); + } + + public interface ExternalConversationIdStage { + /** + * Identifier for the conversation in your application. + */ + ContactStage externalConversationId(@NotNull String externalConversationId); + } + + public interface ContactStage { + AttributeStage contact(@NotNull CustomChannelContact contact); + } + + public interface AttributeStage { + _FinalStage attribute(@NotNull CustomChannelAttribute attribute); + } + + public interface _FinalStage { + NotifyAttributeCollectedRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements EventIdStage, ExternalConversationIdStage, ContactStage, AttributeStage, _FinalStage { + private String eventId; + + private String externalConversationId; + + private CustomChannelContact contact; + + private CustomChannelAttribute attribute; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(NotifyAttributeCollectedRequest other) { + eventId(other.getEventId()); + externalConversationId(other.getExternalConversationId()); + contact(other.getContact()); + attribute(other.getAttribute()); + return this; + } + + /** + * Unique identifier for the event.

    Unique identifier for the event.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("event_id") + public ExternalConversationIdStage eventId(@NotNull String eventId) { + this.eventId = Objects.requireNonNull(eventId, "eventId must not be null"); + return this; + } + + /** + * Identifier for the conversation in your application.

    Identifier for the conversation in your application.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("external_conversation_id") + public ContactStage externalConversationId(@NotNull String externalConversationId) { + this.externalConversationId = + Objects.requireNonNull(externalConversationId, "externalConversationId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("contact") + public AttributeStage contact(@NotNull CustomChannelContact contact) { + this.contact = Objects.requireNonNull(contact, "contact must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("attribute") + public _FinalStage attribute(@NotNull CustomChannelAttribute attribute) { + this.attribute = Objects.requireNonNull(attribute, "attribute must not be null"); + return this; + } + + @java.lang.Override + public NotifyAttributeCollectedRequest build() { + return new NotifyAttributeCollectedRequest( + eventId, externalConversationId, contact, attribute, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/customchannelevents/requests/NotifyNewMessageRequest.java b/src/main/java/com/intercom/api/resources/customchannelevents/requests/NotifyNewMessageRequest.java new file mode 100644 index 0000000..11493e2 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/customchannelevents/requests/NotifyNewMessageRequest.java @@ -0,0 +1,210 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.customchannelevents.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.types.CustomChannelContact; +import com.intercom.api.types.ICustomChannelBaseEvent; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = NotifyNewMessageRequest.Builder.class) +public final class NotifyNewMessageRequest implements ICustomChannelBaseEvent { + private final String eventId; + + private final String externalConversationId; + + private final CustomChannelContact contact; + + private final String body; + + private final Map additionalProperties; + + private NotifyNewMessageRequest( + String eventId, + String externalConversationId, + CustomChannelContact contact, + String body, + Map additionalProperties) { + this.eventId = eventId; + this.externalConversationId = externalConversationId; + this.contact = contact; + this.body = body; + this.additionalProperties = additionalProperties; + } + + /** + * @return Unique identifier for the event. + */ + @JsonProperty("event_id") + public String getEventId() { + return eventId; + } + + /** + * @return Identifier for the conversation in your application. + */ + @JsonProperty("external_conversation_id") + public String getExternalConversationId() { + return externalConversationId; + } + + @JsonProperty("contact") + public CustomChannelContact getContact() { + return contact; + } + + /** + * @return The message content sent by the user. + */ + @JsonProperty("body") + public String getBody() { + return body; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof NotifyNewMessageRequest && equalTo((NotifyNewMessageRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(NotifyNewMessageRequest other) { + return eventId.equals(other.eventId) + && externalConversationId.equals(other.externalConversationId) + && contact.equals(other.contact) + && body.equals(other.body); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.eventId, this.externalConversationId, this.contact, this.body); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static EventIdStage builder() { + return new Builder(); + } + + public interface EventIdStage { + /** + * Unique identifier for the event. + */ + ExternalConversationIdStage eventId(@NotNull String eventId); + + Builder from(NotifyNewMessageRequest other); + } + + public interface ExternalConversationIdStage { + /** + * Identifier for the conversation in your application. + */ + ContactStage externalConversationId(@NotNull String externalConversationId); + } + + public interface ContactStage { + BodyStage contact(@NotNull CustomChannelContact contact); + } + + public interface BodyStage { + /** + * The message content sent by the user. + */ + _FinalStage body(@NotNull String body); + } + + public interface _FinalStage { + NotifyNewMessageRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements EventIdStage, ExternalConversationIdStage, ContactStage, BodyStage, _FinalStage { + private String eventId; + + private String externalConversationId; + + private CustomChannelContact contact; + + private String body; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(NotifyNewMessageRequest other) { + eventId(other.getEventId()); + externalConversationId(other.getExternalConversationId()); + contact(other.getContact()); + body(other.getBody()); + return this; + } + + /** + * Unique identifier for the event.

    Unique identifier for the event.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("event_id") + public ExternalConversationIdStage eventId(@NotNull String eventId) { + this.eventId = Objects.requireNonNull(eventId, "eventId must not be null"); + return this; + } + + /** + * Identifier for the conversation in your application.

    Identifier for the conversation in your application.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("external_conversation_id") + public ContactStage externalConversationId(@NotNull String externalConversationId) { + this.externalConversationId = + Objects.requireNonNull(externalConversationId, "externalConversationId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("contact") + public BodyStage contact(@NotNull CustomChannelContact contact) { + this.contact = Objects.requireNonNull(contact, "contact must not be null"); + return this; + } + + /** + * The message content sent by the user.

    The message content sent by the user.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("body") + public _FinalStage body(@NotNull String body) { + this.body = Objects.requireNonNull(body, "body must not be null"); + return this; + } + + @java.lang.Override + public NotifyNewMessageRequest build() { + return new NotifyNewMessageRequest(eventId, externalConversationId, contact, body, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/customchannelevents/requests/NotifyQuickReplySelectedRequest.java b/src/main/java/com/intercom/api/resources/customchannelevents/requests/NotifyQuickReplySelectedRequest.java new file mode 100644 index 0000000..44f9b59 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/customchannelevents/requests/NotifyQuickReplySelectedRequest.java @@ -0,0 +1,211 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.customchannelevents.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.types.CustomChannelContact; +import com.intercom.api.types.ICustomChannelBaseEvent; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = NotifyQuickReplySelectedRequest.Builder.class) +public final class NotifyQuickReplySelectedRequest implements ICustomChannelBaseEvent { + private final String eventId; + + private final String externalConversationId; + + private final CustomChannelContact contact; + + private final String quickReplyOptionId; + + private final Map additionalProperties; + + private NotifyQuickReplySelectedRequest( + String eventId, + String externalConversationId, + CustomChannelContact contact, + String quickReplyOptionId, + Map additionalProperties) { + this.eventId = eventId; + this.externalConversationId = externalConversationId; + this.contact = contact; + this.quickReplyOptionId = quickReplyOptionId; + this.additionalProperties = additionalProperties; + } + + /** + * @return Unique identifier for the event. + */ + @JsonProperty("event_id") + public String getEventId() { + return eventId; + } + + /** + * @return Identifier for the conversation in your application. + */ + @JsonProperty("external_conversation_id") + public String getExternalConversationId() { + return externalConversationId; + } + + @JsonProperty("contact") + public CustomChannelContact getContact() { + return contact; + } + + /** + * @return Id of the selected quick reply option. + */ + @JsonProperty("quick_reply_option_id") + public String getQuickReplyOptionId() { + return quickReplyOptionId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof NotifyQuickReplySelectedRequest && equalTo((NotifyQuickReplySelectedRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(NotifyQuickReplySelectedRequest other) { + return eventId.equals(other.eventId) + && externalConversationId.equals(other.externalConversationId) + && contact.equals(other.contact) + && quickReplyOptionId.equals(other.quickReplyOptionId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.eventId, this.externalConversationId, this.contact, this.quickReplyOptionId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static EventIdStage builder() { + return new Builder(); + } + + public interface EventIdStage { + /** + * Unique identifier for the event. + */ + ExternalConversationIdStage eventId(@NotNull String eventId); + + Builder from(NotifyQuickReplySelectedRequest other); + } + + public interface ExternalConversationIdStage { + /** + * Identifier for the conversation in your application. + */ + ContactStage externalConversationId(@NotNull String externalConversationId); + } + + public interface ContactStage { + QuickReplyOptionIdStage contact(@NotNull CustomChannelContact contact); + } + + public interface QuickReplyOptionIdStage { + /** + * Id of the selected quick reply option. + */ + _FinalStage quickReplyOptionId(@NotNull String quickReplyOptionId); + } + + public interface _FinalStage { + NotifyQuickReplySelectedRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements EventIdStage, ExternalConversationIdStage, ContactStage, QuickReplyOptionIdStage, _FinalStage { + private String eventId; + + private String externalConversationId; + + private CustomChannelContact contact; + + private String quickReplyOptionId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(NotifyQuickReplySelectedRequest other) { + eventId(other.getEventId()); + externalConversationId(other.getExternalConversationId()); + contact(other.getContact()); + quickReplyOptionId(other.getQuickReplyOptionId()); + return this; + } + + /** + * Unique identifier for the event.

    Unique identifier for the event.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("event_id") + public ExternalConversationIdStage eventId(@NotNull String eventId) { + this.eventId = Objects.requireNonNull(eventId, "eventId must not be null"); + return this; + } + + /** + * Identifier for the conversation in your application.

    Identifier for the conversation in your application.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("external_conversation_id") + public ContactStage externalConversationId(@NotNull String externalConversationId) { + this.externalConversationId = + Objects.requireNonNull(externalConversationId, "externalConversationId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("contact") + public QuickReplyOptionIdStage contact(@NotNull CustomChannelContact contact) { + this.contact = Objects.requireNonNull(contact, "contact must not be null"); + return this; + } + + /** + * Id of the selected quick reply option.

    Id of the selected quick reply option.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("quick_reply_option_id") + public _FinalStage quickReplyOptionId(@NotNull String quickReplyOptionId) { + this.quickReplyOptionId = Objects.requireNonNull(quickReplyOptionId, "quickReplyOptionId must not be null"); + return this; + } + + @java.lang.Override + public NotifyQuickReplySelectedRequest build() { + return new NotifyQuickReplySelectedRequest( + eventId, externalConversationId, contact, quickReplyOptionId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/customobjectinstances/AsyncCustomObjectInstancesClient.java b/src/main/java/com/intercom/api/resources/customobjectinstances/AsyncCustomObjectInstancesClient.java new file mode 100644 index 0000000..240bd25 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/customobjectinstances/AsyncCustomObjectInstancesClient.java @@ -0,0 +1,124 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.customobjectinstances; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.customobjectinstances.requests.CreateOrUpdateCustomObjectInstanceRequest; +import com.intercom.api.resources.customobjectinstances.requests.DeleteCustomObjectInstancesByExternalIdRequest; +import com.intercom.api.resources.customobjectinstances.requests.DeleteCustomObjectInstancesByIdRequest; +import com.intercom.api.resources.customobjectinstances.requests.GetCustomObjectInstancesByExternalIdRequest; +import com.intercom.api.resources.customobjectinstances.requests.GetCustomObjectInstancesByIdRequest; +import com.intercom.api.resources.customobjectinstances.types.CustomObjectInstance; +import com.intercom.api.types.CustomObjectInstanceDeleted; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; + +public class AsyncCustomObjectInstancesClient { + protected final ClientOptions clientOptions; + + private final AsyncRawCustomObjectInstancesClient rawClient; + + public AsyncCustomObjectInstancesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawCustomObjectInstancesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawCustomObjectInstancesClient withRawResponse() { + return this.rawClient; + } + + /** + * Fetch a Custom Object Instance by external_id. + */ + public CompletableFuture> getCustomObjectInstancesByExternalId( + GetCustomObjectInstancesByExternalIdRequest request) { + return this.rawClient.getCustomObjectInstancesByExternalId(request).thenApply(response -> response.body()); + } + + /** + * Fetch a Custom Object Instance by external_id. + */ + public CompletableFuture> getCustomObjectInstancesByExternalId( + GetCustomObjectInstancesByExternalIdRequest request, RequestOptions requestOptions) { + return this.rawClient + .getCustomObjectInstancesByExternalId(request, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * Create or update a custom object instance + */ + public CompletableFuture> createCustomObjectInstances( + CreateOrUpdateCustomObjectInstanceRequest request) { + return this.rawClient.createCustomObjectInstances(request).thenApply(response -> response.body()); + } + + /** + * Create or update a custom object instance + */ + public CompletableFuture> createCustomObjectInstances( + CreateOrUpdateCustomObjectInstanceRequest request, RequestOptions requestOptions) { + return this.rawClient + .createCustomObjectInstances(request, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * Delete a single Custom Object instance by external_id. + */ + public CompletableFuture deleteCustomObjectInstancesById( + DeleteCustomObjectInstancesByIdRequest request) { + return this.rawClient.deleteCustomObjectInstancesById(request).thenApply(response -> response.body()); + } + + /** + * Delete a single Custom Object instance by external_id. + */ + public CompletableFuture deleteCustomObjectInstancesById( + DeleteCustomObjectInstancesByIdRequest request, RequestOptions requestOptions) { + return this.rawClient + .deleteCustomObjectInstancesById(request, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * Fetch a Custom Object Instance by id. + */ + public CompletableFuture> getCustomObjectInstancesById( + GetCustomObjectInstancesByIdRequest request) { + return this.rawClient.getCustomObjectInstancesById(request).thenApply(response -> response.body()); + } + + /** + * Fetch a Custom Object Instance by id. + */ + public CompletableFuture> getCustomObjectInstancesById( + GetCustomObjectInstancesByIdRequest request, RequestOptions requestOptions) { + return this.rawClient + .getCustomObjectInstancesById(request, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * Delete a single Custom Object instance using the Intercom defined id. + */ + public CompletableFuture deleteCustomObjectInstancesByExternalId( + DeleteCustomObjectInstancesByExternalIdRequest request) { + return this.rawClient.deleteCustomObjectInstancesByExternalId(request).thenApply(response -> response.body()); + } + + /** + * Delete a single Custom Object instance using the Intercom defined id. + */ + public CompletableFuture deleteCustomObjectInstancesByExternalId( + DeleteCustomObjectInstancesByExternalIdRequest request, RequestOptions requestOptions) { + return this.rawClient + .deleteCustomObjectInstancesByExternalId(request, requestOptions) + .thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/intercom/api/resources/customobjectinstances/AsyncRawCustomObjectInstancesClient.java b/src/main/java/com/intercom/api/resources/customobjectinstances/AsyncRawCustomObjectInstancesClient.java new file mode 100644 index 0000000..96afadc --- /dev/null +++ b/src/main/java/com/intercom/api/resources/customobjectinstances/AsyncRawCustomObjectInstancesClient.java @@ -0,0 +1,440 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.customobjectinstances; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.QueryStringMapper; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.errors.NotFoundError; +import com.intercom.api.errors.UnauthorizedError; +import com.intercom.api.resources.customobjectinstances.requests.CreateOrUpdateCustomObjectInstanceRequest; +import com.intercom.api.resources.customobjectinstances.requests.DeleteCustomObjectInstancesByExternalIdRequest; +import com.intercom.api.resources.customobjectinstances.requests.DeleteCustomObjectInstancesByIdRequest; +import com.intercom.api.resources.customobjectinstances.requests.GetCustomObjectInstancesByExternalIdRequest; +import com.intercom.api.resources.customobjectinstances.requests.GetCustomObjectInstancesByIdRequest; +import com.intercom.api.resources.customobjectinstances.types.CustomObjectInstance; +import com.intercom.api.types.CustomObjectInstanceDeleted; +import com.intercom.api.types.Error; +import java.io.IOException; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawCustomObjectInstancesClient { + protected final ClientOptions clientOptions; + + public AsyncRawCustomObjectInstancesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Fetch a Custom Object Instance by external_id. + */ + public CompletableFuture>> getCustomObjectInstancesByExternalId( + GetCustomObjectInstancesByExternalIdRequest request) { + return getCustomObjectInstancesByExternalId(request, null); + } + + /** + * Fetch a Custom Object Instance by external_id. + */ + public CompletableFuture>> getCustomObjectInstancesByExternalId( + GetCustomObjectInstancesByExternalIdRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("custom_object_instances") + .addPathSegment(request.getCustomObjectTypeIdentifier()); + QueryStringMapper.addQueryParameter(httpUrl, "external_id", request.getExternalId(), false); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture>> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Create or update a custom object instance + */ + public CompletableFuture>> createCustomObjectInstances( + CreateOrUpdateCustomObjectInstanceRequest request) { + return createCustomObjectInstances(request, null); + } + + /** + * Create or update a custom object instance + */ + public CompletableFuture>> createCustomObjectInstances( + CreateOrUpdateCustomObjectInstanceRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("custom_object_instances") + .addPathSegment(request.getCustomObjectTypeIdentifier()) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture>> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Delete a single Custom Object instance by external_id. + */ + public CompletableFuture> deleteCustomObjectInstancesById( + DeleteCustomObjectInstancesByIdRequest request) { + return deleteCustomObjectInstancesById(request, null); + } + + /** + * Delete a single Custom Object instance by external_id. + */ + public CompletableFuture> deleteCustomObjectInstancesById( + DeleteCustomObjectInstancesByIdRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("custom_object_instances") + .addPathSegment(request.getCustomObjectTypeIdentifier()); + QueryStringMapper.addQueryParameter(httpUrl, "external_id", request.getExternalId(), false); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CustomObjectInstanceDeleted.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Fetch a Custom Object Instance by id. + */ + public CompletableFuture>> getCustomObjectInstancesById( + GetCustomObjectInstancesByIdRequest request) { + return getCustomObjectInstancesById(request, null); + } + + /** + * Fetch a Custom Object Instance by id. + */ + public CompletableFuture>> getCustomObjectInstancesById( + GetCustomObjectInstancesByIdRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("custom_object_instances") + .addPathSegment(request.getCustomObjectTypeIdentifier()) + .addPathSegment(request.getCustomObjectInstanceId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture>> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Delete a single Custom Object instance using the Intercom defined id. + */ + public CompletableFuture> deleteCustomObjectInstancesByExternalId( + DeleteCustomObjectInstancesByExternalIdRequest request) { + return deleteCustomObjectInstancesByExternalId(request, null); + } + + /** + * Delete a single Custom Object instance using the Intercom defined id. + */ + public CompletableFuture> deleteCustomObjectInstancesByExternalId( + DeleteCustomObjectInstancesByExternalIdRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("custom_object_instances") + .addPathSegment(request.getCustomObjectTypeIdentifier()) + .addPathSegment(request.getCustomObjectInstanceId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CustomObjectInstanceDeleted.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/intercom/api/resources/customobjectinstances/CustomObjectInstancesClient.java b/src/main/java/com/intercom/api/resources/customobjectinstances/CustomObjectInstancesClient.java new file mode 100644 index 0000000..b7f77db --- /dev/null +++ b/src/main/java/com/intercom/api/resources/customobjectinstances/CustomObjectInstancesClient.java @@ -0,0 +1,121 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.customobjectinstances; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.customobjectinstances.requests.CreateOrUpdateCustomObjectInstanceRequest; +import com.intercom.api.resources.customobjectinstances.requests.DeleteCustomObjectInstancesByExternalIdRequest; +import com.intercom.api.resources.customobjectinstances.requests.DeleteCustomObjectInstancesByIdRequest; +import com.intercom.api.resources.customobjectinstances.requests.GetCustomObjectInstancesByExternalIdRequest; +import com.intercom.api.resources.customobjectinstances.requests.GetCustomObjectInstancesByIdRequest; +import com.intercom.api.resources.customobjectinstances.types.CustomObjectInstance; +import com.intercom.api.types.CustomObjectInstanceDeleted; +import java.util.Optional; + +public class CustomObjectInstancesClient { + protected final ClientOptions clientOptions; + + private final RawCustomObjectInstancesClient rawClient; + + public CustomObjectInstancesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawCustomObjectInstancesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawCustomObjectInstancesClient withRawResponse() { + return this.rawClient; + } + + /** + * Fetch a Custom Object Instance by external_id. + */ + public Optional getCustomObjectInstancesByExternalId( + GetCustomObjectInstancesByExternalIdRequest request) { + return this.rawClient.getCustomObjectInstancesByExternalId(request).body(); + } + + /** + * Fetch a Custom Object Instance by external_id. + */ + public Optional getCustomObjectInstancesByExternalId( + GetCustomObjectInstancesByExternalIdRequest request, RequestOptions requestOptions) { + return this.rawClient + .getCustomObjectInstancesByExternalId(request, requestOptions) + .body(); + } + + /** + * Create or update a custom object instance + */ + public Optional createCustomObjectInstances( + CreateOrUpdateCustomObjectInstanceRequest request) { + return this.rawClient.createCustomObjectInstances(request).body(); + } + + /** + * Create or update a custom object instance + */ + public Optional createCustomObjectInstances( + CreateOrUpdateCustomObjectInstanceRequest request, RequestOptions requestOptions) { + return this.rawClient + .createCustomObjectInstances(request, requestOptions) + .body(); + } + + /** + * Delete a single Custom Object instance by external_id. + */ + public CustomObjectInstanceDeleted deleteCustomObjectInstancesById(DeleteCustomObjectInstancesByIdRequest request) { + return this.rawClient.deleteCustomObjectInstancesById(request).body(); + } + + /** + * Delete a single Custom Object instance by external_id. + */ + public CustomObjectInstanceDeleted deleteCustomObjectInstancesById( + DeleteCustomObjectInstancesByIdRequest request, RequestOptions requestOptions) { + return this.rawClient + .deleteCustomObjectInstancesById(request, requestOptions) + .body(); + } + + /** + * Fetch a Custom Object Instance by id. + */ + public Optional getCustomObjectInstancesById(GetCustomObjectInstancesByIdRequest request) { + return this.rawClient.getCustomObjectInstancesById(request).body(); + } + + /** + * Fetch a Custom Object Instance by id. + */ + public Optional getCustomObjectInstancesById( + GetCustomObjectInstancesByIdRequest request, RequestOptions requestOptions) { + return this.rawClient + .getCustomObjectInstancesById(request, requestOptions) + .body(); + } + + /** + * Delete a single Custom Object instance using the Intercom defined id. + */ + public CustomObjectInstanceDeleted deleteCustomObjectInstancesByExternalId( + DeleteCustomObjectInstancesByExternalIdRequest request) { + return this.rawClient.deleteCustomObjectInstancesByExternalId(request).body(); + } + + /** + * Delete a single Custom Object instance using the Intercom defined id. + */ + public CustomObjectInstanceDeleted deleteCustomObjectInstancesByExternalId( + DeleteCustomObjectInstancesByExternalIdRequest request, RequestOptions requestOptions) { + return this.rawClient + .deleteCustomObjectInstancesByExternalId(request, requestOptions) + .body(); + } +} diff --git a/src/main/java/com/intercom/api/resources/customobjectinstances/RawCustomObjectInstancesClient.java b/src/main/java/com/intercom/api/resources/customobjectinstances/RawCustomObjectInstancesClient.java new file mode 100644 index 0000000..e7bef5e --- /dev/null +++ b/src/main/java/com/intercom/api/resources/customobjectinstances/RawCustomObjectInstancesClient.java @@ -0,0 +1,349 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.customobjectinstances; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.QueryStringMapper; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.errors.NotFoundError; +import com.intercom.api.errors.UnauthorizedError; +import com.intercom.api.resources.customobjectinstances.requests.CreateOrUpdateCustomObjectInstanceRequest; +import com.intercom.api.resources.customobjectinstances.requests.DeleteCustomObjectInstancesByExternalIdRequest; +import com.intercom.api.resources.customobjectinstances.requests.DeleteCustomObjectInstancesByIdRequest; +import com.intercom.api.resources.customobjectinstances.requests.GetCustomObjectInstancesByExternalIdRequest; +import com.intercom.api.resources.customobjectinstances.requests.GetCustomObjectInstancesByIdRequest; +import com.intercom.api.resources.customobjectinstances.types.CustomObjectInstance; +import com.intercom.api.types.CustomObjectInstanceDeleted; +import com.intercom.api.types.Error; +import java.io.IOException; +import java.util.Optional; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawCustomObjectInstancesClient { + protected final ClientOptions clientOptions; + + public RawCustomObjectInstancesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Fetch a Custom Object Instance by external_id. + */ + public IntercomHttpResponse> getCustomObjectInstancesByExternalId( + GetCustomObjectInstancesByExternalIdRequest request) { + return getCustomObjectInstancesByExternalId(request, null); + } + + /** + * Fetch a Custom Object Instance by external_id. + */ + public IntercomHttpResponse> getCustomObjectInstancesByExternalId( + GetCustomObjectInstancesByExternalIdRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("custom_object_instances") + .addPathSegment(request.getCustomObjectTypeIdentifier()); + QueryStringMapper.addQueryParameter(httpUrl, "external_id", request.getExternalId(), false); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * Create or update a custom object instance + */ + public IntercomHttpResponse> createCustomObjectInstances( + CreateOrUpdateCustomObjectInstanceRequest request) { + return createCustomObjectInstances(request, null); + } + + /** + * Create or update a custom object instance + */ + public IntercomHttpResponse> createCustomObjectInstances( + CreateOrUpdateCustomObjectInstanceRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("custom_object_instances") + .addPathSegment(request.getCustomObjectTypeIdentifier()) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * Delete a single Custom Object instance by external_id. + */ + public IntercomHttpResponse deleteCustomObjectInstancesById( + DeleteCustomObjectInstancesByIdRequest request) { + return deleteCustomObjectInstancesById(request, null); + } + + /** + * Delete a single Custom Object instance by external_id. + */ + public IntercomHttpResponse deleteCustomObjectInstancesById( + DeleteCustomObjectInstancesByIdRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("custom_object_instances") + .addPathSegment(request.getCustomObjectTypeIdentifier()); + QueryStringMapper.addQueryParameter(httpUrl, "external_id", request.getExternalId(), false); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CustomObjectInstanceDeleted.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * Fetch a Custom Object Instance by id. + */ + public IntercomHttpResponse> getCustomObjectInstancesById( + GetCustomObjectInstancesByIdRequest request) { + return getCustomObjectInstancesById(request, null); + } + + /** + * Fetch a Custom Object Instance by id. + */ + public IntercomHttpResponse> getCustomObjectInstancesById( + GetCustomObjectInstancesByIdRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("custom_object_instances") + .addPathSegment(request.getCustomObjectTypeIdentifier()) + .addPathSegment(request.getCustomObjectInstanceId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * Delete a single Custom Object instance using the Intercom defined id. + */ + public IntercomHttpResponse deleteCustomObjectInstancesByExternalId( + DeleteCustomObjectInstancesByExternalIdRequest request) { + return deleteCustomObjectInstancesByExternalId(request, null); + } + + /** + * Delete a single Custom Object instance using the Intercom defined id. + */ + public IntercomHttpResponse deleteCustomObjectInstancesByExternalId( + DeleteCustomObjectInstancesByExternalIdRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("custom_object_instances") + .addPathSegment(request.getCustomObjectTypeIdentifier()) + .addPathSegment(request.getCustomObjectInstanceId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CustomObjectInstanceDeleted.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/customobjectinstances/requests/CreateOrUpdateCustomObjectInstanceRequest.java b/src/main/java/com/intercom/api/resources/customobjectinstances/requests/CreateOrUpdateCustomObjectInstanceRequest.java new file mode 100644 index 0000000..bc825e4 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/customobjectinstances/requests/CreateOrUpdateCustomObjectInstanceRequest.java @@ -0,0 +1,301 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.customobjectinstances.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CreateOrUpdateCustomObjectInstanceRequest.Builder.class) +public final class CreateOrUpdateCustomObjectInstanceRequest { + private final String customObjectTypeIdentifier; + + private final Optional externalId; + + private final Optional externalCreatedAt; + + private final Optional externalUpdatedAt; + + private final Optional>> customAttributes; + + private final Map additionalProperties; + + private CreateOrUpdateCustomObjectInstanceRequest( + String customObjectTypeIdentifier, + Optional externalId, + Optional externalCreatedAt, + Optional externalUpdatedAt, + Optional>> customAttributes, + Map additionalProperties) { + this.customObjectTypeIdentifier = customObjectTypeIdentifier; + this.externalId = externalId; + this.externalCreatedAt = externalCreatedAt; + this.externalUpdatedAt = externalUpdatedAt; + this.customAttributes = customAttributes; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier of the custom object type that defines the structure of the custom object instance. + */ + @JsonProperty("custom_object_type_identifier") + public String getCustomObjectTypeIdentifier() { + return customObjectTypeIdentifier; + } + + /** + * @return A unique identifier for the Custom Object instance in the external system it originated from. + */ + @JsonProperty("external_id") + public Optional getExternalId() { + return externalId; + } + + /** + * @return The time when the Custom Object instance was created in the external system it originated from. + */ + @JsonProperty("external_created_at") + public Optional getExternalCreatedAt() { + return externalCreatedAt; + } + + /** + * @return The time when the Custom Object instance was last updated in the external system it originated from. + */ + @JsonProperty("external_updated_at") + public Optional getExternalUpdatedAt() { + return externalUpdatedAt; + } + + /** + * @return The custom attributes which are set for the Custom Object instance. + */ + @JsonProperty("custom_attributes") + public Optional>> getCustomAttributes() { + return customAttributes; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreateOrUpdateCustomObjectInstanceRequest + && equalTo((CreateOrUpdateCustomObjectInstanceRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreateOrUpdateCustomObjectInstanceRequest other) { + return customObjectTypeIdentifier.equals(other.customObjectTypeIdentifier) + && externalId.equals(other.externalId) + && externalCreatedAt.equals(other.externalCreatedAt) + && externalUpdatedAt.equals(other.externalUpdatedAt) + && customAttributes.equals(other.customAttributes); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.customObjectTypeIdentifier, + this.externalId, + this.externalCreatedAt, + this.externalUpdatedAt, + this.customAttributes); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static CustomObjectTypeIdentifierStage builder() { + return new Builder(); + } + + public interface CustomObjectTypeIdentifierStage { + /** + * The unique identifier of the custom object type that defines the structure of the custom object instance. + */ + _FinalStage customObjectTypeIdentifier(@NotNull String customObjectTypeIdentifier); + + Builder from(CreateOrUpdateCustomObjectInstanceRequest other); + } + + public interface _FinalStage { + CreateOrUpdateCustomObjectInstanceRequest build(); + + /** + *

    A unique identifier for the Custom Object instance in the external system it originated from.

    + */ + _FinalStage externalId(Optional externalId); + + _FinalStage externalId(String externalId); + + /** + *

    The time when the Custom Object instance was created in the external system it originated from.

    + */ + _FinalStage externalCreatedAt(Optional externalCreatedAt); + + _FinalStage externalCreatedAt(Integer externalCreatedAt); + + /** + *

    The time when the Custom Object instance was last updated in the external system it originated from.

    + */ + _FinalStage externalUpdatedAt(Optional externalUpdatedAt); + + _FinalStage externalUpdatedAt(Integer externalUpdatedAt); + + /** + *

    The custom attributes which are set for the Custom Object instance.

    + */ + _FinalStage customAttributes(Optional>> customAttributes); + + _FinalStage customAttributes(Map> customAttributes); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements CustomObjectTypeIdentifierStage, _FinalStage { + private String customObjectTypeIdentifier; + + private Optional>> customAttributes = Optional.empty(); + + private Optional externalUpdatedAt = Optional.empty(); + + private Optional externalCreatedAt = Optional.empty(); + + private Optional externalId = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CreateOrUpdateCustomObjectInstanceRequest other) { + customObjectTypeIdentifier(other.getCustomObjectTypeIdentifier()); + externalId(other.getExternalId()); + externalCreatedAt(other.getExternalCreatedAt()); + externalUpdatedAt(other.getExternalUpdatedAt()); + customAttributes(other.getCustomAttributes()); + return this; + } + + /** + * The unique identifier of the custom object type that defines the structure of the custom object instance.

    The unique identifier of the custom object type that defines the structure of the custom object instance.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("custom_object_type_identifier") + public _FinalStage customObjectTypeIdentifier(@NotNull String customObjectTypeIdentifier) { + this.customObjectTypeIdentifier = + Objects.requireNonNull(customObjectTypeIdentifier, "customObjectTypeIdentifier must not be null"); + return this; + } + + /** + *

    The custom attributes which are set for the Custom Object instance.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage customAttributes(Map> customAttributes) { + this.customAttributes = Optional.ofNullable(customAttributes); + return this; + } + + /** + *

    The custom attributes which are set for the Custom Object instance.

    + */ + @java.lang.Override + @JsonSetter(value = "custom_attributes", nulls = Nulls.SKIP) + public _FinalStage customAttributes(Optional>> customAttributes) { + this.customAttributes = customAttributes; + return this; + } + + /** + *

    The time when the Custom Object instance was last updated in the external system it originated from.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage externalUpdatedAt(Integer externalUpdatedAt) { + this.externalUpdatedAt = Optional.ofNullable(externalUpdatedAt); + return this; + } + + /** + *

    The time when the Custom Object instance was last updated in the external system it originated from.

    + */ + @java.lang.Override + @JsonSetter(value = "external_updated_at", nulls = Nulls.SKIP) + public _FinalStage externalUpdatedAt(Optional externalUpdatedAt) { + this.externalUpdatedAt = externalUpdatedAt; + return this; + } + + /** + *

    The time when the Custom Object instance was created in the external system it originated from.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage externalCreatedAt(Integer externalCreatedAt) { + this.externalCreatedAt = Optional.ofNullable(externalCreatedAt); + return this; + } + + /** + *

    The time when the Custom Object instance was created in the external system it originated from.

    + */ + @java.lang.Override + @JsonSetter(value = "external_created_at", nulls = Nulls.SKIP) + public _FinalStage externalCreatedAt(Optional externalCreatedAt) { + this.externalCreatedAt = externalCreatedAt; + return this; + } + + /** + *

    A unique identifier for the Custom Object instance in the external system it originated from.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage externalId(String externalId) { + this.externalId = Optional.ofNullable(externalId); + return this; + } + + /** + *

    A unique identifier for the Custom Object instance in the external system it originated from.

    + */ + @java.lang.Override + @JsonSetter(value = "external_id", nulls = Nulls.SKIP) + public _FinalStage externalId(Optional externalId) { + this.externalId = externalId; + return this; + } + + @java.lang.Override + public CreateOrUpdateCustomObjectInstanceRequest build() { + return new CreateOrUpdateCustomObjectInstanceRequest( + customObjectTypeIdentifier, + externalId, + externalCreatedAt, + externalUpdatedAt, + customAttributes, + additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/customobjectinstances/requests/DeleteCustomObjectInstancesByExternalIdRequest.java b/src/main/java/com/intercom/api/resources/customobjectinstances/requests/DeleteCustomObjectInstancesByExternalIdRequest.java new file mode 100644 index 0000000..3397097 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/customobjectinstances/requests/DeleteCustomObjectInstancesByExternalIdRequest.java @@ -0,0 +1,153 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.customobjectinstances.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = DeleteCustomObjectInstancesByExternalIdRequest.Builder.class) +public final class DeleteCustomObjectInstancesByExternalIdRequest { + private final String customObjectTypeIdentifier; + + private final String customObjectInstanceId; + + private final Map additionalProperties; + + private DeleteCustomObjectInstancesByExternalIdRequest( + String customObjectTypeIdentifier, + String customObjectInstanceId, + Map additionalProperties) { + this.customObjectTypeIdentifier = customObjectTypeIdentifier; + this.customObjectInstanceId = customObjectInstanceId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier of the custom object type that defines the structure of the custom object instance. + */ + @JsonProperty("custom_object_type_identifier") + public String getCustomObjectTypeIdentifier() { + return customObjectTypeIdentifier; + } + + /** + * @return The Intercom defined id of the custom object instance + */ + @JsonProperty("custom_object_instance_id") + public String getCustomObjectInstanceId() { + return customObjectInstanceId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeleteCustomObjectInstancesByExternalIdRequest + && equalTo((DeleteCustomObjectInstancesByExternalIdRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeleteCustomObjectInstancesByExternalIdRequest other) { + return customObjectTypeIdentifier.equals(other.customObjectTypeIdentifier) + && customObjectInstanceId.equals(other.customObjectInstanceId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.customObjectTypeIdentifier, this.customObjectInstanceId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static CustomObjectTypeIdentifierStage builder() { + return new Builder(); + } + + public interface CustomObjectTypeIdentifierStage { + /** + * The unique identifier of the custom object type that defines the structure of the custom object instance. + */ + CustomObjectInstanceIdStage customObjectTypeIdentifier(@NotNull String customObjectTypeIdentifier); + + Builder from(DeleteCustomObjectInstancesByExternalIdRequest other); + } + + public interface CustomObjectInstanceIdStage { + /** + * The Intercom defined id of the custom object instance + */ + _FinalStage customObjectInstanceId(@NotNull String customObjectInstanceId); + } + + public interface _FinalStage { + DeleteCustomObjectInstancesByExternalIdRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements CustomObjectTypeIdentifierStage, CustomObjectInstanceIdStage, _FinalStage { + private String customObjectTypeIdentifier; + + private String customObjectInstanceId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DeleteCustomObjectInstancesByExternalIdRequest other) { + customObjectTypeIdentifier(other.getCustomObjectTypeIdentifier()); + customObjectInstanceId(other.getCustomObjectInstanceId()); + return this; + } + + /** + * The unique identifier of the custom object type that defines the structure of the custom object instance.

    The unique identifier of the custom object type that defines the structure of the custom object instance.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("custom_object_type_identifier") + public CustomObjectInstanceIdStage customObjectTypeIdentifier(@NotNull String customObjectTypeIdentifier) { + this.customObjectTypeIdentifier = + Objects.requireNonNull(customObjectTypeIdentifier, "customObjectTypeIdentifier must not be null"); + return this; + } + + /** + * The Intercom defined id of the custom object instance

    The Intercom defined id of the custom object instance

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("custom_object_instance_id") + public _FinalStage customObjectInstanceId(@NotNull String customObjectInstanceId) { + this.customObjectInstanceId = + Objects.requireNonNull(customObjectInstanceId, "customObjectInstanceId must not be null"); + return this; + } + + @java.lang.Override + public DeleteCustomObjectInstancesByExternalIdRequest build() { + return new DeleteCustomObjectInstancesByExternalIdRequest( + customObjectTypeIdentifier, customObjectInstanceId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/customobjectinstances/requests/DeleteCustomObjectInstancesByIdRequest.java b/src/main/java/com/intercom/api/resources/customobjectinstances/requests/DeleteCustomObjectInstancesByIdRequest.java new file mode 100644 index 0000000..3121343 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/customobjectinstances/requests/DeleteCustomObjectInstancesByIdRequest.java @@ -0,0 +1,139 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.customobjectinstances.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = DeleteCustomObjectInstancesByIdRequest.Builder.class) +public final class DeleteCustomObjectInstancesByIdRequest { + private final String customObjectTypeIdentifier; + + private final String externalId; + + private final Map additionalProperties; + + private DeleteCustomObjectInstancesByIdRequest( + String customObjectTypeIdentifier, String externalId, Map additionalProperties) { + this.customObjectTypeIdentifier = customObjectTypeIdentifier; + this.externalId = externalId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier of the custom object type that defines the structure of the custom object instance. + */ + @JsonProperty("custom_object_type_identifier") + public String getCustomObjectTypeIdentifier() { + return customObjectTypeIdentifier; + } + + @JsonProperty("external_id") + public String getExternalId() { + return externalId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeleteCustomObjectInstancesByIdRequest + && equalTo((DeleteCustomObjectInstancesByIdRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeleteCustomObjectInstancesByIdRequest other) { + return customObjectTypeIdentifier.equals(other.customObjectTypeIdentifier) + && externalId.equals(other.externalId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.customObjectTypeIdentifier, this.externalId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static CustomObjectTypeIdentifierStage builder() { + return new Builder(); + } + + public interface CustomObjectTypeIdentifierStage { + /** + * The unique identifier of the custom object type that defines the structure of the custom object instance. + */ + ExternalIdStage customObjectTypeIdentifier(@NotNull String customObjectTypeIdentifier); + + Builder from(DeleteCustomObjectInstancesByIdRequest other); + } + + public interface ExternalIdStage { + _FinalStage externalId(@NotNull String externalId); + } + + public interface _FinalStage { + DeleteCustomObjectInstancesByIdRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements CustomObjectTypeIdentifierStage, ExternalIdStage, _FinalStage { + private String customObjectTypeIdentifier; + + private String externalId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DeleteCustomObjectInstancesByIdRequest other) { + customObjectTypeIdentifier(other.getCustomObjectTypeIdentifier()); + externalId(other.getExternalId()); + return this; + } + + /** + * The unique identifier of the custom object type that defines the structure of the custom object instance.

    The unique identifier of the custom object type that defines the structure of the custom object instance.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("custom_object_type_identifier") + public ExternalIdStage customObjectTypeIdentifier(@NotNull String customObjectTypeIdentifier) { + this.customObjectTypeIdentifier = + Objects.requireNonNull(customObjectTypeIdentifier, "customObjectTypeIdentifier must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("external_id") + public _FinalStage externalId(@NotNull String externalId) { + this.externalId = Objects.requireNonNull(externalId, "externalId must not be null"); + return this; + } + + @java.lang.Override + public DeleteCustomObjectInstancesByIdRequest build() { + return new DeleteCustomObjectInstancesByIdRequest( + customObjectTypeIdentifier, externalId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/customobjectinstances/requests/GetCustomObjectInstancesByExternalIdRequest.java b/src/main/java/com/intercom/api/resources/customobjectinstances/requests/GetCustomObjectInstancesByExternalIdRequest.java new file mode 100644 index 0000000..91e22c4 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/customobjectinstances/requests/GetCustomObjectInstancesByExternalIdRequest.java @@ -0,0 +1,139 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.customobjectinstances.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = GetCustomObjectInstancesByExternalIdRequest.Builder.class) +public final class GetCustomObjectInstancesByExternalIdRequest { + private final String customObjectTypeIdentifier; + + private final String externalId; + + private final Map additionalProperties; + + private GetCustomObjectInstancesByExternalIdRequest( + String customObjectTypeIdentifier, String externalId, Map additionalProperties) { + this.customObjectTypeIdentifier = customObjectTypeIdentifier; + this.externalId = externalId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier of the custom object type that defines the structure of the custom object instance. + */ + @JsonProperty("custom_object_type_identifier") + public String getCustomObjectTypeIdentifier() { + return customObjectTypeIdentifier; + } + + @JsonProperty("external_id") + public String getExternalId() { + return externalId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GetCustomObjectInstancesByExternalIdRequest + && equalTo((GetCustomObjectInstancesByExternalIdRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GetCustomObjectInstancesByExternalIdRequest other) { + return customObjectTypeIdentifier.equals(other.customObjectTypeIdentifier) + && externalId.equals(other.externalId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.customObjectTypeIdentifier, this.externalId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static CustomObjectTypeIdentifierStage builder() { + return new Builder(); + } + + public interface CustomObjectTypeIdentifierStage { + /** + * The unique identifier of the custom object type that defines the structure of the custom object instance. + */ + ExternalIdStage customObjectTypeIdentifier(@NotNull String customObjectTypeIdentifier); + + Builder from(GetCustomObjectInstancesByExternalIdRequest other); + } + + public interface ExternalIdStage { + _FinalStage externalId(@NotNull String externalId); + } + + public interface _FinalStage { + GetCustomObjectInstancesByExternalIdRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements CustomObjectTypeIdentifierStage, ExternalIdStage, _FinalStage { + private String customObjectTypeIdentifier; + + private String externalId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(GetCustomObjectInstancesByExternalIdRequest other) { + customObjectTypeIdentifier(other.getCustomObjectTypeIdentifier()); + externalId(other.getExternalId()); + return this; + } + + /** + * The unique identifier of the custom object type that defines the structure of the custom object instance.

    The unique identifier of the custom object type that defines the structure of the custom object instance.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("custom_object_type_identifier") + public ExternalIdStage customObjectTypeIdentifier(@NotNull String customObjectTypeIdentifier) { + this.customObjectTypeIdentifier = + Objects.requireNonNull(customObjectTypeIdentifier, "customObjectTypeIdentifier must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("external_id") + public _FinalStage externalId(@NotNull String externalId) { + this.externalId = Objects.requireNonNull(externalId, "externalId must not be null"); + return this; + } + + @java.lang.Override + public GetCustomObjectInstancesByExternalIdRequest build() { + return new GetCustomObjectInstancesByExternalIdRequest( + customObjectTypeIdentifier, externalId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/customobjectinstances/requests/GetCustomObjectInstancesByIdRequest.java b/src/main/java/com/intercom/api/resources/customobjectinstances/requests/GetCustomObjectInstancesByIdRequest.java new file mode 100644 index 0000000..dba1356 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/customobjectinstances/requests/GetCustomObjectInstancesByIdRequest.java @@ -0,0 +1,153 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.customobjectinstances.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = GetCustomObjectInstancesByIdRequest.Builder.class) +public final class GetCustomObjectInstancesByIdRequest { + private final String customObjectTypeIdentifier; + + private final String customObjectInstanceId; + + private final Map additionalProperties; + + private GetCustomObjectInstancesByIdRequest( + String customObjectTypeIdentifier, + String customObjectInstanceId, + Map additionalProperties) { + this.customObjectTypeIdentifier = customObjectTypeIdentifier; + this.customObjectInstanceId = customObjectInstanceId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier of the custom object type that defines the structure of the custom object instance. + */ + @JsonProperty("custom_object_type_identifier") + public String getCustomObjectTypeIdentifier() { + return customObjectTypeIdentifier; + } + + /** + * @return The id or external_id of the custom object instance + */ + @JsonProperty("custom_object_instance_id") + public String getCustomObjectInstanceId() { + return customObjectInstanceId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GetCustomObjectInstancesByIdRequest + && equalTo((GetCustomObjectInstancesByIdRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GetCustomObjectInstancesByIdRequest other) { + return customObjectTypeIdentifier.equals(other.customObjectTypeIdentifier) + && customObjectInstanceId.equals(other.customObjectInstanceId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.customObjectTypeIdentifier, this.customObjectInstanceId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static CustomObjectTypeIdentifierStage builder() { + return new Builder(); + } + + public interface CustomObjectTypeIdentifierStage { + /** + * The unique identifier of the custom object type that defines the structure of the custom object instance. + */ + CustomObjectInstanceIdStage customObjectTypeIdentifier(@NotNull String customObjectTypeIdentifier); + + Builder from(GetCustomObjectInstancesByIdRequest other); + } + + public interface CustomObjectInstanceIdStage { + /** + * The id or external_id of the custom object instance + */ + _FinalStage customObjectInstanceId(@NotNull String customObjectInstanceId); + } + + public interface _FinalStage { + GetCustomObjectInstancesByIdRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements CustomObjectTypeIdentifierStage, CustomObjectInstanceIdStage, _FinalStage { + private String customObjectTypeIdentifier; + + private String customObjectInstanceId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(GetCustomObjectInstancesByIdRequest other) { + customObjectTypeIdentifier(other.getCustomObjectTypeIdentifier()); + customObjectInstanceId(other.getCustomObjectInstanceId()); + return this; + } + + /** + * The unique identifier of the custom object type that defines the structure of the custom object instance.

    The unique identifier of the custom object type that defines the structure of the custom object instance.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("custom_object_type_identifier") + public CustomObjectInstanceIdStage customObjectTypeIdentifier(@NotNull String customObjectTypeIdentifier) { + this.customObjectTypeIdentifier = + Objects.requireNonNull(customObjectTypeIdentifier, "customObjectTypeIdentifier must not be null"); + return this; + } + + /** + * The id or external_id of the custom object instance

    The id or external_id of the custom object instance

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("custom_object_instance_id") + public _FinalStage customObjectInstanceId(@NotNull String customObjectInstanceId) { + this.customObjectInstanceId = + Objects.requireNonNull(customObjectInstanceId, "customObjectInstanceId must not be null"); + return this; + } + + @java.lang.Override + public GetCustomObjectInstancesByIdRequest build() { + return new GetCustomObjectInstancesByIdRequest( + customObjectTypeIdentifier, customObjectInstanceId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/customobjectinstances/types/CustomObjectInstance.java b/src/main/java/com/intercom/api/resources/customobjectinstances/types/CustomObjectInstance.java new file mode 100644 index 0000000..099b9ed --- /dev/null +++ b/src/main/java/com/intercom/api/resources/customobjectinstances/types/CustomObjectInstance.java @@ -0,0 +1,330 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.customobjectinstances.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CustomObjectInstance.Builder.class) +public final class CustomObjectInstance { + private final Optional id; + + private final Optional externalId; + + private final Optional externalCreatedAt; + + private final Optional externalUpdatedAt; + + private final Optional createdAt; + + private final Optional updatedAt; + + private final Optional type; + + private final Optional> customAttributes; + + private final Map additionalProperties; + + private CustomObjectInstance( + Optional id, + Optional externalId, + Optional externalCreatedAt, + Optional externalUpdatedAt, + Optional createdAt, + Optional updatedAt, + Optional type, + Optional> customAttributes, + Map additionalProperties) { + this.id = id; + this.externalId = externalId; + this.externalCreatedAt = externalCreatedAt; + this.externalUpdatedAt = externalUpdatedAt; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.type = type; + this.customAttributes = customAttributes; + this.additionalProperties = additionalProperties; + } + + /** + * @return The Intercom defined id representing the custom object instance. + */ + @JsonProperty("id") + public Optional getId() { + return id; + } + + /** + * @return The id you have defined for the custom object instance. + */ + @JsonProperty("external_id") + public Optional getExternalId() { + return externalId; + } + + /** + * @return The time when the Custom Object instance was created in the external system it originated from. + */ + @JsonProperty("external_created_at") + public Optional getExternalCreatedAt() { + return externalCreatedAt; + } + + /** + * @return The time when the Custom Object instance was last updated in the external system it originated from. + */ + @JsonProperty("external_updated_at") + public Optional getExternalUpdatedAt() { + return externalUpdatedAt; + } + + /** + * @return The time the attribute was created as a UTC Unix timestamp + */ + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + /** + * @return The time the attribute was last updated as a UTC Unix timestamp + */ + @JsonProperty("updated_at") + public Optional getUpdatedAt() { + return updatedAt; + } + + /** + * @return The identifier of the custom object type that defines the structure of the custom object instance. + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return The custom attributes you have set on the custom object instance. + */ + @JsonProperty("custom_attributes") + public Optional> getCustomAttributes() { + return customAttributes; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CustomObjectInstance && equalTo((CustomObjectInstance) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CustomObjectInstance other) { + return id.equals(other.id) + && externalId.equals(other.externalId) + && externalCreatedAt.equals(other.externalCreatedAt) + && externalUpdatedAt.equals(other.externalUpdatedAt) + && createdAt.equals(other.createdAt) + && updatedAt.equals(other.updatedAt) + && type.equals(other.type) + && customAttributes.equals(other.customAttributes); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.id, + this.externalId, + this.externalCreatedAt, + this.externalUpdatedAt, + this.createdAt, + this.updatedAt, + this.type, + this.customAttributes); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional id = Optional.empty(); + + private Optional externalId = Optional.empty(); + + private Optional externalCreatedAt = Optional.empty(); + + private Optional externalUpdatedAt = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + private Optional updatedAt = Optional.empty(); + + private Optional type = Optional.empty(); + + private Optional> customAttributes = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(CustomObjectInstance other) { + id(other.getId()); + externalId(other.getExternalId()); + externalCreatedAt(other.getExternalCreatedAt()); + externalUpdatedAt(other.getExternalUpdatedAt()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + type(other.getType()); + customAttributes(other.getCustomAttributes()); + return this; + } + + /** + *

    The Intercom defined id representing the custom object instance.

    + */ + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.ofNullable(id); + return this; + } + + /** + *

    The id you have defined for the custom object instance.

    + */ + @JsonSetter(value = "external_id", nulls = Nulls.SKIP) + public Builder externalId(Optional externalId) { + this.externalId = externalId; + return this; + } + + public Builder externalId(String externalId) { + this.externalId = Optional.ofNullable(externalId); + return this; + } + + /** + *

    The time when the Custom Object instance was created in the external system it originated from.

    + */ + @JsonSetter(value = "external_created_at", nulls = Nulls.SKIP) + public Builder externalCreatedAt(Optional externalCreatedAt) { + this.externalCreatedAt = externalCreatedAt; + return this; + } + + public Builder externalCreatedAt(Integer externalCreatedAt) { + this.externalCreatedAt = Optional.ofNullable(externalCreatedAt); + return this; + } + + /** + *

    The time when the Custom Object instance was last updated in the external system it originated from.

    + */ + @JsonSetter(value = "external_updated_at", nulls = Nulls.SKIP) + public Builder externalUpdatedAt(Optional externalUpdatedAt) { + this.externalUpdatedAt = externalUpdatedAt; + return this; + } + + public Builder externalUpdatedAt(Integer externalUpdatedAt) { + this.externalUpdatedAt = Optional.ofNullable(externalUpdatedAt); + return this; + } + + /** + *

    The time the attribute was created as a UTC Unix timestamp

    + */ + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public Builder createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + public Builder createdAt(Integer createdAt) { + this.createdAt = Optional.ofNullable(createdAt); + return this; + } + + /** + *

    The time the attribute was last updated as a UTC Unix timestamp

    + */ + @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) + public Builder updatedAt(Optional updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + public Builder updatedAt(Integer updatedAt) { + this.updatedAt = Optional.ofNullable(updatedAt); + return this; + } + + /** + *

    The identifier of the custom object type that defines the structure of the custom object instance.

    + */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + /** + *

    The custom attributes you have set on the custom object instance.

    + */ + @JsonSetter(value = "custom_attributes", nulls = Nulls.SKIP) + public Builder customAttributes(Optional> customAttributes) { + this.customAttributes = customAttributes; + return this; + } + + public Builder customAttributes(Map customAttributes) { + this.customAttributes = Optional.ofNullable(customAttributes); + return this; + } + + public CustomObjectInstance build() { + return new CustomObjectInstance( + id, + externalId, + externalCreatedAt, + externalUpdatedAt, + createdAt, + updatedAt, + type, + customAttributes, + additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/dataattributes/AsyncDataAttributesClient.java b/src/main/java/com/intercom/api/resources/dataattributes/AsyncDataAttributesClient.java index 175bcf9..ac0f656 100644 --- a/src/main/java/com/intercom/api/resources/dataattributes/AsyncDataAttributesClient.java +++ b/src/main/java/com/intercom/api/resources/dataattributes/AsyncDataAttributesClient.java @@ -5,10 +5,10 @@ import com.intercom.api.core.ClientOptions; import com.intercom.api.core.RequestOptions; -import com.intercom.api.resources.dataattributes.requests.CreateDataAttributeRequest; import com.intercom.api.resources.dataattributes.requests.ListDataAttributesRequest; import com.intercom.api.resources.dataattributes.requests.UpdateDataAttributeRequest; import com.intercom.api.resources.dataattributes.types.DataAttribute; +import com.intercom.api.types.CreateDataAttributeRequest; import com.intercom.api.types.DataAttributeList; import java.util.concurrent.CompletableFuture; diff --git a/src/main/java/com/intercom/api/resources/dataattributes/AsyncRawDataAttributesClient.java b/src/main/java/com/intercom/api/resources/dataattributes/AsyncRawDataAttributesClient.java index aa9b3e6..7afde0e 100644 --- a/src/main/java/com/intercom/api/resources/dataattributes/AsyncRawDataAttributesClient.java +++ b/src/main/java/com/intercom/api/resources/dataattributes/AsyncRawDataAttributesClient.java @@ -16,10 +16,10 @@ import com.intercom.api.errors.NotFoundError; import com.intercom.api.errors.UnauthorizedError; import com.intercom.api.errors.UnprocessableEntityError; -import com.intercom.api.resources.dataattributes.requests.CreateDataAttributeRequest; import com.intercom.api.resources.dataattributes.requests.ListDataAttributesRequest; import com.intercom.api.resources.dataattributes.requests.UpdateDataAttributeRequest; import com.intercom.api.resources.dataattributes.types.DataAttribute; +import com.intercom.api.types.CreateDataAttributeRequest; import com.intercom.api.types.DataAttributeList; import com.intercom.api.types.Error; import java.io.IOException; @@ -230,12 +230,12 @@ public CompletableFuture> update( HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("data_attributes") - .addPathSegment(request.getDataAttributeId()) + .addPathSegment(Integer.toString(request.getDataAttributeId())) .build(); RequestBody body; try { body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request.getBody()), MediaTypes.APPLICATION_JSON); } catch (JsonProcessingException e) { throw new IntercomException("Failed to serialize request", e); } diff --git a/src/main/java/com/intercom/api/resources/dataattributes/DataAttributesClient.java b/src/main/java/com/intercom/api/resources/dataattributes/DataAttributesClient.java index 22e4648..b672ceb 100644 --- a/src/main/java/com/intercom/api/resources/dataattributes/DataAttributesClient.java +++ b/src/main/java/com/intercom/api/resources/dataattributes/DataAttributesClient.java @@ -5,10 +5,10 @@ import com.intercom.api.core.ClientOptions; import com.intercom.api.core.RequestOptions; -import com.intercom.api.resources.dataattributes.requests.CreateDataAttributeRequest; import com.intercom.api.resources.dataattributes.requests.ListDataAttributesRequest; import com.intercom.api.resources.dataattributes.requests.UpdateDataAttributeRequest; import com.intercom.api.resources.dataattributes.types.DataAttribute; +import com.intercom.api.types.CreateDataAttributeRequest; import com.intercom.api.types.DataAttributeList; public class DataAttributesClient { diff --git a/src/main/java/com/intercom/api/resources/dataattributes/RawDataAttributesClient.java b/src/main/java/com/intercom/api/resources/dataattributes/RawDataAttributesClient.java index 3116f21..dbd756e 100644 --- a/src/main/java/com/intercom/api/resources/dataattributes/RawDataAttributesClient.java +++ b/src/main/java/com/intercom/api/resources/dataattributes/RawDataAttributesClient.java @@ -16,10 +16,10 @@ import com.intercom.api.errors.NotFoundError; import com.intercom.api.errors.UnauthorizedError; import com.intercom.api.errors.UnprocessableEntityError; -import com.intercom.api.resources.dataattributes.requests.CreateDataAttributeRequest; import com.intercom.api.resources.dataattributes.requests.ListDataAttributesRequest; import com.intercom.api.resources.dataattributes.requests.UpdateDataAttributeRequest; import com.intercom.api.resources.dataattributes.types.DataAttribute; +import com.intercom.api.types.CreateDataAttributeRequest; import com.intercom.api.types.DataAttributeList; import com.intercom.api.types.Error; import java.io.IOException; @@ -193,12 +193,12 @@ public IntercomHttpResponse update( HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("data_attributes") - .addPathSegment(request.getDataAttributeId()) + .addPathSegment(Integer.toString(request.getDataAttributeId())) .build(); RequestBody body; try { body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request.getBody()), MediaTypes.APPLICATION_JSON); } catch (JsonProcessingException e) { throw new IntercomException("Failed to serialize request", e); } diff --git a/src/main/java/com/intercom/api/resources/dataattributes/requests/CreateDataAttributeRequest.java b/src/main/java/com/intercom/api/resources/dataattributes/requests/CreateDataAttributeRequest.java deleted file mode 100644 index fb47c39..0000000 --- a/src/main/java/com/intercom/api/resources/dataattributes/requests/CreateDataAttributeRequest.java +++ /dev/null @@ -1,508 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.intercom.api.resources.dataattributes.requests; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.intercom.api.core.ObjectMappers; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import org.jetbrains.annotations.NotNull; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = CreateDataAttributeRequest.Builder.class) -public final class CreateDataAttributeRequest { - private final String name; - - private final Model model; - - private final DataType dataType; - - private final Optional description; - - private final Optional> options; - - private final Optional messengerWritable; - - private final Map additionalProperties; - - private CreateDataAttributeRequest( - String name, - Model model, - DataType dataType, - Optional description, - Optional> options, - Optional messengerWritable, - Map additionalProperties) { - this.name = name; - this.model = model; - this.dataType = dataType; - this.description = description; - this.options = options; - this.messengerWritable = messengerWritable; - this.additionalProperties = additionalProperties; - } - - /** - * @return The name of the data attribute. - */ - @JsonProperty("name") - public String getName() { - return name; - } - - /** - * @return The model that the data attribute belongs to. - */ - @JsonProperty("model") - public Model getModel() { - return model; - } - - /** - * @return The type of data stored for this attribute. - */ - @JsonProperty("data_type") - public DataType getDataType() { - return dataType; - } - - /** - * @return The readable description you see in the UI for the attribute. - */ - @JsonProperty("description") - public Optional getDescription() { - return description; - } - - /** - * @return To create list attributes. Provide a set of hashes with value as the key of the options you want to make. data_type must be string. - */ - @JsonProperty("options") - public Optional> getOptions() { - return options; - } - - /** - * @return Can this attribute be updated by the Messenger - */ - @JsonProperty("messenger_writable") - public Optional getMessengerWritable() { - return messengerWritable; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof CreateDataAttributeRequest && equalTo((CreateDataAttributeRequest) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(CreateDataAttributeRequest other) { - return name.equals(other.name) - && model.equals(other.model) - && dataType.equals(other.dataType) - && description.equals(other.description) - && options.equals(other.options) - && messengerWritable.equals(other.messengerWritable); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.name, this.model, this.dataType, this.description, this.options, this.messengerWritable); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static NameStage builder() { - return new Builder(); - } - - public interface NameStage { - /** - * The name of the data attribute. - */ - ModelStage name(@NotNull String name); - - Builder from(CreateDataAttributeRequest other); - } - - public interface ModelStage { - /** - * The model that the data attribute belongs to. - */ - DataTypeStage model(@NotNull Model model); - } - - public interface DataTypeStage { - /** - * The type of data stored for this attribute. - */ - _FinalStage dataType(@NotNull DataType dataType); - } - - public interface _FinalStage { - CreateDataAttributeRequest build(); - - /** - *

    The readable description you see in the UI for the attribute.

    - */ - _FinalStage description(Optional description); - - _FinalStage description(String description); - - /** - *

    To create list attributes. Provide a set of hashes with value as the key of the options you want to make. data_type must be string.

    - */ - _FinalStage options(Optional> options); - - _FinalStage options(List options); - - /** - *

    Can this attribute be updated by the Messenger

    - */ - _FinalStage messengerWritable(Optional messengerWritable); - - _FinalStage messengerWritable(Boolean messengerWritable); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements NameStage, ModelStage, DataTypeStage, _FinalStage { - private String name; - - private Model model; - - private DataType dataType; - - private Optional messengerWritable = Optional.empty(); - - private Optional> options = Optional.empty(); - - private Optional description = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(CreateDataAttributeRequest other) { - name(other.getName()); - model(other.getModel()); - dataType(other.getDataType()); - description(other.getDescription()); - options(other.getOptions()); - messengerWritable(other.getMessengerWritable()); - return this; - } - - /** - * The name of the data attribute.

    The name of the data attribute.

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("name") - public ModelStage name(@NotNull String name) { - this.name = Objects.requireNonNull(name, "name must not be null"); - return this; - } - - /** - * The model that the data attribute belongs to.

    The model that the data attribute belongs to.

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("model") - public DataTypeStage model(@NotNull Model model) { - this.model = Objects.requireNonNull(model, "model must not be null"); - return this; - } - - /** - * The type of data stored for this attribute.

    The type of data stored for this attribute.

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("data_type") - public _FinalStage dataType(@NotNull DataType dataType) { - this.dataType = Objects.requireNonNull(dataType, "dataType must not be null"); - return this; - } - - /** - *

    Can this attribute be updated by the Messenger

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage messengerWritable(Boolean messengerWritable) { - this.messengerWritable = Optional.ofNullable(messengerWritable); - return this; - } - - /** - *

    Can this attribute be updated by the Messenger

    - */ - @java.lang.Override - @JsonSetter(value = "messenger_writable", nulls = Nulls.SKIP) - public _FinalStage messengerWritable(Optional messengerWritable) { - this.messengerWritable = messengerWritable; - return this; - } - - /** - *

    To create list attributes. Provide a set of hashes with value as the key of the options you want to make. data_type must be string.

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage options(List options) { - this.options = Optional.ofNullable(options); - return this; - } - - /** - *

    To create list attributes. Provide a set of hashes with value as the key of the options you want to make. data_type must be string.

    - */ - @java.lang.Override - @JsonSetter(value = "options", nulls = Nulls.SKIP) - public _FinalStage options(Optional> options) { - this.options = options; - return this; - } - - /** - *

    The readable description you see in the UI for the attribute.

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage description(String description) { - this.description = Optional.ofNullable(description); - return this; - } - - /** - *

    The readable description you see in the UI for the attribute.

    - */ - @java.lang.Override - @JsonSetter(value = "description", nulls = Nulls.SKIP) - public _FinalStage description(Optional description) { - this.description = description; - return this; - } - - @java.lang.Override - public CreateDataAttributeRequest build() { - return new CreateDataAttributeRequest( - name, model, dataType, description, options, messengerWritable, additionalProperties); - } - } - - public static final class Model { - public static final Model CONTACT = new Model(Value.CONTACT, "contact"); - - public static final Model COMPANY = new Model(Value.COMPANY, "company"); - - private final Value value; - - private final String string; - - Model(Value value, String string) { - this.value = value; - this.string = string; - } - - public Value getEnumValue() { - return value; - } - - @java.lang.Override - @JsonValue - public String toString() { - return this.string; - } - - @java.lang.Override - public boolean equals(Object other) { - return (this == other) || (other instanceof Model && this.string.equals(((Model) other).string)); - } - - @java.lang.Override - public int hashCode() { - return this.string.hashCode(); - } - - public T visit(Visitor visitor) { - switch (value) { - case CONTACT: - return visitor.visitContact(); - case COMPANY: - return visitor.visitCompany(); - case UNKNOWN: - default: - return visitor.visitUnknown(string); - } - } - - @JsonCreator(mode = JsonCreator.Mode.DELEGATING) - public static Model valueOf(String value) { - switch (value) { - case "contact": - return CONTACT; - case "company": - return COMPANY; - default: - return new Model(Value.UNKNOWN, value); - } - } - - public enum Value { - CONTACT, - - COMPANY, - - UNKNOWN - } - - public interface Visitor { - T visitContact(); - - T visitCompany(); - - T visitUnknown(String unknownType); - } - } - - public static final class DataType { - public static final DataType STRING = new DataType(Value.STRING, "string"); - - public static final DataType FLOAT = new DataType(Value.FLOAT, "float"); - - public static final DataType INTEGER = new DataType(Value.INTEGER, "integer"); - - public static final DataType DATETIME = new DataType(Value.DATETIME, "datetime"); - - public static final DataType BOOLEAN = new DataType(Value.BOOLEAN, "boolean"); - - public static final DataType DATE = new DataType(Value.DATE, "date"); - - private final Value value; - - private final String string; - - DataType(Value value, String string) { - this.value = value; - this.string = string; - } - - public Value getEnumValue() { - return value; - } - - @java.lang.Override - @JsonValue - public String toString() { - return this.string; - } - - @java.lang.Override - public boolean equals(Object other) { - return (this == other) || (other instanceof DataType && this.string.equals(((DataType) other).string)); - } - - @java.lang.Override - public int hashCode() { - return this.string.hashCode(); - } - - public T visit(Visitor visitor) { - switch (value) { - case STRING: - return visitor.visitString(); - case FLOAT: - return visitor.visitFloat(); - case INTEGER: - return visitor.visitInteger(); - case DATETIME: - return visitor.visitDatetime(); - case BOOLEAN: - return visitor.visitBoolean(); - case DATE: - return visitor.visitDate(); - case UNKNOWN: - default: - return visitor.visitUnknown(string); - } - } - - @JsonCreator(mode = JsonCreator.Mode.DELEGATING) - public static DataType valueOf(String value) { - switch (value) { - case "string": - return STRING; - case "float": - return FLOAT; - case "integer": - return INTEGER; - case "datetime": - return DATETIME; - case "boolean": - return BOOLEAN; - case "date": - return DATE; - default: - return new DataType(Value.UNKNOWN, value); - } - } - - public enum Value { - STRING, - - INTEGER, - - FLOAT, - - BOOLEAN, - - DATETIME, - - DATE, - - UNKNOWN - } - - public interface Visitor { - T visitString(); - - T visitInteger(); - - T visitFloat(); - - T visitBoolean(); - - T visitDatetime(); - - T visitDate(); - - T visitUnknown(String unknownType); - } - } -} diff --git a/src/main/java/com/intercom/api/resources/dataattributes/requests/UpdateDataAttributeRequest.java b/src/main/java/com/intercom/api/resources/dataattributes/requests/UpdateDataAttributeRequest.java index 23e4d8f..25dc4b1 100644 --- a/src/main/java/com/intercom/api/resources/dataattributes/requests/UpdateDataAttributeRequest.java +++ b/src/main/java/com/intercom/api/resources/dataattributes/requests/UpdateDataAttributeRequest.java @@ -9,43 +9,27 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.intercom.api.core.ObjectMappers; +import com.intercom.api.types.UpdateDataAttributeRequestBody; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.Objects; -import java.util.Optional; import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = UpdateDataAttributeRequest.Builder.class) public final class UpdateDataAttributeRequest { - private final String dataAttributeId; + private final int dataAttributeId; - private final Optional archived; - - private final Optional description; - - private final Optional> options; - - private final Optional messengerWritable; + private final UpdateDataAttributeRequestBody body; private final Map additionalProperties; private UpdateDataAttributeRequest( - String dataAttributeId, - Optional archived, - Optional description, - Optional> options, - Optional messengerWritable, - Map additionalProperties) { + int dataAttributeId, UpdateDataAttributeRequestBody body, Map additionalProperties) { this.dataAttributeId = dataAttributeId; - this.archived = archived; - this.description = description; - this.options = options; - this.messengerWritable = messengerWritable; + this.body = body; this.additionalProperties = additionalProperties; } @@ -53,40 +37,13 @@ private UpdateDataAttributeRequest( * @return The data attribute id */ @JsonProperty("data_attribute_id") - public String getDataAttributeId() { + public int getDataAttributeId() { return dataAttributeId; } - /** - * @return Whether the attribute is to be archived or not. - */ - @JsonProperty("archived") - public Optional getArchived() { - return archived; - } - - /** - * @return The readable description you see in the UI for the attribute. - */ - @JsonProperty("description") - public Optional getDescription() { - return description; - } - - /** - * @return To create list attributes. Provide a set of hashes with value as the key of the options you want to make. data_type must be string. - */ - @JsonProperty("options") - public Optional> getOptions() { - return options; - } - - /** - * @return Can this attribute be updated by the Messenger - */ - @JsonProperty("messenger_writable") - public Optional getMessengerWritable() { - return messengerWritable; + @JsonProperty("body") + public UpdateDataAttributeRequestBody getBody() { + return body; } @java.lang.Override @@ -101,17 +58,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(UpdateDataAttributeRequest other) { - return dataAttributeId.equals(other.dataAttributeId) - && archived.equals(other.archived) - && description.equals(other.description) - && options.equals(other.options) - && messengerWritable.equals(other.messengerWritable); + return dataAttributeId == other.dataAttributeId && body.equals(other.body); } @java.lang.Override public int hashCode() { - return Objects.hash( - this.dataAttributeId, this.archived, this.description, this.options, this.messengerWritable); + return Objects.hash(this.dataAttributeId, this.body); } @java.lang.Override @@ -127,54 +79,24 @@ public interface DataAttributeIdStage { /** * The data attribute id */ - _FinalStage dataAttributeId(@NotNull String dataAttributeId); + BodyStage dataAttributeId(int dataAttributeId); Builder from(UpdateDataAttributeRequest other); } + public interface BodyStage { + _FinalStage body(@NotNull UpdateDataAttributeRequestBody body); + } + public interface _FinalStage { UpdateDataAttributeRequest build(); - - /** - *

    Whether the attribute is to be archived or not.

    - */ - _FinalStage archived(Optional archived); - - _FinalStage archived(Boolean archived); - - /** - *

    The readable description you see in the UI for the attribute.

    - */ - _FinalStage description(Optional description); - - _FinalStage description(String description); - - /** - *

    To create list attributes. Provide a set of hashes with value as the key of the options you want to make. data_type must be string.

    - */ - _FinalStage options(Optional> options); - - _FinalStage options(List options); - - /** - *

    Can this attribute be updated by the Messenger

    - */ - _FinalStage messengerWritable(Optional messengerWritable); - - _FinalStage messengerWritable(Boolean messengerWritable); } @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements DataAttributeIdStage, _FinalStage { - private String dataAttributeId; - - private Optional messengerWritable = Optional.empty(); - - private Optional> options = Optional.empty(); - - private Optional description = Optional.empty(); + public static final class Builder implements DataAttributeIdStage, BodyStage, _FinalStage { + private int dataAttributeId; - private Optional archived = Optional.empty(); + private UpdateDataAttributeRequestBody body; @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -184,10 +106,7 @@ private Builder() {} @java.lang.Override public Builder from(UpdateDataAttributeRequest other) { dataAttributeId(other.getDataAttributeId()); - archived(other.getArchived()); - description(other.getDescription()); - options(other.getOptions()); - messengerWritable(other.getMessengerWritable()); + body(other.getBody()); return this; } @@ -197,180 +116,21 @@ public Builder from(UpdateDataAttributeRequest other) { */ @java.lang.Override @JsonSetter("data_attribute_id") - public _FinalStage dataAttributeId(@NotNull String dataAttributeId) { - this.dataAttributeId = Objects.requireNonNull(dataAttributeId, "dataAttributeId must not be null"); - return this; - } - - /** - *

    Can this attribute be updated by the Messenger

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage messengerWritable(Boolean messengerWritable) { - this.messengerWritable = Optional.ofNullable(messengerWritable); - return this; - } - - /** - *

    Can this attribute be updated by the Messenger

    - */ - @java.lang.Override - @JsonSetter(value = "messenger_writable", nulls = Nulls.SKIP) - public _FinalStage messengerWritable(Optional messengerWritable) { - this.messengerWritable = messengerWritable; - return this; - } - - /** - *

    To create list attributes. Provide a set of hashes with value as the key of the options you want to make. data_type must be string.

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage options(List options) { - this.options = Optional.ofNullable(options); - return this; - } - - /** - *

    To create list attributes. Provide a set of hashes with value as the key of the options you want to make. data_type must be string.

    - */ - @java.lang.Override - @JsonSetter(value = "options", nulls = Nulls.SKIP) - public _FinalStage options(Optional> options) { - this.options = options; - return this; - } - - /** - *

    The readable description you see in the UI for the attribute.

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage description(String description) { - this.description = Optional.ofNullable(description); - return this; - } - - /** - *

    The readable description you see in the UI for the attribute.

    - */ - @java.lang.Override - @JsonSetter(value = "description", nulls = Nulls.SKIP) - public _FinalStage description(Optional description) { - this.description = description; + public BodyStage dataAttributeId(int dataAttributeId) { + this.dataAttributeId = dataAttributeId; return this; } - /** - *

    Whether the attribute is to be archived or not.

    - * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override - public _FinalStage archived(Boolean archived) { - this.archived = Optional.ofNullable(archived); - return this; - } - - /** - *

    Whether the attribute is to be archived or not.

    - */ - @java.lang.Override - @JsonSetter(value = "archived", nulls = Nulls.SKIP) - public _FinalStage archived(Optional archived) { - this.archived = archived; + @JsonSetter("body") + public _FinalStage body(@NotNull UpdateDataAttributeRequestBody body) { + this.body = Objects.requireNonNull(body, "body must not be null"); return this; } @java.lang.Override public UpdateDataAttributeRequest build() { - return new UpdateDataAttributeRequest( - dataAttributeId, archived, description, options, messengerWritable, additionalProperties); - } - } - - @JsonInclude(JsonInclude.Include.NON_ABSENT) - @JsonDeserialize(builder = OptionsItem.Builder.class) - public static final class OptionsItem { - private final String value; - - private final Map additionalProperties; - - private OptionsItem(String value, Map additionalProperties) { - this.value = value; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("value") - public String getValue() { - return value; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof OptionsItem && equalTo((OptionsItem) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(OptionsItem other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static ValueStage builder() { - return new Builder(); - } - - public interface ValueStage { - _FinalStage value(@NotNull String value); - - Builder from(OptionsItem other); - } - - public interface _FinalStage { - OptionsItem build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements ValueStage, _FinalStage { - private String value; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(OptionsItem other) { - value(other.getValue()); - return this; - } - - @java.lang.Override - @JsonSetter("value") - public _FinalStage value(@NotNull String value) { - this.value = Objects.requireNonNull(value, "value must not be null"); - return this; - } - - @java.lang.Override - public OptionsItem build() { - return new OptionsItem(value, additionalProperties); - } + return new UpdateDataAttributeRequest(dataAttributeId, body, additionalProperties); } } } diff --git a/src/main/java/com/intercom/api/resources/dataattributes/types/DataAttribute.java b/src/main/java/com/intercom/api/resources/dataattributes/types/DataAttribute.java index f8a11fe..9f7160d 100644 --- a/src/main/java/com/intercom/api/resources/dataattributes/types/DataAttribute.java +++ b/src/main/java/com/intercom/api/resources/dataattributes/types/DataAttribute.java @@ -34,7 +34,7 @@ public final class DataAttribute { private final String label; - private final String description; + private final Optional description; private final DataType dataType; @@ -64,7 +64,7 @@ private DataAttribute( String name, String fullName, String label, - String description, + Optional description, DataType dataType, Optional> options, Optional apiWritable, @@ -147,7 +147,7 @@ public String getLabel() { * @return Readable description of the attribute. */ @JsonProperty("description") - public String getDescription() { + public Optional getDescription() { return description; } @@ -311,14 +311,7 @@ public interface LabelStage { /** * Readable name of the attribute (i.e. name you see in the UI) */ - DescriptionStage label(@NotNull String label); - } - - public interface DescriptionStage { - /** - * Readable description of the attribute. - */ - DataTypeStage description(@NotNull String description); + DataTypeStage label(@NotNull String label); } public interface DataTypeStage { @@ -345,6 +338,13 @@ public interface _FinalStage { _FinalStage model(Model model); + /** + *

    Readable description of the attribute.

    + */ + _FinalStage description(Optional description); + + _FinalStage description(String description); + /** *

    List of predefined options for attribute value.

    */ @@ -410,16 +410,13 @@ public interface _FinalStage { } @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder - implements NameStage, FullNameStage, LabelStage, DescriptionStage, DataTypeStage, _FinalStage { + public static final class Builder implements NameStage, FullNameStage, LabelStage, DataTypeStage, _FinalStage { private String name; private String fullName; private String label; - private String description; - private DataType dataType; private Optional adminId = Optional.empty(); @@ -440,6 +437,8 @@ public static final class Builder private Optional> options = Optional.empty(); + private Optional description = Optional.empty(); + private Optional model = Optional.empty(); private Optional id = Optional.empty(); @@ -498,22 +497,11 @@ public LabelStage fullName(@NotNull String fullName) { */ @java.lang.Override @JsonSetter("label") - public DescriptionStage label(@NotNull String label) { + public DataTypeStage label(@NotNull String label) { this.label = Objects.requireNonNull(label, "label must not be null"); return this; } - /** - * Readable description of the attribute.

    Readable description of the attribute.

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("description") - public DataTypeStage description(@NotNull String description) { - this.description = Objects.requireNonNull(description, "description must not be null"); - return this; - } - /** * The data type of the attribute.

    The data type of the attribute.

    * @return Reference to {@code this} so that method calls can be chained together. @@ -705,6 +693,26 @@ public _FinalStage options(Optional> options) { return this; } + /** + *

    Readable description of the attribute.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage description(String description) { + this.description = Optional.ofNullable(description); + return this; + } + + /** + *

    Readable description of the attribute.

    + */ + @java.lang.Override + @JsonSetter(value = "description", nulls = Nulls.SKIP) + public _FinalStage description(Optional description) { + this.description = description; + return this; + } + /** *

    Value is contact for user/lead attributes and company for company attributes.

    * @return Reference to {@code this} so that method calls can be chained together. diff --git a/src/main/java/com/intercom/api/resources/dataexport/AsyncDataExportClient.java b/src/main/java/com/intercom/api/resources/dataexport/AsyncDataExportClient.java index a64e7a7..e5cde46 100644 --- a/src/main/java/com/intercom/api/resources/dataexport/AsyncDataExportClient.java +++ b/src/main/java/com/intercom/api/resources/dataexport/AsyncDataExportClient.java @@ -8,8 +8,11 @@ import com.intercom.api.resources.dataexport.requests.CancelDataExportRequest; import com.intercom.api.resources.dataexport.requests.CreateDataExportRequest; import com.intercom.api.resources.dataexport.requests.DownloadDataExportRequest; +import com.intercom.api.resources.dataexport.requests.DownloadReportingDataExportRequest; +import com.intercom.api.resources.dataexport.requests.ExportReportingDataRequest; import com.intercom.api.resources.dataexport.requests.FindDataExportRequest; import com.intercom.api.resources.dataexport.types.DataExport; +import com.intercom.api.resources.dataexport.types.DataExportExportReportingDataResponse; import java.util.concurrent.CompletableFuture; public class AsyncDataExportClient { @@ -29,6 +32,41 @@ public AsyncRawDataExportClient withRawResponse() { return this.rawClient; } + public CompletableFuture exportReportingData( + ExportReportingDataRequest request) { + return this.rawClient.exportReportingData(request).thenApply(response -> response.body()); + } + + public CompletableFuture exportReportingData( + ExportReportingDataRequest request, RequestOptions requestOptions) { + return this.rawClient.exportReportingData(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Download the data from a completed reporting data export job. + *
    + *

    Octet header required

    + *

    You will have to specify the header Accept: application/octet-stream when hitting this endpoint.

    + *
    + */ + public CompletableFuture downloadReportingDataExport(DownloadReportingDataExportRequest request) { + return this.rawClient.downloadReportingDataExport(request).thenApply(response -> response.body()); + } + + /** + * Download the data from a completed reporting data export job. + *
    + *

    Octet header required

    + *

    You will have to specify the header Accept: application/octet-stream when hitting this endpoint.

    + *
    + */ + public CompletableFuture downloadReportingDataExport( + DownloadReportingDataExportRequest request, RequestOptions requestOptions) { + return this.rawClient + .downloadReportingDataExport(request, requestOptions) + .thenApply(response -> response.body()); + } + /** * 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.

    diff --git a/src/main/java/com/intercom/api/resources/dataexport/AsyncRawDataExportClient.java b/src/main/java/com/intercom/api/resources/dataexport/AsyncRawDataExportClient.java index 7ce121e..1a0a6dc 100644 --- a/src/main/java/com/intercom/api/resources/dataexport/AsyncRawDataExportClient.java +++ b/src/main/java/com/intercom/api/resources/dataexport/AsyncRawDataExportClient.java @@ -10,12 +10,17 @@ import com.intercom.api.core.IntercomHttpResponse; import com.intercom.api.core.MediaTypes; import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.QueryStringMapper; import com.intercom.api.core.RequestOptions; +import com.intercom.api.errors.NotFoundError; import com.intercom.api.resources.dataexport.requests.CancelDataExportRequest; import com.intercom.api.resources.dataexport.requests.CreateDataExportRequest; import com.intercom.api.resources.dataexport.requests.DownloadDataExportRequest; +import com.intercom.api.resources.dataexport.requests.DownloadReportingDataExportRequest; +import com.intercom.api.resources.dataexport.requests.ExportReportingDataRequest; import com.intercom.api.resources.dataexport.requests.FindDataExportRequest; import com.intercom.api.resources.dataexport.types.DataExport; +import com.intercom.api.resources.dataexport.types.DataExportExportReportingDataResponse; import java.io.IOException; import java.util.concurrent.CompletableFuture; import okhttp3.Call; @@ -36,6 +41,147 @@ public AsyncRawDataExportClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; } + public CompletableFuture> exportReportingData( + ExportReportingDataRequest request) { + return exportReportingData(request, null); + } + + public CompletableFuture> exportReportingData( + ExportReportingDataRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("export/reporting_data") + .addPathSegment(request.getJobIdentifier()); + QueryStringMapper.addQueryParameter(httpUrl, "app_id", request.getAppId(), false); + QueryStringMapper.addQueryParameter(httpUrl, "client_id", request.getClientId(), false); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = + new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), DataExportExportReportingDataResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 404) { + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Download the data from a completed reporting data export job. + *
    + *

    Octet header required

    + *

    You will have to specify the header Accept: application/octet-stream when hitting this endpoint.

    + *
    + */ + public CompletableFuture> downloadReportingDataExport( + DownloadReportingDataExportRequest request) { + return downloadReportingDataExport(request, null); + } + + /** + * Download the data from a completed reporting data export job. + *
    + *

    Octet header required

    + *

    You will have to specify the header Accept: application/octet-stream when hitting this endpoint.

    + *
    + */ + public CompletableFuture> downloadReportingDataExport( + DownloadReportingDataExportRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("download/reporting_data") + .addPathSegment(request.getJobIdentifier()); + QueryStringMapper.addQueryParameter(httpUrl, "app_id", request.getAppId(), false); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + _requestBuilder.addHeader("Accept", request.getAccept()); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>(null, response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 404) { + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + /** * 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.

    diff --git a/src/main/java/com/intercom/api/resources/dataexport/DataExportClient.java b/src/main/java/com/intercom/api/resources/dataexport/DataExportClient.java index 0237d41..2aab00a 100644 --- a/src/main/java/com/intercom/api/resources/dataexport/DataExportClient.java +++ b/src/main/java/com/intercom/api/resources/dataexport/DataExportClient.java @@ -8,8 +8,11 @@ import com.intercom.api.resources.dataexport.requests.CancelDataExportRequest; import com.intercom.api.resources.dataexport.requests.CreateDataExportRequest; import com.intercom.api.resources.dataexport.requests.DownloadDataExportRequest; +import com.intercom.api.resources.dataexport.requests.DownloadReportingDataExportRequest; +import com.intercom.api.resources.dataexport.requests.ExportReportingDataRequest; import com.intercom.api.resources.dataexport.requests.FindDataExportRequest; import com.intercom.api.resources.dataexport.types.DataExport; +import com.intercom.api.resources.dataexport.types.DataExportExportReportingDataResponse; public class DataExportClient { protected final ClientOptions clientOptions; @@ -28,6 +31,37 @@ public RawDataExportClient withRawResponse() { return this.rawClient; } + public DataExportExportReportingDataResponse exportReportingData(ExportReportingDataRequest request) { + return this.rawClient.exportReportingData(request).body(); + } + + public DataExportExportReportingDataResponse exportReportingData( + ExportReportingDataRequest request, RequestOptions requestOptions) { + return this.rawClient.exportReportingData(request, requestOptions).body(); + } + + /** + * Download the data from a completed reporting data export job. + *
    + *

    Octet header required

    + *

    You will have to specify the header Accept: application/octet-stream when hitting this endpoint.

    + *
    + */ + public void downloadReportingDataExport(DownloadReportingDataExportRequest request) { + this.rawClient.downloadReportingDataExport(request).body(); + } + + /** + * Download the data from a completed reporting data export job. + *
    + *

    Octet header required

    + *

    You will have to specify the header Accept: application/octet-stream when hitting this endpoint.

    + *
    + */ + public void downloadReportingDataExport(DownloadReportingDataExportRequest request, RequestOptions requestOptions) { + this.rawClient.downloadReportingDataExport(request, requestOptions).body(); + } + /** * 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.

    diff --git a/src/main/java/com/intercom/api/resources/dataexport/RawDataExportClient.java b/src/main/java/com/intercom/api/resources/dataexport/RawDataExportClient.java index 701b488..1309b28 100644 --- a/src/main/java/com/intercom/api/resources/dataexport/RawDataExportClient.java +++ b/src/main/java/com/intercom/api/resources/dataexport/RawDataExportClient.java @@ -10,12 +10,17 @@ import com.intercom.api.core.IntercomHttpResponse; import com.intercom.api.core.MediaTypes; import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.QueryStringMapper; import com.intercom.api.core.RequestOptions; +import com.intercom.api.errors.NotFoundError; import com.intercom.api.resources.dataexport.requests.CancelDataExportRequest; import com.intercom.api.resources.dataexport.requests.CreateDataExportRequest; import com.intercom.api.resources.dataexport.requests.DownloadDataExportRequest; +import com.intercom.api.resources.dataexport.requests.DownloadReportingDataExportRequest; +import com.intercom.api.resources.dataexport.requests.ExportReportingDataRequest; import com.intercom.api.resources.dataexport.requests.FindDataExportRequest; import com.intercom.api.resources.dataexport.types.DataExport; +import com.intercom.api.resources.dataexport.types.DataExportExportReportingDataResponse; import java.io.IOException; import okhttp3.Headers; import okhttp3.HttpUrl; @@ -32,6 +37,117 @@ public RawDataExportClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; } + public IntercomHttpResponse exportReportingData( + ExportReportingDataRequest request) { + return exportReportingData(request, null); + } + + public IntercomHttpResponse exportReportingData( + ExportReportingDataRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("export/reporting_data") + .addPathSegment(request.getJobIdentifier()); + QueryStringMapper.addQueryParameter(httpUrl, "app_id", request.getAppId(), false); + QueryStringMapper.addQueryParameter(httpUrl, "client_id", request.getClientId(), false); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), DataExportExportReportingDataResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 404) { + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * Download the data from a completed reporting data export job. + *
    + *

    Octet header required

    + *

    You will have to specify the header Accept: application/octet-stream when hitting this endpoint.

    + *
    + */ + public IntercomHttpResponse downloadReportingDataExport(DownloadReportingDataExportRequest request) { + return downloadReportingDataExport(request, null); + } + + /** + * Download the data from a completed reporting data export job. + *
    + *

    Octet header required

    + *

    You will have to specify the header Accept: application/octet-stream when hitting this endpoint.

    + *
    + */ + public IntercomHttpResponse downloadReportingDataExport( + DownloadReportingDataExportRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("download/reporting_data") + .addPathSegment(request.getJobIdentifier()); + QueryStringMapper.addQueryParameter(httpUrl, "app_id", request.getAppId(), false); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + _requestBuilder.addHeader("Accept", request.getAccept()); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>(null, response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 404) { + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + /** * 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.

    diff --git a/src/main/java/com/intercom/api/resources/dataexport/requests/DownloadReportingDataExportRequest.java b/src/main/java/com/intercom/api/resources/dataexport/requests/DownloadReportingDataExportRequest.java new file mode 100644 index 0000000..fda19ee --- /dev/null +++ b/src/main/java/com/intercom/api/resources/dataexport/requests/DownloadReportingDataExportRequest.java @@ -0,0 +1,134 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.dataexport.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = DownloadReportingDataExportRequest.Builder.class) +public final class DownloadReportingDataExportRequest { + private final String jobIdentifier; + + private final String appId; + + private final Map additionalProperties; + + private DownloadReportingDataExportRequest( + String jobIdentifier, String appId, Map additionalProperties) { + this.jobIdentifier = jobIdentifier; + this.appId = appId; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("job_identifier") + public String getJobIdentifier() { + return jobIdentifier; + } + + /** + * @return Required header for downloading the export file + */ + @JsonProperty("Accept") + public String getAccept() { + return "application/octet-stream"; + } + + @JsonProperty("app_id") + public String getAppId() { + return appId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DownloadReportingDataExportRequest + && equalTo((DownloadReportingDataExportRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DownloadReportingDataExportRequest other) { + return jobIdentifier.equals(other.jobIdentifier) && appId.equals(other.appId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.jobIdentifier, this.appId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static JobIdentifierStage builder() { + return new Builder(); + } + + public interface JobIdentifierStage { + AppIdStage jobIdentifier(@NotNull String jobIdentifier); + + Builder from(DownloadReportingDataExportRequest other); + } + + public interface AppIdStage { + _FinalStage appId(@NotNull String appId); + } + + public interface _FinalStage { + DownloadReportingDataExportRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements JobIdentifierStage, AppIdStage, _FinalStage { + private String jobIdentifier; + + private String appId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DownloadReportingDataExportRequest other) { + jobIdentifier(other.getJobIdentifier()); + appId(other.getAppId()); + return this; + } + + @java.lang.Override + @JsonSetter("job_identifier") + public AppIdStage jobIdentifier(@NotNull String jobIdentifier) { + this.jobIdentifier = Objects.requireNonNull(jobIdentifier, "jobIdentifier must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("app_id") + public _FinalStage appId(@NotNull String appId) { + this.appId = Objects.requireNonNull(appId, "appId must not be null"); + return this; + } + + @java.lang.Override + public DownloadReportingDataExportRequest build() { + return new DownloadReportingDataExportRequest(jobIdentifier, appId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/dataexport/requests/ExportReportingDataRequest.java b/src/main/java/com/intercom/api/resources/dataexport/requests/ExportReportingDataRequest.java new file mode 100644 index 0000000..91f7359 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/dataexport/requests/ExportReportingDataRequest.java @@ -0,0 +1,169 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.dataexport.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ExportReportingDataRequest.Builder.class) +public final class ExportReportingDataRequest { + private final String jobIdentifier; + + private final String appId; + + private final String clientId; + + private final Map additionalProperties; + + private ExportReportingDataRequest( + String jobIdentifier, String appId, String clientId, Map additionalProperties) { + this.jobIdentifier = jobIdentifier; + this.appId = appId; + this.clientId = clientId; + this.additionalProperties = additionalProperties; + } + + /** + * @return Unique identifier of the job. + */ + @JsonProperty("job_identifier") + public String getJobIdentifier() { + return jobIdentifier; + } + + /** + * @return The Intercom defined code of the workspace the company is associated to. + */ + @JsonProperty("app_id") + public String getAppId() { + return appId; + } + + @JsonProperty("client_id") + public String getClientId() { + return clientId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ExportReportingDataRequest && equalTo((ExportReportingDataRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ExportReportingDataRequest other) { + return jobIdentifier.equals(other.jobIdentifier) + && appId.equals(other.appId) + && clientId.equals(other.clientId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.jobIdentifier, this.appId, this.clientId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static JobIdentifierStage builder() { + return new Builder(); + } + + public interface JobIdentifierStage { + /** + * Unique identifier of the job. + */ + AppIdStage jobIdentifier(@NotNull String jobIdentifier); + + Builder from(ExportReportingDataRequest other); + } + + public interface AppIdStage { + /** + * The Intercom defined code of the workspace the company is associated to. + */ + ClientIdStage appId(@NotNull String appId); + } + + public interface ClientIdStage { + _FinalStage clientId(@NotNull String clientId); + } + + public interface _FinalStage { + ExportReportingDataRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements JobIdentifierStage, AppIdStage, ClientIdStage, _FinalStage { + private String jobIdentifier; + + private String appId; + + private String clientId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ExportReportingDataRequest other) { + jobIdentifier(other.getJobIdentifier()); + appId(other.getAppId()); + clientId(other.getClientId()); + return this; + } + + /** + * Unique identifier of the job.

    Unique identifier of the job.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("job_identifier") + public AppIdStage jobIdentifier(@NotNull String jobIdentifier) { + this.jobIdentifier = Objects.requireNonNull(jobIdentifier, "jobIdentifier must not be null"); + return this; + } + + /** + * The Intercom defined code of the workspace the company is associated to.

    The Intercom defined code of the workspace the company is associated to.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("app_id") + public ClientIdStage appId(@NotNull String appId) { + this.appId = Objects.requireNonNull(appId, "appId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("client_id") + public _FinalStage clientId(@NotNull String clientId) { + this.clientId = Objects.requireNonNull(clientId, "clientId must not be null"); + return this; + } + + @java.lang.Override + public ExportReportingDataRequest build() { + return new ExportReportingDataRequest(jobIdentifier, appId, clientId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/dataexport/types/DataExport.java b/src/main/java/com/intercom/api/resources/dataexport/types/DataExport.java index 3638989..b6d31f3 100644 --- a/src/main/java/com/intercom/api/resources/dataexport/types/DataExport.java +++ b/src/main/java/com/intercom/api/resources/dataexport/types/DataExport.java @@ -11,33 +11,34 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonSetter; import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.intercom.api.core.ObjectMappers; import java.util.HashMap; import java.util.Map; import java.util.Objects; -import org.jetbrains.annotations.NotNull; +import java.util.Optional; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = DataExport.Builder.class) public final class DataExport { - private final String jobIdentifier; + private final Optional jobIdentfier; - private final Status status; + private final Optional status; - private final String downloadExpiresAt; + private final Optional downloadExpiresAt; - private final String downloadUrl; + private final Optional downloadUrl; private final Map additionalProperties; private DataExport( - String jobIdentifier, - Status status, - String downloadExpiresAt, - String downloadUrl, + Optional jobIdentfier, + Optional status, + Optional downloadExpiresAt, + Optional downloadUrl, Map additionalProperties) { - this.jobIdentifier = jobIdentifier; + this.jobIdentfier = jobIdentfier; this.status = status; this.downloadExpiresAt = downloadExpiresAt; this.downloadUrl = downloadUrl; @@ -47,16 +48,16 @@ private DataExport( /** * @return The identifier for your job. */ - @JsonProperty("job_identifier") - public String getJobIdentifier() { - return jobIdentifier; + @JsonProperty("job_identfier") + public Optional getJobIdentfier() { + return jobIdentfier; } /** * @return The current state of your job. */ @JsonProperty("status") - public Status getStatus() { + public Optional getStatus() { return status; } @@ -64,7 +65,7 @@ public Status getStatus() { * @return The time after which you will not be able to access the data. */ @JsonProperty("download_expires_at") - public String getDownloadExpiresAt() { + public Optional getDownloadExpiresAt() { return downloadExpiresAt; } @@ -72,7 +73,7 @@ public String getDownloadExpiresAt() { * @return The location where you can download your data. */ @JsonProperty("download_url") - public String getDownloadUrl() { + public Optional getDownloadUrl() { return downloadUrl; } @@ -88,7 +89,7 @@ public Map getAdditionalProperties() { } private boolean equalTo(DataExport other) { - return jobIdentifier.equals(other.jobIdentifier) + return jobIdentfier.equals(other.jobIdentfier) && status.equals(other.status) && downloadExpiresAt.equals(other.downloadExpiresAt) && downloadUrl.equals(other.downloadUrl); @@ -96,7 +97,7 @@ private boolean equalTo(DataExport other) { @java.lang.Override public int hashCode() { - return Objects.hash(this.jobIdentifier, this.status, this.downloadExpiresAt, this.downloadUrl); + return Objects.hash(this.jobIdentfier, this.status, this.downloadExpiresAt, this.downloadUrl); } @java.lang.Override @@ -104,63 +105,27 @@ public String toString() { return ObjectMappers.stringify(this); } - public static JobIdentifierStage builder() { + public static Builder builder() { return new Builder(); } - public interface JobIdentifierStage { - /** - * The identifier for your job. - */ - StatusStage jobIdentifier(@NotNull String jobIdentifier); - - Builder from(DataExport other); - } - - public interface StatusStage { - /** - * The current state of your job. - */ - DownloadExpiresAtStage status(@NotNull Status status); - } - - public interface DownloadExpiresAtStage { - /** - * The time after which you will not be able to access the data. - */ - DownloadUrlStage downloadExpiresAt(@NotNull String downloadExpiresAt); - } - - public interface DownloadUrlStage { - /** - * The location where you can download your data. - */ - _FinalStage downloadUrl(@NotNull String downloadUrl); - } - - public interface _FinalStage { - DataExport build(); - } - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder - implements JobIdentifierStage, StatusStage, DownloadExpiresAtStage, DownloadUrlStage, _FinalStage { - private String jobIdentifier; + public static final class Builder { + private Optional jobIdentfier = Optional.empty(); - private Status status; + private Optional status = Optional.empty(); - private String downloadExpiresAt; + private Optional downloadExpiresAt = Optional.empty(); - private String downloadUrl; + private Optional downloadUrl = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} - @java.lang.Override public Builder from(DataExport other) { - jobIdentifier(other.getJobIdentifier()); + jobIdentfier(other.getJobIdentfier()); status(other.getStatus()); downloadExpiresAt(other.getDownloadExpiresAt()); downloadUrl(other.getDownloadUrl()); @@ -168,52 +133,63 @@ public Builder from(DataExport other) { } /** - * The identifier for your job.

    The identifier for your job.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The identifier for your job.

    */ - @java.lang.Override - @JsonSetter("job_identifier") - public StatusStage jobIdentifier(@NotNull String jobIdentifier) { - this.jobIdentifier = Objects.requireNonNull(jobIdentifier, "jobIdentifier must not be null"); + @JsonSetter(value = "job_identfier", nulls = Nulls.SKIP) + public Builder jobIdentfier(Optional jobIdentfier) { + this.jobIdentfier = jobIdentfier; + return this; + } + + public Builder jobIdentfier(String jobIdentfier) { + this.jobIdentfier = Optional.ofNullable(jobIdentfier); return this; } /** - * The current state of your job.

    The current state of your job.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The current state of your job.

    */ - @java.lang.Override - @JsonSetter("status") - public DownloadExpiresAtStage status(@NotNull Status status) { - this.status = Objects.requireNonNull(status, "status must not be null"); + @JsonSetter(value = "status", nulls = Nulls.SKIP) + public Builder status(Optional status) { + this.status = status; + return this; + } + + public Builder status(Status status) { + this.status = Optional.ofNullable(status); return this; } /** - * The time after which you will not be able to access the data.

    The time after which you will not be able to access the data.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The time after which you will not be able to access the data.

    */ - @java.lang.Override - @JsonSetter("download_expires_at") - public DownloadUrlStage downloadExpiresAt(@NotNull String downloadExpiresAt) { - this.downloadExpiresAt = Objects.requireNonNull(downloadExpiresAt, "downloadExpiresAt must not be null"); + @JsonSetter(value = "download_expires_at", nulls = Nulls.SKIP) + public Builder downloadExpiresAt(Optional downloadExpiresAt) { + this.downloadExpiresAt = downloadExpiresAt; + return this; + } + + public Builder downloadExpiresAt(String downloadExpiresAt) { + this.downloadExpiresAt = Optional.ofNullable(downloadExpiresAt); return this; } /** - * The location where you can download your data.

    The location where you can download your data.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The location where you can download your data.

    */ - @java.lang.Override - @JsonSetter("download_url") - public _FinalStage downloadUrl(@NotNull String downloadUrl) { - this.downloadUrl = Objects.requireNonNull(downloadUrl, "downloadUrl must not be null"); + @JsonSetter(value = "download_url", nulls = Nulls.SKIP) + public Builder downloadUrl(Optional downloadUrl) { + this.downloadUrl = downloadUrl; + return this; + } + + public Builder downloadUrl(String downloadUrl) { + this.downloadUrl = Optional.ofNullable(downloadUrl); return this; } - @java.lang.Override public DataExport build() { - return new DataExport(jobIdentifier, status, downloadExpiresAt, downloadUrl, additionalProperties); + return new DataExport(jobIdentfier, status, downloadExpiresAt, downloadUrl, additionalProperties); } } diff --git a/src/main/java/com/intercom/api/resources/dataexport/types/DataExportExportReportingDataResponse.java b/src/main/java/com/intercom/api/resources/dataexport/types/DataExportExportReportingDataResponse.java new file mode 100644 index 0000000..315451c --- /dev/null +++ b/src/main/java/com/intercom/api/resources/dataexport/types/DataExportExportReportingDataResponse.java @@ -0,0 +1,171 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.dataexport.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = DataExportExportReportingDataResponse.Builder.class) +public final class DataExportExportReportingDataResponse { + private final Optional jobIdentifier; + + private final Optional status; + + private final Optional downloadUrl; + + private final Optional downloadExpiresAt; + + private final Map additionalProperties; + + private DataExportExportReportingDataResponse( + Optional jobIdentifier, + Optional status, + Optional downloadUrl, + Optional downloadExpiresAt, + Map additionalProperties) { + this.jobIdentifier = jobIdentifier; + this.status = status; + this.downloadUrl = downloadUrl; + this.downloadExpiresAt = downloadExpiresAt; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("job_identifier") + public Optional getJobIdentifier() { + return jobIdentifier; + } + + @JsonProperty("status") + public Optional getStatus() { + return status; + } + + @JsonProperty("download_url") + public Optional getDownloadUrl() { + return downloadUrl; + } + + @JsonProperty("download_expires_at") + public Optional getDownloadExpiresAt() { + return downloadExpiresAt; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DataExportExportReportingDataResponse + && equalTo((DataExportExportReportingDataResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DataExportExportReportingDataResponse other) { + return jobIdentifier.equals(other.jobIdentifier) + && status.equals(other.status) + && downloadUrl.equals(other.downloadUrl) + && downloadExpiresAt.equals(other.downloadExpiresAt); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.jobIdentifier, this.status, this.downloadUrl, this.downloadExpiresAt); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional jobIdentifier = Optional.empty(); + + private Optional status = Optional.empty(); + + private Optional downloadUrl = Optional.empty(); + + private Optional downloadExpiresAt = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(DataExportExportReportingDataResponse other) { + jobIdentifier(other.getJobIdentifier()); + status(other.getStatus()); + downloadUrl(other.getDownloadUrl()); + downloadExpiresAt(other.getDownloadExpiresAt()); + return this; + } + + @JsonSetter(value = "job_identifier", nulls = Nulls.SKIP) + public Builder jobIdentifier(Optional jobIdentifier) { + this.jobIdentifier = jobIdentifier; + return this; + } + + public Builder jobIdentifier(String jobIdentifier) { + this.jobIdentifier = Optional.ofNullable(jobIdentifier); + return this; + } + + @JsonSetter(value = "status", nulls = Nulls.SKIP) + public Builder status(Optional status) { + this.status = status; + return this; + } + + public Builder status(String status) { + this.status = Optional.ofNullable(status); + return this; + } + + @JsonSetter(value = "download_url", nulls = Nulls.SKIP) + public Builder downloadUrl(Optional downloadUrl) { + this.downloadUrl = downloadUrl; + return this; + } + + public Builder downloadUrl(String downloadUrl) { + this.downloadUrl = Optional.ofNullable(downloadUrl); + return this; + } + + @JsonSetter(value = "download_expires_at", nulls = Nulls.SKIP) + public Builder downloadExpiresAt(Optional downloadExpiresAt) { + this.downloadExpiresAt = downloadExpiresAt; + return this; + } + + public Builder downloadExpiresAt(String downloadExpiresAt) { + this.downloadExpiresAt = Optional.ofNullable(downloadExpiresAt); + return this; + } + + public DataExportExportReportingDataResponse build() { + return new DataExportExportReportingDataResponse( + jobIdentifier, status, downloadUrl, downloadExpiresAt, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/export/AsyncExportClient.java b/src/main/java/com/intercom/api/resources/export/AsyncExportClient.java new file mode 100644 index 0000000..1122e61 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/export/AsyncExportClient.java @@ -0,0 +1,50 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.export; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.export.requests.PostExportReportingDataEnqueueRequest; +import com.intercom.api.resources.export.types.GetExportReportingDataGetDatasetsResponse; +import com.intercom.api.resources.export.types.PostExportReportingDataEnqueueResponse; +import java.util.concurrent.CompletableFuture; + +public class AsyncExportClient { + protected final ClientOptions clientOptions; + + private final AsyncRawExportClient rawClient; + + public AsyncExportClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawExportClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawExportClient withRawResponse() { + return this.rawClient; + } + + public CompletableFuture enqueueANewReportingDataExportJob( + PostExportReportingDataEnqueueRequest request) { + return this.rawClient.enqueueANewReportingDataExportJob(request).thenApply(response -> response.body()); + } + + public CompletableFuture enqueueANewReportingDataExportJob( + PostExportReportingDataEnqueueRequest request, RequestOptions requestOptions) { + return this.rawClient + .enqueueANewReportingDataExportJob(request, requestOptions) + .thenApply(response -> response.body()); + } + + public CompletableFuture listAvailableDatasetsAndAttributes() { + return this.rawClient.listAvailableDatasetsAndAttributes().thenApply(response -> response.body()); + } + + public CompletableFuture listAvailableDatasetsAndAttributes( + RequestOptions requestOptions) { + return this.rawClient.listAvailableDatasetsAndAttributes(requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/intercom/api/resources/export/AsyncRawExportClient.java b/src/main/java/com/intercom/api/resources/export/AsyncRawExportClient.java new file mode 100644 index 0000000..73f138f --- /dev/null +++ b/src/main/java/com/intercom/api/resources/export/AsyncRawExportClient.java @@ -0,0 +1,179 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.export; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.errors.BadRequestError; +import com.intercom.api.errors.TooManyRequestsError; +import com.intercom.api.errors.UnauthorizedError; +import com.intercom.api.resources.export.requests.PostExportReportingDataEnqueueRequest; +import com.intercom.api.resources.export.types.GetExportReportingDataGetDatasetsResponse; +import com.intercom.api.resources.export.types.PostExportReportingDataEnqueueResponse; +import com.intercom.api.types.Error; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawExportClient { + protected final ClientOptions clientOptions; + + public AsyncRawExportClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + public CompletableFuture> + enqueueANewReportingDataExportJob(PostExportReportingDataEnqueueRequest request) { + return enqueueANewReportingDataExportJob(request, null); + } + + public CompletableFuture> + enqueueANewReportingDataExportJob( + PostExportReportingDataEnqueueRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("export/reporting_data/enqueue") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = + new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PostExportReportingDataEnqueueResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 429: + future.completeExceptionally(new TooManyRequestsError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> + listAvailableDatasetsAndAttributes() { + return listAvailableDatasetsAndAttributes(null); + } + + public CompletableFuture> + listAvailableDatasetsAndAttributes(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("export/reporting_data/get_datasets") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = + new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), GetExportReportingDataGetDatasetsResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/intercom/api/resources/export/ExportClient.java b/src/main/java/com/intercom/api/resources/export/ExportClient.java new file mode 100644 index 0000000..b2d7985 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/export/ExportClient.java @@ -0,0 +1,48 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.export; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.export.requests.PostExportReportingDataEnqueueRequest; +import com.intercom.api.resources.export.types.GetExportReportingDataGetDatasetsResponse; +import com.intercom.api.resources.export.types.PostExportReportingDataEnqueueResponse; + +public class ExportClient { + protected final ClientOptions clientOptions; + + private final RawExportClient rawClient; + + public ExportClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawExportClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawExportClient withRawResponse() { + return this.rawClient; + } + + public PostExportReportingDataEnqueueResponse enqueueANewReportingDataExportJob( + PostExportReportingDataEnqueueRequest request) { + return this.rawClient.enqueueANewReportingDataExportJob(request).body(); + } + + public PostExportReportingDataEnqueueResponse enqueueANewReportingDataExportJob( + PostExportReportingDataEnqueueRequest request, RequestOptions requestOptions) { + return this.rawClient + .enqueueANewReportingDataExportJob(request, requestOptions) + .body(); + } + + public GetExportReportingDataGetDatasetsResponse listAvailableDatasetsAndAttributes() { + return this.rawClient.listAvailableDatasetsAndAttributes().body(); + } + + public GetExportReportingDataGetDatasetsResponse listAvailableDatasetsAndAttributes(RequestOptions requestOptions) { + return this.rawClient.listAvailableDatasetsAndAttributes(requestOptions).body(); + } +} diff --git a/src/main/java/com/intercom/api/resources/export/RawExportClient.java b/src/main/java/com/intercom/api/resources/export/RawExportClient.java new file mode 100644 index 0000000..d70d765 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/export/RawExportClient.java @@ -0,0 +1,139 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.export; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.errors.BadRequestError; +import com.intercom.api.errors.TooManyRequestsError; +import com.intercom.api.errors.UnauthorizedError; +import com.intercom.api.resources.export.requests.PostExportReportingDataEnqueueRequest; +import com.intercom.api.resources.export.types.GetExportReportingDataGetDatasetsResponse; +import com.intercom.api.resources.export.types.PostExportReportingDataEnqueueResponse; +import com.intercom.api.types.Error; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawExportClient { + protected final ClientOptions clientOptions; + + public RawExportClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + public IntercomHttpResponse enqueueANewReportingDataExportJob( + PostExportReportingDataEnqueueRequest request) { + return enqueueANewReportingDataExportJob(request, null); + } + + public IntercomHttpResponse enqueueANewReportingDataExportJob( + PostExportReportingDataEnqueueRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("export/reporting_data/enqueue") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PostExportReportingDataEnqueueResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 429: + throw new TooManyRequestsError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + public IntercomHttpResponse listAvailableDatasetsAndAttributes() { + return listAvailableDatasetsAndAttributes(null); + } + + public IntercomHttpResponse listAvailableDatasetsAndAttributes( + RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("export/reporting_data/get_datasets") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), GetExportReportingDataGetDatasetsResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/export/requests/PostExportReportingDataEnqueueRequest.java b/src/main/java/com/intercom/api/resources/export/requests/PostExportReportingDataEnqueueRequest.java new file mode 100644 index 0000000..5f832ab --- /dev/null +++ b/src/main/java/com/intercom/api/resources/export/requests/PostExportReportingDataEnqueueRequest.java @@ -0,0 +1,196 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.export.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = PostExportReportingDataEnqueueRequest.Builder.class) +public final class PostExportReportingDataEnqueueRequest { + private final String datasetId; + + private final List attributeIds; + + private final long startTime; + + private final long endTime; + + private final Map additionalProperties; + + private PostExportReportingDataEnqueueRequest( + String datasetId, + List attributeIds, + long startTime, + long endTime, + Map additionalProperties) { + this.datasetId = datasetId; + this.attributeIds = attributeIds; + this.startTime = startTime; + this.endTime = endTime; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("dataset_id") + public String getDatasetId() { + return datasetId; + } + + @JsonProperty("attribute_ids") + public List getAttributeIds() { + return attributeIds; + } + + @JsonProperty("start_time") + public long getStartTime() { + return startTime; + } + + @JsonProperty("end_time") + public long getEndTime() { + return endTime; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof PostExportReportingDataEnqueueRequest + && equalTo((PostExportReportingDataEnqueueRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(PostExportReportingDataEnqueueRequest other) { + return datasetId.equals(other.datasetId) + && attributeIds.equals(other.attributeIds) + && startTime == other.startTime + && endTime == other.endTime; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.datasetId, this.attributeIds, this.startTime, this.endTime); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static DatasetIdStage builder() { + return new Builder(); + } + + public interface DatasetIdStage { + StartTimeStage datasetId(@NotNull String datasetId); + + Builder from(PostExportReportingDataEnqueueRequest other); + } + + public interface StartTimeStage { + EndTimeStage startTime(long startTime); + } + + public interface EndTimeStage { + _FinalStage endTime(long endTime); + } + + public interface _FinalStage { + PostExportReportingDataEnqueueRequest build(); + + _FinalStage attributeIds(List attributeIds); + + _FinalStage addAttributeIds(String attributeIds); + + _FinalStage addAllAttributeIds(List attributeIds); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements DatasetIdStage, StartTimeStage, EndTimeStage, _FinalStage { + private String datasetId; + + private long startTime; + + private long endTime; + + private List attributeIds = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(PostExportReportingDataEnqueueRequest other) { + datasetId(other.getDatasetId()); + attributeIds(other.getAttributeIds()); + startTime(other.getStartTime()); + endTime(other.getEndTime()); + return this; + } + + @java.lang.Override + @JsonSetter("dataset_id") + public StartTimeStage datasetId(@NotNull String datasetId) { + this.datasetId = Objects.requireNonNull(datasetId, "datasetId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("start_time") + public EndTimeStage startTime(long startTime) { + this.startTime = startTime; + return this; + } + + @java.lang.Override + @JsonSetter("end_time") + public _FinalStage endTime(long endTime) { + this.endTime = endTime; + return this; + } + + @java.lang.Override + public _FinalStage addAllAttributeIds(List attributeIds) { + this.attributeIds.addAll(attributeIds); + return this; + } + + @java.lang.Override + public _FinalStage addAttributeIds(String attributeIds) { + this.attributeIds.add(attributeIds); + return this; + } + + @java.lang.Override + @JsonSetter(value = "attribute_ids", nulls = Nulls.SKIP) + public _FinalStage attributeIds(List attributeIds) { + this.attributeIds.clear(); + this.attributeIds.addAll(attributeIds); + return this; + } + + @java.lang.Override + public PostExportReportingDataEnqueueRequest build() { + return new PostExportReportingDataEnqueueRequest( + datasetId, attributeIds, startTime, endTime, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/export/types/GetExportReportingDataGetDatasetsResponse.java b/src/main/java/com/intercom/api/resources/export/types/GetExportReportingDataGetDatasetsResponse.java new file mode 100644 index 0000000..27ab352 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/export/types/GetExportReportingDataGetDatasetsResponse.java @@ -0,0 +1,395 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.export.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = GetExportReportingDataGetDatasetsResponse.Builder.class) +public final class GetExportReportingDataGetDatasetsResponse { + private final Optional type; + + private final Optional> data; + + private final Map additionalProperties; + + private GetExportReportingDataGetDatasetsResponse( + Optional type, Optional> data, Map additionalProperties) { + this.type = type; + this.data = data; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("type") + public Optional getType() { + return type; + } + + @JsonProperty("data") + public Optional> getData() { + return data; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GetExportReportingDataGetDatasetsResponse + && equalTo((GetExportReportingDataGetDatasetsResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GetExportReportingDataGetDatasetsResponse other) { + return type.equals(other.type) && data.equals(other.data); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.data); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); + + private Optional> data = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(GetExportReportingDataGetDatasetsResponse other) { + type(other.getType()); + data(other.getData()); + return this; + } + + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + @JsonSetter(value = "data", nulls = Nulls.SKIP) + public Builder data(Optional> data) { + this.data = data; + return this; + } + + public Builder data(List data) { + this.data = Optional.ofNullable(data); + return this; + } + + public GetExportReportingDataGetDatasetsResponse build() { + return new GetExportReportingDataGetDatasetsResponse(type, data, additionalProperties); + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = DataItem.Builder.class) + public static final class DataItem { + private final Optional id; + + private final Optional name; + + private final Optional description; + + private final Optional defaultTimeAttributeId; + + private final Optional> attributes; + + private final Map additionalProperties; + + private DataItem( + Optional id, + Optional name, + Optional description, + Optional defaultTimeAttributeId, + Optional> attributes, + Map additionalProperties) { + this.id = id; + this.name = name; + this.description = description; + this.defaultTimeAttributeId = defaultTimeAttributeId; + this.attributes = attributes; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("id") + public Optional getId() { + return id; + } + + @JsonProperty("name") + public Optional getName() { + return name; + } + + @JsonProperty("description") + public Optional getDescription() { + return description; + } + + @JsonProperty("default_time_attribute_id") + public Optional getDefaultTimeAttributeId() { + return defaultTimeAttributeId; + } + + @JsonProperty("attributes") + public Optional> getAttributes() { + return attributes; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DataItem && equalTo((DataItem) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DataItem other) { + return id.equals(other.id) + && name.equals(other.name) + && description.equals(other.description) + && defaultTimeAttributeId.equals(other.defaultTimeAttributeId) + && attributes.equals(other.attributes); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id, this.name, this.description, this.defaultTimeAttributeId, this.attributes); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional id = Optional.empty(); + + private Optional name = Optional.empty(); + + private Optional description = Optional.empty(); + + private Optional defaultTimeAttributeId = Optional.empty(); + + private Optional> attributes = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(DataItem other) { + id(other.getId()); + name(other.getName()); + description(other.getDescription()); + defaultTimeAttributeId(other.getDefaultTimeAttributeId()); + attributes(other.getAttributes()); + return this; + } + + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.ofNullable(id); + return this; + } + + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public Builder name(Optional name) { + this.name = name; + return this; + } + + public Builder name(String name) { + this.name = Optional.ofNullable(name); + return this; + } + + @JsonSetter(value = "description", nulls = Nulls.SKIP) + public Builder description(Optional description) { + this.description = description; + return this; + } + + public Builder description(String description) { + this.description = Optional.ofNullable(description); + return this; + } + + @JsonSetter(value = "default_time_attribute_id", nulls = Nulls.SKIP) + public Builder defaultTimeAttributeId(Optional defaultTimeAttributeId) { + this.defaultTimeAttributeId = defaultTimeAttributeId; + return this; + } + + public Builder defaultTimeAttributeId(String defaultTimeAttributeId) { + this.defaultTimeAttributeId = Optional.ofNullable(defaultTimeAttributeId); + return this; + } + + @JsonSetter(value = "attributes", nulls = Nulls.SKIP) + public Builder attributes(Optional> attributes) { + this.attributes = attributes; + return this; + } + + public Builder attributes(List attributes) { + this.attributes = Optional.ofNullable(attributes); + return this; + } + + public DataItem build() { + return new DataItem(id, name, description, defaultTimeAttributeId, attributes, additionalProperties); + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = AttributesItem.Builder.class) + public static final class AttributesItem { + private final Optional id; + + private final Optional name; + + private final Map additionalProperties; + + private AttributesItem( + Optional id, Optional name, Map additionalProperties) { + this.id = id; + this.name = name; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("id") + public Optional getId() { + return id; + } + + @JsonProperty("name") + public Optional getName() { + return name; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AttributesItem && equalTo((AttributesItem) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(AttributesItem other) { + return id.equals(other.id) && name.equals(other.name); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id, this.name); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional id = Optional.empty(); + + private Optional name = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(AttributesItem other) { + id(other.getId()); + name(other.getName()); + return this; + } + + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.ofNullable(id); + return this; + } + + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public Builder name(Optional name) { + this.name = name; + return this; + } + + public Builder name(String name) { + this.name = Optional.ofNullable(name); + return this; + } + + public AttributesItem build() { + return new AttributesItem(id, name, additionalProperties); + } + } + } + } +} diff --git a/src/main/java/com/intercom/api/resources/export/types/PostExportReportingDataEnqueueResponse.java b/src/main/java/com/intercom/api/resources/export/types/PostExportReportingDataEnqueueResponse.java new file mode 100644 index 0000000..982e08f --- /dev/null +++ b/src/main/java/com/intercom/api/resources/export/types/PostExportReportingDataEnqueueResponse.java @@ -0,0 +1,171 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.export.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = PostExportReportingDataEnqueueResponse.Builder.class) +public final class PostExportReportingDataEnqueueResponse { + private final Optional jobIdentifier; + + private final Optional status; + + private final Optional downloadUrl; + + private final Optional downloadExpiresAt; + + private final Map additionalProperties; + + private PostExportReportingDataEnqueueResponse( + Optional jobIdentifier, + Optional status, + Optional downloadUrl, + Optional downloadExpiresAt, + Map additionalProperties) { + this.jobIdentifier = jobIdentifier; + this.status = status; + this.downloadUrl = downloadUrl; + this.downloadExpiresAt = downloadExpiresAt; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("job_identifier") + public Optional getJobIdentifier() { + return jobIdentifier; + } + + @JsonProperty("status") + public Optional getStatus() { + return status; + } + + @JsonProperty("download_url") + public Optional getDownloadUrl() { + return downloadUrl; + } + + @JsonProperty("download_expires_at") + public Optional getDownloadExpiresAt() { + return downloadExpiresAt; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof PostExportReportingDataEnqueueResponse + && equalTo((PostExportReportingDataEnqueueResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(PostExportReportingDataEnqueueResponse other) { + return jobIdentifier.equals(other.jobIdentifier) + && status.equals(other.status) + && downloadUrl.equals(other.downloadUrl) + && downloadExpiresAt.equals(other.downloadExpiresAt); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.jobIdentifier, this.status, this.downloadUrl, this.downloadExpiresAt); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional jobIdentifier = Optional.empty(); + + private Optional status = Optional.empty(); + + private Optional downloadUrl = Optional.empty(); + + private Optional downloadExpiresAt = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(PostExportReportingDataEnqueueResponse other) { + jobIdentifier(other.getJobIdentifier()); + status(other.getStatus()); + downloadUrl(other.getDownloadUrl()); + downloadExpiresAt(other.getDownloadExpiresAt()); + return this; + } + + @JsonSetter(value = "job_identifier", nulls = Nulls.SKIP) + public Builder jobIdentifier(Optional jobIdentifier) { + this.jobIdentifier = jobIdentifier; + return this; + } + + public Builder jobIdentifier(String jobIdentifier) { + this.jobIdentifier = Optional.ofNullable(jobIdentifier); + return this; + } + + @JsonSetter(value = "status", nulls = Nulls.SKIP) + public Builder status(Optional status) { + this.status = status; + return this; + } + + public Builder status(String status) { + this.status = Optional.ofNullable(status); + return this; + } + + @JsonSetter(value = "download_url", nulls = Nulls.SKIP) + public Builder downloadUrl(Optional downloadUrl) { + this.downloadUrl = downloadUrl; + return this; + } + + public Builder downloadUrl(String downloadUrl) { + this.downloadUrl = Optional.ofNullable(downloadUrl); + return this; + } + + @JsonSetter(value = "download_expires_at", nulls = Nulls.SKIP) + public Builder downloadExpiresAt(Optional downloadExpiresAt) { + this.downloadExpiresAt = downloadExpiresAt; + return this; + } + + public Builder downloadExpiresAt(String downloadExpiresAt) { + this.downloadExpiresAt = Optional.ofNullable(downloadExpiresAt); + return this; + } + + public PostExportReportingDataEnqueueResponse build() { + return new PostExportReportingDataEnqueueResponse( + jobIdentifier, status, downloadUrl, downloadExpiresAt, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/helpcenter/types/Collection.java b/src/main/java/com/intercom/api/resources/helpcenter/types/Collection.java index 1231cee..856878b 100644 --- a/src/main/java/com/intercom/api/resources/helpcenter/types/Collection.java +++ b/src/main/java/com/intercom/api/resources/helpcenter/types/Collection.java @@ -40,7 +40,7 @@ public final class Collection { private final int order; - private final String defaultLocale; + private final Optional defaultLocale; private final Optional translatedContent; @@ -60,7 +60,7 @@ private Collection( Optional url, Optional icon, int order, - String defaultLocale, + Optional defaultLocale, Optional translatedContent, Optional parentId, Optional helpCenterId, @@ -157,7 +157,7 @@ public int getOrder() { * @return The default locale of the help center. This field is only returned for multilingual help centers. */ @JsonProperty("default_locale") - public String getDefaultLocale() { + public Optional getDefaultLocale() { return defaultLocale; } @@ -270,14 +270,7 @@ public interface OrderStage { /** * 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. */ - DefaultLocaleStage order(int order); - } - - public interface DefaultLocaleStage { - /** - * The default locale of the help center. This field is only returned for multilingual help centers. - */ - _FinalStage defaultLocale(@NotNull String defaultLocale); + _FinalStage order(int order); } public interface _FinalStage { @@ -311,6 +304,13 @@ public interface _FinalStage { _FinalStage icon(String icon); + /** + *

    The default locale of the help center. This field is only returned for multilingual help centers.

    + */ + _FinalStage defaultLocale(Optional defaultLocale); + + _FinalStage defaultLocale(String defaultLocale); + _FinalStage translatedContent(Optional translatedContent); _FinalStage translatedContent(GroupTranslatedContent translatedContent); @@ -332,13 +332,7 @@ public interface _FinalStage { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder - implements IdStage, - WorkspaceIdStage, - NameStage, - CreatedAtStage, - OrderStage, - DefaultLocaleStage, - _FinalStage { + implements IdStage, WorkspaceIdStage, NameStage, CreatedAtStage, OrderStage, _FinalStage { private String id; private String workspaceId; @@ -349,14 +343,14 @@ public static final class Builder private int order; - private String defaultLocale; - private Optional helpCenterId = Optional.empty(); private Optional parentId = Optional.empty(); private Optional translatedContent = Optional.empty(); + private Optional defaultLocale = Optional.empty(); + private Optional icon = Optional.empty(); private Optional url = Optional.empty(); @@ -438,22 +432,11 @@ public OrderStage createdAt(int createdAt) { */ @java.lang.Override @JsonSetter("order") - public DefaultLocaleStage order(int order) { + public _FinalStage order(int order) { this.order = order; return this; } - /** - * The default locale of the help center. This field is only returned for multilingual help centers.

    The default locale of the help center. This field is only returned for multilingual help centers.

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("default_locale") - public _FinalStage defaultLocale(@NotNull String defaultLocale) { - this.defaultLocale = Objects.requireNonNull(defaultLocale, "defaultLocale must not be null"); - return this; - } - /** *

    The id of the help center the collection is in.

    * @return Reference to {@code this} so that method calls can be chained together. @@ -507,6 +490,26 @@ public _FinalStage translatedContent(Optional translated return this; } + /** + *

    The default locale of the help center. This field is only returned for multilingual help centers.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage defaultLocale(String defaultLocale) { + this.defaultLocale = Optional.ofNullable(defaultLocale); + return this; + } + + /** + *

    The default locale of the help center. This field is only returned for multilingual help centers.

    + */ + @java.lang.Override + @JsonSetter(value = "default_locale", nulls = Nulls.SKIP) + public _FinalStage defaultLocale(Optional defaultLocale) { + this.defaultLocale = defaultLocale; + return this; + } + /** *

    The icon of the collection.

    * @return Reference to {@code this} so that method calls can be chained together. diff --git a/src/main/java/com/intercom/api/resources/helpcenter/types/HelpCenter.java b/src/main/java/com/intercom/api/resources/helpcenter/types/HelpCenter.java index bb52590..81b0dd5 100644 --- a/src/main/java/com/intercom/api/resources/helpcenter/types/HelpCenter.java +++ b/src/main/java/com/intercom/api/resources/helpcenter/types/HelpCenter.java @@ -16,35 +16,40 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; -import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = HelpCenter.Builder.class) public final class HelpCenter { - private final String id; + private final Optional id; - private final String workspaceId; + private final Optional workspaceId; - private final int createdAt; + private final Optional createdAt; private final Optional updatedAt; - private final String identifier; + private final Optional identifier; - private final boolean websiteTurnedOn; + private final Optional websiteTurnedOn; - private final String displayName; + private final Optional displayName; + + private final Optional url; + + private final Optional customDomain; private final Map additionalProperties; private HelpCenter( - String id, - String workspaceId, - int createdAt, + Optional id, + Optional workspaceId, + Optional createdAt, Optional updatedAt, - String identifier, - boolean websiteTurnedOn, - String displayName, + Optional identifier, + Optional websiteTurnedOn, + Optional displayName, + Optional url, + Optional customDomain, Map additionalProperties) { this.id = id; this.workspaceId = workspaceId; @@ -53,6 +58,8 @@ private HelpCenter( this.identifier = identifier; this.websiteTurnedOn = websiteTurnedOn; this.displayName = displayName; + this.url = url; + this.customDomain = customDomain; this.additionalProperties = additionalProperties; } @@ -60,7 +67,7 @@ private HelpCenter( * @return The unique identifier for the Help Center which is given by Intercom. */ @JsonProperty("id") - public String getId() { + public Optional getId() { return id; } @@ -68,7 +75,7 @@ public String getId() { * @return The id of the workspace which the Help Center belongs to. */ @JsonProperty("workspace_id") - public String getWorkspaceId() { + public Optional getWorkspaceId() { return workspaceId; } @@ -76,7 +83,7 @@ public String getWorkspaceId() { * @return The time when the Help Center was created. */ @JsonProperty("created_at") - public int getCreatedAt() { + public Optional getCreatedAt() { return createdAt; } @@ -92,7 +99,7 @@ public Optional getUpdatedAt() { * @return The identifier of the Help Center. This is used in the URL of the Help Center. */ @JsonProperty("identifier") - public String getIdentifier() { + public Optional getIdentifier() { return identifier; } @@ -100,7 +107,7 @@ public String getIdentifier() { * @return Whether the Help Center is turned on or not. This is controlled in your Help Center settings. */ @JsonProperty("website_turned_on") - public boolean getWebsiteTurnedOn() { + public Optional getWebsiteTurnedOn() { return websiteTurnedOn; } @@ -108,10 +115,26 @@ public boolean getWebsiteTurnedOn() { * @return The display name of the Help Center only seen by teammates. */ @JsonProperty("display_name") - public String getDisplayName() { + public Optional getDisplayName() { return displayName; } + /** + * @return The URL for the help center, if you have a custom domain then this will show the URL using the custom domain. + */ + @JsonProperty("url") + public Optional getUrl() { + return url; + } + + /** + * @return Custom domain configured for the help center + */ + @JsonProperty("custom_domain") + public Optional getCustomDomain() { + return customDomain; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -126,11 +149,13 @@ public Map getAdditionalProperties() { private boolean equalTo(HelpCenter other) { return id.equals(other.id) && workspaceId.equals(other.workspaceId) - && createdAt == other.createdAt + && createdAt.equals(other.createdAt) && updatedAt.equals(other.updatedAt) && identifier.equals(other.identifier) - && websiteTurnedOn == other.websiteTurnedOn - && displayName.equals(other.displayName); + && websiteTurnedOn.equals(other.websiteTurnedOn) + && displayName.equals(other.displayName) + && url.equals(other.url) + && customDomain.equals(other.customDomain); } @java.lang.Override @@ -142,7 +167,9 @@ public int hashCode() { this.updatedAt, this.identifier, this.websiteTurnedOn, - this.displayName); + this.displayName, + this.url, + this.customDomain); } @java.lang.Override @@ -150,94 +177,35 @@ public String toString() { return ObjectMappers.stringify(this); } - public static IdStage builder() { + public static Builder builder() { return new Builder(); } - public interface IdStage { - /** - * The unique identifier for the Help Center which is given by Intercom. - */ - WorkspaceIdStage id(@NotNull String id); - - Builder from(HelpCenter other); - } - - public interface WorkspaceIdStage { - /** - * The id of the workspace which the Help Center belongs to. - */ - CreatedAtStage workspaceId(@NotNull String workspaceId); - } - - public interface CreatedAtStage { - /** - * The time when the Help Center was created. - */ - IdentifierStage createdAt(int createdAt); - } - - public interface IdentifierStage { - /** - * The identifier of the Help Center. This is used in the URL of the Help Center. - */ - WebsiteTurnedOnStage identifier(@NotNull String identifier); - } - - public interface WebsiteTurnedOnStage { - /** - * Whether the Help Center is turned on or not. This is controlled in your Help Center settings. - */ - DisplayNameStage websiteTurnedOn(boolean websiteTurnedOn); - } - - public interface DisplayNameStage { - /** - * The display name of the Help Center only seen by teammates. - */ - _FinalStage displayName(@NotNull String displayName); - } - - public interface _FinalStage { - HelpCenter build(); + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional id = Optional.empty(); - /** - *

    The time when the Help Center was last updated.

    - */ - _FinalStage updatedAt(Optional updatedAt); + private Optional workspaceId = Optional.empty(); - _FinalStage updatedAt(Integer updatedAt); - } + private Optional createdAt = Optional.empty(); - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder - implements IdStage, - WorkspaceIdStage, - CreatedAtStage, - IdentifierStage, - WebsiteTurnedOnStage, - DisplayNameStage, - _FinalStage { - private String id; + private Optional updatedAt = Optional.empty(); - private String workspaceId; + private Optional identifier = Optional.empty(); - private int createdAt; + private Optional websiteTurnedOn = Optional.empty(); - private String identifier; + private Optional displayName = Optional.empty(); - private boolean websiteTurnedOn; + private Optional url = Optional.empty(); - private String displayName; - - private Optional updatedAt = Optional.empty(); + private Optional customDomain = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} - @java.lang.Override public Builder from(HelpCenter other) { id(other.getId()); workspaceId(other.getWorkspaceId()); @@ -246,96 +214,137 @@ public Builder from(HelpCenter other) { identifier(other.getIdentifier()); websiteTurnedOn(other.getWebsiteTurnedOn()); displayName(other.getDisplayName()); + url(other.getUrl()); + customDomain(other.getCustomDomain()); return this; } /** - * The unique identifier for the Help Center which is given by Intercom.

    The unique identifier for the Help Center which is given by Intercom.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The unique identifier for the Help Center which is given by Intercom.

    */ - @java.lang.Override - @JsonSetter("id") - public WorkspaceIdStage id(@NotNull String id) { - this.id = Objects.requireNonNull(id, "id must not be null"); + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.ofNullable(id); return this; } /** - * The id of the workspace which the Help Center belongs to.

    The id of the workspace which the Help Center belongs to.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The id of the workspace which the Help Center belongs to.

    */ - @java.lang.Override - @JsonSetter("workspace_id") - public CreatedAtStage workspaceId(@NotNull String workspaceId) { - this.workspaceId = Objects.requireNonNull(workspaceId, "workspaceId must not be null"); + @JsonSetter(value = "workspace_id", nulls = Nulls.SKIP) + public Builder workspaceId(Optional workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + public Builder workspaceId(String workspaceId) { + this.workspaceId = Optional.ofNullable(workspaceId); return this; } /** - * The time when the Help Center was created.

    The time when the Help Center was created.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The time when the Help Center was created.

    */ - @java.lang.Override - @JsonSetter("created_at") - public IdentifierStage createdAt(int createdAt) { + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public Builder createdAt(Optional createdAt) { this.createdAt = createdAt; return this; } + public Builder createdAt(Integer createdAt) { + this.createdAt = Optional.ofNullable(createdAt); + return this; + } + + /** + *

    The time when the Help Center was last updated.

    + */ + @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) + public Builder updatedAt(Optional updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + public Builder updatedAt(Integer updatedAt) { + this.updatedAt = Optional.ofNullable(updatedAt); + return this; + } + /** - * The identifier of the Help Center. This is used in the URL of the Help Center.

    The identifier of the Help Center. This is used in the URL of the Help Center.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The identifier of the Help Center. This is used in the URL of the Help Center.

    */ - @java.lang.Override - @JsonSetter("identifier") - public WebsiteTurnedOnStage identifier(@NotNull String identifier) { - this.identifier = Objects.requireNonNull(identifier, "identifier must not be null"); + @JsonSetter(value = "identifier", nulls = Nulls.SKIP) + public Builder identifier(Optional identifier) { + this.identifier = identifier; + return this; + } + + public Builder identifier(String identifier) { + this.identifier = Optional.ofNullable(identifier); return this; } /** - * Whether the Help Center is turned on or not. This is controlled in your Help Center settings.

    Whether the Help Center is turned on or not. This is controlled in your Help Center settings.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    Whether the Help Center is turned on or not. This is controlled in your Help Center settings.

    */ - @java.lang.Override - @JsonSetter("website_turned_on") - public DisplayNameStage websiteTurnedOn(boolean websiteTurnedOn) { + @JsonSetter(value = "website_turned_on", nulls = Nulls.SKIP) + public Builder websiteTurnedOn(Optional websiteTurnedOn) { this.websiteTurnedOn = websiteTurnedOn; return this; } + public Builder websiteTurnedOn(Boolean websiteTurnedOn) { + this.websiteTurnedOn = Optional.ofNullable(websiteTurnedOn); + return this; + } + /** - * The display name of the Help Center only seen by teammates.

    The display name of the Help Center only seen by teammates.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The display name of the Help Center only seen by teammates.

    */ - @java.lang.Override - @JsonSetter("display_name") - public _FinalStage displayName(@NotNull String displayName) { - this.displayName = Objects.requireNonNull(displayName, "displayName must not be null"); + @JsonSetter(value = "display_name", nulls = Nulls.SKIP) + public Builder displayName(Optional displayName) { + this.displayName = displayName; + return this; + } + + public Builder displayName(String displayName) { + this.displayName = Optional.ofNullable(displayName); return this; } /** - *

    The time when the Help Center was last updated.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The URL for the help center, if you have a custom domain then this will show the URL using the custom domain.

    */ - @java.lang.Override - public _FinalStage updatedAt(Integer updatedAt) { - this.updatedAt = Optional.ofNullable(updatedAt); + @JsonSetter(value = "url", nulls = Nulls.SKIP) + public Builder url(Optional url) { + this.url = url; + return this; + } + + public Builder url(String url) { + this.url = Optional.ofNullable(url); return this; } /** - *

    The time when the Help Center was last updated.

    + *

    Custom domain configured for the help center

    */ - @java.lang.Override - @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) - public _FinalStage updatedAt(Optional updatedAt) { - this.updatedAt = updatedAt; + @JsonSetter(value = "custom_domain", nulls = Nulls.SKIP) + public Builder customDomain(Optional customDomain) { + this.customDomain = customDomain; + return this; + } + + public Builder customDomain(String customDomain) { + this.customDomain = Optional.ofNullable(customDomain); return this; } - @java.lang.Override public HelpCenter build() { return new HelpCenter( id, @@ -345,6 +354,8 @@ public HelpCenter build() { identifier, websiteTurnedOn, displayName, + url, + customDomain, additionalProperties); } } diff --git a/src/main/java/com/intercom/api/resources/helpcenter/types/HelpCenterList.java b/src/main/java/com/intercom/api/resources/helpcenter/types/HelpCenterList.java index 623d7e0..1a1f980 100644 --- a/src/main/java/com/intercom/api/resources/helpcenter/types/HelpCenterList.java +++ b/src/main/java/com/intercom/api/resources/helpcenter/types/HelpCenterList.java @@ -12,20 +12,24 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.intercom.api.core.ObjectMappers; -import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.Optional; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = HelpCenterList.Builder.class) public final class HelpCenterList { - private final List data; + private final Optional type; + + private final Optional> data; private final Map additionalProperties; - private HelpCenterList(List data, Map additionalProperties) { + private HelpCenterList( + Optional type, Optional> data, Map additionalProperties) { + this.type = type; this.data = data; this.additionalProperties = additionalProperties; } @@ -34,15 +38,15 @@ private HelpCenterList(List data, Map additionalProp * @return The type of the object - list. */ @JsonProperty("type") - public String getType() { - return "list"; + public Optional getType() { + return type; } /** * @return An array of Help Center objects */ @JsonProperty("data") - public List getData() { + public Optional> getData() { return data; } @@ -58,12 +62,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(HelpCenterList other) { - return data.equals(other.data); + return type.equals(other.type) && data.equals(other.data); } @java.lang.Override public int hashCode() { - return Objects.hash(this.data); + return Objects.hash(this.type, this.data); } @java.lang.Override @@ -77,7 +81,9 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private List data = new ArrayList<>(); + private Optional type = Optional.empty(); + + private Optional> data = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -85,32 +91,41 @@ public static final class Builder { private Builder() {} public Builder from(HelpCenterList other) { + type(other.getType()); data(other.getData()); return this; } /** - *

    An array of Help Center objects

    + *

    The type of the object - list.

    */ - @JsonSetter(value = "data", nulls = Nulls.SKIP) - public Builder data(List data) { - this.data.clear(); - this.data.addAll(data); + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; return this; } - public Builder addData(HelpCenter data) { - this.data.add(data); + public Builder type(String type) { + this.type = Optional.ofNullable(type); return this; } - public Builder addAllData(List data) { - this.data.addAll(data); + /** + *

    An array of Help Center objects

    + */ + @JsonSetter(value = "data", nulls = Nulls.SKIP) + public Builder data(Optional> data) { + this.data = data; + return this; + } + + public Builder data(List data) { + this.data = Optional.ofNullable(data); return this; } public HelpCenterList build() { - return new HelpCenterList(data, additionalProperties); + return new HelpCenterList(type, data, additionalProperties); } } } diff --git a/src/main/java/com/intercom/api/resources/helpcenters/AsyncRawHelpCentersClient.java b/src/main/java/com/intercom/api/resources/helpcenters/AsyncRawHelpCentersClient.java index ce82a33..9d54cea 100644 --- a/src/main/java/com/intercom/api/resources/helpcenters/AsyncRawHelpCentersClient.java +++ b/src/main/java/com/intercom/api/resources/helpcenters/AsyncRawHelpCentersClient.java @@ -20,6 +20,7 @@ import com.intercom.api.resources.helpcenters.requests.ListHelpCentersRequest; import com.intercom.api.types.Error; import java.io.IOException; +import java.util.Collections; import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; @@ -55,7 +56,7 @@ public CompletableFuture> find( HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("help_center/help_centers") - .addPathSegment(request.getHelpCenterId()) + .addPathSegment(Integer.toString(request.getHelpCenterId())) .build(); Request.Builder _requestBuilder = new Request.Builder() .url(httpUrl) @@ -171,7 +172,7 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO .from(request) .page(newPageNumber) .build(); - List result = parsedResponse.getData(); + List result = parsedResponse.getData().orElse(Collections.emptyList()); future.complete(new IntercomHttpResponse<>( new SyncPagingIterable(true, result, () -> { try { diff --git a/src/main/java/com/intercom/api/resources/helpcenters/RawHelpCentersClient.java b/src/main/java/com/intercom/api/resources/helpcenters/RawHelpCentersClient.java index 3c24161..1706312 100644 --- a/src/main/java/com/intercom/api/resources/helpcenters/RawHelpCentersClient.java +++ b/src/main/java/com/intercom/api/resources/helpcenters/RawHelpCentersClient.java @@ -20,6 +20,7 @@ import com.intercom.api.resources.helpcenters.requests.ListHelpCentersRequest; import com.intercom.api.types.Error; import java.io.IOException; +import java.util.Collections; import java.util.List; import okhttp3.Headers; import okhttp3.HttpUrl; @@ -49,7 +50,7 @@ public IntercomHttpResponse find(FindHelpCenterRequest request, Requ HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("help_center/help_centers") - .addPathSegment(request.getHelpCenterId()) + .addPathSegment(Integer.toString(request.getHelpCenterId())) .build(); Request.Builder _requestBuilder = new Request.Builder() .url(httpUrl) @@ -142,7 +143,7 @@ public IntercomHttpResponse> list( .from(request) .page(newPageNumber) .build(); - List result = parsedResponse.getData(); + List result = parsedResponse.getData().orElse(Collections.emptyList()); return new IntercomHttpResponse<>( new SyncPagingIterable(true, result, () -> list(nextRequest, requestOptions) .body()), diff --git a/src/main/java/com/intercom/api/resources/helpcenters/collections/AsyncRawCollectionsClient.java b/src/main/java/com/intercom/api/resources/helpcenters/collections/AsyncRawCollectionsClient.java index af6a0db..659cefd 100644 --- a/src/main/java/com/intercom/api/resources/helpcenters/collections/AsyncRawCollectionsClient.java +++ b/src/main/java/com/intercom/api/resources/helpcenters/collections/AsyncRawCollectionsClient.java @@ -26,6 +26,7 @@ import com.intercom.api.types.DeletedCollectionObject; import com.intercom.api.types.Error; import java.io.IOException; +import java.util.Collections; import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; @@ -106,7 +107,7 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO .from(request) .page(newPageNumber) .build(); - List result = parsedResponse.getData(); + List result = parsedResponse.getData().orElse(Collections.emptyList()); future.complete(new IntercomHttpResponse<>( new SyncPagingIterable(true, result, () -> { try { @@ -245,7 +246,7 @@ public CompletableFuture> find( HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("help_center/collections") - .addPathSegment(request.getCollectionId()) + .addPathSegment(Integer.toString(request.getCollectionId())) .build(); Request.Builder _requestBuilder = new Request.Builder() .url(httpUrl) @@ -320,7 +321,7 @@ public CompletableFuture> update( HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("help_center/collections") - .addPathSegment(request.getCollectionId()) + .addPathSegment(Integer.toString(request.getCollectionId())) .build(); RequestBody body; try { @@ -402,7 +403,7 @@ public CompletableFuture> delete( HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("help_center/collections") - .addPathSegment(request.getCollectionId()) + .addPathSegment(Integer.toString(request.getCollectionId())) .build(); Request.Builder _requestBuilder = new Request.Builder() .url(httpUrl) diff --git a/src/main/java/com/intercom/api/resources/helpcenters/collections/RawCollectionsClient.java b/src/main/java/com/intercom/api/resources/helpcenters/collections/RawCollectionsClient.java index 8e9cee2..05e5c7f 100644 --- a/src/main/java/com/intercom/api/resources/helpcenters/collections/RawCollectionsClient.java +++ b/src/main/java/com/intercom/api/resources/helpcenters/collections/RawCollectionsClient.java @@ -26,6 +26,7 @@ import com.intercom.api.types.DeletedCollectionObject; import com.intercom.api.types.Error; import java.io.IOException; +import java.util.Collections; import java.util.List; import okhttp3.Headers; import okhttp3.HttpUrl; @@ -96,7 +97,7 @@ public IntercomHttpResponse> list( .from(request) .page(newPageNumber) .build(); - List result = parsedResponse.getData(); + List result = parsedResponse.getData().orElse(Collections.emptyList()); return new IntercomHttpResponse<>( new SyncPagingIterable(true, result, () -> list(nextRequest, requestOptions) .body()), @@ -197,7 +198,7 @@ public IntercomHttpResponse find(FindCollectionRequest request, Requ HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("help_center/collections") - .addPathSegment(request.getCollectionId()) + .addPathSegment(Integer.toString(request.getCollectionId())) .build(); Request.Builder _requestBuilder = new Request.Builder() .url(httpUrl) @@ -253,7 +254,7 @@ public IntercomHttpResponse update(UpdateCollectionRequest request, HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("help_center/collections") - .addPathSegment(request.getCollectionId()) + .addPathSegment(Integer.toString(request.getCollectionId())) .build(); RequestBody body; try { @@ -317,7 +318,7 @@ public IntercomHttpResponse delete( HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("help_center/collections") - .addPathSegment(request.getCollectionId()) + .addPathSegment(Integer.toString(request.getCollectionId())) .build(); Request.Builder _requestBuilder = new Request.Builder() .url(httpUrl) diff --git a/src/main/java/com/intercom/api/resources/helpcenters/collections/requests/DeleteCollectionRequest.java b/src/main/java/com/intercom/api/resources/helpcenters/collections/requests/DeleteCollectionRequest.java index acfdd76..ecfa6ba 100644 --- a/src/main/java/com/intercom/api/resources/helpcenters/collections/requests/DeleteCollectionRequest.java +++ b/src/main/java/com/intercom/api/resources/helpcenters/collections/requests/DeleteCollectionRequest.java @@ -14,16 +14,15 @@ import java.util.HashMap; import java.util.Map; import java.util.Objects; -import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = DeleteCollectionRequest.Builder.class) public final class DeleteCollectionRequest { - private final String collectionId; + private final int collectionId; private final Map additionalProperties; - private DeleteCollectionRequest(String collectionId, Map additionalProperties) { + private DeleteCollectionRequest(int collectionId, Map additionalProperties) { this.collectionId = collectionId; this.additionalProperties = additionalProperties; } @@ -32,7 +31,7 @@ private DeleteCollectionRequest(String collectionId, Map additio * @return The unique identifier for the collection which is given by Intercom. */ @JsonProperty("collection_id") - public String getCollectionId() { + public int getCollectionId() { return collectionId; } @@ -48,7 +47,7 @@ public Map getAdditionalProperties() { } private boolean equalTo(DeleteCollectionRequest other) { - return collectionId.equals(other.collectionId); + return collectionId == other.collectionId; } @java.lang.Override @@ -69,7 +68,7 @@ public interface CollectionIdStage { /** * The unique identifier for the collection which is given by Intercom. */ - _FinalStage collectionId(@NotNull String collectionId); + _FinalStage collectionId(int collectionId); Builder from(DeleteCollectionRequest other); } @@ -80,7 +79,7 @@ public interface _FinalStage { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements CollectionIdStage, _FinalStage { - private String collectionId; + private int collectionId; @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -99,8 +98,8 @@ public Builder from(DeleteCollectionRequest other) { */ @java.lang.Override @JsonSetter("collection_id") - public _FinalStage collectionId(@NotNull String collectionId) { - this.collectionId = Objects.requireNonNull(collectionId, "collectionId must not be null"); + public _FinalStage collectionId(int collectionId) { + this.collectionId = collectionId; return this; } diff --git a/src/main/java/com/intercom/api/resources/helpcenters/collections/requests/FindCollectionRequest.java b/src/main/java/com/intercom/api/resources/helpcenters/collections/requests/FindCollectionRequest.java index bd42768..8c78085 100644 --- a/src/main/java/com/intercom/api/resources/helpcenters/collections/requests/FindCollectionRequest.java +++ b/src/main/java/com/intercom/api/resources/helpcenters/collections/requests/FindCollectionRequest.java @@ -14,16 +14,15 @@ import java.util.HashMap; import java.util.Map; import java.util.Objects; -import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = FindCollectionRequest.Builder.class) public final class FindCollectionRequest { - private final String collectionId; + private final int collectionId; private final Map additionalProperties; - private FindCollectionRequest(String collectionId, Map additionalProperties) { + private FindCollectionRequest(int collectionId, Map additionalProperties) { this.collectionId = collectionId; this.additionalProperties = additionalProperties; } @@ -32,7 +31,7 @@ private FindCollectionRequest(String collectionId, Map additiona * @return The unique identifier for the collection which is given by Intercom. */ @JsonProperty("collection_id") - public String getCollectionId() { + public int getCollectionId() { return collectionId; } @@ -48,7 +47,7 @@ public Map getAdditionalProperties() { } private boolean equalTo(FindCollectionRequest other) { - return collectionId.equals(other.collectionId); + return collectionId == other.collectionId; } @java.lang.Override @@ -69,7 +68,7 @@ public interface CollectionIdStage { /** * The unique identifier for the collection which is given by Intercom. */ - _FinalStage collectionId(@NotNull String collectionId); + _FinalStage collectionId(int collectionId); Builder from(FindCollectionRequest other); } @@ -80,7 +79,7 @@ public interface _FinalStage { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements CollectionIdStage, _FinalStage { - private String collectionId; + private int collectionId; @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -99,8 +98,8 @@ public Builder from(FindCollectionRequest other) { */ @java.lang.Override @JsonSetter("collection_id") - public _FinalStage collectionId(@NotNull String collectionId) { - this.collectionId = Objects.requireNonNull(collectionId, "collectionId must not be null"); + public _FinalStage collectionId(int collectionId) { + this.collectionId = collectionId; return this; } diff --git a/src/main/java/com/intercom/api/resources/helpcenters/collections/requests/UpdateCollectionRequest.java b/src/main/java/com/intercom/api/resources/helpcenters/collections/requests/UpdateCollectionRequest.java index 965fa00..aa29675 100644 --- a/src/main/java/com/intercom/api/resources/helpcenters/collections/requests/UpdateCollectionRequest.java +++ b/src/main/java/com/intercom/api/resources/helpcenters/collections/requests/UpdateCollectionRequest.java @@ -17,12 +17,11 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; -import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = UpdateCollectionRequest.Builder.class) public final class UpdateCollectionRequest { - private final String collectionId; + private final int collectionId; private final Optional name; @@ -35,7 +34,7 @@ public final class UpdateCollectionRequest { private final Map additionalProperties; private UpdateCollectionRequest( - String collectionId, + int collectionId, Optional name, Optional description, Optional translatedContent, @@ -53,7 +52,7 @@ private UpdateCollectionRequest( * @return The unique identifier for the collection which is given by Intercom. */ @JsonProperty("collection_id") - public String getCollectionId() { + public int getCollectionId() { return collectionId; } @@ -98,7 +97,7 @@ public Map getAdditionalProperties() { } private boolean equalTo(UpdateCollectionRequest other) { - return collectionId.equals(other.collectionId) + return collectionId == other.collectionId && name.equals(other.name) && description.equals(other.description) && translatedContent.equals(other.translatedContent) @@ -123,7 +122,7 @@ public interface CollectionIdStage { /** * The unique identifier for the collection which is given by Intercom. */ - _FinalStage collectionId(@NotNull String collectionId); + _FinalStage collectionId(int collectionId); Builder from(UpdateCollectionRequest other); } @@ -159,7 +158,7 @@ public interface _FinalStage { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements CollectionIdStage, _FinalStage { - private String collectionId; + private int collectionId; private Optional parentId = Optional.empty(); @@ -190,8 +189,8 @@ public Builder from(UpdateCollectionRequest other) { */ @java.lang.Override @JsonSetter("collection_id") - public _FinalStage collectionId(@NotNull String collectionId) { - this.collectionId = Objects.requireNonNull(collectionId, "collectionId must not be null"); + public _FinalStage collectionId(int collectionId) { + this.collectionId = collectionId; return this; } diff --git a/src/main/java/com/intercom/api/resources/helpcenters/requests/FindHelpCenterRequest.java b/src/main/java/com/intercom/api/resources/helpcenters/requests/FindHelpCenterRequest.java index 6814db5..9b6cf4c 100644 --- a/src/main/java/com/intercom/api/resources/helpcenters/requests/FindHelpCenterRequest.java +++ b/src/main/java/com/intercom/api/resources/helpcenters/requests/FindHelpCenterRequest.java @@ -14,25 +14,24 @@ import java.util.HashMap; import java.util.Map; import java.util.Objects; -import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = FindHelpCenterRequest.Builder.class) public final class FindHelpCenterRequest { - private final String helpCenterId; + private final int helpCenterId; private final Map additionalProperties; - private FindHelpCenterRequest(String helpCenterId, Map additionalProperties) { + private FindHelpCenterRequest(int helpCenterId, Map additionalProperties) { this.helpCenterId = helpCenterId; this.additionalProperties = additionalProperties; } /** - * @return The unique identifier for the Help Center which is given by Intercom. + * @return The unique identifier for the collection which is given by Intercom. */ @JsonProperty("help_center_id") - public String getHelpCenterId() { + public int getHelpCenterId() { return helpCenterId; } @@ -48,7 +47,7 @@ public Map getAdditionalProperties() { } private boolean equalTo(FindHelpCenterRequest other) { - return helpCenterId.equals(other.helpCenterId); + return helpCenterId == other.helpCenterId; } @java.lang.Override @@ -67,9 +66,9 @@ public static HelpCenterIdStage builder() { public interface HelpCenterIdStage { /** - * The unique identifier for the Help Center which is given by Intercom. + * The unique identifier for the collection which is given by Intercom. */ - _FinalStage helpCenterId(@NotNull String helpCenterId); + _FinalStage helpCenterId(int helpCenterId); Builder from(FindHelpCenterRequest other); } @@ -80,7 +79,7 @@ public interface _FinalStage { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements HelpCenterIdStage, _FinalStage { - private String helpCenterId; + private int helpCenterId; @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -94,13 +93,13 @@ public Builder from(FindHelpCenterRequest other) { } /** - * The unique identifier for the Help Center which is given by Intercom.

    The unique identifier for the Help Center which is given by Intercom.

    + * The unique identifier for the collection which is given by Intercom.

    The unique identifier for the collection which is given by Intercom.

    * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @JsonSetter("help_center_id") - public _FinalStage helpCenterId(@NotNull String helpCenterId) { - this.helpCenterId = Objects.requireNonNull(helpCenterId, "helpCenterId must not be null"); + public _FinalStage helpCenterId(int helpCenterId) { + this.helpCenterId = helpCenterId; return this; } diff --git a/src/main/java/com/intercom/api/resources/internalarticles/AsyncInternalArticlesClient.java b/src/main/java/com/intercom/api/resources/internalarticles/AsyncInternalArticlesClient.java new file mode 100644 index 0000000..5bf7f0e --- /dev/null +++ b/src/main/java/com/intercom/api/resources/internalarticles/AsyncInternalArticlesClient.java @@ -0,0 +1,141 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.internalarticles; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.internalarticles.requests.DeleteInternalArticleRequest; +import com.intercom.api.resources.internalarticles.requests.RetrieveInternalArticleRequest; +import com.intercom.api.resources.internalarticles.requests.SearchInternalArticlesRequest; +import com.intercom.api.resources.internalarticles.requests.UpdateInternalArticleRequestBody; +import com.intercom.api.resources.internalarticles.types.InternalArticleListItem; +import com.intercom.api.resources.internalarticles.types.InternalArticleSearchResponse; +import com.intercom.api.types.CreateInternalArticleRequest; +import com.intercom.api.types.DeletedInternalArticleObject; +import com.intercom.api.types.InternalArticleList; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; + +public class AsyncInternalArticlesClient { + protected final ClientOptions clientOptions; + + private final AsyncRawInternalArticlesClient rawClient; + + public AsyncInternalArticlesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawInternalArticlesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawInternalArticlesClient withRawResponse() { + return this.rawClient; + } + + /** + * You can fetch a list of all internal articles by making a GET request to https://api.intercom.io/internal_articles. + */ + public CompletableFuture listInternalArticles() { + return this.rawClient.listInternalArticles().thenApply(response -> response.body()); + } + + /** + * You can fetch a list of all internal articles by making a GET request to https://api.intercom.io/internal_articles. + */ + public CompletableFuture listInternalArticles(RequestOptions requestOptions) { + return this.rawClient.listInternalArticles(requestOptions).thenApply(response -> response.body()); + } + + /** + * You can create a new internal article by making a POST request to https://api.intercom.io/internal_articles. + */ + public CompletableFuture createInternalArticle() { + return this.rawClient.createInternalArticle().thenApply(response -> response.body()); + } + + /** + * You can create a new internal article by making a POST request to https://api.intercom.io/internal_articles. + */ + public CompletableFuture createInternalArticle( + Optional request) { + return this.rawClient.createInternalArticle(request).thenApply(response -> response.body()); + } + + /** + * You can create a new internal article by making a POST request to https://api.intercom.io/internal_articles. + */ + public CompletableFuture createInternalArticle( + Optional request, RequestOptions requestOptions) { + return this.rawClient.createInternalArticle(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can fetch the details of a single internal article by making a GET request to https://api.intercom.io/internal_articles/<id>. + */ + public CompletableFuture retrieveInternalArticle(RetrieveInternalArticleRequest request) { + return this.rawClient.retrieveInternalArticle(request).thenApply(response -> response.body()); + } + + /** + * You can fetch the details of a single internal article by making a GET request to https://api.intercom.io/internal_articles/<id>. + */ + public CompletableFuture retrieveInternalArticle( + RetrieveInternalArticleRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieveInternalArticle(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can update the details of a single internal article by making a PUT request to https://api.intercom.io/internal_articles/<id>. + */ + public CompletableFuture updateInternalArticle(UpdateInternalArticleRequestBody request) { + return this.rawClient.updateInternalArticle(request).thenApply(response -> response.body()); + } + + /** + * You can update the details of a single internal article by making a PUT request to https://api.intercom.io/internal_articles/<id>. + */ + public CompletableFuture updateInternalArticle( + UpdateInternalArticleRequestBody request, RequestOptions requestOptions) { + return this.rawClient.updateInternalArticle(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can delete a single internal article by making a DELETE request to https://api.intercom.io/internal_articles/<id>. + */ + public CompletableFuture deleteInternalArticle(DeleteInternalArticleRequest request) { + return this.rawClient.deleteInternalArticle(request).thenApply(response -> response.body()); + } + + /** + * You can delete a single internal article by making a DELETE request to https://api.intercom.io/internal_articles/<id>. + */ + public CompletableFuture deleteInternalArticle( + DeleteInternalArticleRequest request, RequestOptions requestOptions) { + return this.rawClient.deleteInternalArticle(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can search for internal articles by making a GET request to https://api.intercom.io/internal_articles/search. + */ + public CompletableFuture searchInternalArticles() { + return this.rawClient.searchInternalArticles().thenApply(response -> response.body()); + } + + /** + * You can search for internal articles by making a GET request to https://api.intercom.io/internal_articles/search. + */ + public CompletableFuture searchInternalArticles( + SearchInternalArticlesRequest request) { + return this.rawClient.searchInternalArticles(request).thenApply(response -> response.body()); + } + + /** + * You can search for internal articles by making a GET request to https://api.intercom.io/internal_articles/search. + */ + public CompletableFuture searchInternalArticles( + SearchInternalArticlesRequest request, RequestOptions requestOptions) { + return this.rawClient.searchInternalArticles(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/intercom/api/resources/internalarticles/AsyncRawInternalArticlesClient.java b/src/main/java/com/intercom/api/resources/internalarticles/AsyncRawInternalArticlesClient.java new file mode 100644 index 0000000..69f51d7 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/internalarticles/AsyncRawInternalArticlesClient.java @@ -0,0 +1,525 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.internalarticles; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.QueryStringMapper; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.errors.BadRequestError; +import com.intercom.api.errors.NotFoundError; +import com.intercom.api.errors.UnauthorizedError; +import com.intercom.api.resources.internalarticles.requests.DeleteInternalArticleRequest; +import com.intercom.api.resources.internalarticles.requests.RetrieveInternalArticleRequest; +import com.intercom.api.resources.internalarticles.requests.SearchInternalArticlesRequest; +import com.intercom.api.resources.internalarticles.requests.UpdateInternalArticleRequestBody; +import com.intercom.api.resources.internalarticles.types.InternalArticleListItem; +import com.intercom.api.resources.internalarticles.types.InternalArticleSearchResponse; +import com.intercom.api.types.CreateInternalArticleRequest; +import com.intercom.api.types.DeletedInternalArticleObject; +import com.intercom.api.types.Error; +import com.intercom.api.types.InternalArticleList; +import java.io.IOException; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawInternalArticlesClient { + protected final ClientOptions clientOptions; + + public AsyncRawInternalArticlesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can fetch a list of all internal articles by making a GET request to https://api.intercom.io/internal_articles. + */ + public CompletableFuture> listInternalArticles() { + return listInternalArticles(null); + } + + /** + * You can fetch a list of all internal articles by making a GET request to https://api.intercom.io/internal_articles. + */ + public CompletableFuture> listInternalArticles( + RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("internal_articles") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), InternalArticleList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can create a new internal article by making a POST request to https://api.intercom.io/internal_articles. + */ + public CompletableFuture> createInternalArticle() { + return createInternalArticle(Optional.empty()); + } + + /** + * You can create a new internal article by making a POST request to https://api.intercom.io/internal_articles. + */ + public CompletableFuture> createInternalArticle( + Optional request) { + return createInternalArticle(request, null); + } + + /** + * You can create a new internal article by making a POST request to https://api.intercom.io/internal_articles. + */ + public CompletableFuture> createInternalArticle( + Optional request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("internal_articles") + .build(); + RequestBody body; + try { + body = RequestBody.create("", null); + if (request.isPresent()) { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), InternalArticleListItem.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can fetch the details of a single internal article by making a GET request to https://api.intercom.io/internal_articles/<id>. + */ + public CompletableFuture> retrieveInternalArticle( + RetrieveInternalArticleRequest request) { + return retrieveInternalArticle(request, null); + } + + /** + * You can fetch the details of a single internal article by making a GET request to https://api.intercom.io/internal_articles/<id>. + */ + public CompletableFuture> retrieveInternalArticle( + RetrieveInternalArticleRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("internal_articles") + .addPathSegment(Integer.toString(request.getInternalArticleId())) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), InternalArticleListItem.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can update the details of a single internal article by making a PUT request to https://api.intercom.io/internal_articles/<id>. + */ + public CompletableFuture> updateInternalArticle( + UpdateInternalArticleRequestBody request) { + return updateInternalArticle(request, null); + } + + /** + * You can update the details of a single internal article by making a PUT request to https://api.intercom.io/internal_articles/<id>. + */ + public CompletableFuture> updateInternalArticle( + UpdateInternalArticleRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("internal_articles") + .addPathSegment(Integer.toString(request.getInternalArticleId())) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), InternalArticleListItem.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can delete a single internal article by making a DELETE request to https://api.intercom.io/internal_articles/<id>. + */ + public CompletableFuture> deleteInternalArticle( + DeleteInternalArticleRequest request) { + return deleteInternalArticle(request, null); + } + + /** + * You can delete a single internal article by making a DELETE request to https://api.intercom.io/internal_articles/<id>. + */ + public CompletableFuture> deleteInternalArticle( + DeleteInternalArticleRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("internal_articles") + .addPathSegment(Integer.toString(request.getInternalArticleId())) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), DeletedInternalArticleObject.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can search for internal articles by making a GET request to https://api.intercom.io/internal_articles/search. + */ + public CompletableFuture> searchInternalArticles() { + return searchInternalArticles(SearchInternalArticlesRequest.builder().build()); + } + + /** + * You can search for internal articles by making a GET request to https://api.intercom.io/internal_articles/search. + */ + public CompletableFuture> searchInternalArticles( + SearchInternalArticlesRequest request) { + return searchInternalArticles(request, null); + } + + /** + * You can search for internal articles by making a GET request to https://api.intercom.io/internal_articles/search. + */ + public CompletableFuture> searchInternalArticles( + SearchInternalArticlesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("internal_articles/search"); + if (request.getFolderId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "folder_id", request.getFolderId().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), InternalArticleSearchResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/intercom/api/resources/internalarticles/InternalArticlesClient.java b/src/main/java/com/intercom/api/resources/internalarticles/InternalArticlesClient.java new file mode 100644 index 0000000..5eb9b9c --- /dev/null +++ b/src/main/java/com/intercom/api/resources/internalarticles/InternalArticlesClient.java @@ -0,0 +1,138 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.internalarticles; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.internalarticles.requests.DeleteInternalArticleRequest; +import com.intercom.api.resources.internalarticles.requests.RetrieveInternalArticleRequest; +import com.intercom.api.resources.internalarticles.requests.SearchInternalArticlesRequest; +import com.intercom.api.resources.internalarticles.requests.UpdateInternalArticleRequestBody; +import com.intercom.api.resources.internalarticles.types.InternalArticleListItem; +import com.intercom.api.resources.internalarticles.types.InternalArticleSearchResponse; +import com.intercom.api.types.CreateInternalArticleRequest; +import com.intercom.api.types.DeletedInternalArticleObject; +import com.intercom.api.types.InternalArticleList; +import java.util.Optional; + +public class InternalArticlesClient { + protected final ClientOptions clientOptions; + + private final RawInternalArticlesClient rawClient; + + public InternalArticlesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawInternalArticlesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawInternalArticlesClient withRawResponse() { + return this.rawClient; + } + + /** + * You can fetch a list of all internal articles by making a GET request to https://api.intercom.io/internal_articles. + */ + public InternalArticleList listInternalArticles() { + return this.rawClient.listInternalArticles().body(); + } + + /** + * You can fetch a list of all internal articles by making a GET request to https://api.intercom.io/internal_articles. + */ + public InternalArticleList listInternalArticles(RequestOptions requestOptions) { + return this.rawClient.listInternalArticles(requestOptions).body(); + } + + /** + * You can create a new internal article by making a POST request to https://api.intercom.io/internal_articles. + */ + public InternalArticleListItem createInternalArticle() { + return this.rawClient.createInternalArticle().body(); + } + + /** + * You can create a new internal article by making a POST request to https://api.intercom.io/internal_articles. + */ + public InternalArticleListItem createInternalArticle(Optional request) { + return this.rawClient.createInternalArticle(request).body(); + } + + /** + * You can create a new internal article by making a POST request to https://api.intercom.io/internal_articles. + */ + public InternalArticleListItem createInternalArticle( + Optional request, RequestOptions requestOptions) { + return this.rawClient.createInternalArticle(request, requestOptions).body(); + } + + /** + * You can fetch the details of a single internal article by making a GET request to https://api.intercom.io/internal_articles/<id>. + */ + public InternalArticleListItem retrieveInternalArticle(RetrieveInternalArticleRequest request) { + return this.rawClient.retrieveInternalArticle(request).body(); + } + + /** + * You can fetch the details of a single internal article by making a GET request to https://api.intercom.io/internal_articles/<id>. + */ + public InternalArticleListItem retrieveInternalArticle( + RetrieveInternalArticleRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieveInternalArticle(request, requestOptions).body(); + } + + /** + * You can update the details of a single internal article by making a PUT request to https://api.intercom.io/internal_articles/<id>. + */ + public InternalArticleListItem updateInternalArticle(UpdateInternalArticleRequestBody request) { + return this.rawClient.updateInternalArticle(request).body(); + } + + /** + * You can update the details of a single internal article by making a PUT request to https://api.intercom.io/internal_articles/<id>. + */ + public InternalArticleListItem updateInternalArticle( + UpdateInternalArticleRequestBody request, RequestOptions requestOptions) { + return this.rawClient.updateInternalArticle(request, requestOptions).body(); + } + + /** + * You can delete a single internal article by making a DELETE request to https://api.intercom.io/internal_articles/<id>. + */ + public DeletedInternalArticleObject deleteInternalArticle(DeleteInternalArticleRequest request) { + return this.rawClient.deleteInternalArticle(request).body(); + } + + /** + * You can delete a single internal article by making a DELETE request to https://api.intercom.io/internal_articles/<id>. + */ + public DeletedInternalArticleObject deleteInternalArticle( + DeleteInternalArticleRequest request, RequestOptions requestOptions) { + return this.rawClient.deleteInternalArticle(request, requestOptions).body(); + } + + /** + * You can search for internal articles by making a GET request to https://api.intercom.io/internal_articles/search. + */ + public InternalArticleSearchResponse searchInternalArticles() { + return this.rawClient.searchInternalArticles().body(); + } + + /** + * You can search for internal articles by making a GET request to https://api.intercom.io/internal_articles/search. + */ + public InternalArticleSearchResponse searchInternalArticles(SearchInternalArticlesRequest request) { + return this.rawClient.searchInternalArticles(request).body(); + } + + /** + * You can search for internal articles by making a GET request to https://api.intercom.io/internal_articles/search. + */ + public InternalArticleSearchResponse searchInternalArticles( + SearchInternalArticlesRequest request, RequestOptions requestOptions) { + return this.rawClient.searchInternalArticles(request, requestOptions).body(); + } +} diff --git a/src/main/java/com/intercom/api/resources/internalarticles/RawInternalArticlesClient.java b/src/main/java/com/intercom/api/resources/internalarticles/RawInternalArticlesClient.java new file mode 100644 index 0000000..ae0ac2b --- /dev/null +++ b/src/main/java/com/intercom/api/resources/internalarticles/RawInternalArticlesClient.java @@ -0,0 +1,419 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.internalarticles; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.QueryStringMapper; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.errors.BadRequestError; +import com.intercom.api.errors.NotFoundError; +import com.intercom.api.errors.UnauthorizedError; +import com.intercom.api.resources.internalarticles.requests.DeleteInternalArticleRequest; +import com.intercom.api.resources.internalarticles.requests.RetrieveInternalArticleRequest; +import com.intercom.api.resources.internalarticles.requests.SearchInternalArticlesRequest; +import com.intercom.api.resources.internalarticles.requests.UpdateInternalArticleRequestBody; +import com.intercom.api.resources.internalarticles.types.InternalArticleListItem; +import com.intercom.api.resources.internalarticles.types.InternalArticleSearchResponse; +import com.intercom.api.types.CreateInternalArticleRequest; +import com.intercom.api.types.DeletedInternalArticleObject; +import com.intercom.api.types.Error; +import com.intercom.api.types.InternalArticleList; +import java.io.IOException; +import java.util.Optional; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawInternalArticlesClient { + protected final ClientOptions clientOptions; + + public RawInternalArticlesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can fetch a list of all internal articles by making a GET request to https://api.intercom.io/internal_articles. + */ + public IntercomHttpResponse listInternalArticles() { + return listInternalArticles(null); + } + + /** + * You can fetch a list of all internal articles by making a GET request to https://api.intercom.io/internal_articles. + */ + public IntercomHttpResponse listInternalArticles(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("internal_articles") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), InternalArticleList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can create a new internal article by making a POST request to https://api.intercom.io/internal_articles. + */ + public IntercomHttpResponse createInternalArticle() { + return createInternalArticle(Optional.empty()); + } + + /** + * You can create a new internal article by making a POST request to https://api.intercom.io/internal_articles. + */ + public IntercomHttpResponse createInternalArticle( + Optional request) { + return createInternalArticle(request, null); + } + + /** + * You can create a new internal article by making a POST request to https://api.intercom.io/internal_articles. + */ + public IntercomHttpResponse createInternalArticle( + Optional request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("internal_articles") + .build(); + RequestBody body; + try { + body = RequestBody.create("", null); + if (request.isPresent()) { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), InternalArticleListItem.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can fetch the details of a single internal article by making a GET request to https://api.intercom.io/internal_articles/<id>. + */ + public IntercomHttpResponse retrieveInternalArticle( + RetrieveInternalArticleRequest request) { + return retrieveInternalArticle(request, null); + } + + /** + * You can fetch the details of a single internal article by making a GET request to https://api.intercom.io/internal_articles/<id>. + */ + public IntercomHttpResponse retrieveInternalArticle( + RetrieveInternalArticleRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("internal_articles") + .addPathSegment(Integer.toString(request.getInternalArticleId())) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), InternalArticleListItem.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can update the details of a single internal article by making a PUT request to https://api.intercom.io/internal_articles/<id>. + */ + public IntercomHttpResponse updateInternalArticle( + UpdateInternalArticleRequestBody request) { + return updateInternalArticle(request, null); + } + + /** + * You can update the details of a single internal article by making a PUT request to https://api.intercom.io/internal_articles/<id>. + */ + public IntercomHttpResponse updateInternalArticle( + UpdateInternalArticleRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("internal_articles") + .addPathSegment(Integer.toString(request.getInternalArticleId())) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), InternalArticleListItem.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can delete a single internal article by making a DELETE request to https://api.intercom.io/internal_articles/<id>. + */ + public IntercomHttpResponse deleteInternalArticle( + DeleteInternalArticleRequest request) { + return deleteInternalArticle(request, null); + } + + /** + * You can delete a single internal article by making a DELETE request to https://api.intercom.io/internal_articles/<id>. + */ + public IntercomHttpResponse deleteInternalArticle( + DeleteInternalArticleRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("internal_articles") + .addPathSegment(Integer.toString(request.getInternalArticleId())) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeletedInternalArticleObject.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can search for internal articles by making a GET request to https://api.intercom.io/internal_articles/search. + */ + public IntercomHttpResponse searchInternalArticles() { + return searchInternalArticles(SearchInternalArticlesRequest.builder().build()); + } + + /** + * You can search for internal articles by making a GET request to https://api.intercom.io/internal_articles/search. + */ + public IntercomHttpResponse searchInternalArticles( + SearchInternalArticlesRequest request) { + return searchInternalArticles(request, null); + } + + /** + * You can search for internal articles by making a GET request to https://api.intercom.io/internal_articles/search. + */ + public IntercomHttpResponse searchInternalArticles( + SearchInternalArticlesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("internal_articles/search"); + if (request.getFolderId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "folder_id", request.getFolderId().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), InternalArticleSearchResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/internalarticles/requests/DeleteInternalArticleRequest.java b/src/main/java/com/intercom/api/resources/internalarticles/requests/DeleteInternalArticleRequest.java new file mode 100644 index 0000000..d8c2745 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/internalarticles/requests/DeleteInternalArticleRequest.java @@ -0,0 +1,111 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.internalarticles.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = DeleteInternalArticleRequest.Builder.class) +public final class DeleteInternalArticleRequest { + private final int internalArticleId; + + private final Map additionalProperties; + + private DeleteInternalArticleRequest(int internalArticleId, Map additionalProperties) { + this.internalArticleId = internalArticleId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the internal article which is given by Intercom. + */ + @JsonProperty("internal_article_id") + public int getInternalArticleId() { + return internalArticleId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeleteInternalArticleRequest && equalTo((DeleteInternalArticleRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeleteInternalArticleRequest other) { + return internalArticleId == other.internalArticleId; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.internalArticleId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static InternalArticleIdStage builder() { + return new Builder(); + } + + public interface InternalArticleIdStage { + /** + * The unique identifier for the internal article which is given by Intercom. + */ + _FinalStage internalArticleId(int internalArticleId); + + Builder from(DeleteInternalArticleRequest other); + } + + public interface _FinalStage { + DeleteInternalArticleRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements InternalArticleIdStage, _FinalStage { + private int internalArticleId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DeleteInternalArticleRequest other) { + internalArticleId(other.getInternalArticleId()); + return this; + } + + /** + * The unique identifier for the internal article which is given by Intercom.

    The unique identifier for the internal article which is given by Intercom.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("internal_article_id") + public _FinalStage internalArticleId(int internalArticleId) { + this.internalArticleId = internalArticleId; + return this; + } + + @java.lang.Override + public DeleteInternalArticleRequest build() { + return new DeleteInternalArticleRequest(internalArticleId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/internalarticles/requests/RetrieveInternalArticleRequest.java b/src/main/java/com/intercom/api/resources/internalarticles/requests/RetrieveInternalArticleRequest.java new file mode 100644 index 0000000..e92eb21 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/internalarticles/requests/RetrieveInternalArticleRequest.java @@ -0,0 +1,111 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.internalarticles.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = RetrieveInternalArticleRequest.Builder.class) +public final class RetrieveInternalArticleRequest { + private final int internalArticleId; + + private final Map additionalProperties; + + private RetrieveInternalArticleRequest(int internalArticleId, Map additionalProperties) { + this.internalArticleId = internalArticleId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the article which is given by Intercom. + */ + @JsonProperty("internal_article_id") + public int getInternalArticleId() { + return internalArticleId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof RetrieveInternalArticleRequest && equalTo((RetrieveInternalArticleRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(RetrieveInternalArticleRequest other) { + return internalArticleId == other.internalArticleId; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.internalArticleId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static InternalArticleIdStage builder() { + return new Builder(); + } + + public interface InternalArticleIdStage { + /** + * The unique identifier for the article which is given by Intercom. + */ + _FinalStage internalArticleId(int internalArticleId); + + Builder from(RetrieveInternalArticleRequest other); + } + + public interface _FinalStage { + RetrieveInternalArticleRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements InternalArticleIdStage, _FinalStage { + private int internalArticleId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(RetrieveInternalArticleRequest other) { + internalArticleId(other.getInternalArticleId()); + return this; + } + + /** + * The unique identifier for the article which is given by Intercom.

    The unique identifier for the article which is given by Intercom.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("internal_article_id") + public _FinalStage internalArticleId(int internalArticleId) { + this.internalArticleId = internalArticleId; + return this; + } + + @java.lang.Override + public RetrieveInternalArticleRequest build() { + return new RetrieveInternalArticleRequest(internalArticleId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/types/DataTableComponent.java b/src/main/java/com/intercom/api/resources/internalarticles/requests/SearchInternalArticlesRequest.java similarity index 52% rename from src/main/java/com/intercom/api/types/DataTableComponent.java rename to src/main/java/com/intercom/api/resources/internalarticles/requests/SearchInternalArticlesRequest.java index 17248fc..ce6c476 100644 --- a/src/main/java/com/intercom/api/types/DataTableComponent.java +++ b/src/main/java/com/intercom/api/resources/internalarticles/requests/SearchInternalArticlesRequest.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.intercom.api.types; +package com.intercom.api.resources.internalarticles.requests; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; @@ -12,36 +12,35 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.intercom.api.core.ObjectMappers; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.Optional; @JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = DataTableComponent.Builder.class) -public final class DataTableComponent { - private final List items; +@JsonDeserialize(builder = SearchInternalArticlesRequest.Builder.class) +public final class SearchInternalArticlesRequest { + private final Optional folderId; private final Map additionalProperties; - private DataTableComponent(List items, Map additionalProperties) { - this.items = items; + private SearchInternalArticlesRequest(Optional folderId, Map additionalProperties) { + this.folderId = folderId; this.additionalProperties = additionalProperties; } /** - * @return The items that will be rendered in the data-table. + * @return The ID of the folder to search in. */ - @JsonProperty("items") - public List getItems() { - return items; + @JsonProperty("folder_id") + public Optional getFolderId() { + return folderId; } @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof DataTableComponent && equalTo((DataTableComponent) other); + return other instanceof SearchInternalArticlesRequest && equalTo((SearchInternalArticlesRequest) other); } @JsonAnyGetter @@ -49,13 +48,13 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(DataTableComponent other) { - return items.equals(other.items); + private boolean equalTo(SearchInternalArticlesRequest other) { + return folderId.equals(other.folderId); } @java.lang.Override public int hashCode() { - return Objects.hash(this.items); + return Objects.hash(this.folderId); } @java.lang.Override @@ -69,40 +68,34 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private List items = new ArrayList<>(); + private Optional folderId = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} - public Builder from(DataTableComponent other) { - items(other.getItems()); + public Builder from(SearchInternalArticlesRequest other) { + folderId(other.getFolderId()); return this; } /** - *

    The items that will be rendered in the data-table.

    + *

    The ID of the folder to search in.

    */ - @JsonSetter(value = "items", nulls = Nulls.SKIP) - public Builder items(List items) { - this.items.clear(); - this.items.addAll(items); + @JsonSetter(value = "folder_id", nulls = Nulls.SKIP) + public Builder folderId(Optional folderId) { + this.folderId = folderId; return this; } - public Builder addItems(DataTableItem items) { - this.items.add(items); + public Builder folderId(String folderId) { + this.folderId = Optional.ofNullable(folderId); return this; } - public Builder addAllItems(List items) { - this.items.addAll(items); - return this; - } - - public DataTableComponent build() { - return new DataTableComponent(items, additionalProperties); + public SearchInternalArticlesRequest build() { + return new SearchInternalArticlesRequest(folderId, additionalProperties); } } } diff --git a/src/main/java/com/intercom/api/resources/internalarticles/requests/UpdateInternalArticleRequestBody.java b/src/main/java/com/intercom/api/resources/internalarticles/requests/UpdateInternalArticleRequestBody.java new file mode 100644 index 0000000..81a3bf1 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/internalarticles/requests/UpdateInternalArticleRequestBody.java @@ -0,0 +1,288 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.internalarticles.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = UpdateInternalArticleRequestBody.Builder.class) +public final class UpdateInternalArticleRequestBody { + private final int internalArticleId; + + private final Optional title; + + private final Optional body; + + private final Optional authorId; + + private final Optional ownerId; + + private final Map additionalProperties; + + private UpdateInternalArticleRequestBody( + int internalArticleId, + Optional title, + Optional body, + Optional authorId, + Optional ownerId, + Map additionalProperties) { + this.internalArticleId = internalArticleId; + this.title = title; + this.body = body; + this.authorId = authorId; + this.ownerId = ownerId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the internal article which is given by Intercom. + */ + @JsonProperty("internal_article_id") + public int getInternalArticleId() { + return internalArticleId; + } + + /** + * @return The title of the article. + */ + @JsonProperty("title") + public Optional getTitle() { + return title; + } + + /** + * @return The content of the article. + */ + @JsonProperty("body") + public Optional getBody() { + return body; + } + + /** + * @return The id of the author of the article. + */ + @JsonProperty("author_id") + public Optional getAuthorId() { + return authorId; + } + + /** + * @return The id of the author of the article. + */ + @JsonProperty("owner_id") + public Optional getOwnerId() { + return ownerId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UpdateInternalArticleRequestBody && equalTo((UpdateInternalArticleRequestBody) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UpdateInternalArticleRequestBody other) { + return internalArticleId == other.internalArticleId + && title.equals(other.title) + && body.equals(other.body) + && authorId.equals(other.authorId) + && ownerId.equals(other.ownerId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.internalArticleId, this.title, this.body, this.authorId, this.ownerId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static InternalArticleIdStage builder() { + return new Builder(); + } + + public interface InternalArticleIdStage { + /** + * The unique identifier for the internal article which is given by Intercom. + */ + _FinalStage internalArticleId(int internalArticleId); + + Builder from(UpdateInternalArticleRequestBody other); + } + + public interface _FinalStage { + UpdateInternalArticleRequestBody build(); + + /** + *

    The title of the article.

    + */ + _FinalStage title(Optional title); + + _FinalStage title(String title); + + /** + *

    The content of the article.

    + */ + _FinalStage body(Optional body); + + _FinalStage body(String body); + + /** + *

    The id of the author of the article.

    + */ + _FinalStage authorId(Optional authorId); + + _FinalStage authorId(Integer authorId); + + /** + *

    The id of the author of the article.

    + */ + _FinalStage ownerId(Optional ownerId); + + _FinalStage ownerId(Integer ownerId); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements InternalArticleIdStage, _FinalStage { + private int internalArticleId; + + private Optional ownerId = Optional.empty(); + + private Optional authorId = Optional.empty(); + + private Optional body = Optional.empty(); + + private Optional title = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(UpdateInternalArticleRequestBody other) { + internalArticleId(other.getInternalArticleId()); + title(other.getTitle()); + body(other.getBody()); + authorId(other.getAuthorId()); + ownerId(other.getOwnerId()); + return this; + } + + /** + * The unique identifier for the internal article which is given by Intercom.

    The unique identifier for the internal article which is given by Intercom.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("internal_article_id") + public _FinalStage internalArticleId(int internalArticleId) { + this.internalArticleId = internalArticleId; + return this; + } + + /** + *

    The id of the author of the article.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage ownerId(Integer ownerId) { + this.ownerId = Optional.ofNullable(ownerId); + return this; + } + + /** + *

    The id of the author of the article.

    + */ + @java.lang.Override + @JsonSetter(value = "owner_id", nulls = Nulls.SKIP) + public _FinalStage ownerId(Optional ownerId) { + this.ownerId = ownerId; + return this; + } + + /** + *

    The id of the author of the article.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage authorId(Integer authorId) { + this.authorId = Optional.ofNullable(authorId); + return this; + } + + /** + *

    The id of the author of the article.

    + */ + @java.lang.Override + @JsonSetter(value = "author_id", nulls = Nulls.SKIP) + public _FinalStage authorId(Optional authorId) { + this.authorId = authorId; + return this; + } + + /** + *

    The content of the article.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage body(String body) { + this.body = Optional.ofNullable(body); + return this; + } + + /** + *

    The content of the article.

    + */ + @java.lang.Override + @JsonSetter(value = "body", nulls = Nulls.SKIP) + public _FinalStage body(Optional body) { + this.body = body; + return this; + } + + /** + *

    The title of the article.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage title(String title) { + this.title = Optional.ofNullable(title); + return this; + } + + /** + *

    The title of the article.

    + */ + @java.lang.Override + @JsonSetter(value = "title", nulls = Nulls.SKIP) + public _FinalStage title(Optional title) { + this.title = title; + return this; + } + + @java.lang.Override + public UpdateInternalArticleRequestBody build() { + return new UpdateInternalArticleRequestBody( + internalArticleId, title, body, authorId, ownerId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/internalarticles/types/InternalArticleListItem.java b/src/main/java/com/intercom/api/resources/internalarticles/types/InternalArticleListItem.java new file mode 100644 index 0000000..e08b939 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/internalarticles/types/InternalArticleListItem.java @@ -0,0 +1,353 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.internalarticles.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = InternalArticleListItem.Builder.class) +public final class InternalArticleListItem { + private final Optional type; + + private final Optional id; + + private final Optional title; + + private final Optional body; + + private final Optional ownerId; + + private final Optional authorId; + + private final Optional createdAt; + + private final Optional updatedAt; + + private final Optional locale; + + private final Map additionalProperties; + + private InternalArticleListItem( + Optional type, + Optional id, + Optional title, + Optional body, + Optional ownerId, + Optional authorId, + Optional createdAt, + Optional updatedAt, + Optional locale, + Map additionalProperties) { + this.type = type; + this.id = id; + this.title = title; + this.body = body; + this.ownerId = ownerId; + this.authorId = authorId; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.locale = locale; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of object - internal_article. + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return The unique identifier for the article which is given by Intercom. + */ + @JsonProperty("id") + public Optional getId() { + return id; + } + + /** + * @return The title of the article. + */ + @JsonProperty("title") + public Optional getTitle() { + return title; + } + + /** + * @return The body of the article in HTML. + */ + @JsonProperty("body") + public Optional getBody() { + return body; + } + + /** + * @return The id of the owner of the article. + */ + @JsonProperty("owner_id") + public Optional getOwnerId() { + return ownerId; + } + + /** + * @return The id of the author of the article. + */ + @JsonProperty("author_id") + public Optional getAuthorId() { + return authorId; + } + + /** + * @return The time when the article was created. + */ + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + /** + * @return The time when the article was last updated. + */ + @JsonProperty("updated_at") + public Optional getUpdatedAt() { + return updatedAt; + } + + /** + * @return The default locale of the article. + */ + @JsonProperty("locale") + public Optional getLocale() { + return locale; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof InternalArticleListItem && equalTo((InternalArticleListItem) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(InternalArticleListItem other) { + return type.equals(other.type) + && id.equals(other.id) + && title.equals(other.title) + && body.equals(other.body) + && ownerId.equals(other.ownerId) + && authorId.equals(other.authorId) + && createdAt.equals(other.createdAt) + && updatedAt.equals(other.updatedAt) + && locale.equals(other.locale); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.type, + this.id, + this.title, + this.body, + this.ownerId, + this.authorId, + this.createdAt, + this.updatedAt, + this.locale); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); + + private Optional id = Optional.empty(); + + private Optional title = Optional.empty(); + + private Optional body = Optional.empty(); + + private Optional ownerId = Optional.empty(); + + private Optional authorId = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + private Optional updatedAt = Optional.empty(); + + private Optional locale = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(InternalArticleListItem other) { + type(other.getType()); + id(other.getId()); + title(other.getTitle()); + body(other.getBody()); + ownerId(other.getOwnerId()); + authorId(other.getAuthorId()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + locale(other.getLocale()); + return this; + } + + /** + *

    The type of object - internal_article.

    + */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + /** + *

    The unique identifier for the article which is given by Intercom.

    + */ + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.ofNullable(id); + return this; + } + + /** + *

    The title of the article.

    + */ + @JsonSetter(value = "title", nulls = Nulls.SKIP) + public Builder title(Optional title) { + this.title = title; + return this; + } + + public Builder title(String title) { + this.title = Optional.ofNullable(title); + return this; + } + + /** + *

    The body of the article in HTML.

    + */ + @JsonSetter(value = "body", nulls = Nulls.SKIP) + public Builder body(Optional body) { + this.body = body; + return this; + } + + public Builder body(String body) { + this.body = Optional.ofNullable(body); + return this; + } + + /** + *

    The id of the owner of the article.

    + */ + @JsonSetter(value = "owner_id", nulls = Nulls.SKIP) + public Builder ownerId(Optional ownerId) { + this.ownerId = ownerId; + return this; + } + + public Builder ownerId(Integer ownerId) { + this.ownerId = Optional.ofNullable(ownerId); + return this; + } + + /** + *

    The id of the author of the article.

    + */ + @JsonSetter(value = "author_id", nulls = Nulls.SKIP) + public Builder authorId(Optional authorId) { + this.authorId = authorId; + return this; + } + + public Builder authorId(Integer authorId) { + this.authorId = Optional.ofNullable(authorId); + return this; + } + + /** + *

    The time when the article was created.

    + */ + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public Builder createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + public Builder createdAt(Integer createdAt) { + this.createdAt = Optional.ofNullable(createdAt); + return this; + } + + /** + *

    The time when the article was last updated.

    + */ + @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) + public Builder updatedAt(Optional updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + public Builder updatedAt(Integer updatedAt) { + this.updatedAt = Optional.ofNullable(updatedAt); + return this; + } + + /** + *

    The default locale of the article.

    + */ + @JsonSetter(value = "locale", nulls = Nulls.SKIP) + public Builder locale(Optional locale) { + this.locale = locale; + return this; + } + + public Builder locale(String locale) { + this.locale = Optional.ofNullable(locale); + return this; + } + + public InternalArticleListItem build() { + return new InternalArticleListItem( + type, id, title, body, ownerId, authorId, createdAt, updatedAt, locale, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/internalarticles/types/InternalArticleSearchResponse.java b/src/main/java/com/intercom/api/resources/internalarticles/types/InternalArticleSearchResponse.java new file mode 100644 index 0000000..7bf51bd --- /dev/null +++ b/src/main/java/com/intercom/api/resources/internalarticles/types/InternalArticleSearchResponse.java @@ -0,0 +1,273 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.internalarticles.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.types.CursorPages; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = InternalArticleSearchResponse.Builder.class) +public final class InternalArticleSearchResponse { + private final Optional type; + + private final Optional totalCount; + + private final Optional data; + + private final Optional pages; + + private final Map additionalProperties; + + private InternalArticleSearchResponse( + Optional type, + Optional totalCount, + Optional data, + Optional pages, + Map additionalProperties) { + this.type = type; + this.totalCount = totalCount; + this.data = data; + this.pages = pages; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of the object - list. + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return The total number of Internal Articles matching the search query + */ + @JsonProperty("total_count") + public Optional getTotalCount() { + return totalCount; + } + + /** + * @return An object containing the results of the search. + */ + @JsonProperty("data") + public Optional getData() { + return data; + } + + @JsonProperty("pages") + public Optional getPages() { + return pages; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof InternalArticleSearchResponse && equalTo((InternalArticleSearchResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(InternalArticleSearchResponse other) { + return type.equals(other.type) + && totalCount.equals(other.totalCount) + && data.equals(other.data) + && pages.equals(other.pages); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.totalCount, this.data, this.pages); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); + + private Optional totalCount = Optional.empty(); + + private Optional data = Optional.empty(); + + private Optional pages = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(InternalArticleSearchResponse other) { + type(other.getType()); + totalCount(other.getTotalCount()); + data(other.getData()); + pages(other.getPages()); + return this; + } + + /** + *

    The type of the object - list.

    + */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + /** + *

    The total number of Internal Articles matching the search query

    + */ + @JsonSetter(value = "total_count", nulls = Nulls.SKIP) + public Builder totalCount(Optional totalCount) { + this.totalCount = totalCount; + return this; + } + + public Builder totalCount(Integer totalCount) { + this.totalCount = Optional.ofNullable(totalCount); + return this; + } + + /** + *

    An object containing the results of the search.

    + */ + @JsonSetter(value = "data", nulls = Nulls.SKIP) + public Builder data(Optional data) { + this.data = data; + return this; + } + + public Builder data(Data data) { + this.data = Optional.ofNullable(data); + return this; + } + + @JsonSetter(value = "pages", nulls = Nulls.SKIP) + public Builder pages(Optional pages) { + this.pages = pages; + return this; + } + + public Builder pages(CursorPages pages) { + this.pages = Optional.ofNullable(pages); + return this; + } + + public InternalArticleSearchResponse build() { + return new InternalArticleSearchResponse(type, totalCount, data, pages, additionalProperties); + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = Data.Builder.class) + public static final class Data { + private final Optional> internalArticles; + + private final Map additionalProperties; + + private Data( + Optional> internalArticles, Map additionalProperties) { + this.internalArticles = internalArticles; + this.additionalProperties = additionalProperties; + } + + /** + * @return An array of Internal Article objects + */ + @JsonProperty("internal_articles") + public Optional> getInternalArticles() { + return internalArticles; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Data && equalTo((Data) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Data other) { + return internalArticles.equals(other.internalArticles); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.internalArticles); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional> internalArticles = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(Data other) { + internalArticles(other.getInternalArticles()); + return this; + } + + /** + *

    An array of Internal Article objects

    + */ + @JsonSetter(value = "internal_articles", nulls = Nulls.SKIP) + public Builder internalArticles(Optional> internalArticles) { + this.internalArticles = internalArticles; + return this; + } + + public Builder internalArticles(List internalArticles) { + this.internalArticles = Optional.ofNullable(internalArticles); + return this; + } + + public Data build() { + return new Data(internalArticles, additionalProperties); + } + } + } +} diff --git a/src/main/java/com/intercom/api/resources/jobs/AsyncJobsClient.java b/src/main/java/com/intercom/api/resources/jobs/AsyncJobsClient.java new file mode 100644 index 0000000..093d4fc --- /dev/null +++ b/src/main/java/com/intercom/api/resources/jobs/AsyncJobsClient.java @@ -0,0 +1,42 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.jobs; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.jobs.requests.JobsStatusRequest; +import com.intercom.api.resources.jobs.types.Jobs; +import java.util.concurrent.CompletableFuture; + +public class AsyncJobsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawJobsClient rawClient; + + public AsyncJobsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawJobsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawJobsClient withRawResponse() { + return this.rawClient; + } + + /** + * Retrieve the status of job execution. + */ + public CompletableFuture status(JobsStatusRequest request) { + return this.rawClient.status(request).thenApply(response -> response.body()); + } + + /** + * Retrieve the status of job execution. + */ + public CompletableFuture status(JobsStatusRequest request, RequestOptions requestOptions) { + return this.rawClient.status(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/intercom/api/resources/jobs/AsyncRawJobsClient.java b/src/main/java/com/intercom/api/resources/jobs/AsyncRawJobsClient.java new file mode 100644 index 0000000..9b98b90 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/jobs/AsyncRawJobsClient.java @@ -0,0 +1,110 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.jobs; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.errors.NotFoundError; +import com.intercom.api.errors.UnauthorizedError; +import com.intercom.api.resources.jobs.requests.JobsStatusRequest; +import com.intercom.api.resources.jobs.types.Jobs; +import com.intercom.api.types.Error; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawJobsClient { + protected final ClientOptions clientOptions; + + public AsyncRawJobsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Retrieve the status of job execution. + */ + public CompletableFuture> status(JobsStatusRequest request) { + return status(request, null); + } + + /** + * Retrieve the status of job execution. + */ + public CompletableFuture> status( + JobsStatusRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("jobs/status") + .addPathSegment(request.getJobId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Jobs.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/intercom/api/resources/jobs/JobsClient.java b/src/main/java/com/intercom/api/resources/jobs/JobsClient.java new file mode 100644 index 0000000..23576e4 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/jobs/JobsClient.java @@ -0,0 +1,41 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.jobs; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.jobs.requests.JobsStatusRequest; +import com.intercom.api.resources.jobs.types.Jobs; + +public class JobsClient { + protected final ClientOptions clientOptions; + + private final RawJobsClient rawClient; + + public JobsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawJobsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawJobsClient withRawResponse() { + return this.rawClient; + } + + /** + * Retrieve the status of job execution. + */ + public Jobs status(JobsStatusRequest request) { + return this.rawClient.status(request).body(); + } + + /** + * Retrieve the status of job execution. + */ + public Jobs status(JobsStatusRequest request, RequestOptions requestOptions) { + return this.rawClient.status(request, requestOptions).body(); + } +} diff --git a/src/main/java/com/intercom/api/resources/jobs/RawJobsClient.java b/src/main/java/com/intercom/api/resources/jobs/RawJobsClient.java new file mode 100644 index 0000000..471c4d1 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/jobs/RawJobsClient.java @@ -0,0 +1,88 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.jobs; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.errors.NotFoundError; +import com.intercom.api.errors.UnauthorizedError; +import com.intercom.api.resources.jobs.requests.JobsStatusRequest; +import com.intercom.api.resources.jobs.types.Jobs; +import com.intercom.api.types.Error; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawJobsClient { + protected final ClientOptions clientOptions; + + public RawJobsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Retrieve the status of job execution. + */ + public IntercomHttpResponse status(JobsStatusRequest request) { + return status(request, null); + } + + /** + * Retrieve the status of job execution. + */ + public IntercomHttpResponse status(JobsStatusRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("jobs/status") + .addPathSegment(request.getJobId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Jobs.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/jobs/requests/JobsStatusRequest.java b/src/main/java/com/intercom/api/resources/jobs/requests/JobsStatusRequest.java new file mode 100644 index 0000000..a57291f --- /dev/null +++ b/src/main/java/com/intercom/api/resources/jobs/requests/JobsStatusRequest.java @@ -0,0 +1,112 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.jobs.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = JobsStatusRequest.Builder.class) +public final class JobsStatusRequest { + private final String jobId; + + private final Map additionalProperties; + + private JobsStatusRequest(String jobId, Map additionalProperties) { + this.jobId = jobId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the job which is given by Intercom + */ + @JsonProperty("job_id") + public String getJobId() { + return jobId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof JobsStatusRequest && equalTo((JobsStatusRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(JobsStatusRequest other) { + return jobId.equals(other.jobId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.jobId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static JobIdStage builder() { + return new Builder(); + } + + public interface JobIdStage { + /** + * The unique identifier for the job which is given by Intercom + */ + _FinalStage jobId(@NotNull String jobId); + + Builder from(JobsStatusRequest other); + } + + public interface _FinalStage { + JobsStatusRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements JobIdStage, _FinalStage { + private String jobId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(JobsStatusRequest other) { + jobId(other.getJobId()); + return this; + } + + /** + * The unique identifier for the job which is given by Intercom

    The unique identifier for the job which is given by Intercom

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("job_id") + public _FinalStage jobId(@NotNull String jobId) { + this.jobId = Objects.requireNonNull(jobId, "jobId must not be null"); + return this; + } + + @java.lang.Override + public JobsStatusRequest build() { + return new JobsStatusRequest(jobId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/jobs/types/Jobs.java b/src/main/java/com/intercom/api/resources/jobs/types/Jobs.java new file mode 100644 index 0000000..7c1e23f --- /dev/null +++ b/src/main/java/com/intercom/api/resources/jobs/types/Jobs.java @@ -0,0 +1,462 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.jobs.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = Jobs.Builder.class) +public final class Jobs { + private final Optional type; + + private final String id; + + private final Optional url; + + private final Optional status; + + private final Optional resourceType; + + private final Optional resourceId; + + private final Optional resourceUrl; + + private final Map additionalProperties; + + private Jobs( + Optional type, + String id, + Optional url, + Optional status, + Optional resourceType, + Optional resourceId, + Optional resourceUrl, + Map additionalProperties) { + this.type = type; + this.id = id; + this.url = url; + this.status = status; + this.resourceType = resourceType; + this.resourceId = resourceId; + this.resourceUrl = resourceUrl; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of the object + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return The id of the job that's currently being processed or has completed. + */ + @JsonProperty("id") + public String getId() { + return id; + } + + /** + * @return API endpoint URL to check the job status. + */ + @JsonProperty("url") + public Optional getUrl() { + return url; + } + + /** + * @return The status of the job execution. + */ + @JsonProperty("status") + public Optional getStatus() { + return status; + } + + /** + * @return The type of resource created during job execution. + */ + @JsonProperty("resource_type") + public Optional getResourceType() { + return resourceType; + } + + /** + * @return The id of the resource created during job execution (e.g. ticket id) + */ + @JsonProperty("resource_id") + public Optional getResourceId() { + return resourceId; + } + + /** + * @return The url of the resource created during job exeuction. Use this url to fetch the resource. + */ + @JsonProperty("resource_url") + public Optional getResourceUrl() { + return resourceUrl; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Jobs && equalTo((Jobs) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Jobs other) { + return type.equals(other.type) + && id.equals(other.id) + && url.equals(other.url) + && status.equals(other.status) + && resourceType.equals(other.resourceType) + && resourceId.equals(other.resourceId) + && resourceUrl.equals(other.resourceUrl); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.type, this.id, this.url, this.status, this.resourceType, this.resourceId, this.resourceUrl); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * The id of the job that's currently being processed or has completed. + */ + _FinalStage id(@NotNull String id); + + Builder from(Jobs other); + } + + public interface _FinalStage { + Jobs build(); + + /** + *

    The type of the object

    + */ + _FinalStage type(Optional type); + + _FinalStage type(String type); + + /** + *

    API endpoint URL to check the job status.

    + */ + _FinalStage url(Optional url); + + _FinalStage url(String url); + + /** + *

    The status of the job execution.

    + */ + _FinalStage status(Optional status); + + _FinalStage status(Status status); + + /** + *

    The type of resource created during job execution.

    + */ + _FinalStage resourceType(Optional resourceType); + + _FinalStage resourceType(String resourceType); + + /** + *

    The id of the resource created during job execution (e.g. ticket id)

    + */ + _FinalStage resourceId(Optional resourceId); + + _FinalStage resourceId(String resourceId); + + /** + *

    The url of the resource created during job exeuction. Use this url to fetch the resource.

    + */ + _FinalStage resourceUrl(Optional resourceUrl); + + _FinalStage resourceUrl(String resourceUrl); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, _FinalStage { + private String id; + + private Optional resourceUrl = Optional.empty(); + + private Optional resourceId = Optional.empty(); + + private Optional resourceType = Optional.empty(); + + private Optional status = Optional.empty(); + + private Optional url = Optional.empty(); + + private Optional type = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(Jobs other) { + type(other.getType()); + id(other.getId()); + url(other.getUrl()); + status(other.getStatus()); + resourceType(other.getResourceType()); + resourceId(other.getResourceId()); + resourceUrl(other.getResourceUrl()); + return this; + } + + /** + * The id of the job that's currently being processed or has completed.

    The id of the job that's currently being processed or has completed.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + /** + *

    The url of the resource created during job exeuction. Use this url to fetch the resource.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage resourceUrl(String resourceUrl) { + this.resourceUrl = Optional.ofNullable(resourceUrl); + return this; + } + + /** + *

    The url of the resource created during job exeuction. Use this url to fetch the resource.

    + */ + @java.lang.Override + @JsonSetter(value = "resource_url", nulls = Nulls.SKIP) + public _FinalStage resourceUrl(Optional resourceUrl) { + this.resourceUrl = resourceUrl; + return this; + } + + /** + *

    The id of the resource created during job execution (e.g. ticket id)

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage resourceId(String resourceId) { + this.resourceId = Optional.ofNullable(resourceId); + return this; + } + + /** + *

    The id of the resource created during job execution (e.g. ticket id)

    + */ + @java.lang.Override + @JsonSetter(value = "resource_id", nulls = Nulls.SKIP) + public _FinalStage resourceId(Optional resourceId) { + this.resourceId = resourceId; + return this; + } + + /** + *

    The type of resource created during job execution.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage resourceType(String resourceType) { + this.resourceType = Optional.ofNullable(resourceType); + return this; + } + + /** + *

    The type of resource created during job execution.

    + */ + @java.lang.Override + @JsonSetter(value = "resource_type", nulls = Nulls.SKIP) + public _FinalStage resourceType(Optional resourceType) { + this.resourceType = resourceType; + return this; + } + + /** + *

    The status of the job execution.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage status(Status status) { + this.status = Optional.ofNullable(status); + return this; + } + + /** + *

    The status of the job execution.

    + */ + @java.lang.Override + @JsonSetter(value = "status", nulls = Nulls.SKIP) + public _FinalStage status(Optional status) { + this.status = status; + return this; + } + + /** + *

    API endpoint URL to check the job status.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage url(String url) { + this.url = Optional.ofNullable(url); + return this; + } + + /** + *

    API endpoint URL to check the job status.

    + */ + @java.lang.Override + @JsonSetter(value = "url", nulls = Nulls.SKIP) + public _FinalStage url(Optional url) { + this.url = url; + return this; + } + + /** + *

    The type of the object

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + /** + *

    The type of the object

    + */ + @java.lang.Override + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public _FinalStage type(Optional type) { + this.type = type; + return this; + } + + @java.lang.Override + public Jobs build() { + return new Jobs(type, id, url, status, resourceType, resourceId, resourceUrl, additionalProperties); + } + } + + public static final class Status { + public static final Status SUCCESS = new Status(Value.SUCCESS, "success"); + + public static final Status FAILED = new Status(Value.FAILED, "failed"); + + public static final Status PENDING = new Status(Value.PENDING, "pending"); + + private final Value value; + + private final String string; + + Status(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) || (other instanceof Status && this.string.equals(((Status) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case SUCCESS: + return visitor.visitSuccess(); + case FAILED: + return visitor.visitFailed(); + case PENDING: + return visitor.visitPending(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static Status valueOf(String value) { + switch (value) { + case "success": + return SUCCESS; + case "failed": + return FAILED; + case "pending": + return PENDING; + default: + return new Status(Value.UNKNOWN, value); + } + } + + public enum Value { + PENDING, + + SUCCESS, + + FAILED, + + UNKNOWN + } + + public interface Visitor { + T visitPending(); + + T visitSuccess(); + + T visitFailed(); + + T visitUnknown(String unknownType); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/messages/AsyncMessagesClient.java b/src/main/java/com/intercom/api/resources/messages/AsyncMessagesClient.java index a0940a6..468fc47 100644 --- a/src/main/java/com/intercom/api/resources/messages/AsyncMessagesClient.java +++ b/src/main/java/com/intercom/api/resources/messages/AsyncMessagesClient.java @@ -7,6 +7,7 @@ import com.intercom.api.core.RequestOptions; import com.intercom.api.resources.messages.types.Message; import com.intercom.api.types.CreateMessageRequest; +import java.util.Optional; import java.util.concurrent.CompletableFuture; public class AsyncMessagesClient { @@ -38,7 +39,23 @@ public AsyncRawMessagesClient withRawResponse() { *

    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.

    * */ - public CompletableFuture create(CreateMessageRequest request) { + public CompletableFuture create() { + return this.rawClient.create().thenApply(response -> response.body()); + } + + /** + * You can create a message that has been initiated by an admin. The conversation can be either an in-app message or an email. + *
    + *

    🚧 Sending for visitors

    + *

    There can be a short delay between when a contact is created and when a contact becomes available to be messaged through the API. A 404 Not Found error will be returned in this case.

    + *
    + *

    This will return the Message model that has been created.

    + *
    + *

    🚧 Retrieving Associated Conversations

    + *

    As this is a message, there will be no conversation present until the contact responds. Once they do, you will have to search for a contact's conversations with the id of the message.

    + *
    + */ + public CompletableFuture create(Optional request) { return this.rawClient.create(request).thenApply(response -> response.body()); } @@ -54,7 +71,7 @@ public CompletableFuture create(CreateMessageRequest request) { *

    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.

    * */ - public CompletableFuture create(CreateMessageRequest request, RequestOptions requestOptions) { + public CompletableFuture create(Optional request, RequestOptions requestOptions) { return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); } } diff --git a/src/main/java/com/intercom/api/resources/messages/AsyncRawMessagesClient.java b/src/main/java/com/intercom/api/resources/messages/AsyncRawMessagesClient.java index 30cc313..cc6f48d 100644 --- a/src/main/java/com/intercom/api/resources/messages/AsyncRawMessagesClient.java +++ b/src/main/java/com/intercom/api/resources/messages/AsyncRawMessagesClient.java @@ -19,6 +19,7 @@ import com.intercom.api.types.CreateMessageRequest; import com.intercom.api.types.Error; import java.io.IOException; +import java.util.Optional; import java.util.concurrent.CompletableFuture; import okhttp3.Call; import okhttp3.Callback; @@ -50,7 +51,23 @@ public AsyncRawMessagesClient(ClientOptions clientOptions) { *

    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.

    * */ - public CompletableFuture> create(CreateMessageRequest request) { + public CompletableFuture> create() { + return create(Optional.empty()); + } + + /** + * You can create a message that has been initiated by an admin. The conversation can be either an in-app message or an email. + *
    + *

    🚧 Sending for visitors

    + *

    There can be a short delay between when a contact is created and when a contact becomes available to be messaged through the API. A 404 Not Found error will be returned in this case.

    + *
    + *

    This will return the Message model that has been created.

    + *
    + *

    🚧 Retrieving Associated Conversations

    + *

    As this is a message, there will be no conversation present until the contact responds. Once they do, you will have to search for a contact's conversations with the id of the message.

    + *
    + */ + public CompletableFuture> create(Optional request) { return create(request, null); } @@ -67,15 +84,18 @@ public CompletableFuture> create(CreateMessageRequ * */ public CompletableFuture> create( - CreateMessageRequest request, RequestOptions requestOptions) { + Optional request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("messages") .build(); RequestBody body; try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + body = RequestBody.create("", null); + if (request.isPresent()) { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } } catch (JsonProcessingException e) { throw new IntercomException("Failed to serialize request", e); } diff --git a/src/main/java/com/intercom/api/resources/messages/MessagesClient.java b/src/main/java/com/intercom/api/resources/messages/MessagesClient.java index 002bd34..afbd3d1 100644 --- a/src/main/java/com/intercom/api/resources/messages/MessagesClient.java +++ b/src/main/java/com/intercom/api/resources/messages/MessagesClient.java @@ -7,6 +7,7 @@ import com.intercom.api.core.RequestOptions; import com.intercom.api.resources.messages.types.Message; import com.intercom.api.types.CreateMessageRequest; +import java.util.Optional; public class MessagesClient { protected final ClientOptions clientOptions; @@ -37,7 +38,23 @@ public RawMessagesClient withRawResponse() { *

    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.

    * */ - public Message create(CreateMessageRequest request) { + public Message create() { + return this.rawClient.create().body(); + } + + /** + * You can create a message that has been initiated by an admin. The conversation can be either an in-app message or an email. + *
    + *

    🚧 Sending for visitors

    + *

    There can be a short delay between when a contact is created and when a contact becomes available to be messaged through the API. A 404 Not Found error will be returned in this case.

    + *
    + *

    This will return the Message model that has been created.

    + *
    + *

    🚧 Retrieving Associated Conversations

    + *

    As this is a message, there will be no conversation present until the contact responds. Once they do, you will have to search for a contact's conversations with the id of the message.

    + *
    + */ + public Message create(Optional request) { return this.rawClient.create(request).body(); } @@ -53,7 +70,7 @@ public Message create(CreateMessageRequest request) { *

    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.

    * */ - public Message create(CreateMessageRequest request, RequestOptions requestOptions) { + public Message create(Optional request, RequestOptions requestOptions) { return this.rawClient.create(request, requestOptions).body(); } } diff --git a/src/main/java/com/intercom/api/resources/messages/RawMessagesClient.java b/src/main/java/com/intercom/api/resources/messages/RawMessagesClient.java index feb1e76..437fd5e 100644 --- a/src/main/java/com/intercom/api/resources/messages/RawMessagesClient.java +++ b/src/main/java/com/intercom/api/resources/messages/RawMessagesClient.java @@ -19,6 +19,7 @@ import com.intercom.api.types.CreateMessageRequest; import com.intercom.api.types.Error; import java.io.IOException; +import java.util.Optional; import okhttp3.Headers; import okhttp3.HttpUrl; import okhttp3.OkHttpClient; @@ -46,7 +47,23 @@ public RawMessagesClient(ClientOptions clientOptions) { *

    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.

    * */ - public IntercomHttpResponse create(CreateMessageRequest request) { + public IntercomHttpResponse create() { + return create(Optional.empty()); + } + + /** + * You can create a message that has been initiated by an admin. The conversation can be either an in-app message or an email. + *
    + *

    🚧 Sending for visitors

    + *

    There can be a short delay between when a contact is created and when a contact becomes available to be messaged through the API. A 404 Not Found error will be returned in this case.

    + *
    + *

    This will return the Message model that has been created.

    + *
    + *

    🚧 Retrieving Associated Conversations

    + *

    As this is a message, there will be no conversation present until the contact responds. Once they do, you will have to search for a contact's conversations with the id of the message.

    + *
    + */ + public IntercomHttpResponse create(Optional request) { return create(request, null); } @@ -62,15 +79,18 @@ public IntercomHttpResponse create(CreateMessageRequest request) { *

    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.

    * */ - public IntercomHttpResponse create(CreateMessageRequest request, RequestOptions requestOptions) { + public IntercomHttpResponse create(Optional request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("messages") .build(); RequestBody body; try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + body = RequestBody.create("", null); + if (request.isPresent()) { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } } catch (JsonProcessingException e) { throw new IntercomException("Failed to serialize request", e); } diff --git a/src/main/java/com/intercom/api/resources/messages/types/Message.java b/src/main/java/com/intercom/api/resources/messages/types/Message.java index 2ad8f7d..f02a9f1 100644 --- a/src/main/java/com/intercom/api/resources/messages/types/Message.java +++ b/src/main/java/com/intercom/api/resources/messages/types/Message.java @@ -11,11 +11,13 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonSetter; import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.intercom.api.core.ObjectMappers; import java.util.HashMap; import java.util.Map; import java.util.Objects; +import java.util.Optional; import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @@ -27,13 +29,13 @@ public final class Message { private final int createdAt; - private final String subject; + private final Optional subject; private final String body; private final MessageType messageType; - private final String conversationId; + private final Optional conversationId; private final Map additionalProperties; @@ -41,10 +43,10 @@ private Message( String type, String id, int createdAt, - String subject, + Optional subject, String body, MessageType messageType, - String conversationId, + Optional conversationId, Map additionalProperties) { this.type = type; this.id = id; @@ -84,7 +86,7 @@ public int getCreatedAt() { * @return The subject of the message. Only present if message_type: email. */ @JsonProperty("subject") - public String getSubject() { + public Optional getSubject() { return subject; } @@ -108,7 +110,7 @@ public MessageType getMessageType() { * @return The associated conversation_id */ @JsonProperty("conversation_id") - public String getConversationId() { + public Optional getConversationId() { return conversationId; } @@ -168,14 +170,7 @@ public interface CreatedAtStage { /** * The time the conversation was created. */ - SubjectStage createdAt(int createdAt); - } - - public interface SubjectStage { - /** - * The subject of the message. Only present if message_type: email. - */ - BodyStage subject(@NotNull String subject); + BodyStage createdAt(int createdAt); } public interface BodyStage { @@ -189,43 +184,43 @@ public interface MessageTypeStage { /** * The type of message that was sent. Can be email, inapp, facebook or twitter. */ - ConversationIdStage messageType(@NotNull MessageType messageType); + _FinalStage messageType(@NotNull MessageType messageType); } - public interface ConversationIdStage { + public interface _FinalStage { + Message build(); + /** - * The associated conversation_id + *

    The subject of the message. Only present if message_type: email.

    */ - _FinalStage conversationId(@NotNull String conversationId); - } + _FinalStage subject(Optional subject); - public interface _FinalStage { - Message build(); + _FinalStage subject(String subject); + + /** + *

    The associated conversation_id

    + */ + _FinalStage conversationId(Optional conversationId); + + _FinalStage conversationId(String conversationId); } @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder - implements TypeStage, - IdStage, - CreatedAtStage, - SubjectStage, - BodyStage, - MessageTypeStage, - ConversationIdStage, - _FinalStage { + implements TypeStage, IdStage, CreatedAtStage, BodyStage, MessageTypeStage, _FinalStage { private String type; private String id; private int createdAt; - private String subject; - private String body; private MessageType messageType; - private String conversationId; + private Optional conversationId = Optional.empty(); + + private Optional subject = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -272,22 +267,11 @@ public CreatedAtStage id(@NotNull String id) { */ @java.lang.Override @JsonSetter("created_at") - public SubjectStage createdAt(int createdAt) { + public BodyStage createdAt(int createdAt) { this.createdAt = createdAt; return this; } - /** - * The subject of the message. Only present if message_type: email.

    The subject of the message. Only present if message_type: email.

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("subject") - public BodyStage subject(@NotNull String subject) { - this.subject = Objects.requireNonNull(subject, "subject must not be null"); - return this; - } - /** * The message body, which may contain HTML.

    The message body, which may contain HTML.

    * @return Reference to {@code this} so that method calls can be chained together. @@ -305,19 +289,48 @@ public MessageTypeStage body(@NotNull String body) { */ @java.lang.Override @JsonSetter("message_type") - public ConversationIdStage messageType(@NotNull MessageType messageType) { + public _FinalStage messageType(@NotNull MessageType messageType) { this.messageType = Objects.requireNonNull(messageType, "messageType must not be null"); return this; } /** - * The associated conversation_id

    The associated conversation_id

    + *

    The associated conversation_id

    * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override - @JsonSetter("conversation_id") - public _FinalStage conversationId(@NotNull String conversationId) { - this.conversationId = Objects.requireNonNull(conversationId, "conversationId must not be null"); + public _FinalStage conversationId(String conversationId) { + this.conversationId = Optional.ofNullable(conversationId); + return this; + } + + /** + *

    The associated conversation_id

    + */ + @java.lang.Override + @JsonSetter(value = "conversation_id", nulls = Nulls.SKIP) + public _FinalStage conversationId(Optional conversationId) { + this.conversationId = conversationId; + return this; + } + + /** + *

    The subject of the message. Only present if message_type: email.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage subject(String subject) { + this.subject = Optional.ofNullable(subject); + return this; + } + + /** + *

    The subject of the message. Only present if message_type: email.

    + */ + @java.lang.Override + @JsonSetter(value = "subject", nulls = Nulls.SKIP) + public _FinalStage subject(Optional subject) { + this.subject = subject; return this; } diff --git a/src/main/java/com/intercom/api/resources/news/feeds/AsyncFeedsClient.java b/src/main/java/com/intercom/api/resources/news/feeds/AsyncFeedsClient.java index 90b558b..c5557e4 100644 --- a/src/main/java/com/intercom/api/resources/news/feeds/AsyncFeedsClient.java +++ b/src/main/java/com/intercom/api/resources/news/feeds/AsyncFeedsClient.java @@ -8,8 +8,7 @@ import com.intercom.api.resources.news.feeds.requests.FindNewsFeedRequest; import com.intercom.api.resources.news.feeds.requests.ListNewsFeedItemsRequest; import com.intercom.api.resources.news.types.Newsfeed; -import com.intercom.api.types.PaginatedNewsItemResponse; -import com.intercom.api.types.PaginatedNewsfeedResponse; +import com.intercom.api.types.PaginatedResponse; import java.util.concurrent.CompletableFuture; public class AsyncFeedsClient { @@ -32,14 +31,14 @@ public AsyncRawFeedsClient withRawResponse() { /** * You can fetch a list of all news items that are live on a given newsfeed */ - public CompletableFuture listItems(ListNewsFeedItemsRequest request) { + public CompletableFuture listItems(ListNewsFeedItemsRequest request) { return this.rawClient.listItems(request).thenApply(response -> response.body()); } /** * You can fetch a list of all news items that are live on a given newsfeed */ - public CompletableFuture listItems( + public CompletableFuture listItems( ListNewsFeedItemsRequest request, RequestOptions requestOptions) { return this.rawClient.listItems(request, requestOptions).thenApply(response -> response.body()); } @@ -47,14 +46,14 @@ public CompletableFuture listItems( /** * You can fetch a list of all newsfeeds */ - public CompletableFuture list() { + public CompletableFuture list() { return this.rawClient.list().thenApply(response -> response.body()); } /** * You can fetch a list of all newsfeeds */ - public CompletableFuture list(RequestOptions requestOptions) { + public CompletableFuture list(RequestOptions requestOptions) { return this.rawClient.list(requestOptions).thenApply(response -> response.body()); } diff --git a/src/main/java/com/intercom/api/resources/news/feeds/AsyncRawFeedsClient.java b/src/main/java/com/intercom/api/resources/news/feeds/AsyncRawFeedsClient.java index 9bb5511..78cd70b 100644 --- a/src/main/java/com/intercom/api/resources/news/feeds/AsyncRawFeedsClient.java +++ b/src/main/java/com/intercom/api/resources/news/feeds/AsyncRawFeedsClient.java @@ -15,8 +15,7 @@ import com.intercom.api.resources.news.feeds.requests.ListNewsFeedItemsRequest; import com.intercom.api.resources.news.types.Newsfeed; import com.intercom.api.types.Error; -import com.intercom.api.types.PaginatedNewsItemResponse; -import com.intercom.api.types.PaginatedNewsfeedResponse; +import com.intercom.api.types.PaginatedResponse; import java.io.IOException; import java.util.concurrent.CompletableFuture; import okhttp3.Call; @@ -39,15 +38,14 @@ public AsyncRawFeedsClient(ClientOptions clientOptions) { /** * You can fetch a list of all news items that are live on a given newsfeed */ - public CompletableFuture> listItems( - ListNewsFeedItemsRequest request) { + public CompletableFuture> listItems(ListNewsFeedItemsRequest request) { return listItems(request, null); } /** * You can fetch a list of all news items that are live on a given newsfeed */ - public CompletableFuture> listItems( + public CompletableFuture> listItems( ListNewsFeedItemsRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -66,15 +64,14 @@ public CompletableFuture> listIt if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } - CompletableFuture> future = new CompletableFuture<>(); + CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), PaginatedNewsItemResponse.class), + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedResponse.class), response)); return; } @@ -110,14 +107,14 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { /** * You can fetch a list of all newsfeeds */ - public CompletableFuture> list() { + public CompletableFuture> list() { return list(null); } /** * You can fetch a list of all newsfeeds */ - public CompletableFuture> list(RequestOptions requestOptions) { + public CompletableFuture> list(RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("news/newsfeeds") @@ -133,15 +130,14 @@ public CompletableFuture> list(R if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } - CompletableFuture> future = new CompletableFuture<>(); + CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), PaginatedNewsfeedResponse.class), + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedResponse.class), response)); return; } diff --git a/src/main/java/com/intercom/api/resources/news/feeds/FeedsClient.java b/src/main/java/com/intercom/api/resources/news/feeds/FeedsClient.java index 895cf2f..9de0753 100644 --- a/src/main/java/com/intercom/api/resources/news/feeds/FeedsClient.java +++ b/src/main/java/com/intercom/api/resources/news/feeds/FeedsClient.java @@ -8,8 +8,7 @@ import com.intercom.api.resources.news.feeds.requests.FindNewsFeedRequest; import com.intercom.api.resources.news.feeds.requests.ListNewsFeedItemsRequest; import com.intercom.api.resources.news.types.Newsfeed; -import com.intercom.api.types.PaginatedNewsItemResponse; -import com.intercom.api.types.PaginatedNewsfeedResponse; +import com.intercom.api.types.PaginatedResponse; public class FeedsClient { protected final ClientOptions clientOptions; @@ -31,28 +30,28 @@ public RawFeedsClient withRawResponse() { /** * You can fetch a list of all news items that are live on a given newsfeed */ - public PaginatedNewsItemResponse listItems(ListNewsFeedItemsRequest request) { + public PaginatedResponse listItems(ListNewsFeedItemsRequest request) { return this.rawClient.listItems(request).body(); } /** * You can fetch a list of all news items that are live on a given newsfeed */ - public PaginatedNewsItemResponse listItems(ListNewsFeedItemsRequest request, RequestOptions requestOptions) { + public PaginatedResponse listItems(ListNewsFeedItemsRequest request, RequestOptions requestOptions) { return this.rawClient.listItems(request, requestOptions).body(); } /** * You can fetch a list of all newsfeeds */ - public PaginatedNewsfeedResponse list() { + public PaginatedResponse list() { return this.rawClient.list().body(); } /** * You can fetch a list of all newsfeeds */ - public PaginatedNewsfeedResponse list(RequestOptions requestOptions) { + public PaginatedResponse list(RequestOptions requestOptions) { return this.rawClient.list(requestOptions).body(); } diff --git a/src/main/java/com/intercom/api/resources/news/feeds/RawFeedsClient.java b/src/main/java/com/intercom/api/resources/news/feeds/RawFeedsClient.java index b297ee9..cbb4680 100644 --- a/src/main/java/com/intercom/api/resources/news/feeds/RawFeedsClient.java +++ b/src/main/java/com/intercom/api/resources/news/feeds/RawFeedsClient.java @@ -15,8 +15,7 @@ import com.intercom.api.resources.news.feeds.requests.ListNewsFeedItemsRequest; import com.intercom.api.resources.news.types.Newsfeed; import com.intercom.api.types.Error; -import com.intercom.api.types.PaginatedNewsItemResponse; -import com.intercom.api.types.PaginatedNewsfeedResponse; +import com.intercom.api.types.PaginatedResponse; import java.io.IOException; import okhttp3.Headers; import okhttp3.HttpUrl; @@ -35,14 +34,14 @@ public RawFeedsClient(ClientOptions clientOptions) { /** * You can fetch a list of all news items that are live on a given newsfeed */ - public IntercomHttpResponse listItems(ListNewsFeedItemsRequest request) { + public IntercomHttpResponse listItems(ListNewsFeedItemsRequest request) { return listItems(request, null); } /** * You can fetch a list of all news items that are live on a given newsfeed */ - public IntercomHttpResponse listItems( + public IntercomHttpResponse listItems( ListNewsFeedItemsRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -65,8 +64,7 @@ public IntercomHttpResponse listItems( ResponseBody responseBody = response.body(); if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedNewsItemResponse.class), - response); + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedResponse.class), response); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { @@ -90,14 +88,14 @@ public IntercomHttpResponse listItems( /** * You can fetch a list of all newsfeeds */ - public IntercomHttpResponse list() { + public IntercomHttpResponse list() { return list(null); } /** * You can fetch a list of all newsfeeds */ - public IntercomHttpResponse list(RequestOptions requestOptions) { + public IntercomHttpResponse list(RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("news/newsfeeds") @@ -117,8 +115,7 @@ public IntercomHttpResponse list(RequestOptions reque ResponseBody responseBody = response.body(); if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedNewsfeedResponse.class), - response); + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedResponse.class), response); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { diff --git a/src/main/java/com/intercom/api/resources/news/items/AsyncItemsClient.java b/src/main/java/com/intercom/api/resources/news/items/AsyncItemsClient.java index c4826f4..f540d56 100644 --- a/src/main/java/com/intercom/api/resources/news/items/AsyncItemsClient.java +++ b/src/main/java/com/intercom/api/resources/news/items/AsyncItemsClient.java @@ -11,7 +11,7 @@ import com.intercom.api.resources.news.types.NewsItem; import com.intercom.api.types.DeletedObject; import com.intercom.api.types.NewsItemRequest; -import com.intercom.api.types.PaginatedNewsItemResponse; +import com.intercom.api.types.PaginatedResponse; import java.util.concurrent.CompletableFuture; public class AsyncItemsClient { @@ -34,14 +34,14 @@ public AsyncRawItemsClient withRawResponse() { /** * You can fetch a list of all news items */ - public CompletableFuture list() { + public CompletableFuture list() { return this.rawClient.list().thenApply(response -> response.body()); } /** * You can fetch a list of all news items */ - public CompletableFuture list(RequestOptions requestOptions) { + public CompletableFuture list(RequestOptions requestOptions) { return this.rawClient.list(requestOptions).thenApply(response -> response.body()); } diff --git a/src/main/java/com/intercom/api/resources/news/items/AsyncRawItemsClient.java b/src/main/java/com/intercom/api/resources/news/items/AsyncRawItemsClient.java index 4386306..c1b9f88 100644 --- a/src/main/java/com/intercom/api/resources/news/items/AsyncRawItemsClient.java +++ b/src/main/java/com/intercom/api/resources/news/items/AsyncRawItemsClient.java @@ -20,7 +20,7 @@ import com.intercom.api.types.DeletedObject; import com.intercom.api.types.Error; import com.intercom.api.types.NewsItemRequest; -import com.intercom.api.types.PaginatedNewsItemResponse; +import com.intercom.api.types.PaginatedResponse; import java.io.IOException; import java.util.concurrent.CompletableFuture; import okhttp3.Call; @@ -44,14 +44,14 @@ public AsyncRawItemsClient(ClientOptions clientOptions) { /** * You can fetch a list of all news items */ - public CompletableFuture> list() { + public CompletableFuture> list() { return list(null); } /** * You can fetch a list of all news items */ - public CompletableFuture> list(RequestOptions requestOptions) { + public CompletableFuture> list(RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("news/news_items") @@ -67,15 +67,14 @@ public CompletableFuture> list(R if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } - CompletableFuture> future = new CompletableFuture<>(); + CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), PaginatedNewsItemResponse.class), + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedResponse.class), response)); return; } @@ -196,7 +195,7 @@ public CompletableFuture> find( HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("news/news_items") - .addPathSegment(request.getNewsItemId()) + .addPathSegment(Integer.toString(request.getNewsItemId())) .build(); Request.Builder _requestBuilder = new Request.Builder() .url(httpUrl) @@ -264,7 +263,7 @@ public CompletableFuture> update( HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("news/news_items") - .addPathSegment(request.getNewsItemId()) + .addPathSegment(Integer.toString(request.getNewsItemId())) .build(); RequestBody body; try { @@ -345,7 +344,7 @@ public CompletableFuture> delete( HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("news/news_items") - .addPathSegment(request.getNewsItemId()) + .addPathSegment(Integer.toString(request.getNewsItemId())) .build(); Request.Builder _requestBuilder = new Request.Builder() .url(httpUrl) diff --git a/src/main/java/com/intercom/api/resources/news/items/ItemsClient.java b/src/main/java/com/intercom/api/resources/news/items/ItemsClient.java index 6c02302..cd7caa8 100644 --- a/src/main/java/com/intercom/api/resources/news/items/ItemsClient.java +++ b/src/main/java/com/intercom/api/resources/news/items/ItemsClient.java @@ -11,7 +11,7 @@ import com.intercom.api.resources.news.types.NewsItem; import com.intercom.api.types.DeletedObject; import com.intercom.api.types.NewsItemRequest; -import com.intercom.api.types.PaginatedNewsItemResponse; +import com.intercom.api.types.PaginatedResponse; public class ItemsClient { protected final ClientOptions clientOptions; @@ -33,14 +33,14 @@ public RawItemsClient withRawResponse() { /** * You can fetch a list of all news items */ - public PaginatedNewsItemResponse list() { + public PaginatedResponse list() { return this.rawClient.list().body(); } /** * You can fetch a list of all news items */ - public PaginatedNewsItemResponse list(RequestOptions requestOptions) { + public PaginatedResponse list(RequestOptions requestOptions) { return this.rawClient.list(requestOptions).body(); } diff --git a/src/main/java/com/intercom/api/resources/news/items/RawItemsClient.java b/src/main/java/com/intercom/api/resources/news/items/RawItemsClient.java index 84644ce..fe1869c 100644 --- a/src/main/java/com/intercom/api/resources/news/items/RawItemsClient.java +++ b/src/main/java/com/intercom/api/resources/news/items/RawItemsClient.java @@ -20,7 +20,7 @@ import com.intercom.api.types.DeletedObject; import com.intercom.api.types.Error; import com.intercom.api.types.NewsItemRequest; -import com.intercom.api.types.PaginatedNewsItemResponse; +import com.intercom.api.types.PaginatedResponse; import java.io.IOException; import okhttp3.Headers; import okhttp3.HttpUrl; @@ -40,14 +40,14 @@ public RawItemsClient(ClientOptions clientOptions) { /** * You can fetch a list of all news items */ - public IntercomHttpResponse list() { + public IntercomHttpResponse list() { return list(null); } /** * You can fetch a list of all news items */ - public IntercomHttpResponse list(RequestOptions requestOptions) { + public IntercomHttpResponse list(RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("news/news_items") @@ -67,8 +67,7 @@ public IntercomHttpResponse list(RequestOptions reque ResponseBody responseBody = response.body(); if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedNewsItemResponse.class), - response); + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedResponse.class), response); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { @@ -161,7 +160,7 @@ public IntercomHttpResponse find(FindNewsItemRequest request, RequestO HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("news/news_items") - .addPathSegment(request.getNewsItemId()) + .addPathSegment(Integer.toString(request.getNewsItemId())) .build(); Request.Builder _requestBuilder = new Request.Builder() .url(httpUrl) @@ -211,7 +210,7 @@ public IntercomHttpResponse update(UpdateNewsItemRequest request, Requ HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("news/news_items") - .addPathSegment(request.getNewsItemId()) + .addPathSegment(Integer.toString(request.getNewsItemId())) .build(); RequestBody body; try { @@ -274,7 +273,7 @@ public IntercomHttpResponse delete(DeleteNewsItemRequest request, HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("news/news_items") - .addPathSegment(request.getNewsItemId()) + .addPathSegment(Integer.toString(request.getNewsItemId())) .build(); Request.Builder _requestBuilder = new Request.Builder() .url(httpUrl) diff --git a/src/main/java/com/intercom/api/resources/news/items/requests/DeleteNewsItemRequest.java b/src/main/java/com/intercom/api/resources/news/items/requests/DeleteNewsItemRequest.java index a75407f..7ac5dd4 100644 --- a/src/main/java/com/intercom/api/resources/news/items/requests/DeleteNewsItemRequest.java +++ b/src/main/java/com/intercom/api/resources/news/items/requests/DeleteNewsItemRequest.java @@ -14,16 +14,15 @@ import java.util.HashMap; import java.util.Map; import java.util.Objects; -import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = DeleteNewsItemRequest.Builder.class) public final class DeleteNewsItemRequest { - private final String newsItemId; + private final int newsItemId; private final Map additionalProperties; - private DeleteNewsItemRequest(String newsItemId, Map additionalProperties) { + private DeleteNewsItemRequest(int newsItemId, Map additionalProperties) { this.newsItemId = newsItemId; this.additionalProperties = additionalProperties; } @@ -32,7 +31,7 @@ private DeleteNewsItemRequest(String newsItemId, Map additionalP * @return The unique identifier for the news item which is given by Intercom. */ @JsonProperty("news_item_id") - public String getNewsItemId() { + public int getNewsItemId() { return newsItemId; } @@ -48,7 +47,7 @@ public Map getAdditionalProperties() { } private boolean equalTo(DeleteNewsItemRequest other) { - return newsItemId.equals(other.newsItemId); + return newsItemId == other.newsItemId; } @java.lang.Override @@ -69,7 +68,7 @@ public interface NewsItemIdStage { /** * The unique identifier for the news item which is given by Intercom. */ - _FinalStage newsItemId(@NotNull String newsItemId); + _FinalStage newsItemId(int newsItemId); Builder from(DeleteNewsItemRequest other); } @@ -80,7 +79,7 @@ public interface _FinalStage { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements NewsItemIdStage, _FinalStage { - private String newsItemId; + private int newsItemId; @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -99,8 +98,8 @@ public Builder from(DeleteNewsItemRequest other) { */ @java.lang.Override @JsonSetter("news_item_id") - public _FinalStage newsItemId(@NotNull String newsItemId) { - this.newsItemId = Objects.requireNonNull(newsItemId, "newsItemId must not be null"); + public _FinalStage newsItemId(int newsItemId) { + this.newsItemId = newsItemId; return this; } diff --git a/src/main/java/com/intercom/api/resources/news/items/requests/FindNewsItemRequest.java b/src/main/java/com/intercom/api/resources/news/items/requests/FindNewsItemRequest.java index e67e4cb..f7fa607 100644 --- a/src/main/java/com/intercom/api/resources/news/items/requests/FindNewsItemRequest.java +++ b/src/main/java/com/intercom/api/resources/news/items/requests/FindNewsItemRequest.java @@ -14,16 +14,15 @@ import java.util.HashMap; import java.util.Map; import java.util.Objects; -import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = FindNewsItemRequest.Builder.class) public final class FindNewsItemRequest { - private final String newsItemId; + private final int newsItemId; private final Map additionalProperties; - private FindNewsItemRequest(String newsItemId, Map additionalProperties) { + private FindNewsItemRequest(int newsItemId, Map additionalProperties) { this.newsItemId = newsItemId; this.additionalProperties = additionalProperties; } @@ -32,7 +31,7 @@ private FindNewsItemRequest(String newsItemId, Map additionalPro * @return The unique identifier for the news item which is given by Intercom. */ @JsonProperty("news_item_id") - public String getNewsItemId() { + public int getNewsItemId() { return newsItemId; } @@ -48,7 +47,7 @@ public Map getAdditionalProperties() { } private boolean equalTo(FindNewsItemRequest other) { - return newsItemId.equals(other.newsItemId); + return newsItemId == other.newsItemId; } @java.lang.Override @@ -69,7 +68,7 @@ public interface NewsItemIdStage { /** * The unique identifier for the news item which is given by Intercom. */ - _FinalStage newsItemId(@NotNull String newsItemId); + _FinalStage newsItemId(int newsItemId); Builder from(FindNewsItemRequest other); } @@ -80,7 +79,7 @@ public interface _FinalStage { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements NewsItemIdStage, _FinalStage { - private String newsItemId; + private int newsItemId; @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -99,8 +98,8 @@ public Builder from(FindNewsItemRequest other) { */ @java.lang.Override @JsonSetter("news_item_id") - public _FinalStage newsItemId(@NotNull String newsItemId) { - this.newsItemId = Objects.requireNonNull(newsItemId, "newsItemId must not be null"); + public _FinalStage newsItemId(int newsItemId) { + this.newsItemId = newsItemId; return this; } diff --git a/src/main/java/com/intercom/api/resources/news/items/requests/UpdateNewsItemRequest.java b/src/main/java/com/intercom/api/resources/news/items/requests/UpdateNewsItemRequest.java index 0c5caf1..c288ead 100644 --- a/src/main/java/com/intercom/api/resources/news/items/requests/UpdateNewsItemRequest.java +++ b/src/main/java/com/intercom/api/resources/news/items/requests/UpdateNewsItemRequest.java @@ -20,13 +20,13 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = UpdateNewsItemRequest.Builder.class) public final class UpdateNewsItemRequest { - private final String newsItemId; + private final int newsItemId; private final NewsItemRequest body; private final Map additionalProperties; - private UpdateNewsItemRequest(String newsItemId, NewsItemRequest body, Map additionalProperties) { + private UpdateNewsItemRequest(int newsItemId, NewsItemRequest body, Map additionalProperties) { this.newsItemId = newsItemId; this.body = body; this.additionalProperties = additionalProperties; @@ -36,7 +36,7 @@ private UpdateNewsItemRequest(String newsItemId, NewsItemRequest body, Map getAdditionalProperties() { } private boolean equalTo(UpdateNewsItemRequest other) { - return newsItemId.equals(other.newsItemId) && body.equals(other.body); + return newsItemId == other.newsItemId && body.equals(other.body); } @java.lang.Override @@ -78,7 +78,7 @@ public interface NewsItemIdStage { /** * The unique identifier for the news item which is given by Intercom. */ - BodyStage newsItemId(@NotNull String newsItemId); + BodyStage newsItemId(int newsItemId); Builder from(UpdateNewsItemRequest other); } @@ -93,7 +93,7 @@ public interface _FinalStage { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements NewsItemIdStage, BodyStage, _FinalStage { - private String newsItemId; + private int newsItemId; private NewsItemRequest body; @@ -115,8 +115,8 @@ public Builder from(UpdateNewsItemRequest other) { */ @java.lang.Override @JsonSetter("news_item_id") - public BodyStage newsItemId(@NotNull String newsItemId) { - this.newsItemId = Objects.requireNonNull(newsItemId, "newsItemId must not be null"); + public BodyStage newsItemId(int newsItemId) { + this.newsItemId = newsItemId; return this; } diff --git a/src/main/java/com/intercom/api/resources/news/types/NewsItem.java b/src/main/java/com/intercom/api/resources/news/types/NewsItem.java index a971ca3..d19656b 100644 --- a/src/main/java/com/intercom/api/resources/news/types/NewsItem.java +++ b/src/main/java/com/intercom/api/resources/news/types/NewsItem.java @@ -19,22 +19,21 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; -import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = NewsItem.Builder.class) public final class NewsItem { - private final String id; + private final Optional id; - private final String workspaceId; + private final Optional workspaceId; - private final String title; + private final Optional title; - private final String body; + private final Optional body; - private final int senderId; + private final Optional senderId; - private final State state; + private final Optional state; private final Optional> newsfeedAssignments; @@ -46,25 +45,25 @@ public final class NewsItem { private final Optional deliverSilently; - private final int createdAt; + private final Optional createdAt; private final Optional updatedAt; private final Map additionalProperties; private NewsItem( - String id, - String workspaceId, - String title, - String body, - int senderId, - State state, + Optional id, + Optional workspaceId, + Optional title, + Optional body, + Optional senderId, + Optional state, Optional> newsfeedAssignments, Optional>> labels, Optional coverImageUrl, Optional>> reactions, Optional deliverSilently, - int createdAt, + Optional createdAt, Optional updatedAt, Map additionalProperties) { this.id = id; @@ -83,19 +82,11 @@ private NewsItem( this.additionalProperties = additionalProperties; } - /** - * @return The type of object. - */ - @JsonProperty("type") - public String getType() { - return "news-item"; - } - /** * @return The unique identifier for the news item which is given by Intercom. */ @JsonProperty("id") - public String getId() { + public Optional getId() { return id; } @@ -103,7 +94,7 @@ public String getId() { * @return The id of the workspace which the news item belongs to. */ @JsonProperty("workspace_id") - public String getWorkspaceId() { + public Optional getWorkspaceId() { return workspaceId; } @@ -111,7 +102,7 @@ public String getWorkspaceId() { * @return The title of the news item. */ @JsonProperty("title") - public String getTitle() { + public Optional getTitle() { return title; } @@ -119,7 +110,7 @@ public String getTitle() { * @return The news item body, which may contain HTML. */ @JsonProperty("body") - public String getBody() { + public Optional getBody() { return body; } @@ -127,7 +118,7 @@ public String getBody() { * @return The id of the sender of the news item. Must be a teammate on the workspace. */ @JsonProperty("sender_id") - public int getSenderId() { + public Optional getSenderId() { return senderId; } @@ -135,7 +126,7 @@ public int getSenderId() { * @return News items will not be visible to your users in the assigned newsfeeds until they are set live. */ @JsonProperty("state") - public State getState() { + public Optional getState() { return state; } @@ -183,7 +174,7 @@ public Optional getDeliverSilently() { * @return Timestamp for when the news item was created. */ @JsonProperty("created_at") - public int getCreatedAt() { + public Optional getCreatedAt() { return createdAt; } @@ -211,14 +202,14 @@ private boolean equalTo(NewsItem other) { && workspaceId.equals(other.workspaceId) && title.equals(other.title) && body.equals(other.body) - && senderId == other.senderId + && senderId.equals(other.senderId) && state.equals(other.state) && newsfeedAssignments.equals(other.newsfeedAssignments) && labels.equals(other.labels) && coverImageUrl.equals(other.coverImageUrl) && reactions.equals(other.reactions) && deliverSilently.equals(other.deliverSilently) - && createdAt == other.createdAt + && createdAt.equals(other.createdAt) && updatedAt.equals(other.updatedAt); } @@ -245,149 +236,43 @@ public String toString() { return ObjectMappers.stringify(this); } - public static IdStage builder() { + public static Builder builder() { return new Builder(); } - public interface IdStage { - /** - * The unique identifier for the news item which is given by Intercom. - */ - WorkspaceIdStage id(@NotNull String id); - - Builder from(NewsItem other); - } - - public interface WorkspaceIdStage { - /** - * The id of the workspace which the news item belongs to. - */ - TitleStage workspaceId(@NotNull String workspaceId); - } - - public interface TitleStage { - /** - * The title of the news item. - */ - BodyStage title(@NotNull String title); - } - - public interface BodyStage { - /** - * The news item body, which may contain HTML. - */ - SenderIdStage body(@NotNull String body); - } - - public interface SenderIdStage { - /** - * The id of the sender of the news item. Must be a teammate on the workspace. - */ - StateStage senderId(int senderId); - } - - public interface StateStage { - /** - * News items will not be visible to your users in the assigned newsfeeds until they are set live. - */ - CreatedAtStage state(@NotNull State state); - } - - public interface CreatedAtStage { - /** - * Timestamp for when the news item was created. - */ - _FinalStage createdAt(int createdAt); - } - - public interface _FinalStage { - NewsItem build(); - - /** - *

    A list of newsfeed_assignments to assign to the specified newsfeed.

    - */ - _FinalStage newsfeedAssignments(Optional> newsfeedAssignments); - - _FinalStage newsfeedAssignments(List newsfeedAssignments); - - /** - *

    Label names displayed to users to categorize the news item.

    - */ - _FinalStage labels(Optional>> labels); - - _FinalStage labels(List> labels); - - /** - *

    URL of the image used as cover. Must have .jpg or .png extension.

    - */ - _FinalStage coverImageUrl(Optional coverImageUrl); - - _FinalStage coverImageUrl(String coverImageUrl); - - /** - *

    Ordered list of emoji reactions to the news item. When empty, reactions are disabled.

    - */ - _FinalStage reactions(Optional>> reactions); - - _FinalStage reactions(List> reactions); - - /** - *

    When set to true, the news item will appear in the messenger newsfeed without showing a notification badge.

    - */ - _FinalStage deliverSilently(Optional deliverSilently); - - _FinalStage deliverSilently(Boolean deliverSilently); - - /** - *

    Timestamp for when the news item was last updated.

    - */ - _FinalStage updatedAt(Optional updatedAt); - - _FinalStage updatedAt(Integer updatedAt); - } - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder - implements IdStage, - WorkspaceIdStage, - TitleStage, - BodyStage, - SenderIdStage, - StateStage, - CreatedAtStage, - _FinalStage { - private String id; + public static final class Builder { + private Optional id = Optional.empty(); - private String workspaceId; + private Optional workspaceId = Optional.empty(); - private String title; + private Optional title = Optional.empty(); - private String body; + private Optional body = Optional.empty(); - private int senderId; + private Optional senderId = Optional.empty(); - private State state; + private Optional state = Optional.empty(); - private int createdAt; + private Optional> newsfeedAssignments = Optional.empty(); - private Optional updatedAt = Optional.empty(); + private Optional>> labels = Optional.empty(); - private Optional deliverSilently = Optional.empty(); + private Optional coverImageUrl = Optional.empty(); private Optional>> reactions = Optional.empty(); - private Optional coverImageUrl = Optional.empty(); + private Optional deliverSilently = Optional.empty(); - private Optional>> labels = Optional.empty(); + private Optional createdAt = Optional.empty(); - private Optional> newsfeedAssignments = Optional.empty(); + private Optional updatedAt = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} - @java.lang.Override public Builder from(NewsItem other) { id(other.getId()); workspaceId(other.getWorkspaceId()); @@ -406,203 +291,187 @@ public Builder from(NewsItem other) { } /** - * The unique identifier for the news item which is given by Intercom.

    The unique identifier for the news item which is given by Intercom.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The unique identifier for the news item which is given by Intercom.

    */ - @java.lang.Override - @JsonSetter("id") - public WorkspaceIdStage id(@NotNull String id) { - this.id = Objects.requireNonNull(id, "id must not be null"); + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.ofNullable(id); return this; } /** - * The id of the workspace which the news item belongs to.

    The id of the workspace which the news item belongs to.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The id of the workspace which the news item belongs to.

    */ - @java.lang.Override - @JsonSetter("workspace_id") - public TitleStage workspaceId(@NotNull String workspaceId) { - this.workspaceId = Objects.requireNonNull(workspaceId, "workspaceId must not be null"); + @JsonSetter(value = "workspace_id", nulls = Nulls.SKIP) + public Builder workspaceId(Optional workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + public Builder workspaceId(String workspaceId) { + this.workspaceId = Optional.ofNullable(workspaceId); return this; } /** - * The title of the news item.

    The title of the news item.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The title of the news item.

    */ - @java.lang.Override - @JsonSetter("title") - public BodyStage title(@NotNull String title) { - this.title = Objects.requireNonNull(title, "title must not be null"); + @JsonSetter(value = "title", nulls = Nulls.SKIP) + public Builder title(Optional title) { + this.title = title; + return this; + } + + public Builder title(String title) { + this.title = Optional.ofNullable(title); return this; } /** - * The news item body, which may contain HTML.

    The news item body, which may contain HTML.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The news item body, which may contain HTML.

    */ - @java.lang.Override - @JsonSetter("body") - public SenderIdStage body(@NotNull String body) { - this.body = Objects.requireNonNull(body, "body must not be null"); + @JsonSetter(value = "body", nulls = Nulls.SKIP) + public Builder body(Optional body) { + this.body = body; + return this; + } + + public Builder body(String body) { + this.body = Optional.ofNullable(body); return this; } /** - * The id of the sender of the news item. Must be a teammate on the workspace.

    The id of the sender of the news item. Must be a teammate on the workspace.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The id of the sender of the news item. Must be a teammate on the workspace.

    */ - @java.lang.Override - @JsonSetter("sender_id") - public StateStage senderId(int senderId) { + @JsonSetter(value = "sender_id", nulls = Nulls.SKIP) + public Builder senderId(Optional senderId) { this.senderId = senderId; return this; } - /** - * News items will not be visible to your users in the assigned newsfeeds until they are set live.

    News items will not be visible to your users in the assigned newsfeeds until they are set live.

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("state") - public CreatedAtStage state(@NotNull State state) { - this.state = Objects.requireNonNull(state, "state must not be null"); + public Builder senderId(Integer senderId) { + this.senderId = Optional.ofNullable(senderId); return this; } /** - * Timestamp for when the news item was created.

    Timestamp for when the news item was created.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    News items will not be visible to your users in the assigned newsfeeds until they are set live.

    */ - @java.lang.Override - @JsonSetter("created_at") - public _FinalStage createdAt(int createdAt) { - this.createdAt = createdAt; + @JsonSetter(value = "state", nulls = Nulls.SKIP) + public Builder state(Optional state) { + this.state = state; return this; } - /** - *

    Timestamp for when the news item was last updated.

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage updatedAt(Integer updatedAt) { - this.updatedAt = Optional.ofNullable(updatedAt); + public Builder state(State state) { + this.state = Optional.ofNullable(state); return this; } /** - *

    Timestamp for when the news item was last updated.

    + *

    A list of newsfeed_assignments to assign to the specified newsfeed.

    */ - @java.lang.Override - @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) - public _FinalStage updatedAt(Optional updatedAt) { - this.updatedAt = updatedAt; + @JsonSetter(value = "newsfeed_assignments", nulls = Nulls.SKIP) + public Builder newsfeedAssignments(Optional> newsfeedAssignments) { + this.newsfeedAssignments = newsfeedAssignments; return this; } - /** - *

    When set to true, the news item will appear in the messenger newsfeed without showing a notification badge.

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage deliverSilently(Boolean deliverSilently) { - this.deliverSilently = Optional.ofNullable(deliverSilently); + public Builder newsfeedAssignments(List newsfeedAssignments) { + this.newsfeedAssignments = Optional.ofNullable(newsfeedAssignments); return this; } /** - *

    When set to true, the news item will appear in the messenger newsfeed without showing a notification badge.

    + *

    Label names displayed to users to categorize the news item.

    */ - @java.lang.Override - @JsonSetter(value = "deliver_silently", nulls = Nulls.SKIP) - public _FinalStage deliverSilently(Optional deliverSilently) { - this.deliverSilently = deliverSilently; + @JsonSetter(value = "labels", nulls = Nulls.SKIP) + public Builder labels(Optional>> labels) { + this.labels = labels; + return this; + } + + public Builder labels(List> labels) { + this.labels = Optional.ofNullable(labels); return this; } /** - *

    Ordered list of emoji reactions to the news item. When empty, reactions are disabled.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    URL of the image used as cover. Must have .jpg or .png extension.

    */ - @java.lang.Override - public _FinalStage reactions(List> reactions) { - this.reactions = Optional.ofNullable(reactions); + @JsonSetter(value = "cover_image_url", nulls = Nulls.SKIP) + public Builder coverImageUrl(Optional coverImageUrl) { + this.coverImageUrl = coverImageUrl; + return this; + } + + public Builder coverImageUrl(String coverImageUrl) { + this.coverImageUrl = Optional.ofNullable(coverImageUrl); return this; } /** *

    Ordered list of emoji reactions to the news item. When empty, reactions are disabled.

    */ - @java.lang.Override @JsonSetter(value = "reactions", nulls = Nulls.SKIP) - public _FinalStage reactions(Optional>> reactions) { + public Builder reactions(Optional>> reactions) { this.reactions = reactions; return this; } - /** - *

    URL of the image used as cover. Must have .jpg or .png extension.

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage coverImageUrl(String coverImageUrl) { - this.coverImageUrl = Optional.ofNullable(coverImageUrl); + public Builder reactions(List> reactions) { + this.reactions = Optional.ofNullable(reactions); return this; } /** - *

    URL of the image used as cover. Must have .jpg or .png extension.

    + *

    When set to true, the news item will appear in the messenger newsfeed without showing a notification badge.

    */ - @java.lang.Override - @JsonSetter(value = "cover_image_url", nulls = Nulls.SKIP) - public _FinalStage coverImageUrl(Optional coverImageUrl) { - this.coverImageUrl = coverImageUrl; + @JsonSetter(value = "deliver_silently", nulls = Nulls.SKIP) + public Builder deliverSilently(Optional deliverSilently) { + this.deliverSilently = deliverSilently; return this; } - /** - *

    Label names displayed to users to categorize the news item.

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage labels(List> labels) { - this.labels = Optional.ofNullable(labels); + public Builder deliverSilently(Boolean deliverSilently) { + this.deliverSilently = Optional.ofNullable(deliverSilently); return this; } /** - *

    Label names displayed to users to categorize the news item.

    + *

    Timestamp for when the news item was created.

    */ - @java.lang.Override - @JsonSetter(value = "labels", nulls = Nulls.SKIP) - public _FinalStage labels(Optional>> labels) { - this.labels = labels; + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public Builder createdAt(Optional createdAt) { + this.createdAt = createdAt; return this; } - /** - *

    A list of newsfeed_assignments to assign to the specified newsfeed.

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage newsfeedAssignments(List newsfeedAssignments) { - this.newsfeedAssignments = Optional.ofNullable(newsfeedAssignments); + public Builder createdAt(Integer createdAt) { + this.createdAt = Optional.ofNullable(createdAt); return this; } /** - *

    A list of newsfeed_assignments to assign to the specified newsfeed.

    + *

    Timestamp for when the news item was last updated.

    */ - @java.lang.Override - @JsonSetter(value = "newsfeed_assignments", nulls = Nulls.SKIP) - public _FinalStage newsfeedAssignments(Optional> newsfeedAssignments) { - this.newsfeedAssignments = newsfeedAssignments; + @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) + public Builder updatedAt(Optional updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + public Builder updatedAt(Integer updatedAt) { + this.updatedAt = Optional.ofNullable(updatedAt); return this; } - @java.lang.Override public NewsItem build() { return new NewsItem( id, diff --git a/src/main/java/com/intercom/api/resources/news/types/Newsfeed.java b/src/main/java/com/intercom/api/resources/news/types/Newsfeed.java index a0056b3..4151bf0 100644 --- a/src/main/java/com/intercom/api/resources/news/types/Newsfeed.java +++ b/src/main/java/com/intercom/api/resources/news/types/Newsfeed.java @@ -16,25 +16,24 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; -import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = Newsfeed.Builder.class) public final class Newsfeed { - private final String id; + private final Optional id; - private final String name; + private final Optional name; - private final int createdAt; + private final Optional createdAt; private final Optional updatedAt; private final Map additionalProperties; private Newsfeed( - String id, - String name, - int createdAt, + Optional id, + Optional name, + Optional createdAt, Optional updatedAt, Map additionalProperties) { this.id = id; @@ -48,23 +47,15 @@ private Newsfeed( * @return The unique identifier for the newsfeed which is given by Intercom. */ @JsonProperty("id") - public String getId() { + public Optional getId() { return id; } - /** - * @return The type of object. - */ - @JsonProperty("type") - public String getType() { - return "newsfeed"; - } - /** * @return The name of the newsfeed. This name will never be visible to your users. */ @JsonProperty("name") - public String getName() { + public Optional getName() { return name; } @@ -72,7 +63,7 @@ public String getName() { * @return Timestamp for when the newsfeed was created. */ @JsonProperty("created_at") - public int getCreatedAt() { + public Optional getCreatedAt() { return createdAt; } @@ -98,7 +89,7 @@ public Map getAdditionalProperties() { private boolean equalTo(Newsfeed other) { return id.equals(other.id) && name.equals(other.name) - && createdAt == other.createdAt + && createdAt.equals(other.createdAt) && updatedAt.equals(other.updatedAt); } @@ -112,51 +103,17 @@ public String toString() { return ObjectMappers.stringify(this); } - public static IdStage builder() { + public static Builder builder() { return new Builder(); } - public interface IdStage { - /** - * The unique identifier for the newsfeed which is given by Intercom. - */ - NameStage id(@NotNull String id); - - Builder from(Newsfeed other); - } - - public interface NameStage { - /** - * The name of the newsfeed. This name will never be visible to your users. - */ - CreatedAtStage name(@NotNull String name); - } - - public interface CreatedAtStage { - /** - * Timestamp for when the newsfeed was created. - */ - _FinalStage createdAt(int createdAt); - } - - public interface _FinalStage { - Newsfeed build(); - - /** - *

    Timestamp for when the newsfeed was last updated.

    - */ - _FinalStage updatedAt(Optional updatedAt); - - _FinalStage updatedAt(Integer updatedAt); - } - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements IdStage, NameStage, CreatedAtStage, _FinalStage { - private String id; + public static final class Builder { + private Optional id = Optional.empty(); - private String name; + private Optional name = Optional.empty(); - private int createdAt; + private Optional createdAt = Optional.empty(); private Optional updatedAt = Optional.empty(); @@ -165,7 +122,6 @@ public static final class Builder implements IdStage, NameStage, CreatedAtStage, private Builder() {} - @java.lang.Override public Builder from(Newsfeed other) { id(other.getId()); name(other.getName()); @@ -175,59 +131,61 @@ public Builder from(Newsfeed other) { } /** - * The unique identifier for the newsfeed which is given by Intercom.

    The unique identifier for the newsfeed which is given by Intercom.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The unique identifier for the newsfeed which is given by Intercom.

    */ - @java.lang.Override - @JsonSetter("id") - public NameStage id(@NotNull String id) { - this.id = Objects.requireNonNull(id, "id must not be null"); + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.ofNullable(id); return this; } /** - * The name of the newsfeed. This name will never be visible to your users.

    The name of the newsfeed. This name will never be visible to your users.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The name of the newsfeed. This name will never be visible to your users.

    */ - @java.lang.Override - @JsonSetter("name") - public CreatedAtStage name(@NotNull String name) { - this.name = Objects.requireNonNull(name, "name must not be null"); + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public Builder name(Optional name) { + this.name = name; + return this; + } + + public Builder name(String name) { + this.name = Optional.ofNullable(name); return this; } /** - * Timestamp for when the newsfeed was created.

    Timestamp for when the newsfeed was created.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    Timestamp for when the newsfeed was created.

    */ - @java.lang.Override - @JsonSetter("created_at") - public _FinalStage createdAt(int createdAt) { + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public Builder createdAt(Optional createdAt) { this.createdAt = createdAt; return this; } - /** - *

    Timestamp for when the newsfeed was last updated.

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage updatedAt(Integer updatedAt) { - this.updatedAt = Optional.ofNullable(updatedAt); + public Builder createdAt(Integer createdAt) { + this.createdAt = Optional.ofNullable(createdAt); return this; } /** *

    Timestamp for when the newsfeed was last updated.

    */ - @java.lang.Override @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) - public _FinalStage updatedAt(Optional updatedAt) { + public Builder updatedAt(Optional updatedAt) { this.updatedAt = updatedAt; return this; } - @java.lang.Override + public Builder updatedAt(Integer updatedAt) { + this.updatedAt = Optional.ofNullable(updatedAt); + return this; + } + public Newsfeed build() { return new Newsfeed(id, name, createdAt, updatedAt, additionalProperties); } diff --git a/src/main/java/com/intercom/api/resources/news/types/NewsfeedAssignment.java b/src/main/java/com/intercom/api/resources/news/types/NewsfeedAssignment.java index f7ba8e7..6781737 100644 --- a/src/main/java/com/intercom/api/resources/news/types/NewsfeedAssignment.java +++ b/src/main/java/com/intercom/api/resources/news/types/NewsfeedAssignment.java @@ -9,22 +9,25 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.intercom.api.core.ObjectMappers; import java.util.HashMap; import java.util.Map; import java.util.Objects; +import java.util.Optional; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = NewsfeedAssignment.Builder.class) public final class NewsfeedAssignment { - private final int newsfeedId; + private final Optional newsfeedId; - private final int publishedAt; + private final Optional publishedAt; private final Map additionalProperties; - private NewsfeedAssignment(int newsfeedId, int publishedAt, Map additionalProperties) { + private NewsfeedAssignment( + Optional newsfeedId, Optional publishedAt, Map additionalProperties) { this.newsfeedId = newsfeedId; this.publishedAt = publishedAt; this.additionalProperties = additionalProperties; @@ -34,7 +37,7 @@ private NewsfeedAssignment(int newsfeedId, int publishedAt, Map * @return 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). */ @JsonProperty("newsfeed_id") - public int getNewsfeedId() { + public Optional getNewsfeedId() { return newsfeedId; } @@ -42,7 +45,7 @@ public int getNewsfeedId() { * @return 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". */ @JsonProperty("published_at") - public int getPublishedAt() { + public Optional getPublishedAt() { return publishedAt; } @@ -58,7 +61,7 @@ public Map getAdditionalProperties() { } private boolean equalTo(NewsfeedAssignment other) { - return newsfeedId == other.newsfeedId && publishedAt == other.publishedAt; + return newsfeedId.equals(other.newsfeedId) && publishedAt.equals(other.publishedAt); } @java.lang.Override @@ -71,42 +74,21 @@ public String toString() { return ObjectMappers.stringify(this); } - public static NewsfeedIdStage builder() { + public static Builder builder() { return new Builder(); } - public interface NewsfeedIdStage { - /** - * 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). - */ - PublishedAtStage newsfeedId(int newsfeedId); - - Builder from(NewsfeedAssignment other); - } - - public interface PublishedAtStage { - /** - * 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". - */ - _FinalStage publishedAt(int publishedAt); - } - - public interface _FinalStage { - NewsfeedAssignment build(); - } - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements NewsfeedIdStage, PublishedAtStage, _FinalStage { - private int newsfeedId; + public static final class Builder { + private Optional newsfeedId = Optional.empty(); - private int publishedAt; + private Optional publishedAt = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} - @java.lang.Override public Builder from(NewsfeedAssignment other) { newsfeedId(other.getNewsfeedId()); publishedAt(other.getPublishedAt()); @@ -114,28 +96,33 @@ public Builder from(NewsfeedAssignment other) { } /** - * 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).

    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).

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    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).

    */ - @java.lang.Override - @JsonSetter("newsfeed_id") - public PublishedAtStage newsfeedId(int newsfeedId) { + @JsonSetter(value = "newsfeed_id", nulls = Nulls.SKIP) + public Builder newsfeedId(Optional newsfeedId) { this.newsfeedId = newsfeedId; return this; } + public Builder newsfeedId(Integer newsfeedId) { + this.newsfeedId = Optional.ofNullable(newsfeedId); + return this; + } + /** - * 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".

    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".

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    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".

    */ - @java.lang.Override - @JsonSetter("published_at") - public _FinalStage publishedAt(int publishedAt) { + @JsonSetter(value = "published_at", nulls = Nulls.SKIP) + public Builder publishedAt(Optional publishedAt) { this.publishedAt = publishedAt; return this; } - @java.lang.Override + public Builder publishedAt(Integer publishedAt) { + this.publishedAt = Optional.ofNullable(publishedAt); + return this; + } + public NewsfeedAssignment build() { return new NewsfeedAssignment(newsfeedId, publishedAt, additionalProperties); } diff --git a/src/main/java/com/intercom/api/resources/notes/AsyncRawNotesClient.java b/src/main/java/com/intercom/api/resources/notes/AsyncRawNotesClient.java index 9fb3e8a..f78c4e7 100644 --- a/src/main/java/com/intercom/api/resources/notes/AsyncRawNotesClient.java +++ b/src/main/java/com/intercom/api/resources/notes/AsyncRawNotesClient.java @@ -22,6 +22,7 @@ import com.intercom.api.types.Error; import com.intercom.api.types.NoteList; import java.io.IOException; +import java.util.Collections; import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; @@ -93,7 +94,7 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO .from(request) .page(newPageNumber) .build(); - List result = parsedResponse.getData(); + List result = parsedResponse.getData().orElse(Collections.emptyList()); future.complete(new IntercomHttpResponse<>( new SyncPagingIterable(true, result, () -> { try { @@ -225,7 +226,7 @@ public CompletableFuture> find(FindNoteRequest reques HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("notes") - .addPathSegment(request.getNoteId()) + .addPathSegment(Integer.toString(request.getNoteId())) .build(); Request.Builder _requestBuilder = new Request.Builder() .url(httpUrl) diff --git a/src/main/java/com/intercom/api/resources/notes/RawNotesClient.java b/src/main/java/com/intercom/api/resources/notes/RawNotesClient.java index e2cc71e..aefa3d9 100644 --- a/src/main/java/com/intercom/api/resources/notes/RawNotesClient.java +++ b/src/main/java/com/intercom/api/resources/notes/RawNotesClient.java @@ -22,6 +22,7 @@ import com.intercom.api.types.Error; import com.intercom.api.types.NoteList; import java.io.IOException; +import java.util.Collections; import java.util.List; import okhttp3.Headers; import okhttp3.HttpUrl; @@ -83,7 +84,7 @@ public IntercomHttpResponse> list( .from(request) .page(newPageNumber) .build(); - List result = parsedResponse.getData(); + List result = parsedResponse.getData().orElse(Collections.emptyList()); return new IntercomHttpResponse<>( new SyncPagingIterable(true, result, () -> list(nextRequest, requestOptions) .body()), @@ -182,7 +183,7 @@ public IntercomHttpResponse find(FindNoteRequest request, RequestOptions r HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("notes") - .addPathSegment(request.getNoteId()) + .addPathSegment(Integer.toString(request.getNoteId())) .build(); Request.Builder _requestBuilder = new Request.Builder() .url(httpUrl) diff --git a/src/main/java/com/intercom/api/resources/notes/requests/FindNoteRequest.java b/src/main/java/com/intercom/api/resources/notes/requests/FindNoteRequest.java index e51a52b..41bdede 100644 --- a/src/main/java/com/intercom/api/resources/notes/requests/FindNoteRequest.java +++ b/src/main/java/com/intercom/api/resources/notes/requests/FindNoteRequest.java @@ -14,16 +14,15 @@ import java.util.HashMap; import java.util.Map; import java.util.Objects; -import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = FindNoteRequest.Builder.class) public final class FindNoteRequest { - private final String noteId; + private final int noteId; private final Map additionalProperties; - private FindNoteRequest(String noteId, Map additionalProperties) { + private FindNoteRequest(int noteId, Map additionalProperties) { this.noteId = noteId; this.additionalProperties = additionalProperties; } @@ -32,7 +31,7 @@ private FindNoteRequest(String noteId, Map additionalProperties) * @return The unique identifier of a given note */ @JsonProperty("note_id") - public String getNoteId() { + public int getNoteId() { return noteId; } @@ -48,7 +47,7 @@ public Map getAdditionalProperties() { } private boolean equalTo(FindNoteRequest other) { - return noteId.equals(other.noteId); + return noteId == other.noteId; } @java.lang.Override @@ -69,7 +68,7 @@ public interface NoteIdStage { /** * The unique identifier of a given note */ - _FinalStage noteId(@NotNull String noteId); + _FinalStage noteId(int noteId); Builder from(FindNoteRequest other); } @@ -80,7 +79,7 @@ public interface _FinalStage { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements NoteIdStage, _FinalStage { - private String noteId; + private int noteId; @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -99,8 +98,8 @@ public Builder from(FindNoteRequest other) { */ @java.lang.Override @JsonSetter("note_id") - public _FinalStage noteId(@NotNull String noteId) { - this.noteId = Objects.requireNonNull(noteId, "noteId must not be null"); + public _FinalStage noteId(int noteId) { + this.noteId = noteId; return this; } diff --git a/src/main/java/com/intercom/api/resources/notes/types/Note.java b/src/main/java/com/intercom/api/resources/notes/types/Note.java index 3e303c4..847c335 100644 --- a/src/main/java/com/intercom/api/resources/notes/types/Note.java +++ b/src/main/java/com/intercom/api/resources/notes/types/Note.java @@ -17,30 +17,33 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; -import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = Note.Builder.class) public final class Note { - private final String id; + private final Optional type; - private final int createdAt; + private final Optional id; + + private final Optional createdAt; private final Optional contact; - private final Admin author; + private final Optional author; - private final String body; + private final Optional body; private final Map additionalProperties; private Note( - String id, - int createdAt, + Optional type, + Optional id, + Optional createdAt, Optional contact, - Admin author, - String body, + Optional author, + Optional body, Map additionalProperties) { + this.type = type; this.id = id; this.createdAt = createdAt; this.contact = contact; @@ -53,15 +56,15 @@ private Note( * @return String representing the object's type. Always has the value note. */ @JsonProperty("type") - public String getType() { - return "note"; + public Optional getType() { + return type; } /** * @return The id of the note. */ @JsonProperty("id") - public String getId() { + public Optional getId() { return id; } @@ -69,7 +72,7 @@ public String getId() { * @return The time the note was created. */ @JsonProperty("created_at") - public int getCreatedAt() { + public Optional getCreatedAt() { return createdAt; } @@ -85,7 +88,7 @@ public Optional getContact() { * @return Optional. Represents the Admin that created the note. */ @JsonProperty("author") - public Admin getAuthor() { + public Optional getAuthor() { return author; } @@ -93,7 +96,7 @@ public Admin getAuthor() { * @return The body text of the note. */ @JsonProperty("body") - public String getBody() { + public Optional getBody() { return body; } @@ -109,8 +112,9 @@ public Map getAdditionalProperties() { } private boolean equalTo(Note other) { - return id.equals(other.id) - && createdAt == other.createdAt + return type.equals(other.type) + && id.equals(other.id) + && createdAt.equals(other.createdAt) && contact.equals(other.contact) && author.equals(other.author) && body.equals(other.body); @@ -118,7 +122,7 @@ private boolean equalTo(Note other) { @java.lang.Override public int hashCode() { - return Objects.hash(this.id, this.createdAt, this.contact, this.author, this.body); + return Objects.hash(this.type, this.id, this.createdAt, this.contact, this.author, this.body); } @java.lang.Override @@ -126,70 +130,31 @@ public String toString() { return ObjectMappers.stringify(this); } - public static IdStage builder() { + public static Builder builder() { return new Builder(); } - public interface IdStage { - /** - * The id of the note. - */ - CreatedAtStage id(@NotNull String id); - - Builder from(Note other); - } - - public interface CreatedAtStage { - /** - * The time the note was created. - */ - AuthorStage createdAt(int createdAt); - } - - public interface AuthorStage { - /** - * Optional. Represents the Admin that created the note. - */ - BodyStage author(@NotNull Admin author); - } - - public interface BodyStage { - /** - * The body text of the note. - */ - _FinalStage body(@NotNull String body); - } - - public interface _FinalStage { - Note build(); - - /** - *

    Represents the contact that the note was created about.

    - */ - _FinalStage contact(Optional contact); - - _FinalStage contact(Contact contact); - } - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements IdStage, CreatedAtStage, AuthorStage, BodyStage, _FinalStage { - private String id; - - private int createdAt; + public static final class Builder { + private Optional type = Optional.empty(); - private Admin author; + private Optional id = Optional.empty(); - private String body; + private Optional createdAt = Optional.empty(); private Optional contact = Optional.empty(); + private Optional author = Optional.empty(); + + private Optional body = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} - @java.lang.Override public Builder from(Note other) { + type(other.getType()); id(other.getId()); createdAt(other.getCreatedAt()); contact(other.getContact()); @@ -199,72 +164,91 @@ public Builder from(Note other) { } /** - * The id of the note.

    The id of the note.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    String representing the object's type. Always has the value note.

    */ - @java.lang.Override - @JsonSetter("id") - public CreatedAtStage id(@NotNull String id) { - this.id = Objects.requireNonNull(id, "id must not be null"); + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; return this; } - /** - * The time the note was created.

    The time the note was created.

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("created_at") - public AuthorStage createdAt(int createdAt) { - this.createdAt = createdAt; + public Builder type(String type) { + this.type = Optional.ofNullable(type); return this; } /** - * Optional. Represents the Admin that created the note.

    Optional. Represents the Admin that created the note.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The id of the note.

    */ - @java.lang.Override - @JsonSetter("author") - public BodyStage author(@NotNull Admin author) { - this.author = Objects.requireNonNull(author, "author must not be null"); + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.ofNullable(id); return this; } /** - * The body text of the note.

    The body text of the note.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The time the note was created.

    */ - @java.lang.Override - @JsonSetter("body") - public _FinalStage body(@NotNull String body) { - this.body = Objects.requireNonNull(body, "body must not be null"); + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public Builder createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + public Builder createdAt(Integer createdAt) { + this.createdAt = Optional.ofNullable(createdAt); return this; } /** *

    Represents the contact that the note was created about.

    - * @return Reference to {@code this} so that method calls can be chained together. */ - @java.lang.Override - public _FinalStage contact(Contact contact) { + @JsonSetter(value = "contact", nulls = Nulls.SKIP) + public Builder contact(Optional contact) { + this.contact = contact; + return this; + } + + public Builder contact(Contact contact) { this.contact = Optional.ofNullable(contact); return this; } /** - *

    Represents the contact that the note was created about.

    + *

    Optional. Represents the Admin that created the note.

    */ - @java.lang.Override - @JsonSetter(value = "contact", nulls = Nulls.SKIP) - public _FinalStage contact(Optional contact) { - this.contact = contact; + @JsonSetter(value = "author", nulls = Nulls.SKIP) + public Builder author(Optional author) { + this.author = author; + return this; + } + + public Builder author(Admin author) { + this.author = Optional.ofNullable(author); + return this; + } + + /** + *

    The body text of the note.

    + */ + @JsonSetter(value = "body", nulls = Nulls.SKIP) + public Builder body(Optional body) { + this.body = body; + return this; + } + + public Builder body(String body) { + this.body = Optional.ofNullable(body); return this; } - @java.lang.Override public Note build() { - return new Note(id, createdAt, contact, author, body, additionalProperties); + return new Note(type, id, createdAt, contact, author, body, additionalProperties); } } diff --git a/src/main/java/com/intercom/api/resources/phonecallredirects/AsyncPhoneCallRedirectsClient.java b/src/main/java/com/intercom/api/resources/phonecallredirects/AsyncPhoneCallRedirectsClient.java index 2c5e358..e7b9676 100644 --- a/src/main/java/com/intercom/api/resources/phonecallredirects/AsyncPhoneCallRedirectsClient.java +++ b/src/main/java/com/intercom/api/resources/phonecallredirects/AsyncPhoneCallRedirectsClient.java @@ -5,8 +5,9 @@ import com.intercom.api.core.ClientOptions; import com.intercom.api.core.RequestOptions; -import com.intercom.api.resources.phonecallredirects.requests.CreatePhoneCallRedirectRequest; +import com.intercom.api.types.CreatePhoneSwitchRequest; import com.intercom.api.types.PhoneSwitch; +import java.util.Optional; import java.util.concurrent.CompletableFuture; public class AsyncPhoneCallRedirectsClient { @@ -31,7 +32,16 @@ public AsyncRawPhoneCallRedirectsClient withRawResponse() { * 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.

    */ - public CompletableFuture create(CreatePhoneCallRedirectRequest request) { + public CompletableFuture> create() { + return this.rawClient.create().thenApply(response -> response.body()); + } + + /** + * 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.

    + */ + public CompletableFuture> create(Optional request) { return this.rawClient.create(request).thenApply(response -> response.body()); } @@ -40,8 +50,8 @@ public CompletableFuture create(CreatePhoneCallRedirectRequest requ * 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.

    */ - public CompletableFuture create( - CreatePhoneCallRedirectRequest request, RequestOptions requestOptions) { + public CompletableFuture> create( + Optional request, RequestOptions requestOptions) { return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); } } diff --git a/src/main/java/com/intercom/api/resources/phonecallredirects/AsyncRawPhoneCallRedirectsClient.java b/src/main/java/com/intercom/api/resources/phonecallredirects/AsyncRawPhoneCallRedirectsClient.java index bcbb060..59f37df 100644 --- a/src/main/java/com/intercom/api/resources/phonecallredirects/AsyncRawPhoneCallRedirectsClient.java +++ b/src/main/java/com/intercom/api/resources/phonecallredirects/AsyncRawPhoneCallRedirectsClient.java @@ -4,6 +4,7 @@ package com.intercom.api.resources.phonecallredirects; import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; import com.intercom.api.core.ClientOptions; import com.intercom.api.core.IntercomApiException; import com.intercom.api.core.IntercomException; @@ -14,10 +15,11 @@ import com.intercom.api.errors.BadRequestError; import com.intercom.api.errors.UnauthorizedError; import com.intercom.api.errors.UnprocessableEntityError; -import com.intercom.api.resources.phonecallredirects.requests.CreatePhoneCallRedirectRequest; +import com.intercom.api.types.CreatePhoneSwitchRequest; import com.intercom.api.types.Error; import com.intercom.api.types.PhoneSwitch; import java.io.IOException; +import java.util.Optional; import java.util.concurrent.CompletableFuture; import okhttp3.Call; import okhttp3.Callback; @@ -42,7 +44,17 @@ public AsyncRawPhoneCallRedirectsClient(ClientOptions clientOptions) { * 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.

    */ - public CompletableFuture> create(CreatePhoneCallRedirectRequest request) { + public CompletableFuture>> create() { + return create(Optional.empty()); + } + + /** + * 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.

    + */ + public CompletableFuture>> create( + Optional request) { return create(request, null); } @@ -51,16 +63,19 @@ public CompletableFuture> create(CreatePhoneCa * 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.

    */ - public CompletableFuture> create( - CreatePhoneCallRedirectRequest request, RequestOptions requestOptions) { + public CompletableFuture>> create( + Optional request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("phone_call_redirects") .build(); RequestBody body; try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + body = RequestBody.create("", null); + if (request.isPresent()) { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } } catch (JsonProcessingException e) { throw new IntercomException("Failed to serialize request", e); } @@ -75,14 +90,15 @@ public CompletableFuture> create( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } - CompletableFuture> future = new CompletableFuture<>(); + CompletableFuture>> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PhoneSwitch.class), + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), response)); return; } diff --git a/src/main/java/com/intercom/api/resources/phonecallredirects/PhoneCallRedirectsClient.java b/src/main/java/com/intercom/api/resources/phonecallredirects/PhoneCallRedirectsClient.java index 836dc4f..dcbceab 100644 --- a/src/main/java/com/intercom/api/resources/phonecallredirects/PhoneCallRedirectsClient.java +++ b/src/main/java/com/intercom/api/resources/phonecallredirects/PhoneCallRedirectsClient.java @@ -5,8 +5,9 @@ import com.intercom.api.core.ClientOptions; import com.intercom.api.core.RequestOptions; -import com.intercom.api.resources.phonecallredirects.requests.CreatePhoneCallRedirectRequest; +import com.intercom.api.types.CreatePhoneSwitchRequest; import com.intercom.api.types.PhoneSwitch; +import java.util.Optional; public class PhoneCallRedirectsClient { protected final ClientOptions clientOptions; @@ -30,7 +31,16 @@ public RawPhoneCallRedirectsClient withRawResponse() { * 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.

    */ - public PhoneSwitch create(CreatePhoneCallRedirectRequest request) { + public Optional create() { + return this.rawClient.create().body(); + } + + /** + * 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.

    + */ + public Optional create(Optional request) { return this.rawClient.create(request).body(); } @@ -39,7 +49,7 @@ public PhoneSwitch create(CreatePhoneCallRedirectRequest request) { * 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.

    */ - public PhoneSwitch create(CreatePhoneCallRedirectRequest request, RequestOptions requestOptions) { + public Optional create(Optional request, RequestOptions requestOptions) { return this.rawClient.create(request, requestOptions).body(); } } diff --git a/src/main/java/com/intercom/api/resources/phonecallredirects/RawPhoneCallRedirectsClient.java b/src/main/java/com/intercom/api/resources/phonecallredirects/RawPhoneCallRedirectsClient.java index 14ee509..208be18 100644 --- a/src/main/java/com/intercom/api/resources/phonecallredirects/RawPhoneCallRedirectsClient.java +++ b/src/main/java/com/intercom/api/resources/phonecallredirects/RawPhoneCallRedirectsClient.java @@ -4,6 +4,7 @@ package com.intercom.api.resources.phonecallredirects; import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; import com.intercom.api.core.ClientOptions; import com.intercom.api.core.IntercomApiException; import com.intercom.api.core.IntercomException; @@ -14,10 +15,11 @@ import com.intercom.api.errors.BadRequestError; import com.intercom.api.errors.UnauthorizedError; import com.intercom.api.errors.UnprocessableEntityError; -import com.intercom.api.resources.phonecallredirects.requests.CreatePhoneCallRedirectRequest; +import com.intercom.api.types.CreatePhoneSwitchRequest; import com.intercom.api.types.Error; import com.intercom.api.types.PhoneSwitch; import java.io.IOException; +import java.util.Optional; import okhttp3.Headers; import okhttp3.HttpUrl; import okhttp3.OkHttpClient; @@ -38,7 +40,16 @@ public RawPhoneCallRedirectsClient(ClientOptions clientOptions) { * 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.

    */ - public IntercomHttpResponse create(CreatePhoneCallRedirectRequest request) { + public IntercomHttpResponse> create() { + return create(Optional.empty()); + } + + /** + * 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.

    + */ + public IntercomHttpResponse> create(Optional request) { return create(request, null); } @@ -47,16 +58,19 @@ public IntercomHttpResponse create(CreatePhoneCallRedirectRequest r * 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.

    */ - public IntercomHttpResponse create( - CreatePhoneCallRedirectRequest request, RequestOptions requestOptions) { + public IntercomHttpResponse> create( + Optional request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("phone_call_redirects") .build(); RequestBody body; try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + body = RequestBody.create("", null); + if (request.isPresent()) { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } } catch (JsonProcessingException e) { throw new IntercomException("Failed to serialize request", e); } @@ -75,7 +89,9 @@ public IntercomHttpResponse create( ResponseBody responseBody = response.body(); if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PhoneSwitch.class), response); + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { diff --git a/src/main/java/com/intercom/api/resources/phonecallredirects/requests/CreatePhoneCallRedirectRequest.java b/src/main/java/com/intercom/api/resources/phonecallredirects/requests/CreatePhoneCallRedirectRequest.java deleted file mode 100644 index 29c1a05..0000000 --- a/src/main/java/com/intercom/api/resources/phonecallredirects/requests/CreatePhoneCallRedirectRequest.java +++ /dev/null @@ -1,143 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.intercom.api.resources.phonecallredirects.requests; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.intercom.api.core.ObjectMappers; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import org.jetbrains.annotations.NotNull; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = CreatePhoneCallRedirectRequest.Builder.class) -public final class CreatePhoneCallRedirectRequest { - private final String phone; - - private final Optional> customAttributes; - - private final Map additionalProperties; - - private CreatePhoneCallRedirectRequest( - String phone, Optional> customAttributes, Map additionalProperties) { - this.phone = phone; - this.customAttributes = customAttributes; - this.additionalProperties = additionalProperties; - } - - /** - * @return Phone number in E.164 format, that will receive the SMS to continue the conversation in the Messenger. - */ - @JsonProperty("phone") - public String getPhone() { - return phone; - } - - @JsonProperty("custom_attributes") - public Optional> getCustomAttributes() { - return customAttributes; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof CreatePhoneCallRedirectRequest && equalTo((CreatePhoneCallRedirectRequest) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(CreatePhoneCallRedirectRequest other) { - return phone.equals(other.phone) && customAttributes.equals(other.customAttributes); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.phone, this.customAttributes); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static PhoneStage builder() { - return new Builder(); - } - - public interface PhoneStage { - /** - * Phone number in E.164 format, that will receive the SMS to continue the conversation in the Messenger. - */ - _FinalStage phone(@NotNull String phone); - - Builder from(CreatePhoneCallRedirectRequest other); - } - - public interface _FinalStage { - CreatePhoneCallRedirectRequest build(); - - _FinalStage customAttributes(Optional> customAttributes); - - _FinalStage customAttributes(Map customAttributes); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements PhoneStage, _FinalStage { - private String phone; - - private Optional> customAttributes = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(CreatePhoneCallRedirectRequest other) { - phone(other.getPhone()); - customAttributes(other.getCustomAttributes()); - return this; - } - - /** - * Phone number in E.164 format, that will receive the SMS to continue the conversation in the Messenger.

    Phone number in E.164 format, that will receive the SMS to continue the conversation in the Messenger.

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("phone") - public _FinalStage phone(@NotNull String phone) { - this.phone = Objects.requireNonNull(phone, "phone must not be null"); - return this; - } - - @java.lang.Override - public _FinalStage customAttributes(Map customAttributes) { - this.customAttributes = Optional.ofNullable(customAttributes); - return this; - } - - @java.lang.Override - @JsonSetter(value = "custom_attributes", nulls = Nulls.SKIP) - public _FinalStage customAttributes(Optional> customAttributes) { - this.customAttributes = customAttributes; - return this; - } - - @java.lang.Override - public CreatePhoneCallRedirectRequest build() { - return new CreatePhoneCallRedirectRequest(phone, customAttributes, additionalProperties); - } - } -} diff --git a/src/main/java/com/intercom/api/resources/segments/types/Segment.java b/src/main/java/com/intercom/api/resources/segments/types/Segment.java index fb148fa..a3db029 100644 --- a/src/main/java/com/intercom/api/resources/segments/types/Segment.java +++ b/src/main/java/com/intercom/api/resources/segments/types/Segment.java @@ -18,33 +18,36 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; -import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = Segment.Builder.class) public final class Segment { - private final String id; + private final Optional type; - private final String name; + private final Optional id; - private final int createdAt; + private final Optional name; + + private final Optional createdAt; private final Optional updatedAt; - private final PersonType personType; + private final Optional personType; private final Optional count; private final Map additionalProperties; private Segment( - String id, - String name, - int createdAt, + Optional type, + Optional id, + Optional name, + Optional createdAt, Optional updatedAt, - PersonType personType, + Optional personType, Optional count, Map additionalProperties) { + this.type = type; this.id = id; this.name = name; this.createdAt = createdAt; @@ -58,15 +61,15 @@ private Segment( * @return The type of object. */ @JsonProperty("type") - public String getType() { - return "segment"; + public Optional getType() { + return type; } /** * @return The unique identifier representing the segment. */ @JsonProperty("id") - public String getId() { + public Optional getId() { return id; } @@ -74,7 +77,7 @@ public String getId() { * @return The name of the segment. */ @JsonProperty("name") - public String getName() { + public Optional getName() { return name; } @@ -82,7 +85,7 @@ public String getName() { * @return The time the segment was created. */ @JsonProperty("created_at") - public int getCreatedAt() { + public Optional getCreatedAt() { return createdAt; } @@ -98,7 +101,7 @@ public Optional getUpdatedAt() { * @return Type of the contact: contact (lead) or user. */ @JsonProperty("person_type") - public PersonType getPersonType() { + public Optional getPersonType() { return personType; } @@ -122,9 +125,10 @@ public Map getAdditionalProperties() { } private boolean equalTo(Segment other) { - return id.equals(other.id) + return type.equals(other.type) + && id.equals(other.id) && name.equals(other.name) - && createdAt == other.createdAt + && createdAt.equals(other.createdAt) && updatedAt.equals(other.updatedAt) && personType.equals(other.personType) && count.equals(other.count); @@ -132,7 +136,7 @@ private boolean equalTo(Segment other) { @java.lang.Override public int hashCode() { - return Objects.hash(this.id, this.name, this.createdAt, this.updatedAt, this.personType, this.count); + return Objects.hash(this.type, this.id, this.name, this.createdAt, this.updatedAt, this.personType, this.count); } @java.lang.Override @@ -140,79 +144,33 @@ public String toString() { return ObjectMappers.stringify(this); } - public static IdStage builder() { + public static Builder builder() { return new Builder(); } - public interface IdStage { - /** - * The unique identifier representing the segment. - */ - NameStage id(@NotNull String id); - - Builder from(Segment other); - } - - public interface NameStage { - /** - * The name of the segment. - */ - CreatedAtStage name(@NotNull String name); - } - - public interface CreatedAtStage { - /** - * The time the segment was created. - */ - PersonTypeStage createdAt(int createdAt); - } - - public interface PersonTypeStage { - /** - * Type of the contact: contact (lead) or user. - */ - _FinalStage personType(@NotNull PersonType personType); - } - - public interface _FinalStage { - Segment build(); - - /** - *

    The time the segment was updated.

    - */ - _FinalStage updatedAt(Optional updatedAt); - - _FinalStage updatedAt(Integer updatedAt); - - /** - *

    The number of items in the user segment. It's returned when include_count=true is included in the request.

    - */ - _FinalStage count(Optional count); + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); - _FinalStage count(Integer count); - } + private Optional id = Optional.empty(); - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements IdStage, NameStage, CreatedAtStage, PersonTypeStage, _FinalStage { - private String id; + private Optional name = Optional.empty(); - private String name; + private Optional createdAt = Optional.empty(); - private int createdAt; + private Optional updatedAt = Optional.empty(); - private PersonType personType; + private Optional personType = Optional.empty(); private Optional count = Optional.empty(); - private Optional updatedAt = Optional.empty(); - @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} - @java.lang.Override public Builder from(Segment other) { + type(other.getType()); id(other.getId()); name(other.getName()); createdAt(other.getCreatedAt()); @@ -223,92 +181,105 @@ public Builder from(Segment other) { } /** - * The unique identifier representing the segment.

    The unique identifier representing the segment.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The type of object.

    */ - @java.lang.Override - @JsonSetter("id") - public NameStage id(@NotNull String id) { - this.id = Objects.requireNonNull(id, "id must not be null"); + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; return this; } - /** - * The name of the segment.

    The name of the segment.

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("name") - public CreatedAtStage name(@NotNull String name) { - this.name = Objects.requireNonNull(name, "name must not be null"); + public Builder type(String type) { + this.type = Optional.ofNullable(type); return this; } /** - * The time the segment was created.

    The time the segment was created.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The unique identifier representing the segment.

    */ - @java.lang.Override - @JsonSetter("created_at") - public PersonTypeStage createdAt(int createdAt) { - this.createdAt = createdAt; + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; return this; } - /** - * Type of the contact: contact (lead) or user.

    Type of the contact: contact (lead) or user.

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("person_type") - public _FinalStage personType(@NotNull PersonType personType) { - this.personType = Objects.requireNonNull(personType, "personType must not be null"); + public Builder id(String id) { + this.id = Optional.ofNullable(id); return this; } /** - *

    The number of items in the user segment. It's returned when include_count=true is included in the request.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The name of the segment.

    */ - @java.lang.Override - public _FinalStage count(Integer count) { - this.count = Optional.ofNullable(count); + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public Builder name(Optional name) { + this.name = name; + return this; + } + + public Builder name(String name) { + this.name = Optional.ofNullable(name); return this; } /** - *

    The number of items in the user segment. It's returned when include_count=true is included in the request.

    + *

    The time the segment was created.

    */ - @java.lang.Override - @JsonSetter(value = "count", nulls = Nulls.SKIP) - public _FinalStage count(Optional count) { - this.count = count; + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public Builder createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + public Builder createdAt(Integer createdAt) { + this.createdAt = Optional.ofNullable(createdAt); return this; } /** *

    The time the segment was updated.

    - * @return Reference to {@code this} so that method calls can be chained together. */ - @java.lang.Override - public _FinalStage updatedAt(Integer updatedAt) { + @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) + public Builder updatedAt(Optional updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + public Builder updatedAt(Integer updatedAt) { this.updatedAt = Optional.ofNullable(updatedAt); return this; } /** - *

    The time the segment was updated.

    + *

    Type of the contact: contact (lead) or user.

    */ - @java.lang.Override - @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) - public _FinalStage updatedAt(Optional updatedAt) { - this.updatedAt = updatedAt; + @JsonSetter(value = "person_type", nulls = Nulls.SKIP) + public Builder personType(Optional personType) { + this.personType = personType; + return this; + } + + public Builder personType(PersonType personType) { + this.personType = Optional.ofNullable(personType); + return this; + } + + /** + *

    The number of items in the user segment. It's returned when include_count=true is included in the request.

    + */ + @JsonSetter(value = "count", nulls = Nulls.SKIP) + public Builder count(Optional count) { + this.count = count; + return this; + } + + public Builder count(Integer count) { + this.count = Optional.ofNullable(count); return this; } - @java.lang.Override public Segment build() { - return new Segment(id, name, createdAt, updatedAt, personType, count, additionalProperties); + return new Segment(type, id, name, createdAt, updatedAt, personType, count, additionalProperties); } } diff --git a/src/main/java/com/intercom/api/resources/subscriptiontypes/types/SubscriptionType.java b/src/main/java/com/intercom/api/resources/subscriptiontypes/types/SubscriptionType.java index a02f3b4..b1a13ff 100644 --- a/src/main/java/com/intercom/api/resources/subscriptiontypes/types/SubscriptionType.java +++ b/src/main/java/com/intercom/api/resources/subscriptiontypes/types/SubscriptionType.java @@ -15,38 +15,41 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.intercom.api.core.ObjectMappers; import com.intercom.api.types.Translation; -import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; -import org.jetbrains.annotations.NotNull; +import java.util.Optional; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = SubscriptionType.Builder.class) public final class SubscriptionType { - private final String id; + private final Optional type; - private final State state; + private final Optional id; - private final Translation defaultTranslation; + private final Optional state; - private final List translations; + private final Optional defaultTranslation; - private final ConsentType consentType; + private final Optional> translations; - private final List contentTypes; + private final Optional consentType; + + private final Optional> contentTypes; private final Map additionalProperties; private SubscriptionType( - String id, - State state, - Translation defaultTranslation, - List translations, - ConsentType consentType, - List contentTypes, + Optional type, + Optional id, + Optional state, + Optional defaultTranslation, + Optional> translations, + Optional consentType, + Optional> contentTypes, Map additionalProperties) { + this.type = type; this.id = id; this.state = state; this.defaultTranslation = defaultTranslation; @@ -60,15 +63,15 @@ private SubscriptionType( * @return The type of the object - subscription */ @JsonProperty("type") - public String getType() { - return "subscription"; + public Optional getType() { + return type; } /** * @return The unique identifier representing the subscription type. */ @JsonProperty("id") - public String getId() { + public Optional getId() { return id; } @@ -76,12 +79,12 @@ public String getId() { * @return The state of the subscription type. */ @JsonProperty("state") - public State getState() { + public Optional getState() { return state; } @JsonProperty("default_translation") - public Translation getDefaultTranslation() { + public Optional getDefaultTranslation() { return defaultTranslation; } @@ -89,7 +92,7 @@ public Translation getDefaultTranslation() { * @return An array of translations objects with the localised version of the subscription type in each available locale within your translation settings. */ @JsonProperty("translations") - public List getTranslations() { + public Optional> getTranslations() { return translations; } @@ -97,7 +100,7 @@ public List getTranslations() { * @return Describes the type of consent. */ @JsonProperty("consent_type") - public ConsentType getConsentType() { + public Optional getConsentType() { return consentType; } @@ -105,7 +108,7 @@ public ConsentType getConsentType() { * @return The message types that this subscription supports - can contain email or sms_message. */ @JsonProperty("content_types") - public List getContentTypes() { + public Optional> getContentTypes() { return contentTypes; } @@ -121,7 +124,8 @@ public Map getAdditionalProperties() { } private boolean equalTo(SubscriptionType other) { - return id.equals(other.id) + return type.equals(other.type) + && id.equals(other.id) && state.equals(other.state) && defaultTranslation.equals(other.defaultTranslation) && translations.equals(other.translations) @@ -132,7 +136,13 @@ private boolean equalTo(SubscriptionType other) { @java.lang.Override public int hashCode() { return Objects.hash( - this.id, this.state, this.defaultTranslation, this.translations, this.consentType, this.contentTypes); + this.type, + this.id, + this.state, + this.defaultTranslation, + this.translations, + this.consentType, + this.contentTypes); } @java.lang.Override @@ -140,81 +150,33 @@ public String toString() { return ObjectMappers.stringify(this); } - public static IdStage builder() { + public static Builder builder() { return new Builder(); } - public interface IdStage { - /** - * The unique identifier representing the subscription type. - */ - StateStage id(@NotNull String id); - - Builder from(SubscriptionType other); - } - - public interface StateStage { - /** - * The state of the subscription type. - */ - DefaultTranslationStage state(@NotNull State state); - } - - public interface DefaultTranslationStage { - ConsentTypeStage defaultTranslation(@NotNull Translation defaultTranslation); - } - - public interface ConsentTypeStage { - /** - * Describes the type of consent. - */ - _FinalStage consentType(@NotNull ConsentType consentType); - } - - public interface _FinalStage { - SubscriptionType build(); - - /** - *

    An array of translations objects with the localised version of the subscription type in each available locale within your translation settings.

    - */ - _FinalStage translations(List translations); - - _FinalStage addTranslations(Translation translations); - - _FinalStage addAllTranslations(List translations); - - /** - *

    The message types that this subscription supports - can contain email or sms_message.

    - */ - _FinalStage contentTypes(List contentTypes); - - _FinalStage addContentTypes(ContentTypesItem contentTypes); - - _FinalStage addAllContentTypes(List contentTypes); - } - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder - implements IdStage, StateStage, DefaultTranslationStage, ConsentTypeStage, _FinalStage { - private String id; + public static final class Builder { + private Optional type = Optional.empty(); - private State state; + private Optional id = Optional.empty(); - private Translation defaultTranslation; + private Optional state = Optional.empty(); - private ConsentType consentType; + private Optional defaultTranslation = Optional.empty(); - private List contentTypes = new ArrayList<>(); + private Optional> translations = Optional.empty(); - private List translations = new ArrayList<>(); + private Optional consentType = Optional.empty(); + + private Optional> contentTypes = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} - @java.lang.Override public Builder from(SubscriptionType other) { + type(other.getType()); id(other.getId()); state(other.getState()); defaultTranslation(other.getDefaultTranslation()); @@ -225,111 +187,103 @@ public Builder from(SubscriptionType other) { } /** - * The unique identifier representing the subscription type.

    The unique identifier representing the subscription type.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The type of the object - subscription

    */ - @java.lang.Override - @JsonSetter("id") - public StateStage id(@NotNull String id) { - this.id = Objects.requireNonNull(id, "id must not be null"); + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); return this; } /** - * The state of the subscription type.

    The state of the subscription type.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The unique identifier representing the subscription type.

    */ - @java.lang.Override - @JsonSetter("state") - public DefaultTranslationStage state(@NotNull State state) { - this.state = Objects.requireNonNull(state, "state must not be null"); + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; return this; } - @java.lang.Override - @JsonSetter("default_translation") - public ConsentTypeStage defaultTranslation(@NotNull Translation defaultTranslation) { - this.defaultTranslation = Objects.requireNonNull(defaultTranslation, "defaultTranslation must not be null"); + public Builder id(String id) { + this.id = Optional.ofNullable(id); return this; } /** - * Describes the type of consent.

    Describes the type of consent.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The state of the subscription type.

    */ - @java.lang.Override - @JsonSetter("consent_type") - public _FinalStage consentType(@NotNull ConsentType consentType) { - this.consentType = Objects.requireNonNull(consentType, "consentType must not be null"); + @JsonSetter(value = "state", nulls = Nulls.SKIP) + public Builder state(Optional state) { + this.state = state; return this; } - /** - *

    The message types that this subscription supports - can contain email or sms_message.

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage addAllContentTypes(List contentTypes) { - this.contentTypes.addAll(contentTypes); + public Builder state(State state) { + this.state = Optional.ofNullable(state); return this; } - /** - *

    The message types that this subscription supports - can contain email or sms_message.

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage addContentTypes(ContentTypesItem contentTypes) { - this.contentTypes.add(contentTypes); + @JsonSetter(value = "default_translation", nulls = Nulls.SKIP) + public Builder defaultTranslation(Optional defaultTranslation) { + this.defaultTranslation = defaultTranslation; return this; } - /** - *

    The message types that this subscription supports - can contain email or sms_message.

    - */ - @java.lang.Override - @JsonSetter(value = "content_types", nulls = Nulls.SKIP) - public _FinalStage contentTypes(List contentTypes) { - this.contentTypes.clear(); - this.contentTypes.addAll(contentTypes); + public Builder defaultTranslation(Translation defaultTranslation) { + this.defaultTranslation = Optional.ofNullable(defaultTranslation); return this; } /** *

    An array of translations objects with the localised version of the subscription type in each available locale within your translation settings.

    - * @return Reference to {@code this} so that method calls can be chained together. */ - @java.lang.Override - public _FinalStage addAllTranslations(List translations) { - this.translations.addAll(translations); + @JsonSetter(value = "translations", nulls = Nulls.SKIP) + public Builder translations(Optional> translations) { + this.translations = translations; + return this; + } + + public Builder translations(List translations) { + this.translations = Optional.ofNullable(translations); return this; } /** - *

    An array of translations objects with the localised version of the subscription type in each available locale within your translation settings.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    Describes the type of consent.

    */ - @java.lang.Override - public _FinalStage addTranslations(Translation translations) { - this.translations.add(translations); + @JsonSetter(value = "consent_type", nulls = Nulls.SKIP) + public Builder consentType(Optional consentType) { + this.consentType = consentType; + return this; + } + + public Builder consentType(ConsentType consentType) { + this.consentType = Optional.ofNullable(consentType); return this; } /** - *

    An array of translations objects with the localised version of the subscription type in each available locale within your translation settings.

    + *

    The message types that this subscription supports - can contain email or sms_message.

    */ - @java.lang.Override - @JsonSetter(value = "translations", nulls = Nulls.SKIP) - public _FinalStage translations(List translations) { - this.translations.clear(); - this.translations.addAll(translations); + @JsonSetter(value = "content_types", nulls = Nulls.SKIP) + public Builder contentTypes(Optional> contentTypes) { + this.contentTypes = contentTypes; + return this; + } + + public Builder contentTypes(List contentTypes) { + this.contentTypes = Optional.ofNullable(contentTypes); return this; } - @java.lang.Override public SubscriptionType build() { return new SubscriptionType( - id, state, defaultTranslation, translations, consentType, contentTypes, additionalProperties); + type, id, state, defaultTranslation, translations, consentType, contentTypes, additionalProperties); } } diff --git a/src/main/java/com/intercom/api/resources/tags/requests/UntagConversationRequest.java b/src/main/java/com/intercom/api/resources/tags/requests/UntagConversationRequest.java index 6a4faa6..ab9c333 100644 --- a/src/main/java/com/intercom/api/resources/tags/requests/UntagConversationRequest.java +++ b/src/main/java/com/intercom/api/resources/tags/requests/UntagConversationRequest.java @@ -44,7 +44,7 @@ public String getConversationId() { } /** - * @return id + * @return tag_id */ @JsonProperty("tag_id") public String getTagId() { @@ -101,7 +101,7 @@ public interface ConversationIdStage { public interface TagIdStage { /** - * id + * tag_id */ AdminIdStage tagId(@NotNull String tagId); } @@ -150,7 +150,7 @@ public TagIdStage conversationId(@NotNull String conversationId) { } /** - * id

    id

    + * tag_id

    tag_id

    * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/tags/types/Tag.java b/src/main/java/com/intercom/api/resources/tags/types/Tag.java index 86ff399..f6a32fc 100644 --- a/src/main/java/com/intercom/api/resources/tags/types/Tag.java +++ b/src/main/java/com/intercom/api/resources/tags/types/Tag.java @@ -9,12 +9,14 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.intercom.api.core.ObjectMappers; import com.intercom.api.types.Reference; import java.util.HashMap; import java.util.Map; import java.util.Objects; +import java.util.Optional; import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @@ -24,13 +26,18 @@ public final class Tag { private final String name; - private final int appliedAt; + private final Optional appliedAt; - private final Reference appliedBy; + private final Optional appliedBy; private final Map additionalProperties; - private Tag(String id, String name, int appliedAt, Reference appliedBy, Map additionalProperties) { + private Tag( + String id, + String name, + Optional appliedAt, + Optional appliedBy, + Map additionalProperties) { this.id = id; this.name = name; this.appliedAt = appliedAt; @@ -66,12 +73,12 @@ public String getName() { * @return The time when the tag was applied to the object */ @JsonProperty("applied_at") - public int getAppliedAt() { + public Optional getAppliedAt() { return appliedAt; } @JsonProperty("applied_by") - public Reference getAppliedBy() { + public Optional getAppliedBy() { return appliedBy; } @@ -89,7 +96,7 @@ public Map getAdditionalProperties() { private boolean equalTo(Tag other) { return id.equals(other.id) && name.equals(other.name) - && appliedAt == other.appliedAt + && appliedAt.equals(other.appliedAt) && appliedBy.equals(other.appliedBy); } @@ -120,33 +127,33 @@ public interface NameStage { /** * The name of the tag */ - AppliedAtStage name(@NotNull String name); + _FinalStage name(@NotNull String name); } - public interface AppliedAtStage { + public interface _FinalStage { + Tag build(); + /** - * The time when the tag was applied to the object + *

    The time when the tag was applied to the object

    */ - AppliedByStage appliedAt(int appliedAt); - } + _FinalStage appliedAt(Optional appliedAt); - public interface AppliedByStage { - _FinalStage appliedBy(@NotNull Reference appliedBy); - } + _FinalStage appliedAt(Integer appliedAt); - public interface _FinalStage { - Tag build(); + _FinalStage appliedBy(Optional appliedBy); + + _FinalStage appliedBy(Reference appliedBy); } @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements IdStage, NameStage, AppliedAtStage, AppliedByStage, _FinalStage { + public static final class Builder implements IdStage, NameStage, _FinalStage { private String id; private String name; - private int appliedAt; + private Optional appliedBy = Optional.empty(); - private Reference appliedBy; + private Optional appliedAt = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -179,26 +186,41 @@ public NameStage id(@NotNull String id) { */ @java.lang.Override @JsonSetter("name") - public AppliedAtStage name(@NotNull String name) { + public _FinalStage name(@NotNull String name) { this.name = Objects.requireNonNull(name, "name must not be null"); return this; } + @java.lang.Override + public _FinalStage appliedBy(Reference appliedBy) { + this.appliedBy = Optional.ofNullable(appliedBy); + return this; + } + + @java.lang.Override + @JsonSetter(value = "applied_by", nulls = Nulls.SKIP) + public _FinalStage appliedBy(Optional appliedBy) { + this.appliedBy = appliedBy; + return this; + } + /** - * The time when the tag was applied to the object

    The time when the tag was applied to the object

    + *

    The time when the tag was applied to the object

    * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override - @JsonSetter("applied_at") - public AppliedByStage appliedAt(int appliedAt) { - this.appliedAt = appliedAt; + public _FinalStage appliedAt(Integer appliedAt) { + this.appliedAt = Optional.ofNullable(appliedAt); return this; } + /** + *

    The time when the tag was applied to the object

    + */ @java.lang.Override - @JsonSetter("applied_by") - public _FinalStage appliedBy(@NotNull Reference appliedBy) { - this.appliedBy = Objects.requireNonNull(appliedBy, "appliedBy must not be null"); + @JsonSetter(value = "applied_at", nulls = Nulls.SKIP) + public _FinalStage appliedAt(Optional appliedAt) { + this.appliedAt = appliedAt; return this; } diff --git a/src/main/java/com/intercom/api/types/DividerComponent.java b/src/main/java/com/intercom/api/resources/tags/types/TagBasic.java similarity index 52% rename from src/main/java/com/intercom/api/types/DividerComponent.java rename to src/main/java/com/intercom/api/resources/tags/types/TagBasic.java index 3cada54..cadc71b 100644 --- a/src/main/java/com/intercom/api/types/DividerComponent.java +++ b/src/main/java/com/intercom/api/resources/tags/types/TagBasic.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.intercom.api.types; +package com.intercom.api.resources.tags.types; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; @@ -18,23 +18,37 @@ import java.util.Optional; @JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = DividerComponent.Builder.class) -public final class DividerComponent { +@JsonDeserialize(builder = TagBasic.Builder.class) +public final class TagBasic { + private final Optional type; + private final Optional id; - private final Optional bottomMargin; + private final Optional name; private final Map additionalProperties; - private DividerComponent( - Optional id, Optional bottomMargin, Map additionalProperties) { + private TagBasic( + Optional type, + Optional id, + Optional name, + Map additionalProperties) { + this.type = type; this.id = id; - this.bottomMargin = bottomMargin; + this.name = name; this.additionalProperties = additionalProperties; } /** - * @return A unique identifier for the component. + * @return value is "tag" + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return The id of the tag */ @JsonProperty("id") public Optional getId() { @@ -42,17 +56,17 @@ public Optional getId() { } /** - * @return Disables a component's margin-bottom of 10px. + * @return The name of the tag */ - @JsonProperty("bottom_margin") - public Optional getBottomMargin() { - return bottomMargin; + @JsonProperty("name") + public Optional getName() { + return name; } @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof DividerComponent && equalTo((DividerComponent) other); + return other instanceof TagBasic && equalTo((TagBasic) other); } @JsonAnyGetter @@ -60,13 +74,13 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(DividerComponent other) { - return id.equals(other.id) && bottomMargin.equals(other.bottomMargin); + private boolean equalTo(TagBasic other) { + return type.equals(other.type) && id.equals(other.id) && name.equals(other.name); } @java.lang.Override public int hashCode() { - return Objects.hash(this.id, this.bottomMargin); + return Objects.hash(this.type, this.id, this.name); } @java.lang.Override @@ -80,23 +94,40 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional type = Optional.empty(); + private Optional id = Optional.empty(); - private Optional bottomMargin = Optional.empty(); + private Optional name = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} - public Builder from(DividerComponent other) { + public Builder from(TagBasic other) { + type(other.getType()); id(other.getId()); - bottomMargin(other.getBottomMargin()); + name(other.getName()); + return this; + } + + /** + *

    value is "tag"

    + */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); return this; } /** - *

    A unique identifier for the component.

    + *

    The id of the tag

    */ @JsonSetter(value = "id", nulls = Nulls.SKIP) public Builder id(Optional id) { @@ -110,21 +141,21 @@ public Builder id(String id) { } /** - *

    Disables a component's margin-bottom of 10px.

    + *

    The name of the tag

    */ - @JsonSetter(value = "bottom_margin", nulls = Nulls.SKIP) - public Builder bottomMargin(Optional bottomMargin) { - this.bottomMargin = bottomMargin; + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public Builder name(Optional name) { + this.name = name; return this; } - public Builder bottomMargin(String bottomMargin) { - this.bottomMargin = Optional.ofNullable(bottomMargin); + public Builder name(String name) { + this.name = Optional.ofNullable(name); return this; } - public DividerComponent build() { - return new DividerComponent(id, bottomMargin, additionalProperties); + public TagBasic build() { + return new TagBasic(type, id, name, additionalProperties); } } } diff --git a/src/main/java/com/intercom/api/resources/teams/types/Team.java b/src/main/java/com/intercom/api/resources/teams/types/Team.java index 3a166c1..7f821b9 100644 --- a/src/main/java/com/intercom/api/resources/teams/types/Team.java +++ b/src/main/java/com/intercom/api/resources/teams/types/Team.java @@ -13,33 +13,35 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.intercom.api.core.ObjectMappers; import com.intercom.api.types.AdminPriorityLevel; -import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; -import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = Team.Builder.class) public final class Team { - private final String id; + private final Optional type; - private final String name; + private final Optional id; - private final List adminIds; + private final Optional name; + + private final Optional> adminIds; private final Optional adminPriorityLevel; private final Map additionalProperties; private Team( - String id, - String name, - List adminIds, + Optional type, + Optional id, + Optional name, + Optional> adminIds, Optional adminPriorityLevel, Map additionalProperties) { + this.type = type; this.id = id; this.name = name; this.adminIds = adminIds; @@ -51,15 +53,15 @@ private Team( * @return Value is always "team" */ @JsonProperty("type") - public String getType() { - return "team"; + public Optional getType() { + return type; } /** * @return The id of the team */ @JsonProperty("id") - public String getId() { + public Optional getId() { return id; } @@ -67,7 +69,7 @@ public String getId() { * @return The name of the team */ @JsonProperty("name") - public String getName() { + public Optional getName() { return name; } @@ -75,7 +77,7 @@ public String getName() { * @return The list of admin IDs that are a part of the team. */ @JsonProperty("admin_ids") - public List getAdminIds() { + public Optional> getAdminIds() { return adminIds; } @@ -96,7 +98,8 @@ public Map getAdditionalProperties() { } private boolean equalTo(Team other) { - return id.equals(other.id) + return type.equals(other.type) + && id.equals(other.id) && name.equals(other.name) && adminIds.equals(other.adminIds) && adminPriorityLevel.equals(other.adminPriorityLevel); @@ -104,7 +107,7 @@ private boolean equalTo(Team other) { @java.lang.Override public int hashCode() { - return Objects.hash(this.id, this.name, this.adminIds, this.adminPriorityLevel); + return Objects.hash(this.type, this.id, this.name, this.adminIds, this.adminPriorityLevel); } @java.lang.Override @@ -112,60 +115,29 @@ public String toString() { return ObjectMappers.stringify(this); } - public static IdStage builder() { + public static Builder builder() { return new Builder(); } - public interface IdStage { - /** - * The id of the team - */ - NameStage id(@NotNull String id); - - Builder from(Team other); - } - - public interface NameStage { - /** - * The name of the team - */ - _FinalStage name(@NotNull String name); - } - - public interface _FinalStage { - Team build(); - - /** - *

    The list of admin IDs that are a part of the team.

    - */ - _FinalStage adminIds(List adminIds); - - _FinalStage addAdminIds(Integer adminIds); - - _FinalStage addAllAdminIds(List adminIds); - - _FinalStage adminPriorityLevel(Optional adminPriorityLevel); + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); - _FinalStage adminPriorityLevel(AdminPriorityLevel adminPriorityLevel); - } + private Optional id = Optional.empty(); - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements IdStage, NameStage, _FinalStage { - private String id; + private Optional name = Optional.empty(); - private String name; + private Optional> adminIds = Optional.empty(); private Optional adminPriorityLevel = Optional.empty(); - private List adminIds = new ArrayList<>(); - @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} - @java.lang.Override public Builder from(Team other) { + type(other.getType()); id(other.getId()); name(other.getName()); adminIds(other.getAdminIds()); @@ -174,74 +146,74 @@ public Builder from(Team other) { } /** - * The id of the team

    The id of the team

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    Value is always "team"

    */ - @java.lang.Override - @JsonSetter("id") - public NameStage id(@NotNull String id) { - this.id = Objects.requireNonNull(id, "id must not be null"); + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; return this; } - /** - * The name of the team

    The name of the team

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("name") - public _FinalStage name(@NotNull String name) { - this.name = Objects.requireNonNull(name, "name must not be null"); + public Builder type(String type) { + this.type = Optional.ofNullable(type); return this; } - @java.lang.Override - public _FinalStage adminPriorityLevel(AdminPriorityLevel adminPriorityLevel) { - this.adminPriorityLevel = Optional.ofNullable(adminPriorityLevel); + /** + *

    The id of the team

    + */ + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; return this; } - @java.lang.Override - @JsonSetter(value = "admin_priority_level", nulls = Nulls.SKIP) - public _FinalStage adminPriorityLevel(Optional adminPriorityLevel) { - this.adminPriorityLevel = adminPriorityLevel; + public Builder id(String id) { + this.id = Optional.ofNullable(id); return this; } /** - *

    The list of admin IDs that are a part of the team.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The name of the team

    */ - @java.lang.Override - public _FinalStage addAllAdminIds(List adminIds) { - this.adminIds.addAll(adminIds); + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public Builder name(Optional name) { + this.name = name; return this; } - /** - *

    The list of admin IDs that are a part of the team.

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage addAdminIds(Integer adminIds) { - this.adminIds.add(adminIds); + public Builder name(String name) { + this.name = Optional.ofNullable(name); return this; } /** *

    The list of admin IDs that are a part of the team.

    */ - @java.lang.Override @JsonSetter(value = "admin_ids", nulls = Nulls.SKIP) - public _FinalStage adminIds(List adminIds) { - this.adminIds.clear(); - this.adminIds.addAll(adminIds); + public Builder adminIds(Optional> adminIds) { + this.adminIds = adminIds; + return this; + } + + public Builder adminIds(List adminIds) { + this.adminIds = Optional.ofNullable(adminIds); + return this; + } + + @JsonSetter(value = "admin_priority_level", nulls = Nulls.SKIP) + public Builder adminPriorityLevel(Optional adminPriorityLevel) { + this.adminPriorityLevel = adminPriorityLevel; + return this; + } + + public Builder adminPriorityLevel(AdminPriorityLevel adminPriorityLevel) { + this.adminPriorityLevel = Optional.ofNullable(adminPriorityLevel); return this; } - @java.lang.Override public Team build() { - return new Team(id, name, adminIds, adminPriorityLevel, additionalProperties); + return new Team(type, id, name, adminIds, adminPriorityLevel, additionalProperties); } } } diff --git a/src/main/java/com/intercom/api/resources/tickets/AsyncRawTicketsClient.java b/src/main/java/com/intercom/api/resources/tickets/AsyncRawTicketsClient.java index 56fcbfa..c69b492 100644 --- a/src/main/java/com/intercom/api/resources/tickets/AsyncRawTicketsClient.java +++ b/src/main/java/com/intercom/api/resources/tickets/AsyncRawTicketsClient.java @@ -4,6 +4,7 @@ package com.intercom.api.resources.tickets; import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; import com.intercom.api.core.ClientOptions; import com.intercom.api.core.IntercomApiException; import com.intercom.api.core.IntercomException; @@ -15,11 +16,15 @@ import com.intercom.api.errors.BadRequestError; import com.intercom.api.errors.NotFoundError; import com.intercom.api.errors.UnauthorizedError; +import com.intercom.api.resources.jobs.types.Jobs; +import com.intercom.api.resources.tickets.requests.CreateTicketRequest; +import com.intercom.api.resources.tickets.requests.DeleteTicketRequest; +import com.intercom.api.resources.tickets.requests.EnqueueCreateTicketRequest; import com.intercom.api.resources.tickets.requests.FindTicketRequest; import com.intercom.api.resources.tickets.requests.ReplyToTicketRequest; import com.intercom.api.resources.tickets.requests.UpdateTicketRequest; +import com.intercom.api.resources.tickets.types.DeleteTicketResponse; import com.intercom.api.resources.tickets.types.Ticket; -import com.intercom.api.types.CreateTicketRequest; import com.intercom.api.types.CursorPages; import com.intercom.api.types.Error; import com.intercom.api.types.SearchRequest; @@ -27,6 +32,7 @@ import com.intercom.api.types.TicketList; import com.intercom.api.types.TicketReply; import java.io.IOException; +import java.util.Collections; import java.util.List; import java.util.Optional; import java.util.concurrent.CompletableFuture; @@ -140,14 +146,14 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { /** * You can create a new ticket. */ - public CompletableFuture> create(CreateTicketRequest request) { + public CompletableFuture>> create(CreateTicketRequest request) { return create(request, null); } /** * You can create a new ticket. */ - public CompletableFuture> create( + public CompletableFuture>> create( CreateTicketRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -171,14 +177,16 @@ public CompletableFuture> create( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } - CompletableFuture> future = new CompletableFuture<>(); + CompletableFuture>> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Ticket.class), response)); + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response)); return; } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -210,17 +218,97 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { return future; } + /** + * 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. + */ + public CompletableFuture> enqueueCreateTicket(EnqueueCreateTicketRequest request) { + return enqueueCreateTicket(request, null); + } + + /** + * Enqueues ticket creation for asynchronous processing, returning if the job was enqueued successfully to be processed. We attempt to perform a best-effort validation on inputs before tasks are enqueued. If the given parameters are incorrect, we won't enqueue the job. + */ + public CompletableFuture> enqueueCreateTicket( + EnqueueCreateTicketRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("tickets/enqueue") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Jobs.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + /** * You can fetch the details of a single ticket. */ - public CompletableFuture> get(FindTicketRequest request) { + public CompletableFuture>> get(FindTicketRequest request) { return get(request, null); } /** * You can fetch the details of a single ticket. */ - public CompletableFuture> get( + public CompletableFuture>> get( FindTicketRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -238,14 +326,16 @@ public CompletableFuture> get( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } - CompletableFuture> future = new CompletableFuture<>(); + CompletableFuture>> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Ticket.class), response)); + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response)); return; } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -280,14 +370,14 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { /** * You can update a ticket. */ - public CompletableFuture> update(UpdateTicketRequest request) { + public CompletableFuture>> update(UpdateTicketRequest request) { return update(request, null); } /** * You can update a ticket. */ - public CompletableFuture> update( + public CompletableFuture>> update( UpdateTicketRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -312,14 +402,96 @@ public CompletableFuture> update( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } - CompletableFuture> future = new CompletableFuture<>(); + CompletableFuture>> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Ticket.class), response)); + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can delete a ticket using the Intercom provided ID. + */ + public CompletableFuture> deleteTicket(DeleteTicketRequest request) { + return deleteTicket(request, null); + } + + /** + * You can delete a ticket using the Intercom provided ID. + */ + public CompletableFuture> deleteTicket( + DeleteTicketRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("tickets") + .addPathSegment(request.getTicketId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeleteTicketResponse.class), + response)); return; } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -376,14 +548,15 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { *
  • 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").

    + *

    Most keys listed as part of the Ticket model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as created_at accepts a date, the value cannot be a string such as "foobar"). + * The source.body field is unique as the search will not be performed against the entire value, but instead against every element of the value separately. For example, when searching for a conversation with a "I need support" body - the query should contain a = operator with the value "support" for such conversation to be returned. A query with a = operator and a "need support" value will not yield a result.

    *

    | Field | Type | * | :---------------------------------------- | :--------------------------------------------------------------------------------------- | * | id | String | * | created_at | Date (UNIX timestamp) | * | updated_at | Date (UNIX timestamp) | - * | default_title | String | - * | default_description | String | + * | title | String | + * | description | String | * | category | String | * | ticket_type_id | String | * | contact_ids | String | @@ -394,6 +567,14 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { * | 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. @@ -412,7 +593,7 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { * | ^ | String | Starts With | * | $ | String | Ends With |

    */ - public CompletableFuture>> search(SearchRequest request) { + public CompletableFuture>>> search(SearchRequest request) { return search(request, null); } @@ -434,14 +615,15 @@ public CompletableFuture>> searc *
  • 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").

    + *

    Most keys listed as part of the Ticket model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as created_at accepts a date, the value cannot be a string such as "foobar"). + * The source.body field is unique as the search will not be performed against the entire value, but instead against every element of the value separately. For example, when searching for a conversation with a "I need support" body - the query should contain a = operator with the value "support" for such conversation to be returned. A query with a = operator and a "need support" value will not yield a result.

    *

    | Field | Type | * | :---------------------------------------- | :--------------------------------------------------------------------------------------- | * | id | String | * | created_at | Date (UNIX timestamp) | * | updated_at | Date (UNIX timestamp) | - * | default_title | String | - * | default_description | String | + * | title | String | + * | description | String | * | category | String | * | ticket_type_id | String | * | contact_ids | String | @@ -452,6 +634,14 @@ public CompletableFuture>> searc * | 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. @@ -470,7 +660,7 @@ public CompletableFuture>> searc * | ^ | String | Starts With | * | $ | String | Ends With |

    */ - public CompletableFuture>> search( + public CompletableFuture>>> search( SearchRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -494,7 +684,8 @@ public CompletableFuture>> searc if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } - CompletableFuture>> future = new CompletableFuture<>(); + CompletableFuture>>> future = + new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { @@ -515,9 +706,10 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO .from(request) .pagination(pagination) .build(); - List result = parsedResponse.getTickets(); + List> result = + parsedResponse.getTickets().orElse(Collections.emptyList()); future.complete(new IntercomHttpResponse<>( - new SyncPagingIterable(startingAfter.isPresent(), result, () -> { + new SyncPagingIterable>(startingAfter.isPresent(), result, () -> { try { return search(nextRequest, requestOptions) .get() diff --git a/src/main/java/com/intercom/api/resources/tickets/AsyncTicketsClient.java b/src/main/java/com/intercom/api/resources/tickets/AsyncTicketsClient.java index 5bb05fd..0d014e0 100644 --- a/src/main/java/com/intercom/api/resources/tickets/AsyncTicketsClient.java +++ b/src/main/java/com/intercom/api/resources/tickets/AsyncTicketsClient.java @@ -6,13 +6,18 @@ import com.intercom.api.core.ClientOptions; import com.intercom.api.core.RequestOptions; import com.intercom.api.core.pagination.SyncPagingIterable; +import com.intercom.api.resources.jobs.types.Jobs; +import com.intercom.api.resources.tickets.requests.CreateTicketRequest; +import com.intercom.api.resources.tickets.requests.DeleteTicketRequest; +import com.intercom.api.resources.tickets.requests.EnqueueCreateTicketRequest; import com.intercom.api.resources.tickets.requests.FindTicketRequest; import com.intercom.api.resources.tickets.requests.ReplyToTicketRequest; import com.intercom.api.resources.tickets.requests.UpdateTicketRequest; +import com.intercom.api.resources.tickets.types.DeleteTicketResponse; import com.intercom.api.resources.tickets.types.Ticket; -import com.intercom.api.types.CreateTicketRequest; import com.intercom.api.types.SearchRequest; import com.intercom.api.types.TicketReply; +import java.util.Optional; import java.util.concurrent.CompletableFuture; public class AsyncTicketsClient { @@ -49,45 +54,75 @@ public CompletableFuture reply(ReplyToTicketRequest request, Reques /** * You can create a new ticket. */ - public CompletableFuture create(CreateTicketRequest request) { + public CompletableFuture> create(CreateTicketRequest request) { return this.rawClient.create(request).thenApply(response -> response.body()); } /** * You can create a new ticket. */ - public CompletableFuture create(CreateTicketRequest request, RequestOptions requestOptions) { + public CompletableFuture> create(CreateTicketRequest request, RequestOptions requestOptions) { return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); } + /** + * 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. + */ + public CompletableFuture enqueueCreateTicket(EnqueueCreateTicketRequest request) { + return this.rawClient.enqueueCreateTicket(request).thenApply(response -> response.body()); + } + + /** + * 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. + */ + public CompletableFuture enqueueCreateTicket( + EnqueueCreateTicketRequest request, RequestOptions requestOptions) { + return this.rawClient.enqueueCreateTicket(request, requestOptions).thenApply(response -> response.body()); + } + /** * You can fetch the details of a single ticket. */ - public CompletableFuture get(FindTicketRequest request) { + public CompletableFuture> get(FindTicketRequest request) { return this.rawClient.get(request).thenApply(response -> response.body()); } /** * You can fetch the details of a single ticket. */ - public CompletableFuture get(FindTicketRequest request, RequestOptions requestOptions) { + public CompletableFuture> get(FindTicketRequest request, RequestOptions requestOptions) { return this.rawClient.get(request, requestOptions).thenApply(response -> response.body()); } /** * You can update a ticket. */ - public CompletableFuture update(UpdateTicketRequest request) { + public CompletableFuture> update(UpdateTicketRequest request) { return this.rawClient.update(request).thenApply(response -> response.body()); } /** * You can update a ticket. */ - public CompletableFuture update(UpdateTicketRequest request, RequestOptions requestOptions) { + public CompletableFuture> update(UpdateTicketRequest request, RequestOptions requestOptions) { return this.rawClient.update(request, requestOptions).thenApply(response -> response.body()); } + /** + * You can delete a ticket using the Intercom provided ID. + */ + public CompletableFuture deleteTicket(DeleteTicketRequest request) { + return this.rawClient.deleteTicket(request).thenApply(response -> response.body()); + } + + /** + * You can delete a ticket using the Intercom provided ID. + */ + public CompletableFuture deleteTicket( + DeleteTicketRequest request, RequestOptions requestOptions) { + return this.rawClient.deleteTicket(request, requestOptions).thenApply(response -> response.body()); + } + /** * 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.

    @@ -106,14 +141,15 @@ public CompletableFuture update(UpdateTicketRequest request, RequestOpti *
  • 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").

    + *

    Most keys listed as part of the Ticket model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as created_at accepts a date, the value cannot be a string such as "foobar"). + * The source.body field is unique as the search will not be performed against the entire value, but instead against every element of the value separately. For example, when searching for a conversation with a "I need support" body - the query should contain a = operator with the value "support" for such conversation to be returned. A query with a = operator and a "need support" value will not yield a result.

    *

    | Field | Type | * | :---------------------------------------- | :--------------------------------------------------------------------------------------- | * | id | String | * | created_at | Date (UNIX timestamp) | * | updated_at | Date (UNIX timestamp) | - * | default_title | String | - * | default_description | String | + * | title | String | + * | description | String | * | category | String | * | ticket_type_id | String | * | contact_ids | String | @@ -124,6 +160,14 @@ public CompletableFuture update(UpdateTicketRequest request, RequestOpti * | 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. @@ -142,7 +186,7 @@ public CompletableFuture update(UpdateTicketRequest request, RequestOpti * | ^ | String | Starts With | * | $ | String | Ends With |

    */ - public CompletableFuture> search(SearchRequest request) { + public CompletableFuture>> search(SearchRequest request) { return this.rawClient.search(request).thenApply(response -> response.body()); } @@ -164,14 +208,15 @@ public CompletableFuture> search(SearchRequest reques *
  • 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").

    + *

    Most keys listed as part of the Ticket model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as created_at accepts a date, the value cannot be a string such as "foobar"). + * The source.body field is unique as the search will not be performed against the entire value, but instead against every element of the value separately. For example, when searching for a conversation with a "I need support" body - the query should contain a = operator with the value "support" for such conversation to be returned. A query with a = operator and a "need support" value will not yield a result.

    *

    | Field | Type | * | :---------------------------------------- | :--------------------------------------------------------------------------------------- | * | id | String | * | created_at | Date (UNIX timestamp) | * | updated_at | Date (UNIX timestamp) | - * | default_title | String | - * | default_description | String | + * | title | String | + * | description | String | * | category | String | * | ticket_type_id | String | * | contact_ids | String | @@ -182,6 +227,14 @@ public CompletableFuture> search(SearchRequest reques * | 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. @@ -200,7 +253,8 @@ public CompletableFuture> search(SearchRequest reques * | ^ | String | Starts With | * | $ | String | Ends With |

    */ - public CompletableFuture> search(SearchRequest request, RequestOptions requestOptions) { + public CompletableFuture>> search( + SearchRequest request, RequestOptions requestOptions) { return this.rawClient.search(request, requestOptions).thenApply(response -> response.body()); } } diff --git a/src/main/java/com/intercom/api/resources/tickets/RawTicketsClient.java b/src/main/java/com/intercom/api/resources/tickets/RawTicketsClient.java index 843c70a..703ccf3 100644 --- a/src/main/java/com/intercom/api/resources/tickets/RawTicketsClient.java +++ b/src/main/java/com/intercom/api/resources/tickets/RawTicketsClient.java @@ -4,6 +4,7 @@ package com.intercom.api.resources.tickets; import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; import com.intercom.api.core.ClientOptions; import com.intercom.api.core.IntercomApiException; import com.intercom.api.core.IntercomException; @@ -15,11 +16,15 @@ import com.intercom.api.errors.BadRequestError; import com.intercom.api.errors.NotFoundError; import com.intercom.api.errors.UnauthorizedError; +import com.intercom.api.resources.jobs.types.Jobs; +import com.intercom.api.resources.tickets.requests.CreateTicketRequest; +import com.intercom.api.resources.tickets.requests.DeleteTicketRequest; +import com.intercom.api.resources.tickets.requests.EnqueueCreateTicketRequest; import com.intercom.api.resources.tickets.requests.FindTicketRequest; import com.intercom.api.resources.tickets.requests.ReplyToTicketRequest; import com.intercom.api.resources.tickets.requests.UpdateTicketRequest; +import com.intercom.api.resources.tickets.types.DeleteTicketResponse; import com.intercom.api.resources.tickets.types.Ticket; -import com.intercom.api.types.CreateTicketRequest; import com.intercom.api.types.CursorPages; import com.intercom.api.types.Error; import com.intercom.api.types.SearchRequest; @@ -27,6 +32,7 @@ import com.intercom.api.types.TicketList; import com.intercom.api.types.TicketReply; import java.io.IOException; +import java.util.Collections; import java.util.List; import java.util.Optional; import okhttp3.Headers; @@ -114,14 +120,14 @@ public IntercomHttpResponse reply(ReplyToTicketRequest request, Req /** * You can create a new ticket. */ - public IntercomHttpResponse create(CreateTicketRequest request) { + public IntercomHttpResponse> create(CreateTicketRequest request) { return create(request, null); } /** * You can create a new ticket. */ - public IntercomHttpResponse create(CreateTicketRequest request, RequestOptions requestOptions) { + public IntercomHttpResponse> create(CreateTicketRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("tickets") @@ -148,7 +154,9 @@ public IntercomHttpResponse create(CreateTicketRequest request, RequestO ResponseBody responseBody = response.body(); if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Ticket.class), response); + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { @@ -169,17 +177,80 @@ public IntercomHttpResponse create(CreateTicketRequest request, RequestO } } + /** + * 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. + */ + public IntercomHttpResponse enqueueCreateTicket(EnqueueCreateTicketRequest request) { + return enqueueCreateTicket(request, null); + } + + /** + * Enqueues ticket creation for asynchronous processing, returning if the job was enqueued successfully to be processed. We attempt to perform a best-effort validation on inputs before tasks are enqueued. If the given parameters are incorrect, we won't enqueue the job. + */ + public IntercomHttpResponse enqueueCreateTicket( + EnqueueCreateTicketRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("tickets/enqueue") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Jobs.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + /** * You can fetch the details of a single ticket. */ - public IntercomHttpResponse get(FindTicketRequest request) { + public IntercomHttpResponse> get(FindTicketRequest request) { return get(request, null); } /** * You can fetch the details of a single ticket. */ - public IntercomHttpResponse get(FindTicketRequest request, RequestOptions requestOptions) { + public IntercomHttpResponse> get(FindTicketRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("tickets") @@ -200,7 +271,9 @@ public IntercomHttpResponse get(FindTicketRequest request, RequestOption ResponseBody responseBody = response.body(); if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Ticket.class), response); + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { @@ -224,14 +297,14 @@ public IntercomHttpResponse get(FindTicketRequest request, RequestOption /** * You can update a ticket. */ - public IntercomHttpResponse update(UpdateTicketRequest request) { + public IntercomHttpResponse> update(UpdateTicketRequest request) { return update(request, null); } /** * You can update a ticket. */ - public IntercomHttpResponse update(UpdateTicketRequest request, RequestOptions requestOptions) { + public IntercomHttpResponse> update(UpdateTicketRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("tickets") @@ -259,7 +332,70 @@ public IntercomHttpResponse update(UpdateTicketRequest request, RequestO ResponseBody responseBody = response.body(); if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Ticket.class), response); + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can delete a ticket using the Intercom provided ID. + */ + public IntercomHttpResponse deleteTicket(DeleteTicketRequest request) { + return deleteTicket(request, null); + } + + /** + * You can delete a ticket using the Intercom provided ID. + */ + public IntercomHttpResponse deleteTicket( + DeleteTicketRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("tickets") + .addPathSegment(request.getTicketId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeleteTicketResponse.class), + response); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { @@ -302,14 +438,15 @@ public IntercomHttpResponse update(UpdateTicketRequest request, RequestO *
  • 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").

    + *

    Most keys listed as part of the Ticket model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as created_at accepts a date, the value cannot be a string such as "foobar"). + * The source.body field is unique as the search will not be performed against the entire value, but instead against every element of the value separately. For example, when searching for a conversation with a "I need support" body - the query should contain a = operator with the value "support" for such conversation to be returned. A query with a = operator and a "need support" value will not yield a result.

    *

    | Field | Type | * | :---------------------------------------- | :--------------------------------------------------------------------------------------- | * | id | String | * | created_at | Date (UNIX timestamp) | * | updated_at | Date (UNIX timestamp) | - * | default_title | String | - * | default_description | String | + * | title | String | + * | description | String | * | category | String | * | ticket_type_id | String | * | contact_ids | String | @@ -320,6 +457,14 @@ public IntercomHttpResponse update(UpdateTicketRequest request, RequestO * | 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. @@ -338,7 +483,7 @@ public IntercomHttpResponse update(UpdateTicketRequest request, RequestO * | ^ | String | Starts With | * | $ | String | Ends With |

    */ - public IntercomHttpResponse> search(SearchRequest request) { + public IntercomHttpResponse>> search(SearchRequest request) { return search(request, null); } @@ -360,14 +505,15 @@ public IntercomHttpResponse> search(SearchRequest req *
  • 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").

    + *

    Most keys listed as part of the Ticket model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as created_at accepts a date, the value cannot be a string such as "foobar"). + * The source.body field is unique as the search will not be performed against the entire value, but instead against every element of the value separately. For example, when searching for a conversation with a "I need support" body - the query should contain a = operator with the value "support" for such conversation to be returned. A query with a = operator and a "need support" value will not yield a result.

    *

    | Field | Type | * | :---------------------------------------- | :--------------------------------------------------------------------------------------- | * | id | String | * | created_at | Date (UNIX timestamp) | * | updated_at | Date (UNIX timestamp) | - * | default_title | String | - * | default_description | String | + * | title | String | + * | description | String | * | category | String | * | ticket_type_id | String | * | contact_ids | String | @@ -378,6 +524,14 @@ public IntercomHttpResponse> search(SearchRequest req * | 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. @@ -396,7 +550,7 @@ public IntercomHttpResponse> search(SearchRequest req * | ^ | String | Starts With | * | $ | String | Ends With |

    */ - public IntercomHttpResponse> search( + public IntercomHttpResponse>> search( SearchRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -438,9 +592,9 @@ public IntercomHttpResponse> search( .from(request) .pagination(pagination) .build(); - List result = parsedResponse.getTickets(); + List> result = parsedResponse.getTickets().orElse(Collections.emptyList()); return new IntercomHttpResponse<>( - new SyncPagingIterable( + new SyncPagingIterable>( startingAfter.isPresent(), result, () -> search(nextRequest, requestOptions) .body()), response); diff --git a/src/main/java/com/intercom/api/resources/tickets/TicketsClient.java b/src/main/java/com/intercom/api/resources/tickets/TicketsClient.java index cee318a..841952f 100644 --- a/src/main/java/com/intercom/api/resources/tickets/TicketsClient.java +++ b/src/main/java/com/intercom/api/resources/tickets/TicketsClient.java @@ -6,13 +6,18 @@ import com.intercom.api.core.ClientOptions; import com.intercom.api.core.RequestOptions; import com.intercom.api.core.pagination.SyncPagingIterable; +import com.intercom.api.resources.jobs.types.Jobs; +import com.intercom.api.resources.tickets.requests.CreateTicketRequest; +import com.intercom.api.resources.tickets.requests.DeleteTicketRequest; +import com.intercom.api.resources.tickets.requests.EnqueueCreateTicketRequest; import com.intercom.api.resources.tickets.requests.FindTicketRequest; import com.intercom.api.resources.tickets.requests.ReplyToTicketRequest; import com.intercom.api.resources.tickets.requests.UpdateTicketRequest; +import com.intercom.api.resources.tickets.types.DeleteTicketResponse; import com.intercom.api.resources.tickets.types.Ticket; -import com.intercom.api.types.CreateTicketRequest; import com.intercom.api.types.SearchRequest; import com.intercom.api.types.TicketReply; +import java.util.Optional; public class TicketsClient { protected final ClientOptions clientOptions; @@ -48,45 +53,73 @@ public TicketReply reply(ReplyToTicketRequest request, RequestOptions requestOpt /** * You can create a new ticket. */ - public Ticket create(CreateTicketRequest request) { + public Optional create(CreateTicketRequest request) { return this.rawClient.create(request).body(); } /** * You can create a new ticket. */ - public Ticket create(CreateTicketRequest request, RequestOptions requestOptions) { + public Optional create(CreateTicketRequest request, RequestOptions requestOptions) { return this.rawClient.create(request, requestOptions).body(); } + /** + * 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. + */ + public Jobs enqueueCreateTicket(EnqueueCreateTicketRequest request) { + return this.rawClient.enqueueCreateTicket(request).body(); + } + + /** + * 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. + */ + public Jobs enqueueCreateTicket(EnqueueCreateTicketRequest request, RequestOptions requestOptions) { + return this.rawClient.enqueueCreateTicket(request, requestOptions).body(); + } + /** * You can fetch the details of a single ticket. */ - public Ticket get(FindTicketRequest request) { + public Optional get(FindTicketRequest request) { return this.rawClient.get(request).body(); } /** * You can fetch the details of a single ticket. */ - public Ticket get(FindTicketRequest request, RequestOptions requestOptions) { + public Optional get(FindTicketRequest request, RequestOptions requestOptions) { return this.rawClient.get(request, requestOptions).body(); } /** * You can update a ticket. */ - public Ticket update(UpdateTicketRequest request) { + public Optional update(UpdateTicketRequest request) { return this.rawClient.update(request).body(); } /** * You can update a ticket. */ - public Ticket update(UpdateTicketRequest request, RequestOptions requestOptions) { + public Optional update(UpdateTicketRequest request, RequestOptions requestOptions) { return this.rawClient.update(request, requestOptions).body(); } + /** + * You can delete a ticket using the Intercom provided ID. + */ + public DeleteTicketResponse deleteTicket(DeleteTicketRequest request) { + return this.rawClient.deleteTicket(request).body(); + } + + /** + * You can delete a ticket using the Intercom provided ID. + */ + public DeleteTicketResponse deleteTicket(DeleteTicketRequest request, RequestOptions requestOptions) { + return this.rawClient.deleteTicket(request, requestOptions).body(); + } + /** * 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.

    @@ -105,14 +138,15 @@ public Ticket update(UpdateTicketRequest request, RequestOptions requestOptions) *
  • 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").

    + *

    Most keys listed as part of the Ticket model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as created_at accepts a date, the value cannot be a string such as "foobar"). + * The source.body field is unique as the search will not be performed against the entire value, but instead against every element of the value separately. For example, when searching for a conversation with a "I need support" body - the query should contain a = operator with the value "support" for such conversation to be returned. A query with a = operator and a "need support" value will not yield a result.

    *

    | Field | Type | * | :---------------------------------------- | :--------------------------------------------------------------------------------------- | * | id | String | * | created_at | Date (UNIX timestamp) | * | updated_at | Date (UNIX timestamp) | - * | default_title | String | - * | default_description | String | + * | title | String | + * | description | String | * | category | String | * | ticket_type_id | String | * | contact_ids | String | @@ -123,6 +157,14 @@ public Ticket update(UpdateTicketRequest request, RequestOptions requestOptions) * | 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. @@ -141,7 +183,7 @@ public Ticket update(UpdateTicketRequest request, RequestOptions requestOptions) * | ^ | String | Starts With | * | $ | String | Ends With |

    */ - public SyncPagingIterable search(SearchRequest request) { + public SyncPagingIterable> search(SearchRequest request) { return this.rawClient.search(request).body(); } @@ -163,14 +205,15 @@ public SyncPagingIterable search(SearchRequest request) { *
  • 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").

    + *

    Most keys listed as part of the Ticket model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as created_at accepts a date, the value cannot be a string such as "foobar"). + * The source.body field is unique as the search will not be performed against the entire value, but instead against every element of the value separately. For example, when searching for a conversation with a "I need support" body - the query should contain a = operator with the value "support" for such conversation to be returned. A query with a = operator and a "need support" value will not yield a result.

    *

    | Field | Type | * | :---------------------------------------- | :--------------------------------------------------------------------------------------- | * | id | String | * | created_at | Date (UNIX timestamp) | * | updated_at | Date (UNIX timestamp) | - * | default_title | String | - * | default_description | String | + * | title | String | + * | description | String | * | category | String | * | ticket_type_id | String | * | contact_ids | String | @@ -181,6 +224,14 @@ public SyncPagingIterable search(SearchRequest request) { * | 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. @@ -199,7 +250,7 @@ public SyncPagingIterable search(SearchRequest request) { * | ^ | String | Starts With | * | $ | String | Ends With |

    */ - public SyncPagingIterable search(SearchRequest request, RequestOptions requestOptions) { + public SyncPagingIterable> search(SearchRequest request, RequestOptions requestOptions) { return this.rawClient.search(request, requestOptions).body(); } } diff --git a/src/main/java/com/intercom/api/resources/tickets/requests/CreateTicketRequest.java b/src/main/java/com/intercom/api/resources/tickets/requests/CreateTicketRequest.java new file mode 100644 index 0000000..b742d91 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/tickets/requests/CreateTicketRequest.java @@ -0,0 +1,914 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.tickets.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.types.ICreateTicketRequestBody; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CreateTicketRequest.Builder.class) +public final class CreateTicketRequest implements ICreateTicketRequestBody { + private final String ticketTypeId; + + private final List contacts; + + private final Optional conversationToLinkId; + + private final Optional companyId; + + private final Optional createdAt; + + private final Optional assignment; + + private final Optional skipNotifications; + + private final Map additionalProperties; + + private CreateTicketRequest( + String ticketTypeId, + List contacts, + Optional conversationToLinkId, + Optional companyId, + Optional createdAt, + Optional assignment, + Optional skipNotifications, + Map additionalProperties) { + this.ticketTypeId = ticketTypeId; + this.contacts = contacts; + this.conversationToLinkId = conversationToLinkId; + this.companyId = companyId; + this.createdAt = createdAt; + this.assignment = assignment; + this.skipNotifications = skipNotifications; + this.additionalProperties = additionalProperties; + } + + /** + * @return The ID of the type of ticket you want to create + */ + @JsonProperty("ticket_type_id") + public String getTicketTypeId() { + return ticketTypeId; + } + + /** + * @return The list of contacts (users or leads) affected by this ticket. Currently only one is allowed + */ + @JsonProperty("contacts") + public List getContacts() { + return contacts; + } + + /** + * @return 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
    • + *
    + */ + @JsonProperty("conversation_to_link_id") + public Optional getConversationToLinkId() { + return conversationToLinkId; + } + + /** + * @return The ID of the company that the ticket is associated with. The unique identifier for the company which is given by Intercom + */ + @JsonProperty("company_id") + public Optional getCompanyId() { + return companyId; + } + + /** + * @return The time the ticket was created. If not provided, the current time will be used. + */ + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + @JsonProperty("assignment") + public Optional getAssignment() { + return assignment; + } + + /** + * @return Option to disable notifications when a Ticket is created. + */ + @JsonProperty("skip_notifications") + public Optional getSkipNotifications() { + return skipNotifications; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreateTicketRequest && equalTo((CreateTicketRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreateTicketRequest other) { + return ticketTypeId.equals(other.ticketTypeId) + && contacts.equals(other.contacts) + && conversationToLinkId.equals(other.conversationToLinkId) + && companyId.equals(other.companyId) + && createdAt.equals(other.createdAt) + && assignment.equals(other.assignment) + && skipNotifications.equals(other.skipNotifications); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.ticketTypeId, + this.contacts, + this.conversationToLinkId, + this.companyId, + this.createdAt, + this.assignment, + this.skipNotifications); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TicketTypeIdStage builder() { + return new Builder(); + } + + public interface TicketTypeIdStage { + /** + * The ID of the type of ticket you want to create + */ + _FinalStage ticketTypeId(@NotNull String ticketTypeId); + + Builder from(CreateTicketRequest other); + } + + public interface _FinalStage { + CreateTicketRequest build(); + + /** + *

    The list of contacts (users or leads) affected by this ticket. Currently only one is allowed

    + */ + _FinalStage contacts(List contacts); + + _FinalStage addContacts(ContactsItem contacts); + + _FinalStage addAllContacts(List contacts); + + /** + *

    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
    • + *
    + */ + _FinalStage conversationToLinkId(Optional conversationToLinkId); + + _FinalStage conversationToLinkId(String conversationToLinkId); + + /** + *

    The ID of the company that the ticket is associated with. The unique identifier for the company which is given by Intercom

    + */ + _FinalStage companyId(Optional companyId); + + _FinalStage companyId(String companyId); + + /** + *

    The time the ticket was created. If not provided, the current time will be used.

    + */ + _FinalStage createdAt(Optional createdAt); + + _FinalStage createdAt(Integer createdAt); + + _FinalStage assignment(Optional assignment); + + _FinalStage assignment(Assignment assignment); + + /** + *

    Option to disable notifications when a Ticket is created.

    + */ + _FinalStage skipNotifications(Optional skipNotifications); + + _FinalStage skipNotifications(Boolean skipNotifications); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements TicketTypeIdStage, _FinalStage { + private String ticketTypeId; + + private Optional skipNotifications = Optional.empty(); + + private Optional assignment = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + private Optional companyId = Optional.empty(); + + private Optional conversationToLinkId = Optional.empty(); + + private List contacts = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CreateTicketRequest other) { + ticketTypeId(other.getTicketTypeId()); + contacts(other.getContacts()); + conversationToLinkId(other.getConversationToLinkId()); + companyId(other.getCompanyId()); + createdAt(other.getCreatedAt()); + assignment(other.getAssignment()); + skipNotifications(other.getSkipNotifications()); + return this; + } + + /** + * The ID of the type of ticket you want to create

    The ID of the type of ticket you want to create

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("ticket_type_id") + public _FinalStage ticketTypeId(@NotNull String ticketTypeId) { + this.ticketTypeId = Objects.requireNonNull(ticketTypeId, "ticketTypeId must not be null"); + return this; + } + + /** + *

    Option to disable notifications when a Ticket is created.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage skipNotifications(Boolean skipNotifications) { + this.skipNotifications = Optional.ofNullable(skipNotifications); + return this; + } + + /** + *

    Option to disable notifications when a Ticket is created.

    + */ + @java.lang.Override + @JsonSetter(value = "skip_notifications", nulls = Nulls.SKIP) + public _FinalStage skipNotifications(Optional skipNotifications) { + this.skipNotifications = skipNotifications; + return this; + } + + @java.lang.Override + public _FinalStage assignment(Assignment assignment) { + this.assignment = Optional.ofNullable(assignment); + return this; + } + + @java.lang.Override + @JsonSetter(value = "assignment", nulls = Nulls.SKIP) + public _FinalStage assignment(Optional assignment) { + this.assignment = assignment; + return this; + } + + /** + *

    The time the ticket was created. If not provided, the current time will be used.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage createdAt(Integer createdAt) { + this.createdAt = Optional.ofNullable(createdAt); + return this; + } + + /** + *

    The time the ticket was created. If not provided, the current time will be used.

    + */ + @java.lang.Override + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public _FinalStage createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + /** + *

    The ID of the company that the ticket is associated with. The unique identifier for the company which is given by Intercom

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage companyId(String companyId) { + this.companyId = Optional.ofNullable(companyId); + return this; + } + + /** + *

    The ID of the company that the ticket is associated with. The unique identifier for the company which is given by Intercom

    + */ + @java.lang.Override + @JsonSetter(value = "company_id", nulls = Nulls.SKIP) + public _FinalStage companyId(Optional companyId) { + this.companyId = companyId; + return this; + } + + /** + *

    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
    • + *
    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage conversationToLinkId(String conversationToLinkId) { + this.conversationToLinkId = Optional.ofNullable(conversationToLinkId); + return this; + } + + /** + *

    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
    • + *
    + */ + @java.lang.Override + @JsonSetter(value = "conversation_to_link_id", nulls = Nulls.SKIP) + public _FinalStage conversationToLinkId(Optional conversationToLinkId) { + this.conversationToLinkId = conversationToLinkId; + return this; + } + + /** + *

    The list of contacts (users or leads) affected by this ticket. Currently only one is allowed

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage addAllContacts(List contacts) { + this.contacts.addAll(contacts); + return this; + } + + /** + *

    The list of contacts (users or leads) affected by this ticket. Currently only one is allowed

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage addContacts(ContactsItem contacts) { + this.contacts.add(contacts); + return this; + } + + /** + *

    The list of contacts (users or leads) affected by this ticket. Currently only one is allowed

    + */ + @java.lang.Override + @JsonSetter(value = "contacts", nulls = Nulls.SKIP) + public _FinalStage contacts(List contacts) { + this.contacts.clear(); + this.contacts.addAll(contacts); + return this; + } + + @java.lang.Override + public CreateTicketRequest build() { + return new CreateTicketRequest( + ticketTypeId, + contacts, + conversationToLinkId, + companyId, + createdAt, + assignment, + skipNotifications, + additionalProperties); + } + } + + @JsonDeserialize(using = ContactsItem.Deserializer.class) + public static final class ContactsItem { + private final Object value; + + private final int type; + + private ContactsItem(Object value, int type) { + this.value = value; + this.type = type; + } + + @JsonValue + public Object get() { + return this.value; + } + + @SuppressWarnings("unchecked") + public T visit(Visitor visitor) { + if (this.type == 0) { + return visitor.visit((Id) this.value); + } else if (this.type == 1) { + return visitor.visit((ExternalId) this.value); + } else if (this.type == 2) { + return visitor.visit((Email) this.value); + } + throw new IllegalStateException("Failed to visit value. This should never happen."); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ContactsItem && equalTo((ContactsItem) other); + } + + private boolean equalTo(ContactsItem other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return this.value.toString(); + } + + public static ContactsItem of(Id value) { + return new ContactsItem(value, 0); + } + + public static ContactsItem of(ExternalId value) { + return new ContactsItem(value, 1); + } + + public static ContactsItem of(Email value) { + return new ContactsItem(value, 2); + } + + public interface Visitor { + T visit(Id value); + + T visit(ExternalId value); + + T visit(Email value); + } + + static final class Deserializer extends StdDeserializer { + Deserializer() { + super(ContactsItem.class); + } + + @java.lang.Override + public ContactsItem deserialize(JsonParser p, DeserializationContext context) throws IOException { + Object value = p.readValueAs(Object.class); + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, Id.class)); + } catch (IllegalArgumentException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, ExternalId.class)); + } catch (IllegalArgumentException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, Email.class)); + } catch (IllegalArgumentException e) { + } + throw new JsonParseException(p, "Failed to deserialize"); + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = ExternalId.Builder.class) + public static final class ExternalId { + private final String externalId; + + private final Map additionalProperties; + + private ExternalId(String externalId, Map additionalProperties) { + this.externalId = externalId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The external_id you have defined for the contact who is being added as a participant. + */ + @JsonProperty("external_id") + public String getExternalId() { + return externalId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ExternalId && equalTo((ExternalId) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ExternalId other) { + return externalId.equals(other.externalId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.externalId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ExternalIdStage builder() { + return new Builder(); + } + + public interface ExternalIdStage { + /** + * The external_id you have defined for the contact who is being added as a participant. + */ + _FinalStage externalId(@NotNull String externalId); + + Builder from(ExternalId other); + } + + public interface _FinalStage { + ExternalId build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ExternalIdStage, _FinalStage { + private String externalId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ExternalId other) { + externalId(other.getExternalId()); + return this; + } + + /** + * The external_id you have defined for the contact who is being added as a participant.

    The external_id you have defined for the contact who is being added as a participant.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("external_id") + public _FinalStage externalId(@NotNull String externalId) { + this.externalId = Objects.requireNonNull(externalId, "externalId must not be null"); + return this; + } + + @java.lang.Override + public ExternalId build() { + return new ExternalId(externalId, additionalProperties); + } + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = Email.Builder.class) + public static final class Email { + private final String email; + + private final Map additionalProperties; + + private Email(String email, Map additionalProperties) { + this.email = email; + this.additionalProperties = additionalProperties; + } + + /** + * @return The email you have defined for the contact who is being added as a participant. If a contact with this email does not exist, one will be created. + */ + @JsonProperty("email") + public String getEmail() { + return email; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Email && equalTo((Email) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Email other) { + return email.equals(other.email); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.email); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static EmailStage builder() { + return new Builder(); + } + + public interface EmailStage { + /** + * The email you have defined for the contact who is being added as a participant. If a contact with this email does not exist, one will be created. + */ + _FinalStage email(@NotNull String email); + + Builder from(Email other); + } + + public interface _FinalStage { + Email build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements EmailStage, _FinalStage { + private String email; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(Email other) { + email(other.getEmail()); + return this; + } + + /** + * The email you have defined for the contact who is being added as a participant. If a contact with this email does not exist, one will be created.

    The email you have defined for the contact who is being added as a participant. If a contact with this email does not exist, one will be created.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("email") + public _FinalStage email(@NotNull String email) { + this.email = Objects.requireNonNull(email, "email must not be null"); + return this; + } + + @java.lang.Override + public Email build() { + return new Email(email, additionalProperties); + } + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = Id.Builder.class) + public static final class Id { + private final String id; + + private final Map additionalProperties; + + private Id(String id, Map additionalProperties) { + this.id = id; + this.additionalProperties = additionalProperties; + } + + /** + * @return The identifier for the contact as given by Intercom. + */ + @JsonProperty("id") + public String getId() { + return id; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Id && equalTo((Id) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Id other) { + return id.equals(other.id); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * The identifier for the contact as given by Intercom. + */ + _FinalStage id(@NotNull String id); + + Builder from(Id other); + } + + public interface _FinalStage { + Id build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, _FinalStage { + private String id; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(Id other) { + id(other.getId()); + return this; + } + + /** + * The identifier for the contact as given by Intercom.

    The identifier for the contact as given by Intercom.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + public Id build() { + return new Id(id, additionalProperties); + } + } + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = Assignment.Builder.class) + public static final class Assignment { + private final Optional adminAssigneeId; + + private final Optional teamAssigneeId; + + private final Map additionalProperties; + + private Assignment( + Optional adminAssigneeId, + Optional teamAssigneeId, + Map additionalProperties) { + this.adminAssigneeId = adminAssigneeId; + this.teamAssigneeId = teamAssigneeId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The ID of the admin to which the ticket is assigned. If not provided, the ticket will be unassigned. + */ + @JsonProperty("admin_assignee_id") + public Optional getAdminAssigneeId() { + return adminAssigneeId; + } + + /** + * @return The ID of the team to which the ticket is assigned. If not provided, the ticket will be unassigned. + */ + @JsonProperty("team_assignee_id") + public Optional getTeamAssigneeId() { + return teamAssigneeId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Assignment && equalTo((Assignment) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Assignment other) { + return adminAssigneeId.equals(other.adminAssigneeId) && teamAssigneeId.equals(other.teamAssigneeId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.adminAssigneeId, this.teamAssigneeId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional adminAssigneeId = Optional.empty(); + + private Optional teamAssigneeId = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(Assignment other) { + adminAssigneeId(other.getAdminAssigneeId()); + teamAssigneeId(other.getTeamAssigneeId()); + return this; + } + + /** + *

    The ID of the admin to which the ticket is assigned. If not provided, the ticket will be unassigned.

    + */ + @JsonSetter(value = "admin_assignee_id", nulls = Nulls.SKIP) + public Builder adminAssigneeId(Optional adminAssigneeId) { + this.adminAssigneeId = adminAssigneeId; + return this; + } + + public Builder adminAssigneeId(String adminAssigneeId) { + this.adminAssigneeId = Optional.ofNullable(adminAssigneeId); + return this; + } + + /** + *

    The ID of the team to which the ticket is assigned. If not provided, the ticket will be unassigned.

    + */ + @JsonSetter(value = "team_assignee_id", nulls = Nulls.SKIP) + public Builder teamAssigneeId(Optional teamAssigneeId) { + this.teamAssigneeId = teamAssigneeId; + return this; + } + + public Builder teamAssigneeId(String teamAssigneeId) { + this.teamAssigneeId = Optional.ofNullable(teamAssigneeId); + return this; + } + + public Assignment build() { + return new Assignment(adminAssigneeId, teamAssigneeId, additionalProperties); + } + } + } +} diff --git a/src/main/java/com/intercom/api/resources/tickets/requests/DeleteTicketRequest.java b/src/main/java/com/intercom/api/resources/tickets/requests/DeleteTicketRequest.java new file mode 100644 index 0000000..cc8b3ed --- /dev/null +++ b/src/main/java/com/intercom/api/resources/tickets/requests/DeleteTicketRequest.java @@ -0,0 +1,112 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.tickets.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = DeleteTicketRequest.Builder.class) +public final class DeleteTicketRequest { + private final String ticketId; + + private final Map additionalProperties; + + private DeleteTicketRequest(String ticketId, Map additionalProperties) { + this.ticketId = ticketId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the ticket which is given by Intercom. + */ + @JsonProperty("ticket_id") + public String getTicketId() { + return ticketId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeleteTicketRequest && equalTo((DeleteTicketRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeleteTicketRequest other) { + return ticketId.equals(other.ticketId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.ticketId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TicketIdStage builder() { + return new Builder(); + } + + public interface TicketIdStage { + /** + * The unique identifier for the ticket which is given by Intercom. + */ + _FinalStage ticketId(@NotNull String ticketId); + + Builder from(DeleteTicketRequest other); + } + + public interface _FinalStage { + DeleteTicketRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements TicketIdStage, _FinalStage { + private String ticketId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DeleteTicketRequest other) { + ticketId(other.getTicketId()); + return this; + } + + /** + * The unique identifier for the ticket which is given by Intercom.

    The unique identifier for the ticket which is given by Intercom.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("ticket_id") + public _FinalStage ticketId(@NotNull String ticketId) { + this.ticketId = Objects.requireNonNull(ticketId, "ticketId must not be null"); + return this; + } + + @java.lang.Override + public DeleteTicketRequest build() { + return new DeleteTicketRequest(ticketId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/tickets/requests/EnqueueCreateTicketRequest.java b/src/main/java/com/intercom/api/resources/tickets/requests/EnqueueCreateTicketRequest.java new file mode 100644 index 0000000..d9ebfc2 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/tickets/requests/EnqueueCreateTicketRequest.java @@ -0,0 +1,914 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.tickets.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.types.ICreateTicketRequestBody; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = EnqueueCreateTicketRequest.Builder.class) +public final class EnqueueCreateTicketRequest implements ICreateTicketRequestBody { + private final String ticketTypeId; + + private final List contacts; + + private final Optional conversationToLinkId; + + private final Optional companyId; + + private final Optional createdAt; + + private final Optional assignment; + + private final Optional skipNotifications; + + private final Map additionalProperties; + + private EnqueueCreateTicketRequest( + String ticketTypeId, + List contacts, + Optional conversationToLinkId, + Optional companyId, + Optional createdAt, + Optional assignment, + Optional skipNotifications, + Map additionalProperties) { + this.ticketTypeId = ticketTypeId; + this.contacts = contacts; + this.conversationToLinkId = conversationToLinkId; + this.companyId = companyId; + this.createdAt = createdAt; + this.assignment = assignment; + this.skipNotifications = skipNotifications; + this.additionalProperties = additionalProperties; + } + + /** + * @return The ID of the type of ticket you want to create + */ + @JsonProperty("ticket_type_id") + public String getTicketTypeId() { + return ticketTypeId; + } + + /** + * @return The list of contacts (users or leads) affected by this ticket. Currently only one is allowed + */ + @JsonProperty("contacts") + public List getContacts() { + return contacts; + } + + /** + * @return 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
    • + *
    + */ + @JsonProperty("conversation_to_link_id") + public Optional getConversationToLinkId() { + return conversationToLinkId; + } + + /** + * @return The ID of the company that the ticket is associated with. The unique identifier for the company which is given by Intercom + */ + @JsonProperty("company_id") + public Optional getCompanyId() { + return companyId; + } + + /** + * @return The time the ticket was created. If not provided, the current time will be used. + */ + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + @JsonProperty("assignment") + public Optional getAssignment() { + return assignment; + } + + /** + * @return Option to disable notifications when a Ticket is created. + */ + @JsonProperty("skip_notifications") + public Optional getSkipNotifications() { + return skipNotifications; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof EnqueueCreateTicketRequest && equalTo((EnqueueCreateTicketRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(EnqueueCreateTicketRequest other) { + return ticketTypeId.equals(other.ticketTypeId) + && contacts.equals(other.contacts) + && conversationToLinkId.equals(other.conversationToLinkId) + && companyId.equals(other.companyId) + && createdAt.equals(other.createdAt) + && assignment.equals(other.assignment) + && skipNotifications.equals(other.skipNotifications); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.ticketTypeId, + this.contacts, + this.conversationToLinkId, + this.companyId, + this.createdAt, + this.assignment, + this.skipNotifications); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TicketTypeIdStage builder() { + return new Builder(); + } + + public interface TicketTypeIdStage { + /** + * The ID of the type of ticket you want to create + */ + _FinalStage ticketTypeId(@NotNull String ticketTypeId); + + Builder from(EnqueueCreateTicketRequest other); + } + + public interface _FinalStage { + EnqueueCreateTicketRequest build(); + + /** + *

    The list of contacts (users or leads) affected by this ticket. Currently only one is allowed

    + */ + _FinalStage contacts(List contacts); + + _FinalStage addContacts(ContactsItem contacts); + + _FinalStage addAllContacts(List contacts); + + /** + *

    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
    • + *
    + */ + _FinalStage conversationToLinkId(Optional conversationToLinkId); + + _FinalStage conversationToLinkId(String conversationToLinkId); + + /** + *

    The ID of the company that the ticket is associated with. The unique identifier for the company which is given by Intercom

    + */ + _FinalStage companyId(Optional companyId); + + _FinalStage companyId(String companyId); + + /** + *

    The time the ticket was created. If not provided, the current time will be used.

    + */ + _FinalStage createdAt(Optional createdAt); + + _FinalStage createdAt(Integer createdAt); + + _FinalStage assignment(Optional assignment); + + _FinalStage assignment(Assignment assignment); + + /** + *

    Option to disable notifications when a Ticket is created.

    + */ + _FinalStage skipNotifications(Optional skipNotifications); + + _FinalStage skipNotifications(Boolean skipNotifications); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements TicketTypeIdStage, _FinalStage { + private String ticketTypeId; + + private Optional skipNotifications = Optional.empty(); + + private Optional assignment = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + private Optional companyId = Optional.empty(); + + private Optional conversationToLinkId = Optional.empty(); + + private List contacts = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(EnqueueCreateTicketRequest other) { + ticketTypeId(other.getTicketTypeId()); + contacts(other.getContacts()); + conversationToLinkId(other.getConversationToLinkId()); + companyId(other.getCompanyId()); + createdAt(other.getCreatedAt()); + assignment(other.getAssignment()); + skipNotifications(other.getSkipNotifications()); + return this; + } + + /** + * The ID of the type of ticket you want to create

    The ID of the type of ticket you want to create

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("ticket_type_id") + public _FinalStage ticketTypeId(@NotNull String ticketTypeId) { + this.ticketTypeId = Objects.requireNonNull(ticketTypeId, "ticketTypeId must not be null"); + return this; + } + + /** + *

    Option to disable notifications when a Ticket is created.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage skipNotifications(Boolean skipNotifications) { + this.skipNotifications = Optional.ofNullable(skipNotifications); + return this; + } + + /** + *

    Option to disable notifications when a Ticket is created.

    + */ + @java.lang.Override + @JsonSetter(value = "skip_notifications", nulls = Nulls.SKIP) + public _FinalStage skipNotifications(Optional skipNotifications) { + this.skipNotifications = skipNotifications; + return this; + } + + @java.lang.Override + public _FinalStage assignment(Assignment assignment) { + this.assignment = Optional.ofNullable(assignment); + return this; + } + + @java.lang.Override + @JsonSetter(value = "assignment", nulls = Nulls.SKIP) + public _FinalStage assignment(Optional assignment) { + this.assignment = assignment; + return this; + } + + /** + *

    The time the ticket was created. If not provided, the current time will be used.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage createdAt(Integer createdAt) { + this.createdAt = Optional.ofNullable(createdAt); + return this; + } + + /** + *

    The time the ticket was created. If not provided, the current time will be used.

    + */ + @java.lang.Override + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public _FinalStage createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + /** + *

    The ID of the company that the ticket is associated with. The unique identifier for the company which is given by Intercom

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage companyId(String companyId) { + this.companyId = Optional.ofNullable(companyId); + return this; + } + + /** + *

    The ID of the company that the ticket is associated with. The unique identifier for the company which is given by Intercom

    + */ + @java.lang.Override + @JsonSetter(value = "company_id", nulls = Nulls.SKIP) + public _FinalStage companyId(Optional companyId) { + this.companyId = companyId; + return this; + } + + /** + *

    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
    • + *
    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage conversationToLinkId(String conversationToLinkId) { + this.conversationToLinkId = Optional.ofNullable(conversationToLinkId); + return this; + } + + /** + *

    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
    • + *
    + */ + @java.lang.Override + @JsonSetter(value = "conversation_to_link_id", nulls = Nulls.SKIP) + public _FinalStage conversationToLinkId(Optional conversationToLinkId) { + this.conversationToLinkId = conversationToLinkId; + return this; + } + + /** + *

    The list of contacts (users or leads) affected by this ticket. Currently only one is allowed

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage addAllContacts(List contacts) { + this.contacts.addAll(contacts); + return this; + } + + /** + *

    The list of contacts (users or leads) affected by this ticket. Currently only one is allowed

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage addContacts(ContactsItem contacts) { + this.contacts.add(contacts); + return this; + } + + /** + *

    The list of contacts (users or leads) affected by this ticket. Currently only one is allowed

    + */ + @java.lang.Override + @JsonSetter(value = "contacts", nulls = Nulls.SKIP) + public _FinalStage contacts(List contacts) { + this.contacts.clear(); + this.contacts.addAll(contacts); + return this; + } + + @java.lang.Override + public EnqueueCreateTicketRequest build() { + return new EnqueueCreateTicketRequest( + ticketTypeId, + contacts, + conversationToLinkId, + companyId, + createdAt, + assignment, + skipNotifications, + additionalProperties); + } + } + + @JsonDeserialize(using = ContactsItem.Deserializer.class) + public static final class ContactsItem { + private final Object value; + + private final int type; + + private ContactsItem(Object value, int type) { + this.value = value; + this.type = type; + } + + @JsonValue + public Object get() { + return this.value; + } + + @SuppressWarnings("unchecked") + public T visit(Visitor visitor) { + if (this.type == 0) { + return visitor.visit((Id) this.value); + } else if (this.type == 1) { + return visitor.visit((ExternalId) this.value); + } else if (this.type == 2) { + return visitor.visit((Email) this.value); + } + throw new IllegalStateException("Failed to visit value. This should never happen."); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ContactsItem && equalTo((ContactsItem) other); + } + + private boolean equalTo(ContactsItem other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return this.value.toString(); + } + + public static ContactsItem of(Id value) { + return new ContactsItem(value, 0); + } + + public static ContactsItem of(ExternalId value) { + return new ContactsItem(value, 1); + } + + public static ContactsItem of(Email value) { + return new ContactsItem(value, 2); + } + + public interface Visitor { + T visit(Id value); + + T visit(ExternalId value); + + T visit(Email value); + } + + static final class Deserializer extends StdDeserializer { + Deserializer() { + super(ContactsItem.class); + } + + @java.lang.Override + public ContactsItem deserialize(JsonParser p, DeserializationContext context) throws IOException { + Object value = p.readValueAs(Object.class); + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, Id.class)); + } catch (IllegalArgumentException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, ExternalId.class)); + } catch (IllegalArgumentException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, Email.class)); + } catch (IllegalArgumentException e) { + } + throw new JsonParseException(p, "Failed to deserialize"); + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = ExternalId.Builder.class) + public static final class ExternalId { + private final String externalId; + + private final Map additionalProperties; + + private ExternalId(String externalId, Map additionalProperties) { + this.externalId = externalId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The external_id you have defined for the contact who is being added as a participant. + */ + @JsonProperty("external_id") + public String getExternalId() { + return externalId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ExternalId && equalTo((ExternalId) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ExternalId other) { + return externalId.equals(other.externalId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.externalId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ExternalIdStage builder() { + return new Builder(); + } + + public interface ExternalIdStage { + /** + * The external_id you have defined for the contact who is being added as a participant. + */ + _FinalStage externalId(@NotNull String externalId); + + Builder from(ExternalId other); + } + + public interface _FinalStage { + ExternalId build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ExternalIdStage, _FinalStage { + private String externalId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ExternalId other) { + externalId(other.getExternalId()); + return this; + } + + /** + * The external_id you have defined for the contact who is being added as a participant.

    The external_id you have defined for the contact who is being added as a participant.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("external_id") + public _FinalStage externalId(@NotNull String externalId) { + this.externalId = Objects.requireNonNull(externalId, "externalId must not be null"); + return this; + } + + @java.lang.Override + public ExternalId build() { + return new ExternalId(externalId, additionalProperties); + } + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = Email.Builder.class) + public static final class Email { + private final String email; + + private final Map additionalProperties; + + private Email(String email, Map additionalProperties) { + this.email = email; + this.additionalProperties = additionalProperties; + } + + /** + * @return The email you have defined for the contact who is being added as a participant. If a contact with this email does not exist, one will be created. + */ + @JsonProperty("email") + public String getEmail() { + return email; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Email && equalTo((Email) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Email other) { + return email.equals(other.email); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.email); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static EmailStage builder() { + return new Builder(); + } + + public interface EmailStage { + /** + * The email you have defined for the contact who is being added as a participant. If a contact with this email does not exist, one will be created. + */ + _FinalStage email(@NotNull String email); + + Builder from(Email other); + } + + public interface _FinalStage { + Email build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements EmailStage, _FinalStage { + private String email; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(Email other) { + email(other.getEmail()); + return this; + } + + /** + * The email you have defined for the contact who is being added as a participant. If a contact with this email does not exist, one will be created.

    The email you have defined for the contact who is being added as a participant. If a contact with this email does not exist, one will be created.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("email") + public _FinalStage email(@NotNull String email) { + this.email = Objects.requireNonNull(email, "email must not be null"); + return this; + } + + @java.lang.Override + public Email build() { + return new Email(email, additionalProperties); + } + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = Id.Builder.class) + public static final class Id { + private final String id; + + private final Map additionalProperties; + + private Id(String id, Map additionalProperties) { + this.id = id; + this.additionalProperties = additionalProperties; + } + + /** + * @return The identifier for the contact as given by Intercom. + */ + @JsonProperty("id") + public String getId() { + return id; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Id && equalTo((Id) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Id other) { + return id.equals(other.id); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * The identifier for the contact as given by Intercom. + */ + _FinalStage id(@NotNull String id); + + Builder from(Id other); + } + + public interface _FinalStage { + Id build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, _FinalStage { + private String id; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(Id other) { + id(other.getId()); + return this; + } + + /** + * The identifier for the contact as given by Intercom.

    The identifier for the contact as given by Intercom.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + public Id build() { + return new Id(id, additionalProperties); + } + } + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = Assignment.Builder.class) + public static final class Assignment { + private final Optional adminAssigneeId; + + private final Optional teamAssigneeId; + + private final Map additionalProperties; + + private Assignment( + Optional adminAssigneeId, + Optional teamAssigneeId, + Map additionalProperties) { + this.adminAssigneeId = adminAssigneeId; + this.teamAssigneeId = teamAssigneeId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The ID of the admin to which the ticket is assigned. If not provided, the ticket will be unassigned. + */ + @JsonProperty("admin_assignee_id") + public Optional getAdminAssigneeId() { + return adminAssigneeId; + } + + /** + * @return The ID of the team to which the ticket is assigned. If not provided, the ticket will be unassigned. + */ + @JsonProperty("team_assignee_id") + public Optional getTeamAssigneeId() { + return teamAssigneeId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Assignment && equalTo((Assignment) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Assignment other) { + return adminAssigneeId.equals(other.adminAssigneeId) && teamAssigneeId.equals(other.teamAssigneeId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.adminAssigneeId, this.teamAssigneeId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional adminAssigneeId = Optional.empty(); + + private Optional teamAssigneeId = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(Assignment other) { + adminAssigneeId(other.getAdminAssigneeId()); + teamAssigneeId(other.getTeamAssigneeId()); + return this; + } + + /** + *

    The ID of the admin to which the ticket is assigned. If not provided, the ticket will be unassigned.

    + */ + @JsonSetter(value = "admin_assignee_id", nulls = Nulls.SKIP) + public Builder adminAssigneeId(Optional adminAssigneeId) { + this.adminAssigneeId = adminAssigneeId; + return this; + } + + public Builder adminAssigneeId(String adminAssigneeId) { + this.adminAssigneeId = Optional.ofNullable(adminAssigneeId); + return this; + } + + /** + *

    The ID of the team to which the ticket is assigned. If not provided, the ticket will be unassigned.

    + */ + @JsonSetter(value = "team_assignee_id", nulls = Nulls.SKIP) + public Builder teamAssigneeId(Optional teamAssigneeId) { + this.teamAssigneeId = teamAssigneeId; + return this; + } + + public Builder teamAssigneeId(String teamAssigneeId) { + this.teamAssigneeId = Optional.ofNullable(teamAssigneeId); + return this; + } + + public Assignment build() { + return new Assignment(adminAssigneeId, teamAssigneeId, additionalProperties); + } + } + } +} diff --git a/src/main/java/com/intercom/api/resources/tickets/requests/UpdateTicketRequest.java b/src/main/java/com/intercom/api/resources/tickets/requests/UpdateTicketRequest.java index 9392614..3fe4cb6 100644 --- a/src/main/java/com/intercom/api/resources/tickets/requests/UpdateTicketRequest.java +++ b/src/main/java/com/intercom/api/resources/tickets/requests/UpdateTicketRequest.java @@ -5,12 +5,10 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.JsonValue; import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.intercom.api.core.ObjectMappers; @@ -27,7 +25,9 @@ public final class UpdateTicketRequest { private final Optional> ticketAttributes; - private final Optional state; + private final Optional ticketStateId; + + private final Optional companyId; private final Optional open; @@ -35,26 +35,32 @@ public final class UpdateTicketRequest { private final Optional snoozedUntil; - private final Optional assignment; + private final Optional adminId; + + private final Optional assigneeId; private final Map additionalProperties; private UpdateTicketRequest( String ticketId, Optional> ticketAttributes, - Optional state, + Optional ticketStateId, + Optional companyId, Optional open, Optional isShared, Optional snoozedUntil, - Optional assignment, + Optional adminId, + Optional assigneeId, Map additionalProperties) { this.ticketId = ticketId; this.ticketAttributes = ticketAttributes; - this.state = state; + this.ticketStateId = ticketStateId; + this.companyId = companyId; this.open = open; this.isShared = isShared; this.snoozedUntil = snoozedUntil; - this.assignment = assignment; + this.adminId = adminId; + this.assigneeId = assigneeId; this.additionalProperties = additionalProperties; } @@ -75,11 +81,19 @@ public Optional> getTicketAttributes() { } /** - * @return The state of the ticket. + * @return The ID of the ticket state associated with the ticket type. + */ + @JsonProperty("ticket_state_id") + public Optional getTicketStateId() { + return ticketStateId; + } + + /** + * @return 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. */ - @JsonProperty("state") - public Optional getState() { - return state; + @JsonProperty("company_id") + public Optional getCompanyId() { + return companyId; } /** @@ -106,9 +120,20 @@ public Optional getSnoozedUntil() { return snoozedUntil; } - @JsonProperty("assignment") - public Optional getAssignment() { - return assignment; + /** + * @return The ID of the admin performing ticket update. Needed for workflows execution and attributing actions to specific admins. + */ + @JsonProperty("admin_id") + public Optional getAdminId() { + return adminId; + } + + /** + * @return The ID of the admin or team to which the ticket is assigned. Set this 0 to unassign it. + */ + @JsonProperty("assignee_id") + public Optional getAssigneeId() { + return assigneeId; } @java.lang.Override @@ -125,11 +150,13 @@ public Map getAdditionalProperties() { private boolean equalTo(UpdateTicketRequest other) { return ticketId.equals(other.ticketId) && ticketAttributes.equals(other.ticketAttributes) - && state.equals(other.state) + && ticketStateId.equals(other.ticketStateId) + && companyId.equals(other.companyId) && open.equals(other.open) && isShared.equals(other.isShared) && snoozedUntil.equals(other.snoozedUntil) - && assignment.equals(other.assignment); + && adminId.equals(other.adminId) + && assigneeId.equals(other.assigneeId); } @java.lang.Override @@ -137,11 +164,13 @@ public int hashCode() { return Objects.hash( this.ticketId, this.ticketAttributes, - this.state, + this.ticketStateId, + this.companyId, this.open, this.isShared, this.snoozedUntil, - this.assignment); + this.adminId, + this.assigneeId); } @java.lang.Override @@ -173,11 +202,18 @@ public interface _FinalStage { _FinalStage ticketAttributes(Map ticketAttributes); /** - *

    The state of the ticket.

    + *

    The ID of the ticket state associated with the ticket type.

    + */ + _FinalStage ticketStateId(Optional ticketStateId); + + _FinalStage ticketStateId(String ticketStateId); + + /** + *

    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.

    */ - _FinalStage state(Optional state); + _FinalStage companyId(Optional companyId); - _FinalStage state(State state); + _FinalStage companyId(String companyId); /** *

    Specify if a ticket is open. Set to false to close a ticket. Closing a ticket will also unsnooze it.

    @@ -200,16 +236,28 @@ public interface _FinalStage { _FinalStage snoozedUntil(Integer snoozedUntil); - _FinalStage assignment(Optional assignment); + /** + *

    The ID of the admin performing ticket update. Needed for workflows execution and attributing actions to specific admins.

    + */ + _FinalStage adminId(Optional adminId); + + _FinalStage adminId(Integer adminId); + + /** + *

    The ID of the admin or team to which the ticket is assigned. Set this 0 to unassign it.

    + */ + _FinalStage assigneeId(Optional assigneeId); - _FinalStage assignment(Assignment assignment); + _FinalStage assigneeId(String assigneeId); } @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements TicketIdStage, _FinalStage { private String ticketId; - private Optional assignment = Optional.empty(); + private Optional assigneeId = Optional.empty(); + + private Optional adminId = Optional.empty(); private Optional snoozedUntil = Optional.empty(); @@ -217,7 +265,9 @@ public static final class Builder implements TicketIdStage, _FinalStage { private Optional open = Optional.empty(); - private Optional state = Optional.empty(); + private Optional companyId = Optional.empty(); + + private Optional ticketStateId = Optional.empty(); private Optional> ticketAttributes = Optional.empty(); @@ -230,11 +280,13 @@ private Builder() {} public Builder from(UpdateTicketRequest other) { ticketId(other.getTicketId()); ticketAttributes(other.getTicketAttributes()); - state(other.getState()); + ticketStateId(other.getTicketStateId()); + companyId(other.getCompanyId()); open(other.getOpen()); isShared(other.getIsShared()); snoozedUntil(other.getSnoozedUntil()); - assignment(other.getAssignment()); + adminId(other.getAdminId()); + assigneeId(other.getAssigneeId()); return this; } @@ -249,16 +301,43 @@ public _FinalStage ticketId(@NotNull String ticketId) { return this; } + /** + *

    The ID of the admin or team to which the ticket is assigned. Set this 0 to unassign it.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage assigneeId(String assigneeId) { + this.assigneeId = Optional.ofNullable(assigneeId); + return this; + } + + /** + *

    The ID of the admin or team to which the ticket is assigned. Set this 0 to unassign it.

    + */ + @java.lang.Override + @JsonSetter(value = "assignee_id", nulls = Nulls.SKIP) + public _FinalStage assigneeId(Optional assigneeId) { + this.assigneeId = assigneeId; + return this; + } + + /** + *

    The ID of the admin performing ticket update. Needed for workflows execution and attributing actions to specific admins.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ @java.lang.Override - public _FinalStage assignment(Assignment assignment) { - this.assignment = Optional.ofNullable(assignment); + public _FinalStage adminId(Integer adminId) { + this.adminId = Optional.ofNullable(adminId); return this; } + /** + *

    The ID of the admin performing ticket update. Needed for workflows execution and attributing actions to specific admins.

    + */ @java.lang.Override - @JsonSetter(value = "assignment", nulls = Nulls.SKIP) - public _FinalStage assignment(Optional assignment) { - this.assignment = assignment; + @JsonSetter(value = "admin_id", nulls = Nulls.SKIP) + public _FinalStage adminId(Optional adminId) { + this.adminId = adminId; return this; } @@ -323,246 +402,78 @@ public _FinalStage open(Optional open) { } /** - *

    The state of the ticket.

    + *

    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.

    * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override - public _FinalStage state(State state) { - this.state = Optional.ofNullable(state); + public _FinalStage companyId(String companyId) { + this.companyId = Optional.ofNullable(companyId); return this; } /** - *

    The state of the ticket.

    + *

    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.

    */ @java.lang.Override - @JsonSetter(value = "state", nulls = Nulls.SKIP) - public _FinalStage state(Optional state) { - this.state = state; + @JsonSetter(value = "company_id", nulls = Nulls.SKIP) + public _FinalStage companyId(Optional companyId) { + this.companyId = companyId; return this; } /** - *

    The attributes set on the ticket.

    + *

    The ID of the ticket state associated with the ticket type.

    * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override - public _FinalStage ticketAttributes(Map ticketAttributes) { - this.ticketAttributes = Optional.ofNullable(ticketAttributes); + public _FinalStage ticketStateId(String ticketStateId) { + this.ticketStateId = Optional.ofNullable(ticketStateId); return this; } /** - *

    The attributes set on the ticket.

    + *

    The ID of the ticket state associated with the ticket type.

    */ @java.lang.Override - @JsonSetter(value = "ticket_attributes", nulls = Nulls.SKIP) - public _FinalStage ticketAttributes(Optional> ticketAttributes) { - this.ticketAttributes = ticketAttributes; + @JsonSetter(value = "ticket_state_id", nulls = Nulls.SKIP) + public _FinalStage ticketStateId(Optional ticketStateId) { + this.ticketStateId = ticketStateId; return this; } - @java.lang.Override - public UpdateTicketRequest build() { - return new UpdateTicketRequest( - ticketId, ticketAttributes, state, open, isShared, snoozedUntil, assignment, additionalProperties); - } - } - - public static final class State { - public static final State IN_PROGRESS = new State(Value.IN_PROGRESS, "in_progress"); - - public static final State RESOLVED = new State(Value.RESOLVED, "resolved"); - - public static final State WAITING_ON_CUSTOMER = new State(Value.WAITING_ON_CUSTOMER, "waiting_on_customer"); - - private final Value value; - - private final String string; - - State(Value value, String string) { - this.value = value; - this.string = string; - } - - public Value getEnumValue() { - return value; - } - - @java.lang.Override - @JsonValue - public String toString() { - return this.string; - } - - @java.lang.Override - public boolean equals(Object other) { - return (this == other) || (other instanceof State && this.string.equals(((State) other).string)); - } - - @java.lang.Override - public int hashCode() { - return this.string.hashCode(); - } - - public T visit(Visitor visitor) { - switch (value) { - case IN_PROGRESS: - return visitor.visitInProgress(); - case RESOLVED: - return visitor.visitResolved(); - case WAITING_ON_CUSTOMER: - return visitor.visitWaitingOnCustomer(); - case UNKNOWN: - default: - return visitor.visitUnknown(string); - } - } - - @JsonCreator(mode = JsonCreator.Mode.DELEGATING) - public static State valueOf(String value) { - switch (value) { - case "in_progress": - return IN_PROGRESS; - case "resolved": - return RESOLVED; - case "waiting_on_customer": - return WAITING_ON_CUSTOMER; - default: - return new State(Value.UNKNOWN, value); - } - } - - public enum Value { - IN_PROGRESS, - - WAITING_ON_CUSTOMER, - - RESOLVED, - - UNKNOWN - } - - public interface Visitor { - T visitInProgress(); - - T visitWaitingOnCustomer(); - - T visitResolved(); - - T visitUnknown(String unknownType); - } - } - - @JsonInclude(JsonInclude.Include.NON_ABSENT) - @JsonDeserialize(builder = Assignment.Builder.class) - public static final class Assignment { - private final Optional adminId; - - private final Optional assigneeId; - - private final Map additionalProperties; - - private Assignment( - Optional adminId, Optional assigneeId, Map additionalProperties) { - this.adminId = adminId; - this.assigneeId = assigneeId; - this.additionalProperties = additionalProperties; - } - /** - * @return The ID of the admin performing the action. + *

    The attributes set on the ticket.

    + * @return Reference to {@code this} so that method calls can be chained together. */ - @JsonProperty("admin_id") - public Optional getAdminId() { - return adminId; + @java.lang.Override + public _FinalStage ticketAttributes(Map ticketAttributes) { + this.ticketAttributes = Optional.ofNullable(ticketAttributes); + return this; } /** - * @return The ID of the admin or team to which the ticket is assigned. Set this 0 to unassign it. + *

    The attributes set on the ticket.

    */ - @JsonProperty("assignee_id") - public Optional getAssigneeId() { - return assigneeId; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Assignment && equalTo((Assignment) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(Assignment other) { - return adminId.equals(other.adminId) && assigneeId.equals(other.assigneeId); - } - @java.lang.Override - public int hashCode() { - return Objects.hash(this.adminId, this.assigneeId); + @JsonSetter(value = "ticket_attributes", nulls = Nulls.SKIP) + public _FinalStage ticketAttributes(Optional> ticketAttributes) { + this.ticketAttributes = ticketAttributes; + return this; } @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional adminId = Optional.empty(); - - private Optional assigneeId = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(Assignment other) { - adminId(other.getAdminId()); - assigneeId(other.getAssigneeId()); - return this; - } - - /** - *

    The ID of the admin performing the action.

    - */ - @JsonSetter(value = "admin_id", nulls = Nulls.SKIP) - public Builder adminId(Optional adminId) { - this.adminId = adminId; - return this; - } - - public Builder adminId(String adminId) { - this.adminId = Optional.ofNullable(adminId); - return this; - } - - /** - *

    The ID of the admin or team to which the ticket is assigned. Set this 0 to unassign it.

    - */ - @JsonSetter(value = "assignee_id", nulls = Nulls.SKIP) - public Builder assigneeId(Optional assigneeId) { - this.assigneeId = assigneeId; - return this; - } - - public Builder assigneeId(String assigneeId) { - this.assigneeId = Optional.ofNullable(assigneeId); - return this; - } - - public Assignment build() { - return new Assignment(adminId, assigneeId, additionalProperties); - } + public UpdateTicketRequest build() { + return new UpdateTicketRequest( + ticketId, + ticketAttributes, + ticketStateId, + companyId, + open, + isShared, + snoozedUntil, + adminId, + assigneeId, + additionalProperties); } } } diff --git a/src/main/java/com/intercom/api/resources/tickets/types/DeleteTicketResponse.java b/src/main/java/com/intercom/api/resources/tickets/types/DeleteTicketResponse.java new file mode 100644 index 0000000..52ccea1 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/tickets/types/DeleteTicketResponse.java @@ -0,0 +1,161 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.tickets.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = DeleteTicketResponse.Builder.class) +public final class DeleteTicketResponse { + private final Optional id; + + private final Optional object; + + private final Optional deleted; + + private final Map additionalProperties; + + private DeleteTicketResponse( + Optional id, + Optional object, + Optional deleted, + Map additionalProperties) { + this.id = id; + this.object = object; + this.deleted = deleted; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the ticket. + */ + @JsonProperty("id") + public Optional getId() { + return id; + } + + /** + * @return always ticket + */ + @JsonProperty("object") + public Optional getObject() { + return object; + } + + /** + * @return Whether the ticket is deleted or not. + */ + @JsonProperty("deleted") + public Optional getDeleted() { + return deleted; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeleteTicketResponse && equalTo((DeleteTicketResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeleteTicketResponse other) { + return id.equals(other.id) && object.equals(other.object) && deleted.equals(other.deleted); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id, this.object, this.deleted); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional id = Optional.empty(); + + private Optional object = Optional.empty(); + + private Optional deleted = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(DeleteTicketResponse other) { + id(other.getId()); + object(other.getObject()); + deleted(other.getDeleted()); + return this; + } + + /** + *

    The unique identifier for the ticket.

    + */ + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.ofNullable(id); + return this; + } + + /** + *

    always ticket

    + */ + @JsonSetter(value = "object", nulls = Nulls.SKIP) + public Builder object(Optional object) { + this.object = object; + return this; + } + + public Builder object(String object) { + this.object = Optional.ofNullable(object); + return this; + } + + /** + *

    Whether the ticket is deleted or not.

    + */ + @JsonSetter(value = "deleted", nulls = Nulls.SKIP) + public Builder deleted(Optional deleted) { + this.deleted = deleted; + return this; + } + + public Builder deleted(Boolean deleted) { + this.deleted = Optional.ofNullable(deleted); + return this; + } + + public DeleteTicketResponse build() { + return new DeleteTicketResponse(id, object, deleted, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/tickets/types/Ticket.java b/src/main/java/com/intercom/api/resources/tickets/types/Ticket.java index 4fb4b46..3f4a197 100644 --- a/src/main/java/com/intercom/api/resources/tickets/types/Ticket.java +++ b/src/main/java/com/intercom/api/resources/tickets/types/Ticket.java @@ -17,28 +17,28 @@ import com.intercom.api.types.LinkedObjectList; import com.intercom.api.types.TicketParts; import java.util.HashMap; -import java.util.LinkedHashMap; import java.util.Map; import java.util.Objects; import java.util.Optional; -import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = Ticket.Builder.class) public final class Ticket { - private final String id; + private final Optional type; - private final String ticketId; + private final Optional id; - private final Category category; + private final Optional ticketId; - private final Map ticketAttributes; + private final Optional category; - private final TicketState ticketState; + private final Optional> ticketAttributes; - private final TicketType ticketType; + private final Optional ticketState; - private final TicketContacts contacts; + private final Optional ticketType; + + private final Optional contacts; private final Optional adminAssigneeId; @@ -58,20 +58,17 @@ public final class Ticket { private final Optional isShared; - private final Optional ticketStateInternalLabel; - - private final Optional ticketStateExternalLabel; - private final Map additionalProperties; private Ticket( - String id, - String ticketId, - Category category, - Map ticketAttributes, - TicketState ticketState, - TicketType ticketType, - TicketContacts contacts, + Optional type, + Optional id, + Optional ticketId, + Optional category, + Optional> ticketAttributes, + Optional ticketState, + Optional ticketType, + Optional contacts, Optional adminAssigneeId, Optional teamAssigneeId, Optional createdAt, @@ -81,9 +78,8 @@ private Ticket( Optional linkedObjects, Optional ticketParts, Optional isShared, - Optional ticketStateInternalLabel, - Optional ticketStateExternalLabel, Map additionalProperties) { + this.type = type; this.id = id; this.ticketId = ticketId; this.category = category; @@ -100,8 +96,6 @@ private Ticket( this.linkedObjects = linkedObjects; this.ticketParts = ticketParts; this.isShared = isShared; - this.ticketStateInternalLabel = ticketStateInternalLabel; - this.ticketStateExternalLabel = ticketStateExternalLabel; this.additionalProperties = additionalProperties; } @@ -109,15 +103,15 @@ private Ticket( * @return Always ticket */ @JsonProperty("type") - public String getType() { - return "ticket"; + public Optional getType() { + return type; } /** * @return The unique identifier for the ticket which is given by Intercom. */ @JsonProperty("id") - public String getId() { + public Optional getId() { return id; } @@ -125,7 +119,7 @@ public String getId() { * @return The ID of the Ticket used in the Intercom Inbox and Messenger. Do not use ticket_id for API queries. */ @JsonProperty("ticket_id") - public String getTicketId() { + public Optional getTicketId() { return ticketId; } @@ -133,30 +127,27 @@ public String getTicketId() { * @return Category of the Ticket. */ @JsonProperty("category") - public Category getCategory() { + public Optional getCategory() { return category; } @JsonProperty("ticket_attributes") - public Map getTicketAttributes() { + public Optional> getTicketAttributes() { return ticketAttributes; } - /** - * @return The state the ticket is currently in - */ @JsonProperty("ticket_state") - public TicketState getTicketState() { + public Optional getTicketState() { return ticketState; } @JsonProperty("ticket_type") - public TicketType getTicketType() { + public Optional getTicketType() { return ticketType; } @JsonProperty("contacts") - public TicketContacts getContacts() { + public Optional getContacts() { return contacts; } @@ -226,22 +217,6 @@ public Optional getIsShared() { return isShared; } - /** - * @return The state the ticket is currently in, in a human readable form - visible in Intercom - */ - @JsonProperty("ticket_state_internal_label") - public Optional getTicketStateInternalLabel() { - return ticketStateInternalLabel; - } - - /** - * @return The state the ticket is currently in, in a human readable form - visible to customers, in the messenger, email and tickets portal. - */ - @JsonProperty("ticket_state_external_label") - public Optional getTicketStateExternalLabel() { - return ticketStateExternalLabel; - } - @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -254,7 +229,8 @@ public Map getAdditionalProperties() { } private boolean equalTo(Ticket other) { - return id.equals(other.id) + return type.equals(other.type) + && id.equals(other.id) && ticketId.equals(other.ticketId) && category.equals(other.category) && ticketAttributes.equals(other.ticketAttributes) @@ -269,14 +245,13 @@ private boolean equalTo(Ticket other) { && snoozedUntil.equals(other.snoozedUntil) && linkedObjects.equals(other.linkedObjects) && ticketParts.equals(other.ticketParts) - && isShared.equals(other.isShared) - && ticketStateInternalLabel.equals(other.ticketStateInternalLabel) - && ticketStateExternalLabel.equals(other.ticketStateExternalLabel); + && isShared.equals(other.isShared); } @java.lang.Override public int hashCode() { return Objects.hash( + this.type, this.id, this.ticketId, this.category, @@ -292,9 +267,7 @@ public int hashCode() { this.snoozedUntil, this.linkedObjects, this.ticketParts, - this.isShared, - this.ticketStateInternalLabel, - this.ticketStateExternalLabel); + this.isShared); } @java.lang.Override @@ -302,181 +275,53 @@ public String toString() { return ObjectMappers.stringify(this); } - public static IdStage builder() { + public static Builder builder() { return new Builder(); } - public interface IdStage { - /** - * The unique identifier for the ticket which is given by Intercom. - */ - TicketIdStage id(@NotNull String id); - - Builder from(Ticket other); - } - - public interface TicketIdStage { - /** - * The ID of the Ticket used in the Intercom Inbox and Messenger. Do not use ticket_id for API queries. - */ - CategoryStage ticketId(@NotNull String ticketId); - } - - public interface CategoryStage { - /** - * Category of the Ticket. - */ - TicketStateStage category(@NotNull Category category); - } - - public interface TicketStateStage { - /** - * The state the ticket is currently in - */ - TicketTypeStage ticketState(@NotNull TicketState ticketState); - } - - public interface TicketTypeStage { - ContactsStage ticketType(@NotNull TicketType ticketType); - } - - public interface ContactsStage { - _FinalStage contacts(@NotNull TicketContacts contacts); - } - - public interface _FinalStage { - Ticket build(); - - _FinalStage ticketAttributes(Map ticketAttributes); - - _FinalStage putAllTicketAttributes(Map ticketAttributes); - - _FinalStage ticketAttributes(String key, Object value); - - /** - *

    The id representing the admin assigned to the ticket.

    - */ - _FinalStage adminAssigneeId(Optional adminAssigneeId); - - _FinalStage adminAssigneeId(String adminAssigneeId); - - /** - *

    The id representing the team assigned to the ticket.

    - */ - _FinalStage teamAssigneeId(Optional teamAssigneeId); - - _FinalStage teamAssigneeId(String teamAssigneeId); - - /** - *

    The time the ticket was created as a UTC Unix timestamp.

    - */ - _FinalStage createdAt(Optional createdAt); - - _FinalStage createdAt(Integer createdAt); - - /** - *

    The last time the ticket was updated as a UTC Unix timestamp.

    - */ - _FinalStage updatedAt(Optional updatedAt); - - _FinalStage updatedAt(Integer updatedAt); - - /** - *

    Whether or not the ticket is open. If false, the ticket is closed.

    - */ - _FinalStage open(Optional open); - - _FinalStage open(Boolean open); - - /** - *

    The time the ticket will be snoozed until as a UTC Unix timestamp. If null, the ticket is not currently snoozed.

    - */ - _FinalStage snoozedUntil(Optional snoozedUntil); - - _FinalStage snoozedUntil(Integer snoozedUntil); - - _FinalStage linkedObjects(Optional linkedObjects); - - _FinalStage linkedObjects(LinkedObjectList linkedObjects); - - _FinalStage ticketParts(Optional ticketParts); - - _FinalStage ticketParts(TicketParts ticketParts); - - /** - *

    Whether or not the ticket is shared with the customer.

    - */ - _FinalStage isShared(Optional isShared); - - _FinalStage isShared(Boolean isShared); - - /** - *

    The state the ticket is currently in, in a human readable form - visible in Intercom

    - */ - _FinalStage ticketStateInternalLabel(Optional ticketStateInternalLabel); - - _FinalStage ticketStateInternalLabel(String ticketStateInternalLabel); - - /** - *

    The state the ticket is currently in, in a human readable form - visible to customers, in the messenger, email and tickets portal.

    - */ - _FinalStage ticketStateExternalLabel(Optional ticketStateExternalLabel); - - _FinalStage ticketStateExternalLabel(String ticketStateExternalLabel); - } - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder - implements IdStage, - TicketIdStage, - CategoryStage, - TicketStateStage, - TicketTypeStage, - ContactsStage, - _FinalStage { - private String id; + public static final class Builder { + private Optional type = Optional.empty(); - private String ticketId; + private Optional id = Optional.empty(); - private Category category; + private Optional ticketId = Optional.empty(); - private TicketState ticketState; + private Optional category = Optional.empty(); - private TicketType ticketType; + private Optional> ticketAttributes = Optional.empty(); - private TicketContacts contacts; + private Optional ticketState = Optional.empty(); - private Optional ticketStateExternalLabel = Optional.empty(); + private Optional ticketType = Optional.empty(); - private Optional ticketStateInternalLabel = Optional.empty(); + private Optional contacts = Optional.empty(); - private Optional isShared = Optional.empty(); + private Optional adminAssigneeId = Optional.empty(); - private Optional ticketParts = Optional.empty(); + private Optional teamAssigneeId = Optional.empty(); - private Optional linkedObjects = Optional.empty(); + private Optional createdAt = Optional.empty(); - private Optional snoozedUntil = Optional.empty(); + private Optional updatedAt = Optional.empty(); private Optional open = Optional.empty(); - private Optional updatedAt = Optional.empty(); - - private Optional createdAt = Optional.empty(); + private Optional snoozedUntil = Optional.empty(); - private Optional teamAssigneeId = Optional.empty(); + private Optional linkedObjects = Optional.empty(); - private Optional adminAssigneeId = Optional.empty(); + private Optional ticketParts = Optional.empty(); - private Map ticketAttributes = new LinkedHashMap<>(); + private Optional isShared = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} - @java.lang.Override public Builder from(Ticket other) { + type(other.getType()); id(other.getId()); ticketId(other.getTicketId()); category(other.getCategory()); @@ -493,298 +338,232 @@ public Builder from(Ticket other) { linkedObjects(other.getLinkedObjects()); ticketParts(other.getTicketParts()); isShared(other.getIsShared()); - ticketStateInternalLabel(other.getTicketStateInternalLabel()); - ticketStateExternalLabel(other.getTicketStateExternalLabel()); return this; } /** - * The unique identifier for the ticket which is given by Intercom.

    The unique identifier for the ticket which is given by Intercom.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    Always ticket

    */ - @java.lang.Override - @JsonSetter("id") - public TicketIdStage id(@NotNull String id) { - this.id = Objects.requireNonNull(id, "id must not be null"); + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; return this; } - /** - * The ID of the Ticket used in the Intercom Inbox and Messenger. Do not use ticket_id for API queries.

    The ID of the Ticket used in the Intercom Inbox and Messenger. Do not use ticket_id for API queries.

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("ticket_id") - public CategoryStage ticketId(@NotNull String ticketId) { - this.ticketId = Objects.requireNonNull(ticketId, "ticketId must not be null"); + public Builder type(String type) { + this.type = Optional.ofNullable(type); return this; } /** - * Category of the Ticket.

    Category of the Ticket.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The unique identifier for the ticket which is given by Intercom.

    */ - @java.lang.Override - @JsonSetter("category") - public TicketStateStage category(@NotNull Category category) { - this.category = Objects.requireNonNull(category, "category must not be null"); + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; return this; } - /** - * The state the ticket is currently in

    The state the ticket is currently in

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("ticket_state") - public TicketTypeStage ticketState(@NotNull TicketState ticketState) { - this.ticketState = Objects.requireNonNull(ticketState, "ticketState must not be null"); + public Builder id(String id) { + this.id = Optional.ofNullable(id); return this; } - @java.lang.Override - @JsonSetter("ticket_type") - public ContactsStage ticketType(@NotNull TicketType ticketType) { - this.ticketType = Objects.requireNonNull(ticketType, "ticketType must not be null"); + /** + *

    The ID of the Ticket used in the Intercom Inbox and Messenger. Do not use ticket_id for API queries.

    + */ + @JsonSetter(value = "ticket_id", nulls = Nulls.SKIP) + public Builder ticketId(Optional ticketId) { + this.ticketId = ticketId; return this; } - @java.lang.Override - @JsonSetter("contacts") - public _FinalStage contacts(@NotNull TicketContacts contacts) { - this.contacts = Objects.requireNonNull(contacts, "contacts must not be null"); + public Builder ticketId(String ticketId) { + this.ticketId = Optional.ofNullable(ticketId); return this; } /** - *

    The state the ticket is currently in, in a human readable form - visible to customers, in the messenger, email and tickets portal.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    Category of the Ticket.

    */ - @java.lang.Override - public _FinalStage ticketStateExternalLabel(String ticketStateExternalLabel) { - this.ticketStateExternalLabel = Optional.ofNullable(ticketStateExternalLabel); + @JsonSetter(value = "category", nulls = Nulls.SKIP) + public Builder category(Optional category) { + this.category = category; return this; } - /** - *

    The state the ticket is currently in, in a human readable form - visible to customers, in the messenger, email and tickets portal.

    - */ - @java.lang.Override - @JsonSetter(value = "ticket_state_external_label", nulls = Nulls.SKIP) - public _FinalStage ticketStateExternalLabel(Optional ticketStateExternalLabel) { - this.ticketStateExternalLabel = ticketStateExternalLabel; + public Builder category(Category category) { + this.category = Optional.ofNullable(category); return this; } - /** - *

    The state the ticket is currently in, in a human readable form - visible in Intercom

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage ticketStateInternalLabel(String ticketStateInternalLabel) { - this.ticketStateInternalLabel = Optional.ofNullable(ticketStateInternalLabel); + @JsonSetter(value = "ticket_attributes", nulls = Nulls.SKIP) + public Builder ticketAttributes(Optional> ticketAttributes) { + this.ticketAttributes = ticketAttributes; return this; } - /** - *

    The state the ticket is currently in, in a human readable form - visible in Intercom

    - */ - @java.lang.Override - @JsonSetter(value = "ticket_state_internal_label", nulls = Nulls.SKIP) - public _FinalStage ticketStateInternalLabel(Optional ticketStateInternalLabel) { - this.ticketStateInternalLabel = ticketStateInternalLabel; + public Builder ticketAttributes(Map ticketAttributes) { + this.ticketAttributes = Optional.ofNullable(ticketAttributes); return this; } - /** - *

    Whether or not the ticket is shared with the customer.

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage isShared(Boolean isShared) { - this.isShared = Optional.ofNullable(isShared); + @JsonSetter(value = "ticket_state", nulls = Nulls.SKIP) + public Builder ticketState(Optional ticketState) { + this.ticketState = ticketState; return this; } - /** - *

    Whether or not the ticket is shared with the customer.

    - */ - @java.lang.Override - @JsonSetter(value = "is_shared", nulls = Nulls.SKIP) - public _FinalStage isShared(Optional isShared) { - this.isShared = isShared; + public Builder ticketState(TicketState ticketState) { + this.ticketState = Optional.ofNullable(ticketState); return this; } - @java.lang.Override - public _FinalStage ticketParts(TicketParts ticketParts) { - this.ticketParts = Optional.ofNullable(ticketParts); + @JsonSetter(value = "ticket_type", nulls = Nulls.SKIP) + public Builder ticketType(Optional ticketType) { + this.ticketType = ticketType; return this; } - @java.lang.Override - @JsonSetter(value = "ticket_parts", nulls = Nulls.SKIP) - public _FinalStage ticketParts(Optional ticketParts) { - this.ticketParts = ticketParts; + public Builder ticketType(TicketType ticketType) { + this.ticketType = Optional.ofNullable(ticketType); return this; } - @java.lang.Override - public _FinalStage linkedObjects(LinkedObjectList linkedObjects) { - this.linkedObjects = Optional.ofNullable(linkedObjects); + @JsonSetter(value = "contacts", nulls = Nulls.SKIP) + public Builder contacts(Optional contacts) { + this.contacts = contacts; return this; } - @java.lang.Override - @JsonSetter(value = "linked_objects", nulls = Nulls.SKIP) - public _FinalStage linkedObjects(Optional linkedObjects) { - this.linkedObjects = linkedObjects; + public Builder contacts(TicketContacts contacts) { + this.contacts = Optional.ofNullable(contacts); return this; } /** - *

    The time the ticket will be snoozed until as a UTC Unix timestamp. If null, the ticket is not currently snoozed.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The id representing the admin assigned to the ticket.

    */ - @java.lang.Override - public _FinalStage snoozedUntil(Integer snoozedUntil) { - this.snoozedUntil = Optional.ofNullable(snoozedUntil); + @JsonSetter(value = "admin_assignee_id", nulls = Nulls.SKIP) + public Builder adminAssigneeId(Optional adminAssigneeId) { + this.adminAssigneeId = adminAssigneeId; return this; } - /** - *

    The time the ticket will be snoozed until as a UTC Unix timestamp. If null, the ticket is not currently snoozed.

    - */ - @java.lang.Override - @JsonSetter(value = "snoozed_until", nulls = Nulls.SKIP) - public _FinalStage snoozedUntil(Optional snoozedUntil) { - this.snoozedUntil = snoozedUntil; + public Builder adminAssigneeId(String adminAssigneeId) { + this.adminAssigneeId = Optional.ofNullable(adminAssigneeId); return this; } /** - *

    Whether or not the ticket is open. If false, the ticket is closed.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The id representing the team assigned to the ticket.

    */ - @java.lang.Override - public _FinalStage open(Boolean open) { - this.open = Optional.ofNullable(open); + @JsonSetter(value = "team_assignee_id", nulls = Nulls.SKIP) + public Builder teamAssigneeId(Optional teamAssigneeId) { + this.teamAssigneeId = teamAssigneeId; return this; } - /** - *

    Whether or not the ticket is open. If false, the ticket is closed.

    - */ - @java.lang.Override - @JsonSetter(value = "open", nulls = Nulls.SKIP) - public _FinalStage open(Optional open) { - this.open = open; + public Builder teamAssigneeId(String teamAssigneeId) { + this.teamAssigneeId = Optional.ofNullable(teamAssigneeId); return this; } /** - *

    The last time the ticket was updated as a UTC Unix timestamp.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The time the ticket was created as a UTC Unix timestamp.

    */ - @java.lang.Override - public _FinalStage updatedAt(Integer updatedAt) { - this.updatedAt = Optional.ofNullable(updatedAt); + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public Builder createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + public Builder createdAt(Integer createdAt) { + this.createdAt = Optional.ofNullable(createdAt); return this; } /** *

    The last time the ticket was updated as a UTC Unix timestamp.

    */ - @java.lang.Override @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) - public _FinalStage updatedAt(Optional updatedAt) { + public Builder updatedAt(Optional updatedAt) { this.updatedAt = updatedAt; return this; } - /** - *

    The time the ticket was created as a UTC Unix timestamp.

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage createdAt(Integer createdAt) { - this.createdAt = Optional.ofNullable(createdAt); + public Builder updatedAt(Integer updatedAt) { + this.updatedAt = Optional.ofNullable(updatedAt); return this; } /** - *

    The time the ticket was created as a UTC Unix timestamp.

    + *

    Whether or not the ticket is open. If false, the ticket is closed.

    */ - @java.lang.Override - @JsonSetter(value = "created_at", nulls = Nulls.SKIP) - public _FinalStage createdAt(Optional createdAt) { - this.createdAt = createdAt; + @JsonSetter(value = "open", nulls = Nulls.SKIP) + public Builder open(Optional open) { + this.open = open; return this; } - /** - *

    The id representing the team assigned to the ticket.

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage teamAssigneeId(String teamAssigneeId) { - this.teamAssigneeId = Optional.ofNullable(teamAssigneeId); + public Builder open(Boolean open) { + this.open = Optional.ofNullable(open); return this; } /** - *

    The id representing the team assigned to the ticket.

    + *

    The time the ticket will be snoozed until as a UTC Unix timestamp. If null, the ticket is not currently snoozed.

    */ - @java.lang.Override - @JsonSetter(value = "team_assignee_id", nulls = Nulls.SKIP) - public _FinalStage teamAssigneeId(Optional teamAssigneeId) { - this.teamAssigneeId = teamAssigneeId; + @JsonSetter(value = "snoozed_until", nulls = Nulls.SKIP) + public Builder snoozedUntil(Optional snoozedUntil) { + this.snoozedUntil = snoozedUntil; return this; } - /** - *

    The id representing the admin assigned to the ticket.

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage adminAssigneeId(String adminAssigneeId) { - this.adminAssigneeId = Optional.ofNullable(adminAssigneeId); + public Builder snoozedUntil(Integer snoozedUntil) { + this.snoozedUntil = Optional.ofNullable(snoozedUntil); return this; } - /** - *

    The id representing the admin assigned to the ticket.

    - */ - @java.lang.Override - @JsonSetter(value = "admin_assignee_id", nulls = Nulls.SKIP) - public _FinalStage adminAssigneeId(Optional adminAssigneeId) { - this.adminAssigneeId = adminAssigneeId; + @JsonSetter(value = "linked_objects", nulls = Nulls.SKIP) + public Builder linkedObjects(Optional linkedObjects) { + this.linkedObjects = linkedObjects; return this; } - @java.lang.Override - public _FinalStage ticketAttributes(String key, Object value) { - this.ticketAttributes.put(key, value); + public Builder linkedObjects(LinkedObjectList linkedObjects) { + this.linkedObjects = Optional.ofNullable(linkedObjects); return this; } - @java.lang.Override - public _FinalStage putAllTicketAttributes(Map ticketAttributes) { - this.ticketAttributes.putAll(ticketAttributes); + @JsonSetter(value = "ticket_parts", nulls = Nulls.SKIP) + public Builder ticketParts(Optional ticketParts) { + this.ticketParts = ticketParts; return this; } - @java.lang.Override - @JsonSetter(value = "ticket_attributes", nulls = Nulls.SKIP) - public _FinalStage ticketAttributes(Map ticketAttributes) { - this.ticketAttributes.clear(); - this.ticketAttributes.putAll(ticketAttributes); + public Builder ticketParts(TicketParts ticketParts) { + this.ticketParts = Optional.ofNullable(ticketParts); + return this; + } + + /** + *

    Whether or not the ticket is shared with the customer.

    + */ + @JsonSetter(value = "is_shared", nulls = Nulls.SKIP) + public Builder isShared(Optional isShared) { + this.isShared = isShared; + return this; + } + + public Builder isShared(Boolean isShared) { + this.isShared = Optional.ofNullable(isShared); return this; } - @java.lang.Override public Ticket build() { return new Ticket( + type, id, ticketId, category, @@ -801,109 +580,10 @@ public Ticket build() { linkedObjects, ticketParts, isShared, - ticketStateInternalLabel, - ticketStateExternalLabel, additionalProperties); } } - public static final class TicketState { - public static final TicketState IN_PROGRESS = new TicketState(Value.IN_PROGRESS, "in_progress"); - - public static final TicketState SUBMITTED = new TicketState(Value.SUBMITTED, "submitted"); - - public static final TicketState RESOLVED = new TicketState(Value.RESOLVED, "resolved"); - - public static final TicketState WAITING_ON_CUSTOMER = - new TicketState(Value.WAITING_ON_CUSTOMER, "waiting_on_customer"); - - private final Value value; - - private final String string; - - TicketState(Value value, String string) { - this.value = value; - this.string = string; - } - - public Value getEnumValue() { - return value; - } - - @java.lang.Override - @JsonValue - public String toString() { - return this.string; - } - - @java.lang.Override - public boolean equals(Object other) { - return (this == other) - || (other instanceof TicketState && this.string.equals(((TicketState) other).string)); - } - - @java.lang.Override - public int hashCode() { - return this.string.hashCode(); - } - - public T visit(Visitor visitor) { - switch (value) { - case IN_PROGRESS: - return visitor.visitInProgress(); - case SUBMITTED: - return visitor.visitSubmitted(); - case RESOLVED: - return visitor.visitResolved(); - case WAITING_ON_CUSTOMER: - return visitor.visitWaitingOnCustomer(); - case UNKNOWN: - default: - return visitor.visitUnknown(string); - } - } - - @JsonCreator(mode = JsonCreator.Mode.DELEGATING) - public static TicketState valueOf(String value) { - switch (value) { - case "in_progress": - return IN_PROGRESS; - case "submitted": - return SUBMITTED; - case "resolved": - return RESOLVED; - case "waiting_on_customer": - return WAITING_ON_CUSTOMER; - default: - return new TicketState(Value.UNKNOWN, value); - } - } - - public enum Value { - SUBMITTED, - - IN_PROGRESS, - - WAITING_ON_CUSTOMER, - - RESOLVED, - - UNKNOWN - } - - public interface Visitor { - T visitSubmitted(); - - T visitInProgress(); - - T visitWaitingOnCustomer(); - - T visitResolved(); - - T visitUnknown(String unknownType); - } - } - public static final class Category { public static final Category BACK_OFFICE = new Category(Value.BACK_OFFICE, "Back-office"); diff --git a/src/main/java/com/intercom/api/resources/tickets/types/TicketContacts.java b/src/main/java/com/intercom/api/resources/tickets/types/TicketContacts.java index b1406f9..06e83ad 100644 --- a/src/main/java/com/intercom/api/resources/tickets/types/TicketContacts.java +++ b/src/main/java/com/intercom/api/resources/tickets/types/TicketContacts.java @@ -13,20 +13,26 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.intercom.api.core.ObjectMappers; import com.intercom.api.types.ContactReference; -import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.Optional; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = TicketContacts.Builder.class) public final class TicketContacts { - private final List contacts; + private final Optional type; + + private final Optional> contacts; private final Map additionalProperties; - private TicketContacts(List contacts, Map additionalProperties) { + private TicketContacts( + Optional type, + Optional> contacts, + Map additionalProperties) { + this.type = type; this.contacts = contacts; this.additionalProperties = additionalProperties; } @@ -35,15 +41,15 @@ private TicketContacts(List contacts, Map addi * @return always contact.list */ @JsonProperty("type") - public String getType() { - return "contact.list"; + public Optional getType() { + return type; } /** * @return The list of contacts affected by this ticket. */ @JsonProperty("contacts") - public List getContacts() { + public Optional> getContacts() { return contacts; } @@ -59,12 +65,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(TicketContacts other) { - return contacts.equals(other.contacts); + return type.equals(other.type) && contacts.equals(other.contacts); } @java.lang.Override public int hashCode() { - return Objects.hash(this.contacts); + return Objects.hash(this.type, this.contacts); } @java.lang.Override @@ -78,7 +84,9 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private List contacts = new ArrayList<>(); + private Optional type = Optional.empty(); + + private Optional> contacts = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -86,32 +94,41 @@ public static final class Builder { private Builder() {} public Builder from(TicketContacts other) { + type(other.getType()); contacts(other.getContacts()); return this; } /** - *

    The list of contacts affected by this ticket.

    + *

    always contact.list

    */ - @JsonSetter(value = "contacts", nulls = Nulls.SKIP) - public Builder contacts(List contacts) { - this.contacts.clear(); - this.contacts.addAll(contacts); + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; return this; } - public Builder addContacts(ContactReference contacts) { - this.contacts.add(contacts); + public Builder type(String type) { + this.type = Optional.ofNullable(type); return this; } - public Builder addAllContacts(List contacts) { - this.contacts.addAll(contacts); + /** + *

    The list of contacts affected by this ticket.

    + */ + @JsonSetter(value = "contacts", nulls = Nulls.SKIP) + public Builder contacts(Optional> contacts) { + this.contacts = contacts; + return this; + } + + public Builder contacts(List contacts) { + this.contacts = Optional.ofNullable(contacts); return this; } public TicketContacts build() { - return new TicketContacts(contacts, additionalProperties); + return new TicketContacts(type, contacts, additionalProperties); } } } diff --git a/src/main/java/com/intercom/api/resources/tickets/types/TicketPart.java b/src/main/java/com/intercom/api/resources/tickets/types/TicketPart.java index fd9f787..c09697a 100644 --- a/src/main/java/com/intercom/api/resources/tickets/types/TicketPart.java +++ b/src/main/java/com/intercom/api/resources/tickets/types/TicketPart.java @@ -12,11 +12,17 @@ import com.fasterxml.jackson.annotation.JsonSetter; import com.fasterxml.jackson.annotation.JsonValue; import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; import com.intercom.api.core.ObjectMappers; import com.intercom.api.types.PartAttachment; import com.intercom.api.types.Reference; import com.intercom.api.types.TicketPartAuthor; +import java.io.IOException; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -27,17 +33,19 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = TicketPart.Builder.class) public final class TicketPart { - private final String id; + private final Optional type; - private final String partType; + private final Optional id; + + private final Optional partType; private final Optional body; private final Optional previousTicketState; - private final TicketState ticketState; + private final Optional ticketState; - private final int createdAt; + private final Optional createdAt; private final Optional updatedAt; @@ -51,22 +59,30 @@ public final class TicketPart { private final Optional redacted; + private final Optional appPackageCode; + + private final Optional updatedAttributeData; + private final Map additionalProperties; private TicketPart( - String id, - String partType, + Optional type, + Optional id, + Optional partType, Optional body, Optional previousTicketState, - TicketState ticketState, - int createdAt, + Optional ticketState, + Optional createdAt, Optional updatedAt, Optional assignedTo, Optional author, Optional> attachments, Optional externalId, Optional redacted, + Optional appPackageCode, + Optional updatedAttributeData, Map additionalProperties) { + this.type = type; this.id = id; this.partType = partType; this.body = body; @@ -79,6 +95,8 @@ private TicketPart( this.attachments = attachments; this.externalId = externalId; this.redacted = redacted; + this.appPackageCode = appPackageCode; + this.updatedAttributeData = updatedAttributeData; this.additionalProperties = additionalProperties; } @@ -86,15 +104,15 @@ private TicketPart( * @return Always ticket_part */ @JsonProperty("type") - public String getType() { - return "ticket_part"; + public Optional getType() { + return type; } /** * @return The id representing the ticket part. */ @JsonProperty("id") - public String getId() { + public Optional getId() { return id; } @@ -102,7 +120,7 @@ public String getId() { * @return The type of ticket part. */ @JsonProperty("part_type") - public String getPartType() { + public Optional getPartType() { return partType; } @@ -126,7 +144,7 @@ public Optional getPreviousTicketState() { * @return The state of the ticket. */ @JsonProperty("ticket_state") - public TicketState getTicketState() { + public Optional getTicketState() { return ticketState; } @@ -134,7 +152,7 @@ public TicketState getTicketState() { * @return The time the ticket part was created. */ @JsonProperty("created_at") - public int getCreatedAt() { + public Optional getCreatedAt() { return createdAt; } @@ -183,6 +201,22 @@ public Optional getRedacted() { return redacted; } + /** + * @return 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. + */ + @JsonProperty("app_package_code") + public Optional getAppPackageCode() { + return appPackageCode; + } + + /** + * @return The updated attribute data of the ticket part. Only present for attribute update parts. + */ + @JsonProperty("updated_attribute_data") + public Optional getUpdatedAttributeData() { + return updatedAttributeData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -195,23 +229,27 @@ public Map getAdditionalProperties() { } private boolean equalTo(TicketPart other) { - return id.equals(other.id) + return type.equals(other.type) + && id.equals(other.id) && partType.equals(other.partType) && body.equals(other.body) && previousTicketState.equals(other.previousTicketState) && ticketState.equals(other.ticketState) - && createdAt == other.createdAt + && createdAt.equals(other.createdAt) && updatedAt.equals(other.updatedAt) && assignedTo.equals(other.assignedTo) && author.equals(other.author) && attachments.equals(other.attachments) && externalId.equals(other.externalId) - && redacted.equals(other.redacted); + && redacted.equals(other.redacted) + && appPackageCode.equals(other.appPackageCode) + && updatedAttributeData.equals(other.updatedAttributeData); } @java.lang.Override public int hashCode() { return Objects.hash( + this.type, this.id, this.partType, this.body, @@ -223,7 +261,9 @@ public int hashCode() { this.author, this.attachments, this.externalId, - this.redacted); + this.redacted, + this.appPackageCode, + this.updatedAttributeData); } @java.lang.Override @@ -231,130 +271,49 @@ public String toString() { return ObjectMappers.stringify(this); } - public static IdStage builder() { + public static Builder builder() { return new Builder(); } - public interface IdStage { - /** - * The id representing the ticket part. - */ - PartTypeStage id(@NotNull String id); - - Builder from(TicketPart other); - } - - public interface PartTypeStage { - /** - * The type of ticket part. - */ - TicketStateStage partType(@NotNull String partType); - } - - public interface TicketStateStage { - /** - * The state of the ticket. - */ - CreatedAtStage ticketState(@NotNull TicketState ticketState); - } - - public interface CreatedAtStage { - /** - * The time the ticket part was created. - */ - _FinalStage createdAt(int createdAt); - } - - public interface _FinalStage { - TicketPart build(); - - /** - *

    The message body, which may contain HTML.

    - */ - _FinalStage body(Optional body); - - _FinalStage body(String body); - - /** - *

    The previous state of the ticket.

    - */ - _FinalStage previousTicketState(Optional previousTicketState); - - _FinalStage previousTicketState(PreviousTicketState previousTicketState); - - /** - *

    The last time the ticket part was updated.

    - */ - _FinalStage updatedAt(Optional updatedAt); - - _FinalStage updatedAt(Integer updatedAt); - - /** - *

    The id of the admin that was assigned the ticket by this ticket_part (null if there has been no change in assignment.)

    - */ - _FinalStage assignedTo(Optional assignedTo); - - _FinalStage assignedTo(Reference assignedTo); - - _FinalStage author(Optional author); - - _FinalStage author(TicketPartAuthor author); - - /** - *

    A list of attachments for the part.

    - */ - _FinalStage attachments(Optional> attachments); - - _FinalStage attachments(List attachments); - - /** - *

    The external id of the ticket part

    - */ - _FinalStage externalId(Optional externalId); + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); - _FinalStage externalId(String externalId); + private Optional id = Optional.empty(); - /** - *

    Whether or not the ticket part has been redacted.

    - */ - _FinalStage redacted(Optional redacted); + private Optional partType = Optional.empty(); - _FinalStage redacted(Boolean redacted); - } + private Optional body = Optional.empty(); - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements IdStage, PartTypeStage, TicketStateStage, CreatedAtStage, _FinalStage { - private String id; + private Optional previousTicketState = Optional.empty(); - private String partType; + private Optional ticketState = Optional.empty(); - private TicketState ticketState; + private Optional createdAt = Optional.empty(); - private int createdAt; + private Optional updatedAt = Optional.empty(); - private Optional redacted = Optional.empty(); + private Optional assignedTo = Optional.empty(); - private Optional externalId = Optional.empty(); + private Optional author = Optional.empty(); private Optional> attachments = Optional.empty(); - private Optional author = Optional.empty(); - - private Optional assignedTo = Optional.empty(); + private Optional externalId = Optional.empty(); - private Optional updatedAt = Optional.empty(); + private Optional redacted = Optional.empty(); - private Optional previousTicketState = Optional.empty(); + private Optional appPackageCode = Optional.empty(); - private Optional body = Optional.empty(); + private Optional updatedAttributeData = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} - @java.lang.Override public Builder from(TicketPart other) { + type(other.getType()); id(other.getId()); partType(other.getPartType()); body(other.getBody()); @@ -367,209 +326,221 @@ public Builder from(TicketPart other) { attachments(other.getAttachments()); externalId(other.getExternalId()); redacted(other.getRedacted()); + appPackageCode(other.getAppPackageCode()); + updatedAttributeData(other.getUpdatedAttributeData()); return this; } /** - * The id representing the ticket part.

    The id representing the ticket part.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    Always ticket_part

    */ - @java.lang.Override - @JsonSetter("id") - public PartTypeStage id(@NotNull String id) { - this.id = Objects.requireNonNull(id, "id must not be null"); + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; return this; } - /** - * The type of ticket part.

    The type of ticket part.

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("part_type") - public TicketStateStage partType(@NotNull String partType) { - this.partType = Objects.requireNonNull(partType, "partType must not be null"); + public Builder type(String type) { + this.type = Optional.ofNullable(type); return this; } /** - * The state of the ticket.

    The state of the ticket.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The id representing the ticket part.

    */ - @java.lang.Override - @JsonSetter("ticket_state") - public CreatedAtStage ticketState(@NotNull TicketState ticketState) { - this.ticketState = Objects.requireNonNull(ticketState, "ticketState must not be null"); + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.ofNullable(id); return this; } /** - * The time the ticket part was created.

    The time the ticket part was created.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The type of ticket part.

    */ - @java.lang.Override - @JsonSetter("created_at") - public _FinalStage createdAt(int createdAt) { - this.createdAt = createdAt; + @JsonSetter(value = "part_type", nulls = Nulls.SKIP) + public Builder partType(Optional partType) { + this.partType = partType; + return this; + } + + public Builder partType(String partType) { + this.partType = Optional.ofNullable(partType); return this; } /** - *

    Whether or not the ticket part has been redacted.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The message body, which may contain HTML.

    */ - @java.lang.Override - public _FinalStage redacted(Boolean redacted) { - this.redacted = Optional.ofNullable(redacted); + @JsonSetter(value = "body", nulls = Nulls.SKIP) + public Builder body(Optional body) { + this.body = body; + return this; + } + + public Builder body(String body) { + this.body = Optional.ofNullable(body); return this; } /** - *

    Whether or not the ticket part has been redacted.

    + *

    The previous state of the ticket.

    */ - @java.lang.Override - @JsonSetter(value = "redacted", nulls = Nulls.SKIP) - public _FinalStage redacted(Optional redacted) { - this.redacted = redacted; + @JsonSetter(value = "previous_ticket_state", nulls = Nulls.SKIP) + public Builder previousTicketState(Optional previousTicketState) { + this.previousTicketState = previousTicketState; + return this; + } + + public Builder previousTicketState(PreviousTicketState previousTicketState) { + this.previousTicketState = Optional.ofNullable(previousTicketState); return this; } /** - *

    The external id of the ticket part

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The state of the ticket.

    */ - @java.lang.Override - public _FinalStage externalId(String externalId) { - this.externalId = Optional.ofNullable(externalId); + @JsonSetter(value = "ticket_state", nulls = Nulls.SKIP) + public Builder ticketState(Optional ticketState) { + this.ticketState = ticketState; + return this; + } + + public Builder ticketState(TicketState ticketState) { + this.ticketState = Optional.ofNullable(ticketState); return this; } /** - *

    The external id of the ticket part

    + *

    The time the ticket part was created.

    */ - @java.lang.Override - @JsonSetter(value = "external_id", nulls = Nulls.SKIP) - public _FinalStage externalId(Optional externalId) { - this.externalId = externalId; + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public Builder createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + public Builder createdAt(Integer createdAt) { + this.createdAt = Optional.ofNullable(createdAt); return this; } /** - *

    A list of attachments for the part.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The last time the ticket part was updated.

    */ - @java.lang.Override - public _FinalStage attachments(List attachments) { - this.attachments = Optional.ofNullable(attachments); + @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) + public Builder updatedAt(Optional updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + public Builder updatedAt(Integer updatedAt) { + this.updatedAt = Optional.ofNullable(updatedAt); return this; } /** - *

    A list of attachments for the part.

    + *

    The id of the admin that was assigned the ticket by this ticket_part (null if there has been no change in assignment.)

    */ - @java.lang.Override - @JsonSetter(value = "attachments", nulls = Nulls.SKIP) - public _FinalStage attachments(Optional> attachments) { - this.attachments = attachments; + @JsonSetter(value = "assigned_to", nulls = Nulls.SKIP) + public Builder assignedTo(Optional assignedTo) { + this.assignedTo = assignedTo; return this; } - @java.lang.Override - public _FinalStage author(TicketPartAuthor author) { - this.author = Optional.ofNullable(author); + public Builder assignedTo(Reference assignedTo) { + this.assignedTo = Optional.ofNullable(assignedTo); return this; } - @java.lang.Override @JsonSetter(value = "author", nulls = Nulls.SKIP) - public _FinalStage author(Optional author) { + public Builder author(Optional author) { this.author = author; return this; } - /** - *

    The id of the admin that was assigned the ticket by this ticket_part (null if there has been no change in assignment.)

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage assignedTo(Reference assignedTo) { - this.assignedTo = Optional.ofNullable(assignedTo); + public Builder author(TicketPartAuthor author) { + this.author = Optional.ofNullable(author); return this; } /** - *

    The id of the admin that was assigned the ticket by this ticket_part (null if there has been no change in assignment.)

    + *

    A list of attachments for the part.

    */ - @java.lang.Override - @JsonSetter(value = "assigned_to", nulls = Nulls.SKIP) - public _FinalStage assignedTo(Optional assignedTo) { - this.assignedTo = assignedTo; + @JsonSetter(value = "attachments", nulls = Nulls.SKIP) + public Builder attachments(Optional> attachments) { + this.attachments = attachments; return this; } - /** - *

    The last time the ticket part was updated.

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage updatedAt(Integer updatedAt) { - this.updatedAt = Optional.ofNullable(updatedAt); + public Builder attachments(List attachments) { + this.attachments = Optional.ofNullable(attachments); return this; } /** - *

    The last time the ticket part was updated.

    + *

    The external id of the ticket part

    */ - @java.lang.Override - @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) - public _FinalStage updatedAt(Optional updatedAt) { - this.updatedAt = updatedAt; + @JsonSetter(value = "external_id", nulls = Nulls.SKIP) + public Builder externalId(Optional externalId) { + this.externalId = externalId; return this; } - /** - *

    The previous state of the ticket.

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage previousTicketState(PreviousTicketState previousTicketState) { - this.previousTicketState = Optional.ofNullable(previousTicketState); + public Builder externalId(String externalId) { + this.externalId = Optional.ofNullable(externalId); return this; } /** - *

    The previous state of the ticket.

    + *

    Whether or not the ticket part has been redacted.

    */ - @java.lang.Override - @JsonSetter(value = "previous_ticket_state", nulls = Nulls.SKIP) - public _FinalStage previousTicketState(Optional previousTicketState) { - this.previousTicketState = previousTicketState; + @JsonSetter(value = "redacted", nulls = Nulls.SKIP) + public Builder redacted(Optional redacted) { + this.redacted = redacted; + return this; + } + + public Builder redacted(Boolean redacted) { + this.redacted = Optional.ofNullable(redacted); return this; } /** - *

    The message body, which may contain HTML.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    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.

    */ - @java.lang.Override - public _FinalStage body(String body) { - this.body = Optional.ofNullable(body); + @JsonSetter(value = "app_package_code", nulls = Nulls.SKIP) + public Builder appPackageCode(Optional appPackageCode) { + this.appPackageCode = appPackageCode; + return this; + } + + public Builder appPackageCode(String appPackageCode) { + this.appPackageCode = Optional.ofNullable(appPackageCode); return this; } /** - *

    The message body, which may contain HTML.

    + *

    The updated attribute data of the ticket part. Only present for attribute update parts.

    */ - @java.lang.Override - @JsonSetter(value = "body", nulls = Nulls.SKIP) - public _FinalStage body(Optional body) { - this.body = body; + @JsonSetter(value = "updated_attribute_data", nulls = Nulls.SKIP) + public Builder updatedAttributeData(Optional updatedAttributeData) { + this.updatedAttributeData = updatedAttributeData; + return this; + } + + public Builder updatedAttributeData(UpdatedAttributeData updatedAttributeData) { + this.updatedAttributeData = Optional.ofNullable(updatedAttributeData); return this; } - @java.lang.Override public TicketPart build() { return new TicketPart( + type, id, partType, body, @@ -582,6 +553,8 @@ public TicketPart build() { attachments, externalId, redacted, + appPackageCode, + updatedAttributeData, additionalProperties); } } @@ -780,4 +753,546 @@ public interface Visitor { T visitUnknown(String unknownType); } } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = UpdatedAttributeData.Builder.class) + public static final class UpdatedAttributeData { + private final Attribute attribute; + + private final Value value; + + private final Map additionalProperties; + + private UpdatedAttributeData(Attribute attribute, Value value, Map additionalProperties) { + this.attribute = attribute; + this.value = value; + this.additionalProperties = additionalProperties; + } + + /** + * @return Information about the attribute that was updated. + */ + @JsonProperty("attribute") + public Attribute getAttribute() { + return attribute; + } + + /** + * @return The new value of the attribute. + */ + @JsonProperty("value") + public Value getValue() { + return value; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UpdatedAttributeData && equalTo((UpdatedAttributeData) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UpdatedAttributeData other) { + return attribute.equals(other.attribute) && value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.attribute, this.value); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static AttributeStage builder() { + return new Builder(); + } + + public interface AttributeStage { + /** + * Information about the attribute that was updated. + */ + ValueStage attribute(@NotNull Attribute attribute); + + Builder from(UpdatedAttributeData other); + } + + public interface ValueStage { + /** + * The new value of the attribute. + */ + _FinalStage value(@NotNull Value value); + } + + public interface _FinalStage { + UpdatedAttributeData build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements AttributeStage, ValueStage, _FinalStage { + private Attribute attribute; + + private Value value; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(UpdatedAttributeData other) { + attribute(other.getAttribute()); + value(other.getValue()); + return this; + } + + /** + * Information about the attribute that was updated.

    Information about the attribute that was updated.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("attribute") + public ValueStage attribute(@NotNull Attribute attribute) { + this.attribute = Objects.requireNonNull(attribute, "attribute must not be null"); + return this; + } + + /** + * The new value of the attribute.

    The new value of the attribute.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("value") + public _FinalStage value(@NotNull Value value) { + this.value = Objects.requireNonNull(value, "value must not be null"); + return this; + } + + @java.lang.Override + public UpdatedAttributeData build() { + return new UpdatedAttributeData(attribute, value, additionalProperties); + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = Attribute.Builder.class) + public static final class Attribute { + private final String id; + + private final String label; + + private final Map additionalProperties; + + private Attribute(String id, String label, Map additionalProperties) { + this.id = id; + this.label = label; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of the object. Always 'attribute'. + */ + @JsonProperty("type") + public String getType() { + return "attribute"; + } + + /** + * @return The unique identifier of the attribute. + */ + @JsonProperty("id") + public String getId() { + return id; + } + + /** + * @return The human-readable name of the attribute. + */ + @JsonProperty("label") + public String getLabel() { + return label; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Attribute && equalTo((Attribute) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Attribute other) { + return id.equals(other.id) && label.equals(other.label); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id, this.label); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * The unique identifier of the attribute. + */ + LabelStage id(@NotNull String id); + + Builder from(Attribute other); + } + + public interface LabelStage { + /** + * The human-readable name of the attribute. + */ + _FinalStage label(@NotNull String label); + } + + public interface _FinalStage { + Attribute build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, LabelStage, _FinalStage { + private String id; + + private String label; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(Attribute other) { + id(other.getId()); + label(other.getLabel()); + return this; + } + + /** + * The unique identifier of the attribute.

    The unique identifier of the attribute.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public LabelStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + /** + * The human-readable name of the attribute.

    The human-readable name of the attribute.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("label") + public _FinalStage label(@NotNull String label) { + this.label = Objects.requireNonNull(label, "label must not be null"); + return this; + } + + @java.lang.Override + public Attribute build() { + return new Attribute(id, label, additionalProperties); + } + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = Value.Builder.class) + public static final class Value { + private final Id id; + + private final Label label; + + private final Map additionalProperties; + + private Value(Id id, Label label, Map additionalProperties) { + this.id = id; + this.label = label; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of the object. Always 'value'. + */ + @JsonProperty("type") + public String getType() { + return "value"; + } + + @JsonProperty("id") + public Id getId() { + return id; + } + + @JsonProperty("label") + public Label getLabel() { + return label; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Value && equalTo((Value) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Value other) { + return id.equals(other.id) && label.equals(other.label); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id, this.label); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + LabelStage id(@NotNull Id id); + + Builder from(Value other); + } + + public interface LabelStage { + _FinalStage label(@NotNull Label label); + } + + public interface _FinalStage { + Value build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, LabelStage, _FinalStage { + private Id id; + + private Label label; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(Value other) { + id(other.getId()); + label(other.getLabel()); + return this; + } + + @java.lang.Override + @JsonSetter("id") + public LabelStage id(@NotNull Id id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("label") + public _FinalStage label(@NotNull Label label) { + this.label = Objects.requireNonNull(label, "label must not be null"); + return this; + } + + @java.lang.Override + public Value build() { + return new Value(id, label, additionalProperties); + } + } + + @JsonDeserialize(using = Label.Deserializer.class) + public static final class Label { + private final Object value; + + private final int type; + + private Label(Object value, int type) { + this.value = value; + this.type = type; + } + + @JsonValue + public Object get() { + return this.value; + } + + @SuppressWarnings("unchecked") + public T visit(Visitor visitor) { + if (this.type == 0) { + return visitor.visit((String) this.value); + } else if (this.type == 1) { + return visitor.visit((List) this.value); + } + throw new IllegalStateException("Failed to visit value. This should never happen."); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Label && equalTo((Label) other); + } + + private boolean equalTo(Label other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return this.value.toString(); + } + + public static Label of(String value) { + return new Label(value, 0); + } + + public static Label of(List value) { + return new Label(value, 1); + } + + public interface Visitor { + T visit(String value); + + T visit(List value); + } + + static final class Deserializer extends StdDeserializer