From 128bacbc35462d56e492bd0cdde78824b2cc6505 Mon Sep 17 00:00:00 2001 From: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Date: Mon, 7 Apr 2025 17:39:52 +0000 Subject: [PATCH] SDK regeneration --- .circleci/config.yml | 15 - .fernignore | 1 + .github/ISSUE_TEMPLATE.md | 19 - .github/PULL_REQUEST_TEMPLATE.md | 5 - .github/dependabot.yml | 14 - .github/workflows/ci.yml | 38 + .gitignore | 33 +- CHANGES.md | 288 --- LICENSE | 202 -- README.md | 825 ------ build.gradle | 78 +- gradle.properties | 8 - gradle/wrapper/gradle-wrapper.jar | Bin 54413 -> 43705 bytes gradle/wrapper/gradle-wrapper.properties | 4 +- gradlew | 303 ++- gradlew.bat | 78 +- intercom-java/.gitignore | 1 - intercom-java/build.gradle | 134 - .../src/main/java/io/intercom/api/Admin.java | 233 -- .../java/io/intercom/api/AdminAwayMode.java | 44 - .../java/io/intercom/api/AdminCollection.java | 29 - .../java/io/intercom/api/AdminMessage.java | 173 -- .../io/intercom/api/AdminMessageResponse.java | 129 - .../main/java/io/intercom/api/AdminReply.java | 99 - .../main/java/io/intercom/api/Attachment.java | 100 - .../src/main/java/io/intercom/api/Author.java | 117 - .../intercom/api/AuthorizationException.java | 22 - .../src/main/java/io/intercom/api/Avatar.java | 67 - .../java/io/intercom/api/ClientException.java | 22 - .../main/java/io/intercom/api/Company.java | 444 ---- .../io/intercom/api/CompanyCollection.java | 50 - .../io/intercom/api/CompanyUpdateBuilder.java | 69 - .../intercom/api/CompanyWithStringPlan.java | 156 -- .../main/java/io/intercom/api/Conditions.java | 26 - .../main/java/io/intercom/api/Contact.java | 678 ----- .../io/intercom/api/ContactCollection.java | 33 - .../java/io/intercom/api/ContactMessage.java | 21 - .../java/io/intercom/api/Conversation.java | 435 ---- .../intercom/api/ConversationCollection.java | 28 - .../io/intercom/api/ConversationMessage.java | 117 - .../io/intercom/api/ConversationPart.java | 125 - .../api/ConversationPartCollection.java | 26 - .../io/intercom/api/ConversationRating.java | 87 - .../intercom/api/CountItemDeserializer.java | 27 - .../io/intercom/api/CountItemSerializer.java | 22 - .../src/main/java/io/intercom/api/Counts.java | 340 --- .../java/io/intercom/api/CustomAttribute.java | 202 -- .../api/CustomAttributeDeserializer.java | 53 - .../api/CustomAttributeSerializer.java | 21 - .../main/java/io/intercom/api/Customer.java | 69 - .../io/intercom/api/CustomerFirstReply.java | 85 - .../java/io/intercom/api/DataResource.java | 78 - .../src/main/java/io/intercom/api/Error.java | 77 - .../java/io/intercom/api/ErrorCollection.java | 33 - .../src/main/java/io/intercom/api/Event.java | 271 -- .../java/io/intercom/api/EventCollection.java | 32 - .../java/io/intercom/api/EventSummary.java | 101 - .../intercom/api/EventSummaryCollection.java | 88 - .../main/java/io/intercom/api/HttpClient.java | 268 -- .../intercom/api/HttpConnectorSupplier.java | 16 - .../main/java/io/intercom/api/IOUtils.java | 47 - .../main/java/io/intercom/api/Intercom.java | 115 - .../io/intercom/api/IntercomException.java | 48 - .../io/intercom/api/InvalidException.java | 22 - .../src/main/java/io/intercom/api/Job.java | 216 -- .../main/java/io/intercom/api/JobItem.java | 134 - .../io/intercom/api/JobItemCollection.java | 31 - .../java/io/intercom/api/JobItemRequest.java | 38 - .../main/java/io/intercom/api/JobSupport.java | 24 - .../main/java/io/intercom/api/JobTask.java | 47 - .../java/io/intercom/api/LocationData.java | 136 - .../java/io/intercom/api/MapperSupport.java | 40 - .../io/intercom/api/NotFoundException.java | 22 - .../src/main/java/io/intercom/api/Note.java | 133 - .../java/io/intercom/api/NoteCollection.java | 27 - .../java/io/intercom/api/Notification.java | 217 -- .../intercom/api/NotificationCollection.java | 28 - .../io/intercom/api/NotificationData.java | 63 - .../io/intercom/api/NotificationError.java | 29 - .../api/NotificationErrorCollection.java | 27 - .../io/intercom/api/RateLimitException.java | 60 - .../main/java/io/intercom/api/Replier.java | 7 - .../src/main/java/io/intercom/api/Reply.java | 97 - .../intercom/api/RequestResponseCapture.java | 68 - .../api/ScrollableCompanyCollection.java | 19 - .../api/ScrollableContactCollection.java | 19 - .../api/ScrollableTypedDataCollection.java | 35 - .../api/ScrollableUserCollection.java | 20 - .../main/java/io/intercom/api/Segment.java | 113 - .../io/intercom/api/SegmentCollection.java | 35 - .../java/io/intercom/api/ServerException.java | 22 - .../java/io/intercom/api/SocialProfile.java | 90 - .../intercom/api/SocialProfileCollection.java | 62 - .../java/io/intercom/api/Subscription.java | 459 ---- .../intercom/api/SubscriptionCollection.java | 34 - .../src/main/java/io/intercom/api/Tag.java | 285 --- .../java/io/intercom/api/TagCollection.java | 34 - .../main/java/io/intercom/api/Teammate.java | 68 - .../io/intercom/api/TopicDeserializer.java | 25 - .../java/io/intercom/api/TopicSerializer.java | 20 - .../main/java/io/intercom/api/TypedData.java | 9 - .../io/intercom/api/TypedDataCollection.java | 109 - .../api/TypedDataCollectionIterator.java | 56 - .../java/io/intercom/api/TypedMessage.java | 116 - .../java/io/intercom/api/URIDeserializer.java | 44 - .../main/java/io/intercom/api/UriBuilder.java | 106 - .../src/main/java/io/intercom/api/User.java | 719 ------ .../java/io/intercom/api/UserCollection.java | 32 - .../java/io/intercom/api/UserMessage.java | 28 - .../api/UserPermanentDeleteRequest.java | 37 - .../api/UserPermanentDeleteResponse.java | 33 - .../main/java/io/intercom/api/UserReply.java | 69 - .../main/java/io/intercom/api/Visitor.java | 770 ------ .../test/java/io/intercom/api/AdminTest.java | 80 - .../java/io/intercom/api/CompanyTest.java | 223 -- .../api/CompanyUpdateBuilderTest.java | 93 - .../java/io/intercom/api/ContactTest.java | 35 - .../io/intercom/api/ConversationTest.java | 286 --- .../io/intercom/api/ErrorCollectionTest.java | 43 - .../test/java/io/intercom/api/EventTest.java | 244 -- .../intercom/api/IntercomExceptionTest.java | 32 - .../java/io/intercom/api/IntercomTest.java | 179 -- .../java/io/intercom/api/JobItemTest.java | 27 - .../java/io/intercom/api/JobSupportTest.java | 22 - .../test/java/io/intercom/api/NoteTest.java | 61 - .../io/intercom/api/NotificationTest.java | 39 - .../java/io/intercom/api/SegmentTest.java | 45 - .../io/intercom/api/SocialProfileTest.java | 39 - .../test/java/io/intercom/api/TagTest.java | 154 -- .../java/io/intercom/api/TestSupport.java | 19 - .../java/io/intercom/api/UriBuilderTest.java | 45 - .../test/java/io/intercom/api/UserTest.java | 276 --- .../java/io/intercom/api/VisitorTest.java | 109 - intercom-java/src/test/resources/admin.json | 17 - .../src/test/resources/admin_team.json | 17 - intercom-java/src/test/resources/admins.json | 91 - intercom-java/src/test/resources/company.json | 54 - .../company_no_data_except_company_id.json | 21 - .../src/test/resources/conversation.json | 104 - .../conversation_no_attachments.json | 83 - .../test/resources/conversation_no_parts.json | 38 - .../test/resources/conversation_no_tags.json | 38 - .../src/test/resources/conversations.json | 102 - intercom-java/src/test/resources/errors.json | 13 - .../src/test/resources/event_summary.json | 29 - intercom-java/src/test/resources/events.json | 32 - intercom-java/src/test/resources/note.json | 17 - .../src/test/resources/notification.json | 72 - .../resources/permanent_delete_response.json | 3 - intercom-java/src/test/resources/segment.json | 7 - .../test/resources/social_profile_url_1.json | 6 - .../test/resources/social_profile_url_2.json | 6 - .../test/resources/social_profile_url_3.json | 6 - .../test/resources/social_profile_url_4.json | 6 - intercom-java/src/test/resources/tag.json | 7 - intercom-java/src/test/resources/user.json | 77 - .../src/test/resources/user_no_avatar.json | 77 - intercom-java/src/test/resources/visitor.json | 61 - sample-app/build.gradle | 19 + sample-app/src/main/java/sample/App.java | 13 + settings.gradle | 2 +- .../java/com/intercom/api/AsyncIntercom.java | 180 ++ .../intercom/api/AsyncIntercomBuilder.java | 60 + src/main/java/com/intercom/api/Intercom.java | 180 ++ .../com/intercom/api/IntercomBuilder.java | 60 + .../com/intercom/api/core/ApiVersion.java | 252 ++ .../com/intercom/api/core/ClientOptions.java | 185 ++ .../api/core/DateTimeDeserializer.java | 55 + .../com/intercom/api/core/Environment.java | 26 + .../com/intercom/api/core/FileStream.java | 60 + .../api/core/InputStreamRequestBody.java | 79 + .../api/core/IntercomApiException.java | 45 + .../intercom/api/core/IntercomException.java | 17 + .../com/intercom/api/core/MediaTypes.java | 13 + .../java/com/intercom/api/core/Nullable.java | 140 ++ .../api/core/NullableNonemptyFilter.java | 19 + .../com/intercom/api/core/ObjectMappers.java | 36 + .../intercom/api/core/QueryStringMapper.java | 142 ++ .../com/intercom/api/core/RequestOptions.java | 128 + .../api/core/ResponseBodyInputStream.java | 45 + .../intercom/api/core/ResponseBodyReader.java | 44 + .../intercom/api/core/RetryInterceptor.java | 78 + .../java/com/intercom/api/core/Stream.java | 97 + .../java/com/intercom/api/core/Suppliers.java | 23 + .../api/core/pagination/BasePage.java | 24 + .../api/core/pagination/SyncPage.java | 24 + .../core/pagination/SyncPagingIterable.java | 61 + .../intercom/api/errors/BadRequestError.java | 26 + .../intercom/api/errors/ForbiddenError.java | 27 + .../intercom/api/errors/NotFoundError.java | 26 + .../api/errors/UnauthorizedError.java | 27 + .../api/errors/UnprocessableEntityError.java | 26 + .../api/resources/admins/AdminsClient.java | 302 +++ .../resources/admins/AsyncAdminsClient.java | 383 +++ .../requests/ConfigureAwayAdminRequest.java | 174 ++ .../admins/requests/FindAdminRequest.java | 109 + .../requests/ListAllActivityLogsRequest.java | 147 ++ .../api/resources/admins/types/Admin.java | 579 +++++ .../api/resources/aiagent/types/AiAgent.java | 452 ++++ .../aicontentsource/types/ContentSource.java | 175 ++ .../resources/articles/ArticlesClient.java | 424 ++++ .../articles/AsyncArticlesClient.java | 533 ++++ .../requests/CreateArticleRequest.java | 529 ++++ .../requests/DeleteArticleRequest.java | 109 + .../articles/requests/FindArticleRequest.java | 109 + .../requests/ListArticlesRequest.java | 124 + .../requests/SearchArticlesRequest.java | 181 ++ .../requests/UpdateArticleRequest.java | 574 +++++ .../api/resources/articles/types/Article.java | 768 ++++++ .../articles/types/ArticleListItem.java | 735 ++++++ .../types/ArticleSearchHighlights.java | 579 +++++ .../articles/types/IArticleListItem.java | 40 + .../types/SearchArticlesResponse.java | 287 +++ .../companies/AsyncCompaniesClient.java | 1034 ++++++++ .../resources/companies/CompaniesClient.java | 834 +++++++ .../AttachContactToCompanyRequest.java | 139 ++ .../CreateOrUpdateCompanyRequest.java | 335 +++ .../requests/DeleteCompanyRequest.java | 109 + .../DetachContactFromCompanyRequest.java | 139 ++ .../requests/FindCompanyRequest.java | 109 + .../requests/ListAttachedContactsRequest.java | 185 ++ .../requests/ListCompaniesRequest.java | 152 ++ .../ListSegmentsAttachedToCompanyRequest.java | 110 + .../requests/RetrieveCompanyRequest.java | 235 ++ .../requests/ScrollCompaniesRequest.java | 98 + .../requests/UpdateCompanyRequest.java | 109 + .../resources/companies/types/Company.java | 1089 ++++++++ .../contacts/AsyncContactsClient.java | 1371 ++++++++++ .../resources/contacts/ContactsClient.java | 1112 +++++++++ .../requests/ArchiveContactRequest.java | 109 + .../AttachSubscriptionToContactRequest.java | 171 ++ .../requests/DeleteContactRequest.java | 109 + .../DetachSubscriptionFromContactRequest.java | 140 ++ .../contacts/requests/FindContactRequest.java | 109 + .../ListAttachedCompaniesRequest.java | 185 ++ .../ListAttachedSubscriptionsRequest.java | 109 + .../requests/ListContactsRequest.java | 152 ++ .../ListSegmentsAttachedToContactRequest.java | 110 + .../ListTagsAttachedToContactRequest.java | 109 + .../requests/MergeContactsRequest.java | 138 ++ .../requests/UnarchiveContactRequest.java | 109 + .../requests/UpdateContactRequest.java | 545 ++++ .../api/resources/contacts/types/Contact.java | 1798 ++++++++++++++ .../AsyncConversationsClient.java | 1313 ++++++++++ .../conversations/ConversationsClient.java | 1087 ++++++++ .../AttachContactToConversationRequest.java | 645 +++++ .../AutoAssignConversationRequest.java | 109 + .../ConvertConversationToTicketRequest.java | 286 +++ .../requests/CreateConversationRequest.java | 377 +++ .../DetachContactFromConversationRequest.java | 171 ++ .../requests/FindConversationRequest.java | 147 ++ .../requests/ListConversationsRequest.java | 124 + .../ManageConversationPartsRequest.java | 133 + .../requests/ReplyToConversationRequest.java | 133 + .../requests/UpdateConversationRequest.java | 218 ++ .../conversations/types/Conversation.java | 1152 +++++++++ .../types/ConversationsManageRequestBody.java | 328 +++ .../AsyncDataAttributesClient.java | 293 +++ .../dataattributes/DataAttributesClient.java | 238 ++ .../requests/CreateDataAttributeRequest.java | 481 ++++ .../requests/ListDataAttributesRequest.java | 127 + .../requests/UpdateDataAttributeRequest.java | 349 +++ .../dataattributes/types/DataAttribute.java | 869 +++++++ .../types/DataAttributesListRequestModel.java | 97 + .../resources/dataevents/types/DataEvent.java | 375 +++ .../dataexport/AsyncDataExportClient.java | 307 +++ .../dataexport/DataExportClient.java | 251 ++ .../requests/CancelDataExportRequest.java | 109 + .../requests/CreateDataExportRequest.java | 137 + .../requests/DownloadDataExportRequest.java | 109 + .../requests/FindDataExportRequest.java | 109 + .../dataexport/types/DataExport.java | 322 +++ .../resources/events/AsyncEventsClient.java | 352 +++ .../api/resources/events/EventsClient.java | 302 +++ .../requests/ListEventSummariesRequest.java | 289 +++ .../events/requests/ListEventsRequest.java | 298 +++ .../helpcenter/types/Collection.java | 555 +++++ .../helpcenter/types/HelpCenter.java | 327 +++ .../helpcenter/types/HelpCenterList.java | 113 + .../helpcenters/AsyncHelpCentersClient.java | 213 ++ .../helpcenters/HelpCentersClient.java | 169 ++ .../collections/AsyncCollectionsClient.java | 435 ++++ .../collections/CollectionsClient.java | 342 +++ .../requests/CreateCollectionRequest.java | 256 ++ .../requests/DeleteCollectionRequest.java | 109 + .../requests/FindCollectionRequest.java | 109 + .../requests/ListCollectionsRequest.java | 124 + .../requests/UpdateCollectionRequest.java | 256 ++ .../requests/FindHelpCenterRequest.java | 109 + .../requests/ListHelpCentersRequest.java | 124 + .../messages/AsyncMessagesClient.java | 140 ++ .../resources/messages/MessagesClient.java | 118 + .../api/resources/messages/types/Message.java | 404 +++ .../api/resources/news/AsyncNewsClient.java | 32 + .../api/resources/news/NewsClient.java | 32 + .../news/feeds/AsyncFeedsClient.java | 232 ++ .../api/resources/news/feeds/FeedsClient.java | 180 ++ .../feeds/requests/FindNewsFeedRequest.java | 109 + .../requests/ListNewsFeedItemsRequest.java | 109 + .../news/items/AsyncItemsClient.java | 385 +++ .../api/resources/news/items/ItemsClient.java | 301 +++ .../items/requests/DeleteNewsItemRequest.java | 109 + .../items/requests/FindNewsItemRequest.java | 109 + .../items/requests/UpdateNewsItemRequest.java | 132 + .../api/resources/news/types/NewsItem.java | 642 +++++ .../api/resources/news/types/Newsfeed.java | 220 ++ .../news/types/NewsfeedAssignment.java | 137 + .../api/resources/notes/AsyncNotesClient.java | 273 ++ .../api/resources/notes/NotesClient.java | 213 ++ .../requests/CreateContactNoteRequest.java | 176 ++ .../notes/requests/FindNoteRequest.java | 109 + .../requests/ListContactNotesRequest.java | 185 ++ .../api/resources/notes/types/Note.java | 357 +++ .../AsyncPhoneCallRedirectsClient.java | 122 + .../PhoneCallRedirectsClient.java | 101 + .../CreatePhoneCallRedirectRequest.java | 140 ++ .../segments/AsyncSegmentsClient.java | 180 ++ .../resources/segments/SegmentsClient.java | 145 ++ .../segments/requests/FindSegmentRequest.java | 109 + .../requests/ListSegmentsRequest.java | 98 + .../api/resources/segments/types/Segment.java | 365 +++ .../AsyncSubscriptionTypesClient.java | 97 + .../SubscriptionTypesClient.java | 77 + .../types/SubscriptionType.java | 551 ++++ .../api/resources/tags/AsyncTagsClient.java | 802 ++++++ .../api/resources/tags/TagsClient.java | 637 +++++ .../tags/requests/DeleteTagRequest.java | 109 + .../tags/requests/FindTagRequest.java | 109 + .../tags/requests/TagContactRequest.java | 138 ++ .../tags/requests/TagConversationRequest.java | 170 ++ .../tags/requests/TagTicketRequest.java | 167 ++ .../tags/requests/UntagContactRequest.java | 138 ++ .../requests/UntagConversationRequest.java | 170 ++ .../tags/requests/UntagTicketRequest.java | 168 ++ .../api/resources/tags/types/Tag.java | 201 ++ .../tags/types/TagsCreateRequestBody.java | 122 + .../api/resources/teams/AsyncTeamsClient.java | 168 ++ .../api/resources/teams/TeamsClient.java | 133 + .../teams/requests/FindTeamRequest.java | 109 + .../api/resources/teams/types/Team.java | 235 ++ .../resources/tickets/AsyncTicketsClient.java | 526 ++++ .../api/resources/tickets/TicketsClient.java | 440 ++++ .../tickets/requests/CreateTicketRequest.java | 747 ++++++ .../tickets/requests/FindTicketRequest.java | 109 + .../requests/ReplyToTicketRequest.java | 126 + .../tickets/requests/UpdateTicketRequest.java | 529 ++++ .../api/resources/tickets/types/Ticket.java | 1047 ++++++++ .../tickets/types/TicketContacts.java | 114 + .../resources/tickets/types/TicketPart.java | 729 ++++++ .../resources/tickets/types/TicketType.java | 519 ++++ .../types/TicketsReplyRequestBody.java | 96 + .../tickettypes/AsyncTicketTypesClient.java | 336 +++ .../tickettypes/TicketTypesClient.java | 271 ++ .../attributes/AsyncAttributesClient.java | 186 ++ .../attributes/AttributesClient.java | 148 ++ .../CreateTicketTypeAttributeRequest.java | 616 +++++ .../UpdateTicketTypeAttributeRequest.java | 539 ++++ .../requests/CreateTicketTypeRequest.java | 348 +++ .../requests/FindTicketTypeRequest.java | 109 + .../requests/UpdateTicketTypeRequest.java | 430 ++++ .../visitors/AsyncVisitorsClient.java | 267 ++ .../resources/visitors/VisitorsClient.java | 215 ++ .../visitors/requests/FindVisitorRequest.java | 109 + .../MergeVisitorToContactRequest.java | 878 +++++++ .../intercom/api/types/ActionComponent.java | 263 ++ .../com/intercom/api/types/ActivityLog.java | 1217 +++++++++ .../intercom/api/types/ActivityLogList.java | 137 + .../api/types/ActivityLogMetadata.java | 335 +++ .../intercom/api/types/AddressableList.java | 167 ++ .../com/intercom/api/types/AdminList.java | 114 + .../api/types/AdminPriorityLevel.java | 127 + .../types/AdminReplyConversationRequest.java | 371 +++ .../api/types/AdminReplyTicketRequest.java | 502 ++++ .../com/intercom/api/types/AdminWithApp.java | 606 +++++ src/main/java/com/intercom/api/types/App.java | 311 +++ .../intercom/api/types/ArticleContent.java | 443 ++++ .../com/intercom/api/types/ArticleList.java | 201 ++ .../intercom/api/types/ArticleStatistics.java | 293 +++ .../api/types/ArticleTranslatedContent.java | 1142 +++++++++ .../api/types/AssignConversationRequest.java | 282 +++ .../intercom/api/types/ButtonComponent.java | 336 +++ .../com/intercom/api/types/CanvasObject.java | 187 ++ .../intercom/api/types/CheckboxComponent.java | 394 +++ .../intercom/api/types/CheckboxOption.java | 184 ++ .../api/types/CloseConversationRequest.java | 151 ++ .../intercom/api/types/CollectionList.java | 201 ++ .../api/types/CompanyAttachedContacts.java | 198 ++ .../api/types/CompanyAttachedSegments.java | 114 + .../com/intercom/api/types/CompanyList.java | 198 ++ .../com/intercom/api/types/CompanyScroll.java | 192 ++ .../com/intercom/api/types/Component.java | 776 ++++++ .../intercom/api/types/ConfigureRequest.java | 577 +++++ .../intercom/api/types/ConfigureResponse.java | 195 ++ .../intercom/api/types/ContactArchived.java | 184 ++ .../api/types/ContactAttachedCompanies.java | 201 ++ .../intercom/api/types/ContactCompanies.java | 250 ++ .../intercom/api/types/ContactCompany.java | 146 ++ .../intercom/api/types/ContactDeleted.java | 184 ++ .../com/intercom/api/types/ContactList.java | 198 ++ .../intercom/api/types/ContactLocation.java | 160 ++ .../com/intercom/api/types/ContactNotes.java | 226 ++ .../intercom/api/types/ContactReference.java | 154 ++ .../api/types/ContactReplyBaseRequest.java | 198 ++ .../ContactReplyConversationRequest.java | 107 + .../api/types/ContactReplyEmailRequest.java | 267 ++ .../ContactReplyIntercomUserIdRequest.java | 267 ++ .../types/ContactReplyTicketEmailRequest.java | 229 ++ ...ntactReplyTicketIntercomUserIdRequest.java | 231 ++ .../api/types/ContactReplyTicketRequest.java | 106 + .../ContactReplyTicketUserIdRequest.java | 229 ++ .../api/types/ContactReplyUserIdRequest.java | 267 ++ .../intercom/api/types/ContactSegments.java | 114 + .../api/types/ContactSocialProfiles.java | 105 + .../api/types/ContactSubscriptionTypes.java | 226 ++ .../com/intercom/api/types/ContactTags.java | 226 ++ .../intercom/api/types/ContactUnarchived.java | 184 ++ .../com/intercom/api/types/ContentObject.java | 105 + .../api/types/ContentSourcesList.java | 166 ++ .../java/com/intercom/api/types/Context.java | 345 +++ .../types/ConversationAttachmentFiles.java | 168 ++ .../api/types/ConversationContacts.java | 110 + .../types/ConversationFirstContactReply.java | 173 ++ .../intercom/api/types/ConversationPart.java | 485 ++++ .../api/types/ConversationPartAuthor.java | 197 ++ .../intercom/api/types/ConversationParts.java | 167 ++ .../api/types/ConversationRating.java | 222 ++ .../api/types/ConversationSource.java | 541 ++++ .../api/types/ConversationStatistics.java | 604 +++++ .../api/types/ConversationTeammates.java | 113 + .../api/types/CreateContactRequest.java | 1344 ++++++++++ .../api/types/CreateDataEventRequest.java | 696 ++++++ .../api/types/CreateMessageRequest.java | 1438 +++++++++++ .../api/types/CreateOrUpdateTagRequest.java | 146 ++ .../CreateTicketReplyWithCommentRequest.java | 96 + .../com/intercom/api/types/CurrentCanvas.java | 109 + .../com/intercom/api/types/CursorPages.java | 186 ++ .../intercom/api/types/CustomerRequest.java | 391 +++ .../intercom/api/types/DataAttributeList.java | 114 + .../com/intercom/api/types/DataEventList.java | 239 ++ .../intercom/api/types/DataEventSummary.java | 234 ++ .../api/types/DataEventSummaryItem.java | 243 ++ .../com/intercom/api/types/DataExportCsv.java | 1058 ++++++++ .../api/types/DataTableComponent.java | 105 + .../com/intercom/api/types/DataTableItem.java | 146 ++ .../api/types/DeletedArticleObject.java | 146 ++ .../api/types/DeletedCollectionObject.java | 146 ++ .../api/types/DeletedCompanyObject.java | 146 ++ .../com/intercom/api/types/DeletedObject.java | 146 ++ .../intercom/api/types/DividerComponent.java | 124 + .../intercom/api/types/DropdownComponent.java | 400 +++ .../intercom/api/types/DropdownOption.java | 184 ++ .../java/com/intercom/api/types/Error.java | 306 +++ .../java/com/intercom/api/types/Event.java | 68 + .../com/intercom/api/types/FileAttribute.java | 298 +++ .../com/intercom/api/types/GroupContent.java | 146 ++ .../api/types/GroupTranslatedContent.java | 1122 +++++++++ .../api/types/IContactReplyBaseRequest.java | 19 + .../com/intercom/api/types/IListItem.java | 24 + .../intercom/api/types/ImageComponent.java | 459 ++++ .../intercom/api/types/InitializeRequest.java | 343 +++ .../api/types/InitializeResponse.java | 109 + .../intercom/api/types/InputComponent.java | 423 ++++ .../com/intercom/api/types/LinkedObject.java | 252 ++ .../intercom/api/types/LinkedObjectList.java | 197 ++ .../com/intercom/api/types/ListComponent.java | 217 ++ .../java/com/intercom/api/types/ListItem.java | 339 +++ .../intercom/api/types/ListItemWithImage.java | 452 ++++ .../api/types/ListItemWithoutImage.java | 469 ++++ .../intercom/api/types/LiveCanvasRequest.java | 237 ++ .../api/types/LiveCanvasResponse.java | 109 + .../types/MultipleFilterSearchRequest.java | 201 ++ .../MultipleOrSingleFilterSearchRequest.java | 96 + .../intercom/api/types/NewsItemRequest.java | 462 ++++ .../java/com/intercom/api/types/NoteList.java | 198 ++ .../com/intercom/api/types/OffsetPages.java | 186 ++ .../api/types/OpenConversationRequest.java | 109 + .../com/intercom/api/types/PagesLink.java | 191 ++ .../types/PaginatedConversationResponse.java | 201 ++ .../api/types/PaginatedNewsItemResponse.java | 201 ++ .../api/types/PaginatedNewsfeedResponse.java | 201 ++ .../intercom/api/types/PartAttachment.java | 305 +++ .../com/intercom/api/types/PhoneSwitch.java | 117 + .../api/types/RedactConversationRequest.java | 456 ++++ .../com/intercom/api/types/Reference.java | 144 ++ .../api/types/ReplyConversationRequest.java | 94 + .../intercom/api/types/ResultsResponse.java | 104 + .../com/intercom/api/types/SearchRequest.java | 219 ++ .../com/intercom/api/types/SegmentList.java | 141 ++ .../api/types/SheetActionComponent.java | 109 + .../api/types/SingleFilterSearchRequest.java | 421 ++++ .../api/types/SingleSelectComponent.java | 438 ++++ .../api/types/SingleSelectOption.java | 184 ++ .../com/intercom/api/types/SlaApplied.java | 270 ++ .../api/types/SnoozeConversationRequest.java | 138 ++ .../com/intercom/api/types/SocialProfile.java | 146 ++ .../intercom/api/types/SpacerComponent.java | 230 ++ .../api/types/StartingAfterPaging.java | 145 ++ .../api/types/SubmitActionComponent.java | 59 + .../com/intercom/api/types/SubmitRequest.java | 445 ++++ .../intercom/api/types/SubmitResponse.java | 187 ++ .../api/types/SubscriptionTypeList.java | 114 + .../intercom/api/types/TagCompanyRequest.java | 267 ++ .../java/com/intercom/api/types/TagList.java | 114 + .../api/types/TagMultipleUsersRequest.java | 230 ++ .../java/com/intercom/api/types/Tags.java | 114 + .../java/com/intercom/api/types/TeamList.java | 114 + .../intercom/api/types/TeamPriorityLevel.java | 127 + .../intercom/api/types/TextAreaComponent.java | 298 +++ .../com/intercom/api/types/TextComponent.java | 443 ++++ .../com/intercom/api/types/TicketList.java | 201 ++ .../intercom/api/types/TicketPartAuthor.java | 302 +++ .../com/intercom/api/types/TicketParts.java | 167 ++ .../com/intercom/api/types/TicketReply.java | 458 ++++ .../api/types/TicketTypeAttribute.java | 787 ++++++ .../api/types/TicketTypeAttributeList.java | 114 + .../intercom/api/types/TicketTypeList.java | 114 + .../com/intercom/api/types/Translation.java | 167 ++ .../api/types/UntagCompanyRequest.java | 289 +++ .../api/types/UpdateVisitorRequest.java | 439 ++++ .../api/types/UrlActionComponent.java | 109 + .../java/com/intercom/api/types/Visitor.java | 2205 +++++++++++++++++ .../api/types/VisitorDeletedObject.java | 146 ++ .../java/com/intercom/api/TestClient.java | 11 + .../api/core/QueryStringMapperTest.java | 339 +++ 524 files changed, 101082 insertions(+), 15000 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .fernignore delete mode 100644 .github/ISSUE_TEMPLATE.md delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/ci.yml delete mode 100644 CHANGES.md delete mode 100644 LICENSE delete mode 100644 README.md delete mode 100644 gradle.properties delete mode 100644 intercom-java/.gitignore delete mode 100644 intercom-java/build.gradle delete mode 100644 intercom-java/src/main/java/io/intercom/api/Admin.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/AdminAwayMode.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/AdminCollection.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/AdminMessage.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/AdminMessageResponse.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/AdminReply.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/Attachment.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/Author.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/AuthorizationException.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/Avatar.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/ClientException.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/Company.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/CompanyCollection.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/CompanyUpdateBuilder.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/CompanyWithStringPlan.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/Conditions.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/Contact.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/ContactCollection.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/ContactMessage.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/Conversation.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/ConversationCollection.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/ConversationMessage.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/ConversationPart.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/ConversationPartCollection.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/ConversationRating.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/CountItemDeserializer.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/CountItemSerializer.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/Counts.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/CustomAttribute.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/CustomAttributeDeserializer.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/CustomAttributeSerializer.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/Customer.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/CustomerFirstReply.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/DataResource.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/Error.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/ErrorCollection.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/Event.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/EventCollection.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/EventSummary.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/EventSummaryCollection.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/HttpClient.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/HttpConnectorSupplier.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/IOUtils.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/Intercom.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/IntercomException.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/InvalidException.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/Job.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/JobItem.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/JobItemCollection.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/JobItemRequest.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/JobSupport.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/JobTask.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/LocationData.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/MapperSupport.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/NotFoundException.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/Note.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/NoteCollection.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/Notification.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/NotificationCollection.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/NotificationData.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/NotificationError.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/NotificationErrorCollection.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/RateLimitException.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/Replier.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/Reply.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/RequestResponseCapture.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/ScrollableCompanyCollection.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/ScrollableContactCollection.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/ScrollableTypedDataCollection.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/ScrollableUserCollection.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/Segment.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/SegmentCollection.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/ServerException.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/SocialProfile.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/SocialProfileCollection.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/Subscription.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/SubscriptionCollection.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/Tag.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/TagCollection.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/Teammate.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/TopicDeserializer.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/TopicSerializer.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/TypedData.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/TypedDataCollection.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/TypedDataCollectionIterator.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/TypedMessage.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/URIDeserializer.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/UriBuilder.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/User.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/UserCollection.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/UserMessage.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/UserPermanentDeleteRequest.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/UserPermanentDeleteResponse.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/UserReply.java delete mode 100644 intercom-java/src/main/java/io/intercom/api/Visitor.java delete mode 100644 intercom-java/src/test/java/io/intercom/api/AdminTest.java delete mode 100644 intercom-java/src/test/java/io/intercom/api/CompanyTest.java delete mode 100644 intercom-java/src/test/java/io/intercom/api/CompanyUpdateBuilderTest.java delete mode 100644 intercom-java/src/test/java/io/intercom/api/ContactTest.java delete mode 100644 intercom-java/src/test/java/io/intercom/api/ConversationTest.java delete mode 100644 intercom-java/src/test/java/io/intercom/api/ErrorCollectionTest.java delete mode 100644 intercom-java/src/test/java/io/intercom/api/EventTest.java delete mode 100644 intercom-java/src/test/java/io/intercom/api/IntercomExceptionTest.java delete mode 100644 intercom-java/src/test/java/io/intercom/api/IntercomTest.java delete mode 100644 intercom-java/src/test/java/io/intercom/api/JobItemTest.java delete mode 100644 intercom-java/src/test/java/io/intercom/api/JobSupportTest.java delete mode 100644 intercom-java/src/test/java/io/intercom/api/NoteTest.java delete mode 100644 intercom-java/src/test/java/io/intercom/api/NotificationTest.java delete mode 100644 intercom-java/src/test/java/io/intercom/api/SegmentTest.java delete mode 100644 intercom-java/src/test/java/io/intercom/api/SocialProfileTest.java delete mode 100644 intercom-java/src/test/java/io/intercom/api/TagTest.java delete mode 100644 intercom-java/src/test/java/io/intercom/api/TestSupport.java delete mode 100644 intercom-java/src/test/java/io/intercom/api/UriBuilderTest.java delete mode 100644 intercom-java/src/test/java/io/intercom/api/UserTest.java delete mode 100644 intercom-java/src/test/java/io/intercom/api/VisitorTest.java delete mode 100644 intercom-java/src/test/resources/admin.json delete mode 100644 intercom-java/src/test/resources/admin_team.json delete mode 100644 intercom-java/src/test/resources/admins.json delete mode 100644 intercom-java/src/test/resources/company.json delete mode 100644 intercom-java/src/test/resources/company_no_data_except_company_id.json delete mode 100644 intercom-java/src/test/resources/conversation.json delete mode 100644 intercom-java/src/test/resources/conversation_no_attachments.json delete mode 100644 intercom-java/src/test/resources/conversation_no_parts.json delete mode 100644 intercom-java/src/test/resources/conversation_no_tags.json delete mode 100644 intercom-java/src/test/resources/conversations.json delete mode 100644 intercom-java/src/test/resources/errors.json delete mode 100644 intercom-java/src/test/resources/event_summary.json delete mode 100644 intercom-java/src/test/resources/events.json delete mode 100644 intercom-java/src/test/resources/note.json delete mode 100644 intercom-java/src/test/resources/notification.json delete mode 100644 intercom-java/src/test/resources/permanent_delete_response.json delete mode 100644 intercom-java/src/test/resources/segment.json delete mode 100644 intercom-java/src/test/resources/social_profile_url_1.json delete mode 100644 intercom-java/src/test/resources/social_profile_url_2.json delete mode 100644 intercom-java/src/test/resources/social_profile_url_3.json delete mode 100644 intercom-java/src/test/resources/social_profile_url_4.json delete mode 100644 intercom-java/src/test/resources/tag.json delete mode 100644 intercom-java/src/test/resources/user.json delete mode 100644 intercom-java/src/test/resources/user_no_avatar.json delete mode 100644 intercom-java/src/test/resources/visitor.json create mode 100644 sample-app/build.gradle create mode 100644 sample-app/src/main/java/sample/App.java create mode 100644 src/main/java/com/intercom/api/AsyncIntercom.java create mode 100644 src/main/java/com/intercom/api/AsyncIntercomBuilder.java create mode 100644 src/main/java/com/intercom/api/Intercom.java create mode 100644 src/main/java/com/intercom/api/IntercomBuilder.java create mode 100644 src/main/java/com/intercom/api/core/ApiVersion.java create mode 100644 src/main/java/com/intercom/api/core/ClientOptions.java create mode 100644 src/main/java/com/intercom/api/core/DateTimeDeserializer.java create mode 100644 src/main/java/com/intercom/api/core/Environment.java create mode 100644 src/main/java/com/intercom/api/core/FileStream.java create mode 100644 src/main/java/com/intercom/api/core/InputStreamRequestBody.java create mode 100644 src/main/java/com/intercom/api/core/IntercomApiException.java create mode 100644 src/main/java/com/intercom/api/core/IntercomException.java create mode 100644 src/main/java/com/intercom/api/core/MediaTypes.java create mode 100644 src/main/java/com/intercom/api/core/Nullable.java create mode 100644 src/main/java/com/intercom/api/core/NullableNonemptyFilter.java create mode 100644 src/main/java/com/intercom/api/core/ObjectMappers.java create mode 100644 src/main/java/com/intercom/api/core/QueryStringMapper.java create mode 100644 src/main/java/com/intercom/api/core/RequestOptions.java create mode 100644 src/main/java/com/intercom/api/core/ResponseBodyInputStream.java create mode 100644 src/main/java/com/intercom/api/core/ResponseBodyReader.java create mode 100644 src/main/java/com/intercom/api/core/RetryInterceptor.java create mode 100644 src/main/java/com/intercom/api/core/Stream.java create mode 100644 src/main/java/com/intercom/api/core/Suppliers.java create mode 100644 src/main/java/com/intercom/api/core/pagination/BasePage.java create mode 100644 src/main/java/com/intercom/api/core/pagination/SyncPage.java create mode 100644 src/main/java/com/intercom/api/core/pagination/SyncPagingIterable.java create mode 100644 src/main/java/com/intercom/api/errors/BadRequestError.java create mode 100644 src/main/java/com/intercom/api/errors/ForbiddenError.java create mode 100644 src/main/java/com/intercom/api/errors/NotFoundError.java create mode 100644 src/main/java/com/intercom/api/errors/UnauthorizedError.java create mode 100644 src/main/java/com/intercom/api/errors/UnprocessableEntityError.java create mode 100644 src/main/java/com/intercom/api/resources/admins/AdminsClient.java create mode 100644 src/main/java/com/intercom/api/resources/admins/AsyncAdminsClient.java create mode 100644 src/main/java/com/intercom/api/resources/admins/requests/ConfigureAwayAdminRequest.java create mode 100644 src/main/java/com/intercom/api/resources/admins/requests/FindAdminRequest.java create mode 100644 src/main/java/com/intercom/api/resources/admins/requests/ListAllActivityLogsRequest.java create mode 100644 src/main/java/com/intercom/api/resources/admins/types/Admin.java create mode 100644 src/main/java/com/intercom/api/resources/aiagent/types/AiAgent.java create mode 100644 src/main/java/com/intercom/api/resources/aicontentsource/types/ContentSource.java create mode 100644 src/main/java/com/intercom/api/resources/articles/ArticlesClient.java create mode 100644 src/main/java/com/intercom/api/resources/articles/AsyncArticlesClient.java create mode 100644 src/main/java/com/intercom/api/resources/articles/requests/CreateArticleRequest.java create mode 100644 src/main/java/com/intercom/api/resources/articles/requests/DeleteArticleRequest.java create mode 100644 src/main/java/com/intercom/api/resources/articles/requests/FindArticleRequest.java create mode 100644 src/main/java/com/intercom/api/resources/articles/requests/ListArticlesRequest.java create mode 100644 src/main/java/com/intercom/api/resources/articles/requests/SearchArticlesRequest.java create mode 100644 src/main/java/com/intercom/api/resources/articles/requests/UpdateArticleRequest.java create mode 100644 src/main/java/com/intercom/api/resources/articles/types/Article.java create mode 100644 src/main/java/com/intercom/api/resources/articles/types/ArticleListItem.java create mode 100644 src/main/java/com/intercom/api/resources/articles/types/ArticleSearchHighlights.java create mode 100644 src/main/java/com/intercom/api/resources/articles/types/IArticleListItem.java create mode 100644 src/main/java/com/intercom/api/resources/articles/types/SearchArticlesResponse.java create mode 100644 src/main/java/com/intercom/api/resources/companies/AsyncCompaniesClient.java create mode 100644 src/main/java/com/intercom/api/resources/companies/CompaniesClient.java create mode 100644 src/main/java/com/intercom/api/resources/companies/requests/AttachContactToCompanyRequest.java create mode 100644 src/main/java/com/intercom/api/resources/companies/requests/CreateOrUpdateCompanyRequest.java create mode 100644 src/main/java/com/intercom/api/resources/companies/requests/DeleteCompanyRequest.java create mode 100644 src/main/java/com/intercom/api/resources/companies/requests/DetachContactFromCompanyRequest.java create mode 100644 src/main/java/com/intercom/api/resources/companies/requests/FindCompanyRequest.java create mode 100644 src/main/java/com/intercom/api/resources/companies/requests/ListAttachedContactsRequest.java create mode 100644 src/main/java/com/intercom/api/resources/companies/requests/ListCompaniesRequest.java create mode 100644 src/main/java/com/intercom/api/resources/companies/requests/ListSegmentsAttachedToCompanyRequest.java create mode 100644 src/main/java/com/intercom/api/resources/companies/requests/RetrieveCompanyRequest.java create mode 100644 src/main/java/com/intercom/api/resources/companies/requests/ScrollCompaniesRequest.java create mode 100644 src/main/java/com/intercom/api/resources/companies/requests/UpdateCompanyRequest.java create mode 100644 src/main/java/com/intercom/api/resources/companies/types/Company.java create mode 100644 src/main/java/com/intercom/api/resources/contacts/AsyncContactsClient.java create mode 100644 src/main/java/com/intercom/api/resources/contacts/ContactsClient.java create mode 100644 src/main/java/com/intercom/api/resources/contacts/requests/ArchiveContactRequest.java create mode 100644 src/main/java/com/intercom/api/resources/contacts/requests/AttachSubscriptionToContactRequest.java create mode 100644 src/main/java/com/intercom/api/resources/contacts/requests/DeleteContactRequest.java create mode 100644 src/main/java/com/intercom/api/resources/contacts/requests/DetachSubscriptionFromContactRequest.java create mode 100644 src/main/java/com/intercom/api/resources/contacts/requests/FindContactRequest.java create mode 100644 src/main/java/com/intercom/api/resources/contacts/requests/ListAttachedCompaniesRequest.java create mode 100644 src/main/java/com/intercom/api/resources/contacts/requests/ListAttachedSubscriptionsRequest.java create mode 100644 src/main/java/com/intercom/api/resources/contacts/requests/ListContactsRequest.java create mode 100644 src/main/java/com/intercom/api/resources/contacts/requests/ListSegmentsAttachedToContactRequest.java create mode 100644 src/main/java/com/intercom/api/resources/contacts/requests/ListTagsAttachedToContactRequest.java create mode 100644 src/main/java/com/intercom/api/resources/contacts/requests/MergeContactsRequest.java create mode 100644 src/main/java/com/intercom/api/resources/contacts/requests/UnarchiveContactRequest.java create mode 100644 src/main/java/com/intercom/api/resources/contacts/requests/UpdateContactRequest.java create mode 100644 src/main/java/com/intercom/api/resources/contacts/types/Contact.java create mode 100644 src/main/java/com/intercom/api/resources/conversations/AsyncConversationsClient.java create mode 100644 src/main/java/com/intercom/api/resources/conversations/ConversationsClient.java create mode 100644 src/main/java/com/intercom/api/resources/conversations/requests/AttachContactToConversationRequest.java create mode 100644 src/main/java/com/intercom/api/resources/conversations/requests/AutoAssignConversationRequest.java create mode 100644 src/main/java/com/intercom/api/resources/conversations/requests/ConvertConversationToTicketRequest.java create mode 100644 src/main/java/com/intercom/api/resources/conversations/requests/CreateConversationRequest.java create mode 100644 src/main/java/com/intercom/api/resources/conversations/requests/DetachContactFromConversationRequest.java create mode 100644 src/main/java/com/intercom/api/resources/conversations/requests/FindConversationRequest.java create mode 100644 src/main/java/com/intercom/api/resources/conversations/requests/ListConversationsRequest.java create mode 100644 src/main/java/com/intercom/api/resources/conversations/requests/ManageConversationPartsRequest.java create mode 100644 src/main/java/com/intercom/api/resources/conversations/requests/ReplyToConversationRequest.java create mode 100644 src/main/java/com/intercom/api/resources/conversations/requests/UpdateConversationRequest.java create mode 100644 src/main/java/com/intercom/api/resources/conversations/types/Conversation.java create mode 100644 src/main/java/com/intercom/api/resources/conversations/types/ConversationsManageRequestBody.java create mode 100644 src/main/java/com/intercom/api/resources/dataattributes/AsyncDataAttributesClient.java create mode 100644 src/main/java/com/intercom/api/resources/dataattributes/DataAttributesClient.java create mode 100644 src/main/java/com/intercom/api/resources/dataattributes/requests/CreateDataAttributeRequest.java create mode 100644 src/main/java/com/intercom/api/resources/dataattributes/requests/ListDataAttributesRequest.java create mode 100644 src/main/java/com/intercom/api/resources/dataattributes/requests/UpdateDataAttributeRequest.java create mode 100644 src/main/java/com/intercom/api/resources/dataattributes/types/DataAttribute.java create mode 100644 src/main/java/com/intercom/api/resources/dataattributes/types/DataAttributesListRequestModel.java create mode 100644 src/main/java/com/intercom/api/resources/dataevents/types/DataEvent.java create mode 100644 src/main/java/com/intercom/api/resources/dataexport/AsyncDataExportClient.java create mode 100644 src/main/java/com/intercom/api/resources/dataexport/DataExportClient.java create mode 100644 src/main/java/com/intercom/api/resources/dataexport/requests/CancelDataExportRequest.java create mode 100644 src/main/java/com/intercom/api/resources/dataexport/requests/CreateDataExportRequest.java create mode 100644 src/main/java/com/intercom/api/resources/dataexport/requests/DownloadDataExportRequest.java create mode 100644 src/main/java/com/intercom/api/resources/dataexport/requests/FindDataExportRequest.java create mode 100644 src/main/java/com/intercom/api/resources/dataexport/types/DataExport.java create mode 100644 src/main/java/com/intercom/api/resources/events/AsyncEventsClient.java create mode 100644 src/main/java/com/intercom/api/resources/events/EventsClient.java create mode 100644 src/main/java/com/intercom/api/resources/events/requests/ListEventSummariesRequest.java create mode 100644 src/main/java/com/intercom/api/resources/events/requests/ListEventsRequest.java create mode 100644 src/main/java/com/intercom/api/resources/helpcenter/types/Collection.java create mode 100644 src/main/java/com/intercom/api/resources/helpcenter/types/HelpCenter.java create mode 100644 src/main/java/com/intercom/api/resources/helpcenter/types/HelpCenterList.java create mode 100644 src/main/java/com/intercom/api/resources/helpcenters/AsyncHelpCentersClient.java create mode 100644 src/main/java/com/intercom/api/resources/helpcenters/HelpCentersClient.java create mode 100644 src/main/java/com/intercom/api/resources/helpcenters/collections/AsyncCollectionsClient.java create mode 100644 src/main/java/com/intercom/api/resources/helpcenters/collections/CollectionsClient.java create mode 100644 src/main/java/com/intercom/api/resources/helpcenters/collections/requests/CreateCollectionRequest.java create mode 100644 src/main/java/com/intercom/api/resources/helpcenters/collections/requests/DeleteCollectionRequest.java create mode 100644 src/main/java/com/intercom/api/resources/helpcenters/collections/requests/FindCollectionRequest.java create mode 100644 src/main/java/com/intercom/api/resources/helpcenters/collections/requests/ListCollectionsRequest.java create mode 100644 src/main/java/com/intercom/api/resources/helpcenters/collections/requests/UpdateCollectionRequest.java create mode 100644 src/main/java/com/intercom/api/resources/helpcenters/requests/FindHelpCenterRequest.java create mode 100644 src/main/java/com/intercom/api/resources/helpcenters/requests/ListHelpCentersRequest.java create mode 100644 src/main/java/com/intercom/api/resources/messages/AsyncMessagesClient.java create mode 100644 src/main/java/com/intercom/api/resources/messages/MessagesClient.java create mode 100644 src/main/java/com/intercom/api/resources/messages/types/Message.java create mode 100644 src/main/java/com/intercom/api/resources/news/AsyncNewsClient.java create mode 100644 src/main/java/com/intercom/api/resources/news/NewsClient.java create mode 100644 src/main/java/com/intercom/api/resources/news/feeds/AsyncFeedsClient.java create mode 100644 src/main/java/com/intercom/api/resources/news/feeds/FeedsClient.java create mode 100644 src/main/java/com/intercom/api/resources/news/feeds/requests/FindNewsFeedRequest.java create mode 100644 src/main/java/com/intercom/api/resources/news/feeds/requests/ListNewsFeedItemsRequest.java create mode 100644 src/main/java/com/intercom/api/resources/news/items/AsyncItemsClient.java create mode 100644 src/main/java/com/intercom/api/resources/news/items/ItemsClient.java create mode 100644 src/main/java/com/intercom/api/resources/news/items/requests/DeleteNewsItemRequest.java create mode 100644 src/main/java/com/intercom/api/resources/news/items/requests/FindNewsItemRequest.java create mode 100644 src/main/java/com/intercom/api/resources/news/items/requests/UpdateNewsItemRequest.java create mode 100644 src/main/java/com/intercom/api/resources/news/types/NewsItem.java create mode 100644 src/main/java/com/intercom/api/resources/news/types/Newsfeed.java create mode 100644 src/main/java/com/intercom/api/resources/news/types/NewsfeedAssignment.java create mode 100644 src/main/java/com/intercom/api/resources/notes/AsyncNotesClient.java create mode 100644 src/main/java/com/intercom/api/resources/notes/NotesClient.java create mode 100644 src/main/java/com/intercom/api/resources/notes/requests/CreateContactNoteRequest.java create mode 100644 src/main/java/com/intercom/api/resources/notes/requests/FindNoteRequest.java create mode 100644 src/main/java/com/intercom/api/resources/notes/requests/ListContactNotesRequest.java create mode 100644 src/main/java/com/intercom/api/resources/notes/types/Note.java create mode 100644 src/main/java/com/intercom/api/resources/phonecallredirects/AsyncPhoneCallRedirectsClient.java create mode 100644 src/main/java/com/intercom/api/resources/phonecallredirects/PhoneCallRedirectsClient.java create mode 100644 src/main/java/com/intercom/api/resources/phonecallredirects/requests/CreatePhoneCallRedirectRequest.java create mode 100644 src/main/java/com/intercom/api/resources/segments/AsyncSegmentsClient.java create mode 100644 src/main/java/com/intercom/api/resources/segments/SegmentsClient.java create mode 100644 src/main/java/com/intercom/api/resources/segments/requests/FindSegmentRequest.java create mode 100644 src/main/java/com/intercom/api/resources/segments/requests/ListSegmentsRequest.java create mode 100644 src/main/java/com/intercom/api/resources/segments/types/Segment.java create mode 100644 src/main/java/com/intercom/api/resources/subscriptiontypes/AsyncSubscriptionTypesClient.java create mode 100644 src/main/java/com/intercom/api/resources/subscriptiontypes/SubscriptionTypesClient.java create mode 100644 src/main/java/com/intercom/api/resources/subscriptiontypes/types/SubscriptionType.java create mode 100644 src/main/java/com/intercom/api/resources/tags/AsyncTagsClient.java create mode 100644 src/main/java/com/intercom/api/resources/tags/TagsClient.java create mode 100644 src/main/java/com/intercom/api/resources/tags/requests/DeleteTagRequest.java create mode 100644 src/main/java/com/intercom/api/resources/tags/requests/FindTagRequest.java create mode 100644 src/main/java/com/intercom/api/resources/tags/requests/TagContactRequest.java create mode 100644 src/main/java/com/intercom/api/resources/tags/requests/TagConversationRequest.java create mode 100644 src/main/java/com/intercom/api/resources/tags/requests/TagTicketRequest.java create mode 100644 src/main/java/com/intercom/api/resources/tags/requests/UntagContactRequest.java create mode 100644 src/main/java/com/intercom/api/resources/tags/requests/UntagConversationRequest.java create mode 100644 src/main/java/com/intercom/api/resources/tags/requests/UntagTicketRequest.java create mode 100644 src/main/java/com/intercom/api/resources/tags/types/Tag.java create mode 100644 src/main/java/com/intercom/api/resources/tags/types/TagsCreateRequestBody.java create mode 100644 src/main/java/com/intercom/api/resources/teams/AsyncTeamsClient.java create mode 100644 src/main/java/com/intercom/api/resources/teams/TeamsClient.java create mode 100644 src/main/java/com/intercom/api/resources/teams/requests/FindTeamRequest.java create mode 100644 src/main/java/com/intercom/api/resources/teams/types/Team.java create mode 100644 src/main/java/com/intercom/api/resources/tickets/AsyncTicketsClient.java create mode 100644 src/main/java/com/intercom/api/resources/tickets/TicketsClient.java 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/FindTicketRequest.java create mode 100644 src/main/java/com/intercom/api/resources/tickets/requests/ReplyToTicketRequest.java create mode 100644 src/main/java/com/intercom/api/resources/tickets/requests/UpdateTicketRequest.java create mode 100644 src/main/java/com/intercom/api/resources/tickets/types/Ticket.java create mode 100644 src/main/java/com/intercom/api/resources/tickets/types/TicketContacts.java create mode 100644 src/main/java/com/intercom/api/resources/tickets/types/TicketPart.java create mode 100644 src/main/java/com/intercom/api/resources/tickets/types/TicketType.java create mode 100644 src/main/java/com/intercom/api/resources/tickets/types/TicketsReplyRequestBody.java create mode 100644 src/main/java/com/intercom/api/resources/tickettypes/AsyncTicketTypesClient.java create mode 100644 src/main/java/com/intercom/api/resources/tickettypes/TicketTypesClient.java create mode 100644 src/main/java/com/intercom/api/resources/tickettypes/attributes/AsyncAttributesClient.java create mode 100644 src/main/java/com/intercom/api/resources/tickettypes/attributes/AttributesClient.java create mode 100644 src/main/java/com/intercom/api/resources/tickettypes/attributes/requests/CreateTicketTypeAttributeRequest.java create mode 100644 src/main/java/com/intercom/api/resources/tickettypes/attributes/requests/UpdateTicketTypeAttributeRequest.java create mode 100644 src/main/java/com/intercom/api/resources/tickettypes/requests/CreateTicketTypeRequest.java create mode 100644 src/main/java/com/intercom/api/resources/tickettypes/requests/FindTicketTypeRequest.java create mode 100644 src/main/java/com/intercom/api/resources/tickettypes/requests/UpdateTicketTypeRequest.java create mode 100644 src/main/java/com/intercom/api/resources/visitors/AsyncVisitorsClient.java create mode 100644 src/main/java/com/intercom/api/resources/visitors/VisitorsClient.java create mode 100644 src/main/java/com/intercom/api/resources/visitors/requests/FindVisitorRequest.java create mode 100644 src/main/java/com/intercom/api/resources/visitors/requests/MergeVisitorToContactRequest.java create mode 100644 src/main/java/com/intercom/api/types/ActionComponent.java create mode 100644 src/main/java/com/intercom/api/types/ActivityLog.java create mode 100644 src/main/java/com/intercom/api/types/ActivityLogList.java create mode 100644 src/main/java/com/intercom/api/types/ActivityLogMetadata.java create mode 100644 src/main/java/com/intercom/api/types/AddressableList.java create mode 100644 src/main/java/com/intercom/api/types/AdminList.java create mode 100644 src/main/java/com/intercom/api/types/AdminPriorityLevel.java create mode 100644 src/main/java/com/intercom/api/types/AdminReplyConversationRequest.java create mode 100644 src/main/java/com/intercom/api/types/AdminReplyTicketRequest.java create mode 100644 src/main/java/com/intercom/api/types/AdminWithApp.java create mode 100644 src/main/java/com/intercom/api/types/App.java create mode 100644 src/main/java/com/intercom/api/types/ArticleContent.java create mode 100644 src/main/java/com/intercom/api/types/ArticleList.java create mode 100644 src/main/java/com/intercom/api/types/ArticleStatistics.java create mode 100644 src/main/java/com/intercom/api/types/ArticleTranslatedContent.java create mode 100644 src/main/java/com/intercom/api/types/AssignConversationRequest.java create mode 100644 src/main/java/com/intercom/api/types/ButtonComponent.java create mode 100644 src/main/java/com/intercom/api/types/CanvasObject.java create mode 100644 src/main/java/com/intercom/api/types/CheckboxComponent.java create mode 100644 src/main/java/com/intercom/api/types/CheckboxOption.java create mode 100644 src/main/java/com/intercom/api/types/CloseConversationRequest.java create mode 100644 src/main/java/com/intercom/api/types/CollectionList.java create mode 100644 src/main/java/com/intercom/api/types/CompanyAttachedContacts.java create mode 100644 src/main/java/com/intercom/api/types/CompanyAttachedSegments.java create mode 100644 src/main/java/com/intercom/api/types/CompanyList.java create mode 100644 src/main/java/com/intercom/api/types/CompanyScroll.java create mode 100644 src/main/java/com/intercom/api/types/Component.java create mode 100644 src/main/java/com/intercom/api/types/ConfigureRequest.java create mode 100644 src/main/java/com/intercom/api/types/ConfigureResponse.java create mode 100644 src/main/java/com/intercom/api/types/ContactArchived.java create mode 100644 src/main/java/com/intercom/api/types/ContactAttachedCompanies.java create mode 100644 src/main/java/com/intercom/api/types/ContactCompanies.java create mode 100644 src/main/java/com/intercom/api/types/ContactCompany.java create mode 100644 src/main/java/com/intercom/api/types/ContactDeleted.java create mode 100644 src/main/java/com/intercom/api/types/ContactList.java create mode 100644 src/main/java/com/intercom/api/types/ContactLocation.java create mode 100644 src/main/java/com/intercom/api/types/ContactNotes.java create mode 100644 src/main/java/com/intercom/api/types/ContactReference.java create mode 100644 src/main/java/com/intercom/api/types/ContactReplyBaseRequest.java create mode 100644 src/main/java/com/intercom/api/types/ContactReplyConversationRequest.java create mode 100644 src/main/java/com/intercom/api/types/ContactReplyEmailRequest.java create mode 100644 src/main/java/com/intercom/api/types/ContactReplyIntercomUserIdRequest.java create mode 100644 src/main/java/com/intercom/api/types/ContactReplyTicketEmailRequest.java create mode 100644 src/main/java/com/intercom/api/types/ContactReplyTicketIntercomUserIdRequest.java create mode 100644 src/main/java/com/intercom/api/types/ContactReplyTicketRequest.java create mode 100644 src/main/java/com/intercom/api/types/ContactReplyTicketUserIdRequest.java create mode 100644 src/main/java/com/intercom/api/types/ContactReplyUserIdRequest.java create mode 100644 src/main/java/com/intercom/api/types/ContactSegments.java create mode 100644 src/main/java/com/intercom/api/types/ContactSocialProfiles.java create mode 100644 src/main/java/com/intercom/api/types/ContactSubscriptionTypes.java create mode 100644 src/main/java/com/intercom/api/types/ContactTags.java create mode 100644 src/main/java/com/intercom/api/types/ContactUnarchived.java create mode 100644 src/main/java/com/intercom/api/types/ContentObject.java create mode 100644 src/main/java/com/intercom/api/types/ContentSourcesList.java create mode 100644 src/main/java/com/intercom/api/types/Context.java create mode 100644 src/main/java/com/intercom/api/types/ConversationAttachmentFiles.java create mode 100644 src/main/java/com/intercom/api/types/ConversationContacts.java create mode 100644 src/main/java/com/intercom/api/types/ConversationFirstContactReply.java create mode 100644 src/main/java/com/intercom/api/types/ConversationPart.java create mode 100644 src/main/java/com/intercom/api/types/ConversationPartAuthor.java create mode 100644 src/main/java/com/intercom/api/types/ConversationParts.java create mode 100644 src/main/java/com/intercom/api/types/ConversationRating.java create mode 100644 src/main/java/com/intercom/api/types/ConversationSource.java create mode 100644 src/main/java/com/intercom/api/types/ConversationStatistics.java create mode 100644 src/main/java/com/intercom/api/types/ConversationTeammates.java create mode 100644 src/main/java/com/intercom/api/types/CreateContactRequest.java create mode 100644 src/main/java/com/intercom/api/types/CreateDataEventRequest.java create mode 100644 src/main/java/com/intercom/api/types/CreateMessageRequest.java create mode 100644 src/main/java/com/intercom/api/types/CreateOrUpdateTagRequest.java create mode 100644 src/main/java/com/intercom/api/types/CreateTicketReplyWithCommentRequest.java create mode 100644 src/main/java/com/intercom/api/types/CurrentCanvas.java create mode 100644 src/main/java/com/intercom/api/types/CursorPages.java create mode 100644 src/main/java/com/intercom/api/types/CustomerRequest.java create mode 100644 src/main/java/com/intercom/api/types/DataAttributeList.java create mode 100644 src/main/java/com/intercom/api/types/DataEventList.java create mode 100644 src/main/java/com/intercom/api/types/DataEventSummary.java create mode 100644 src/main/java/com/intercom/api/types/DataEventSummaryItem.java create mode 100644 src/main/java/com/intercom/api/types/DataExportCsv.java create mode 100644 src/main/java/com/intercom/api/types/DataTableComponent.java create mode 100644 src/main/java/com/intercom/api/types/DataTableItem.java create mode 100644 src/main/java/com/intercom/api/types/DeletedArticleObject.java create mode 100644 src/main/java/com/intercom/api/types/DeletedCollectionObject.java create mode 100644 src/main/java/com/intercom/api/types/DeletedCompanyObject.java create mode 100644 src/main/java/com/intercom/api/types/DeletedObject.java create mode 100644 src/main/java/com/intercom/api/types/DividerComponent.java create mode 100644 src/main/java/com/intercom/api/types/DropdownComponent.java create mode 100644 src/main/java/com/intercom/api/types/DropdownOption.java create mode 100644 src/main/java/com/intercom/api/types/Error.java create mode 100644 src/main/java/com/intercom/api/types/Event.java create mode 100644 src/main/java/com/intercom/api/types/FileAttribute.java create mode 100644 src/main/java/com/intercom/api/types/GroupContent.java create mode 100644 src/main/java/com/intercom/api/types/GroupTranslatedContent.java create mode 100644 src/main/java/com/intercom/api/types/IContactReplyBaseRequest.java create mode 100644 src/main/java/com/intercom/api/types/IListItem.java create mode 100644 src/main/java/com/intercom/api/types/ImageComponent.java create mode 100644 src/main/java/com/intercom/api/types/InitializeRequest.java create mode 100644 src/main/java/com/intercom/api/types/InitializeResponse.java create mode 100644 src/main/java/com/intercom/api/types/InputComponent.java create mode 100644 src/main/java/com/intercom/api/types/LinkedObject.java create mode 100644 src/main/java/com/intercom/api/types/LinkedObjectList.java create mode 100644 src/main/java/com/intercom/api/types/ListComponent.java create mode 100644 src/main/java/com/intercom/api/types/ListItem.java create mode 100644 src/main/java/com/intercom/api/types/ListItemWithImage.java create mode 100644 src/main/java/com/intercom/api/types/ListItemWithoutImage.java create mode 100644 src/main/java/com/intercom/api/types/LiveCanvasRequest.java create mode 100644 src/main/java/com/intercom/api/types/LiveCanvasResponse.java create mode 100644 src/main/java/com/intercom/api/types/MultipleFilterSearchRequest.java create mode 100644 src/main/java/com/intercom/api/types/MultipleOrSingleFilterSearchRequest.java create mode 100644 src/main/java/com/intercom/api/types/NewsItemRequest.java create mode 100644 src/main/java/com/intercom/api/types/NoteList.java create mode 100644 src/main/java/com/intercom/api/types/OffsetPages.java create mode 100644 src/main/java/com/intercom/api/types/OpenConversationRequest.java create mode 100644 src/main/java/com/intercom/api/types/PagesLink.java create mode 100644 src/main/java/com/intercom/api/types/PaginatedConversationResponse.java create mode 100644 src/main/java/com/intercom/api/types/PaginatedNewsItemResponse.java create mode 100644 src/main/java/com/intercom/api/types/PaginatedNewsfeedResponse.java create mode 100644 src/main/java/com/intercom/api/types/PartAttachment.java create mode 100644 src/main/java/com/intercom/api/types/PhoneSwitch.java create mode 100644 src/main/java/com/intercom/api/types/RedactConversationRequest.java create mode 100644 src/main/java/com/intercom/api/types/Reference.java create mode 100644 src/main/java/com/intercom/api/types/ReplyConversationRequest.java create mode 100644 src/main/java/com/intercom/api/types/ResultsResponse.java create mode 100644 src/main/java/com/intercom/api/types/SearchRequest.java create mode 100644 src/main/java/com/intercom/api/types/SegmentList.java create mode 100644 src/main/java/com/intercom/api/types/SheetActionComponent.java create mode 100644 src/main/java/com/intercom/api/types/SingleFilterSearchRequest.java create mode 100644 src/main/java/com/intercom/api/types/SingleSelectComponent.java create mode 100644 src/main/java/com/intercom/api/types/SingleSelectOption.java create mode 100644 src/main/java/com/intercom/api/types/SlaApplied.java create mode 100644 src/main/java/com/intercom/api/types/SnoozeConversationRequest.java create mode 100644 src/main/java/com/intercom/api/types/SocialProfile.java create mode 100644 src/main/java/com/intercom/api/types/SpacerComponent.java create mode 100644 src/main/java/com/intercom/api/types/StartingAfterPaging.java create mode 100644 src/main/java/com/intercom/api/types/SubmitActionComponent.java create mode 100644 src/main/java/com/intercom/api/types/SubmitRequest.java create mode 100644 src/main/java/com/intercom/api/types/SubmitResponse.java create mode 100644 src/main/java/com/intercom/api/types/SubscriptionTypeList.java create mode 100644 src/main/java/com/intercom/api/types/TagCompanyRequest.java create mode 100644 src/main/java/com/intercom/api/types/TagList.java create mode 100644 src/main/java/com/intercom/api/types/TagMultipleUsersRequest.java create mode 100644 src/main/java/com/intercom/api/types/Tags.java create mode 100644 src/main/java/com/intercom/api/types/TeamList.java create mode 100644 src/main/java/com/intercom/api/types/TeamPriorityLevel.java create mode 100644 src/main/java/com/intercom/api/types/TextAreaComponent.java create mode 100644 src/main/java/com/intercom/api/types/TextComponent.java create mode 100644 src/main/java/com/intercom/api/types/TicketList.java create mode 100644 src/main/java/com/intercom/api/types/TicketPartAuthor.java create mode 100644 src/main/java/com/intercom/api/types/TicketParts.java create mode 100644 src/main/java/com/intercom/api/types/TicketReply.java create mode 100644 src/main/java/com/intercom/api/types/TicketTypeAttribute.java create mode 100644 src/main/java/com/intercom/api/types/TicketTypeAttributeList.java create mode 100644 src/main/java/com/intercom/api/types/TicketTypeList.java create mode 100644 src/main/java/com/intercom/api/types/Translation.java create mode 100644 src/main/java/com/intercom/api/types/UntagCompanyRequest.java create mode 100644 src/main/java/com/intercom/api/types/UpdateVisitorRequest.java create mode 100644 src/main/java/com/intercom/api/types/UrlActionComponent.java create mode 100644 src/main/java/com/intercom/api/types/Visitor.java create mode 100644 src/main/java/com/intercom/api/types/VisitorDeletedObject.java create mode 100644 src/test/java/com/intercom/api/TestClient.java create mode 100644 src/test/java/com/intercom/api/core/QueryStringMapperTest.java diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 1ec6e757..00000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,15 +0,0 @@ -version: 2.1 - -jobs: - build: - docker: - - image: cimg/openjdk:8.0 - - working_directory: ~/intercom-java - - steps: - - checkout - - - run: chmod +x ./gradlew - - run: TERM="dumb" ./gradlew dependencies - - run: TERM="dumb" ./gradlew test diff --git a/.fernignore b/.fernignore new file mode 100644 index 00000000..084a8ebb --- /dev/null +++ b/.fernignore @@ -0,0 +1 @@ +# Specify files that shouldn't be modified by Fern diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md deleted file mode 100644 index 7932aff1..00000000 --- a/.github/ISSUE_TEMPLATE.md +++ /dev/null @@ -1,19 +0,0 @@ -Please use the following template to submit your issue. Following this template will allow us to quickly investigate and help you with your issue. Please be aware that issues which do not conform to this template may be closed. - -For feature requests please contact us at team@intercom.io - - -## Version info - - intercom-java version: - - Java version: - -## Expected behavior - -## Actual behavior - -## Steps to reproduce - 1. - 2. - 3. - -## Logs diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 7c94e728..00000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,5 +0,0 @@ -#### Why? -Why are you making this change? - -#### How? -Technical details on your change diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index 2fd88763..00000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,14 +0,0 @@ -version: 2 -updates: - - package-ecosystem: "gradle" - directory: "/" - schedule: - interval: "weekly" - open-pull-requests-limit: 5 - commit-message: - prefix: "chore" - - - package-ecosystem: "github-actions" - directory: "/" - schedule: - interval: "weekly" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..260533c2 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,38 @@ +name: ci + +on: [push] + +jobs: + compile: + runs-on: ubuntu-latest + + steps: + - name: Checkout repo + uses: actions/checkout@v3 + + - name: Set up Java + id: setup-jre + uses: actions/setup-java@v1 + with: + java-version: "11" + architecture: x64 + + - name: Compile + run: ./gradlew compileJava + + test: + needs: [ compile ] + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v3 + + - name: Set up Java + id: setup-jre + uses: actions/setup-java@v1 + with: + java-version: "11" + architecture: x64 + + - name: Test + run: ./gradlew test diff --git a/.gitignore b/.gitignore index dcac0a87..d4199abc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,21 +1,24 @@ -*/**/Spike*.java -.gradle *.class -out/* +.project +.gradle +? +.classpath +.checkstyle +.settings +.node +build + +# IntelliJ *.iml *.ipr *.iws -build -out -*/build/* -*/build/**/*.jar -*.war -*.ear -hs_err_pid* -.idea -/bin/ +.idea/ +out/ -intercom-java/.project +# Eclipse/IntelliJ APT +generated_src/ +generated_testSrc/ +generated/ -.project -securing.gpg +bin +build \ No newline at end of file diff --git a/CHANGES.md b/CHANGES.md deleted file mode 100644 index 8f9933c9..00000000 --- a/CHANGES.md +++ /dev/null @@ -1,288 +0,0 @@ -### Changes - -### 2.8.2 - -#### Add support for has_inbox_seat field (#272) -Added mapping for the has_inbox_seat field to the Admin user model. -### 2.8.1 - -#### Add support for delivered_as field (#264) -Added mapping for the delivered_as field on the Conversation model. - -#### Add support for customer_first_reply field (#263) -Added mapping for the customer_first_reply field on the Conversation model. - -### 2.8.0 -There are a number of new features and changes in this release so will move to version 2.8. -The most important one from a breaking change point of view is that the use of API keys is no longer allowed. -You should now be using Access Tokens to access the API -For more information on any of the changes please see the README. -We have added examples for all of the new features - -#### Remove API Key references (#230) -API Keys are no longer valid. We now use Acces tokens. -So removing reference to use API keys in the SDK - -#### Add support for snooze (#236) -Added appropriate code to be able to snooze conversation and to read the conversation model for snooze attributes - -#### Add conversation ratings (#235) -Add extra code to support reading conversation ratings - -#### Add support for marking conversation as read (#234) -Add ability to make a conversation as read - -#### Add support for display_as when finding conversation (#239) -Add a new find that allows extra parameters - -#### Support running assignment rules (#243) -Build support for recent API feature to allow running assignment rules on a conversation -https://developers.intercom.com/intercom-api-reference/reference#run-conversation-assignment-rules - -#### Support Event Summaries (#244) -List event summaries of a user -https://developers.intercom.com/intercom-api-reference/reference#view-user-events-summaries - -#### Extract Iterator implementation into TypedDataCollection (#247) -First thing, TypedDataCollection now implements Iterator, it is delegating the hasNext(), next() and remove() methods to a TypedDataCollectionIterator instance. -Second, I have removed all specific implementations of Iterator from all Collection classes, which were just copy-paste. - -#### Update webhook topics and add ping (#245) -Added support for more topics - -#### Allow parsing of responses from DELETE requests (#248) -Now we check if DELETE response has data if it does proceed to process it as any other normal data -If there is no data just return null - -### 2.7.0 -This update includes the removal of an option which is not possible viua the API. -There was an option in the SDK to manually update the company sessions account but this is not possible vai the API. -It is doubbtful that it was being used but just in case we will make this release 2.7.0 - -#232 - Add the visitor endpoint functionality for the java SDK. -#233 - Remove option to set company session count since it returns error as it is not possible to set it - -#### 2.6.0 -There a number of changed in this version so updating to 2.6 -Highlights are adding more attributes to the company resource and new features on admin resource. -For more info see the specific PR or issue noted here and/or the updated readme -- use thread local (optionally) for context setting (#204) -- Add support for more company attributes (#183) -- Add deletion by ID and User ID (#200) -- Add support for new Admin endpoints and attributes (#198) -- Add tests for companies (#215) -- Update readme to document permanent deletion and rename old delete method to archive (#228) - -#### 2.5.2 -- Adding tagging abilities to Contacts. - -#### 2.5.1 -- Adding new release due to issues with previous. - -#### 2.5.0 -- Fix for #207 to remove a non-existent API call (PR #211) -- Fix for #197 to prioritise user_id when tagging users (PR #199) -- Update of Jackson dependencies (PR #203) -- Fix for #197 to prioritise user_id when tagging users (PR #199) -- Fix for #202 to enable retrieving company session count (PR #213) -- Update Gradle (PR #216) -- Add template for Pull Requests (PR #217) -- Removal of Travis (PR #219) - -#### 2.4.0 -- Fix for gradle release issue #192 -- Update related to API user archive and permanent delete option #195 - -#### 2.3.3 -- Fix for #185: scroll issue where requests not reaching endpoint (PR #186) - -#### 2.3.2 -- fix for #(174) to Handle records with no avatars (#181) - -#### 2.3.1 -- Updating release versions due to number of new features ebing added -- Add support for deletion by user_id or email (#175) -- Add support for listing events (#173) -- Add support for updating avatars for Users and Contacts/Leads (#174) -- Add support for more message attributes: url, id and attachments (#177) - -#### 2.2.12 -- Update readme with more list examples (#165) -- Remove restrictions on listing conversations via user and admin (#171) - -#### 2.2.11 -- Add support for retrieving conversation tags - -#### 2.2.10 -- Add option to create events with ID -- Fix issues with README headers - -#### 2.2.7 -- Add scroll to companies - -#### 2.2.6 -- Add rate limit fields to `RateLimitException` (submitted by @loonydevil) - -#### 2.2.5 -- Add scroll to contacts and users - -#### 2.2.4 - -- Add phone attribute -- Fix infinite recursive call on get conversation parts - -#### 2.2.3 - -- Add next page size check for pagination - -#### 2.2.2 - -- Add data_type for bulk user actions - -#### 2.2.1 - -- Add attachment support for replies -- Fix remove user from company bug - -#### 2.2.0 - -- Include company custom attributes when updating a user with an embedded company object -- Include support for Personal Access Token API access - -#### 2.1.0 - -- Dynamically retrieve the parts for a conversation if not present - -#### 2.0.0 - -- Fixes subscription metadata deserialization - -#### 1.3.1 - -- Fixes company removal - -#### 1.3.0 - -- Is a rollup of the 1.3.0 beta releases. - -#### 1.3.0-b3 - -- Configure Jackson ObjectMapper once [76](https://github.com/intercom/intercom-java/issues/76) - -#### 1.3.0-b2 - -- Allow users to be removed from companies. - -#### 1.3.0-b1 - -- Support bulk user and event submission. Save your request rate limit for -a rainy day! You can post and delete users, and post events. - -- Add a currentTimestamp() helper to Intercom. This divides currentTimeMillis -by 1000 to produce a second level value. - -#### 1.2.1 - -- Do not send empty company arrays for user updates. Honestly, what's the point? - -#### 1.2.0 - -- Allow conversations to be assigned to others on your team. Conversations -are the most beautiful things, and now you can share them with others through -the API. - -- Support closing and opening conversations, either directly or with a reply. - - -#### 1.1.2 - - - make setUserAgentData public. Previously this was a protected method. - -#### 1.1.1 - - - add support for [Contact Messaging](https://github.com/intercom/intercom-java#conversations) - -#### 1.1.0 - - - add support for [Contacts](https://github.com/intercom/intercom-java#contacts) - -#### 1.0.9 - - - remove secondary getters on user that stop older jackson versions working [48](https://github.com/intercom/intercom-java/issues/45) (caused in [40](https://github.com/intercom/intercom-java/issues/48)). Doing a bang up job on regression bugs atm. - -#### 1.0.8 - - - fix user update regression [45](https://github.com/intercom/intercom-java/issues/45) (caused in [40](https://github.com/intercom/intercom-java/issues/40)) - - - don't send values for `unsubscribed_from_emails`, `update_last_request_at` or `new_session` unless set - -#### 1.0.7 - - - handle more kinds of social urls [35](https://github.com/intercom/intercom-java/issues/35) - -#### 1.0.6 - - - fix user message sending [40](https://github.com/intercom/intercom-java/issues/40) - -#### 1.0.5 - -allow the signed_up_at user field to be submitted - -#### 1.0.4 - -allow the intercom user id field to be submitted - -#### 1.0.3 - -encode social profile urls for user objects - -#### 1.0.2 - -- fix NPE when errors have no data [30](https://github.com/intercom/intercom-java/pull/30) - -#### 1.0.1 - - - send custom company attributes on update - - - fix NPE when company has no plan on update - - - invalidate setSessionCount on Company [27](https://github.com/intercom/intercom-java/issues/27) - -#### 1.0.0 - - - removed tag methods requiring collections - - - handle non-json error entities from server - -#### 0.1.0 - - - support untag of users and companies - - - renamed of current page and page methods on collections (breaking) - -#### 0.0.5 - -- fix bulk user tagging when using fully populated users [13](https://github.com/intercom/intercom-java/issues/13) -- add client side validation of events [14](https://github.com/intercom/intercom-java/issues/14) -- fix npe when updating users [15](https://github.com/intercom/intercom-java/issues/15) - - -#### 0.0.4 - -- send false boolean values for user updates [8](https://github.com/intercom/intercom-java/issues/8) - -#### 0.0.3 - -- only send allowed fields when adding a company to a user [7](https://github.com/intercom/intercom-java/issues/7) - -#### 0.0.2 - - - add toString methods on some classes - -#### 0.0.1 - - - fix bintray publication task (was sending empty jars) - -#### 0.0.0 - - - initial client diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 305509fc..00000000 --- a/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - -2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - -3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - -4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - -5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - -6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - -8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - -9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - -END OF TERMS AND CONDITIONS - -APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - -Copyright 2014 Intercom, Inc. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. \ No newline at end of file diff --git a/README.md b/README.md deleted file mode 100644 index f8f09d12..00000000 --- a/README.md +++ /dev/null @@ -1,825 +0,0 @@ -# intercom-java - -[![Circle CI](https://circleci.com/gh/intercom/intercom-java.svg?style=shield)](https://circleci.com/gh/intercom/intercom-java) -[![Maven Central](https://img.shields.io/maven-central/v/io.intercom/intercom-java.svg?label=Maven%20Central)](https://search.maven.org/artifact/io.intercom/intercom-java) -![Intercom API Version](https://img.shields.io/badge/Intercom%20API%20Version-1.3-blue) - -> Java bindings for the [Intercom API](https://api.intercom.io/docs) - -## Project Updates - -### Retirement of Bintray/JCenter - -This project was previously publishing releases to JCenter, which is being retired by JFrog on May 1st 2021. - -To allow continued access to past versions, we've migrated them to Maven Central. - -### Maintenance - -We're currently building a new team to provide in-depth and dedicated SDK support. - -In the meantime, we'll be operating on limited capacity, meaning all pull requests will be evaluated on a best effort basis and will be limited to critical issues. - -We'll communicate all relevant updates as we build this new team and support strategy in the coming months. - -- [Installation](#add-a-dependency) -- [Resources](#resources) -- [Authorization](#authorization) -- [Usage](#usage) -- [Idioms](#idioms) -- [Configuration](#configuration) - -## Add a dependency - -The distribution is hosted on [mavenCentral](https://search.maven.org/artifact/io.intercom/intercom-java). -To use the client, you can add the mavenCentral repository to your dependencies. - -### Maven - -Add the project declaration to your `pom.xml`: - -```xml - - io.intercom - intercom-java - 2.8.2 - -``` - -### Gradle - -Add mavenCentral to your `repositories` block: - -```groovy -repositories { - mavenCentral() -} -``` - -and add the project to the `dependencies` block in your `build.gradle`: - -```groovy -dependencies { - implementation 'io.intercom:intercom-java:2.8.2' -} -``` - -### SBT - -Add mavenCentral to your `resolvers` in your `build.sbt`: - -```scala -resolvers += "mavenCentral" at "https://repo1.maven.org/maven2" -``` - -and add the project to your `libraryDependencies` in your `build.sbt`: - -```scala -libraryDependencies += "io.intercom" % "intercom-java" % "2.8.2" -``` - -## Resources - -Resources this API supports: - -- [Users](#users) -- [Contacts](#contacts) -- [Visitors](#visitors) -- [Companies](#companies) -- [Admins](#admins) -- [Events](#events) -- [Tags](#tags) -- [Segments](#segments) -- [Notes](#notes) -- [Conversations](#conversations) -- [Webhooks](#webhooks) -- [Counts](#counts) - -## Authorization - -> If you already have an access token you can find it [here](https://app.intercom.com/developers/_). If you want to create or learn more about access tokens then you can find more info [here](https://developers.intercom.io/docs/personal-access-tokens). - -```java -# With an OAuth or Access token: -Intercom.setToken("da39a3ee5e6b4b0d3255bfef95601890afd80709"); -``` - -If you are building a third party application you can get your OAuth token by [setting-up-oauth](https://developers.intercom.io/page/setting-up-oauth) for Intercom. - -## Usage - -### Users - -```java -// Create a user -User user = new User() - .setEmail("malcolm@serenity.io") - .setUserId("1") - .addCustomAttribute(CustomAttribute.newStringAttribute("role", "sergeant")) - .addCustomAttribute(CustomAttribute.newBooleanAttribute("browncoat", true)); -User created = User.create(user); - -// Find user by id -user = User.find("541a144b201ebf2ec5000001"); - -// Find user by email -Map params = Maps.newHashMap(); -params.put("email", "malcolm@serenity.io"); -user = User.find(params); - -// Find user by user_id -params = Maps.newHashMap(); -params.put("user_id", "1"); -user = User.find(params); - -// Update custom_attributes for a user -user.addCustomAttribute(CustomAttribute.newStringAttribute("role", "captain")); -User.update(user); - -// Iterate over all users (up to 10k records, to read all use Scroll API) -UserCollection users = User.list(); -while(users.hasNext()) { - System.out.println(users.next().getUserId()); -} - -// List users (sorting) -Map params = Maps.newHashMap(); -params.put("sort", "updated_at"); -params.put("order", "asc"); -UserCollection users = User.list(params); - -// List users (created within the past X days) -Map params = Maps.newHashMap(); -params.put("created_since", "2"); -UserCollection users = User.list(params); - -// List users by tag -Map params = Maps.newHashMap(); -params.put("tag_id", "12345"); -UserCollection users = User.list(params); - -// List users by segment -Map params = Maps.newHashMap(); -params.put("segment_id", "1234567890abcdef12345678"); -UserCollection users = User.list(params); - -// Retrieve users via Scroll API -ScrollableUserCollection usersScroll = User.scroll(); -List users = usersScroll.getPage(); -usersScroll = usersScroll.scroll(); - -// Archive a user by Intercom ID -User user = User.find("541a144b201ebf2ec5000001"); -User.archive(user.getId()); - -// Archive a user by user_id -Map params = Maps.newHashMap(); -params.put("user_id", "1"); -User.archive(params); - -// Archive a user by email -Map params = Maps.newHashMap(); -params.put("email", "malcolm@serenity.io"); -User.archive(params); - -// Permanently delete a user by Intercom ID -User.permanentDelete("541a144b201ebf2ec5000001"); -``` - -### Contacts - -_Contacts were added in version 1.1 of the client._ - -```java -// Create a Contact -Contact contact = new Contact() - .setEmail("fantastic@serenity.io") - .addCustomAttribute(newStringAttribute("role", "fence")); -Contact created = Contact.create(contact); - -// Find a single contact by server supplied user id or id -contact = Contact.findByID("541a144b201ebf2ec5000002"); -contact = Contact.findByUserID("e1a7d875-d83a-46f7-86f4-73be98a98584"); - -// Update a contact -contact.setName("Stitch Hessian"); -Contact updated = Contact.update(contact); - -// Update a contact by ID -Contact contact = new Contact().setID("541a144b201ebf2ec5000002").setName("Stitch Hessian"); -Contact updated = Contact.update(contact); - -// Update a contact by User ID -Contact contact = new Contact().setUserID("e1a7d875-d83a-46f7-86f4-73be98a98584").setName("Stitch Hessian"); -Contact updated = Contact.update(contact); - -// Read a contact list by email -ContactCollection contacts = Contact.listByEmail("jubal@serenity.io"); -while(contacts.hasNext()) { - System.out.println(contacts.next()); -} - -// Iterate over all contacts (up to 10k records, to read all use Scroll API) -ContactCollection allContacts = Contact.list(); -while(allContacts.hasNext()) { - System.out.println(allContacts.next()); -} - -// Retrieve contacts via Scroll API -ScrollableContactCollection contactsScroll = Contact.scroll(); -List contacts = contactsScroll.getPage(); -contactsScroll = contactsScroll.scroll(); - -// List contacts (sorting) -Map params = Maps.newHashMap(); -params.put("sort", "created_at"); -params.put("order", "asc"); -ContactCollection contacts = Contact.list(params); - -// Remove a contact -Contact.delete(contact); - -// Remove a contact by id -Contact.delete(contact.getID()); - -// Remove a contact by user_id -Contact.deleteByUserID(contact.getUserID()); - -// Convert a contact -User converted = Contact.convert(contact, user); -``` - -### Visitors - -```java -// Find visitor by ID -Visitor visitor = Visitor.findByID("5b69565fa737210d1c2127f1"); - -// Find visitor by User ID -Visitor visitor = Visitor.findByUserID("6a347bc9-0b96-4925-bbbc-1f8b11f94c50"); - -// Update a visitor -Visitor visitor = Visitor.findByID("5b69565fa737210d1c2127f1"); -visitor.setName("Visitor's Name"); -Visitor.update(visitor); - -// Delete a visitor by ID -Visitor.delete("5b69565fa737210d1c2127f1"); - -// Delete a visitor -Visitor visitor = Visitor.findByUserID("6a347bc9-0b96-4925-bbbc-1f8b11f94c50"); -Visitor.delete(visitor); - -// Convert a visitor to a lead -Visitor visitor = Visitor.findByUserID("6a347bc9-0b96-4925-bbbc-1f8b11f94c50"); -Contact contact = Visitor.convertToContact(visitor); - -// Convert a visitor to a user -Visitor visitor = Visitor.findByUserID("6a347bc9-0b96-4925-bbbc-1f8b11f94c50"); -User user = new User(); -user.setUserId("1"); -User convertUser = Visitor.convertToUser(visitor, user); -``` - -### Companies - -```java -// Create a company -Company company = new Company(); - company.setName("Blue Sun"); - company.setCompanyID("1"); - company.setMonthlySpend(123.10f); - company.setPlan(new Company.Plan("premium")); - company.addCustomAttribute(CustomAttribute.newIntegerAttribute("foddstuff-items", 246)); - company.addCustomAttribute(CustomAttribute.newStringAttribute("bestseller", "fruity oaty bar")); -Company.create(company); - -// Find a company by company_id -map = Maps.newHashMap(); -map.put("company_id", "1"); -Company company = Company.find(map); - -// Find a company by name -map = Maps.newHashMap(); -map.put("name", "Blue Sun"); -Company company = Company.find(map); - -// Find a company by id -Company company = Company.find("541a144b201ebf2ec5000001"); - -// Update a company -company.setName("Blue Sun Corporation"); -Company.update(company); - -// Iterate over all companies -CompanyCollection companies = Company.list(); -while(companies.hasNext()) { - System.out.println(companies.next().getName()); -} - -// Retrieve companies via Scroll API -ScrollableCompanyCollection companiesScroll = Company.scroll(); -List companies = companiesScroll.getPage(); -companiesScroll = companiesScroll.scroll(); - -// Get a list of users in a company -map = Maps.newHashMap(); -map.put("company_id", "6"); -UserCollection users = Company.listUsers(map); - -// Add a user to one or more companies -User user = User.find("541a144b201ebf2ec5000001"); -user.addCompany(company); -User.update(user); -``` - -### Admins - -```java -// Iterate over all admins -AdminCollection admins = Admin.list(); -while(admins.hasNext()) { - System.out.println(admins.next().getName()); -} - -// Find admin by ID -Admin admin = Admin.find("123456"); - -// Set admin as away and enable away mode reassignment -Admin admin = Admin.setAwayMode("123456", true, true); -``` - -### Events - -```java -// Create an event with a user ID -// This is only valid for users -Event event = new Event() - .setEventName("bought-hat") - .setUserID("1") - .putMetadata("invitee_email", "jayne@serenity.io") - .putMetadata("found_date", System.currentTimeMillis()) - .putMetadata("new_signup", true); -Event.create(event); - -// Create an event with an email -// This is only valid for users -Event event = new Event() - .setEventName("bought-hat") - .setEmail("test@example.com"); -Event.create(event); - -// Create an event with an ID -// This is valid for both users and leads -Event event = new Event() - .setEventName("bought-hat") - .setId("599d6aeeda850883ed8ba7c2"); -Event.create(event); - - -// List events of a user -Map params = Maps.newHashMap(); -params.put("type", "user"); -params.put("user_id", "1"); -// Alternatively list by Intercom ID -// params.put("intercom_user_id", "541a144b201ebf2ec5000001"); -// Or by email -// params.put("email", "river@serenity.io"); -EventCollection events = Event.list(params); -while (events.hasNext()) { - System.out.println(events.next().getEventName()); -} - -// List event summaries of a user -Map params = Maps.newHashMap(); -params.put("type", "user"); -params.put("user_id", "1"); -// Alternatively list by Intercom ID -// params.put("intercom_user_id", "541a144b201ebf2ec5000001"); -// Or by email -// params.put("email", "river@serenity.io"); -EventSummaryCollection eventSummaryCollection = Event.listSummary(params); -for(EventSummary eventSummary : eventSummaryCollection.getEventSummaries()){ - System.out.println(eventSummary); -} -``` - -### Tags - -```java -// create a tag -Tag tag = new Tag().setName("alliance"); -tag = Tag.create(tag); - -// update a tag -tag.setName("independent"); -tag = Tag.update(tag); - -// tag and untag users -User one = new User().setEmail("river@serenity.io"); -User two = new User().setEmail("simon@serenity.io").untag(); -User.create(one); -User.create(two); -Tag.tag(tag, one, two); - -// tag and untag contacts -Contact contact1 = Contact.findByID("5ab313046e4997e35bc13e7c"); -Contact contact2 = Contact.findByUserID("697ea3e0-227d-4d70-b776-1652e94f9583").untag(); -Tag.tag(tag, contact1, contact2); - -// iterate over all tags -final TagCollection tags = Tag.list(); -while (tags.hasNext()) { - System.out.println(tags.next().getId()); -} - -// tag and untag companies -Company c1 = new Company().setCompanyID("1"); -Company c2 = new Company().setCompanyID("2").untag(); -Company.create(c1); -Company.create(c2); -Tag.tag(tag, c1, c2); - -// delete a tag -Tag.delete(tag); -``` - -### Segments - -```java -// Find a segment -Segment segment = Segment.find("1"); - -// Update a segment -segment.setName("new name"); -Segment.update(segment); - -// Iterate over all segments -SegmentCollection segments = Segment.list(); -while(segments.hasNext()) { - System.out.println(segments.next().getId()); -} -``` - -### Notes - -```java -// create a user note -User user = new User().setId("5310d8e8598c9a0b24000005"); -Author author = new Author().setId("1"); -Note note = new Note() - .setUser(user) - .setAuthor(author) - .setBody("The note"); -Note.create(note); - -// Find a note by id -note = Note.find("1"); - -// Iterate over all notes for a user via their user_id -Map params = Maps.newHashMap(); -params.put("user_id", "1"); -NoteCollection notes = Note.list(params); -while(notes.hasNext()) { - System.out.println(notes.next().getBody()); -} - -// Iterate over all notes for a user via their email address -params = Maps.newHashMap(); -params.put("email", "malcolm@serenity.io"); -notes = Note.list(params); -while(notes.hasNext()) { - System.out.println(notes.next().getBody()); -} -``` - -### Conversations - -```java -// send a message to a user -User user = new User().setId("5310d8e8598c9a0b24000005"); -Admin admin = new Admin().setId("1"); -AdminMessage adminMessage = new AdminMessage() - .setAdmin(admin) - .setUser(user) - .setSubject("This Land") - .setBody("Har har har! Mine is an evil laugh!") - .setMessageType("email") - .setTemplate("plain"); -Conversation.create(adminMessage); - -// send a message from a user -UserMessage userMessage = new UserMessage() - .setBody("Hey! Is there, is there a reward?") - .setFrom(user); -Conversation.create(userMessage); - -// send a message from a contact -ContactMessage contactMessage = new ContactMessage() - .setBody("Hey! Is there, is there a reward?") - .setFrom(contact); -Conversation.create(contactMessage); - -//list all conversations -ConversationCollection conversations = Conversation.list(); -while (conversations.hasNext()) { - Conversation conversation = conversations.next(); -} - -// find admin conversations -Map params = Maps.newHashMap(); -params.put("type", "admin"); -params.put("admin_id", "1"); -ConversationCollection adminConversations = Conversation.list(params); -while (adminConversations.hasNext()) { - Conversation conversation = adminConversations.next(); -} - -// find user conversations -params = Maps.newHashMap(); -params.put("type", "user"); -params.put("user_id", "1"); -ConversationCollection userConversations = Conversation.list(params); -while (userConversations.hasNext()) { - Conversation conversation = userConversations.next(); -} - -// find a conversation by id -final Conversation conversation = Conversation.find("66"); -ConversationMessage conversationMessage = conversation.getConversationMessage(); -ConversationPartCollection parts = conversation.getConversationPartCollection(); -List partList = parts.getPage(); -for (ConversationPart part : partList) { - String partType = part.getPartType(); - Author author = part.getAuthor(); - String body = part.getBody(); -} -ConversationPart part = conversation.getMostRecentConversationPart(); -Admin assignee = conversation.getAssignee(); -User user = conversation.getUser(); - -// Find all open conversations assigned to an admin and render as plaintext -params = Maps.newHashMap(); -params.put("type", "admin"); -params.put("admin_id", "7"); -params.put("display_as", "plaintext"); -ConversationCollection openForAdmin = Conversation.list(params); - -// admin reply -Admin admin = new Admin().setId("1"); -AdminReply adminReply = new AdminReply(admin); -adminReply.setBody("These apples are healthsome"); -adminReply.setAttachmentUrls(new String[]{"http://www.example.com/attachment.jpg"}); // optional - list of attachments -Conversation.reply("66", adminReply); - -// admin close -Admin admin = new Admin().setId("1"); -AdminReply adminReply = new AdminReply(admin); -adminReply.setMessageType("close"); -Conversation.reply("66", adminReply); - -// admin snooze -Admin admin = new Admin().setId("1"); -AdminReply adminReply = new AdminReply(admin); -adminReply.setSnoozedUntil(1549092382); -Conversation.reply("66", adminReply); - -// admin open / unsnooze -Admin admin = new Admin().setId("1"); -AdminReply adminReply = new AdminReply(admin); -adminReply.setMessageType("open"); -Conversation.reply("66", adminReply); - -// user reply -User user1 = new User().setId("5310d8e8598c9a0b24000005"); -UserReply userReply = new UserReply(user1); -userReply.setBody("Mighty fine shindig"); -userReply.setAttachmentUrls(new String[]{"http://www.example.com/attachment.jpg"}); // optional - list of attachments -System.out.println(MapperSupport.objectMapper().writeValueAsString(userReply)); -Conversation.reply("66", userReply); - -// run assignment rules -Conversation.runAssignmentRules("19240007891"); - -// mark conversation as read -Conversation.markAsRead("66"); -``` - -### Webhooks - -```java -// create a subscription -Subscription subscription = new Subscription(); -subscription.setUrl(new URI("https://example.org/webhooks/1")); -subscription.addTopic(Subscription.Topic.USER_CREATED); -subscription.addTopic(Subscription.Topic.USER_TAG_CREATED); -Subscription.create(subscription); - -// create a subscribtion and subscribe to events -Subscription subscription = new Subscription(); -subscription.addTopic(Subscription.Topic.EVENT_CREATED); -Map> metadata = new HashMap>(); -ArrayList events = new ArrayList(Arrays.asList("cart")); -metadata.put("event_names", events); -subscription.setMetadata(metadata); -subscription.setMetadata(metadata); -Subscription.create(subscription); - -// update a subscription -Subscription subscription = Subscription.find("nsub_60ca7690-4020-11e4-b789-4961958e51bd"); -subscription.addTopic(Subscription.Topic.COMPANY_CREATED); -Subscription updatedSubscription = Subscription.update(subscription); - -// delete a subscription -Subscription subscription = new Subscription(); -subscription.setId("nsub_83793feb-8394-4cb6-91d6-68ef4dd08a8e"); -Subscription deletedSubscription = Subscription.delete(subscription); - -// find a subscription -subscription = Subscription.find("nsub_60ca7690-4020-11e4-b789-4961958e51bd"); - -// ping a subscription by ID -Subscription.ping("nsub_60ca7690-4020-11e4-b789-4961958e51bd"); -// ping a subscription by subscription object -subscription = Subscription.find("nsub_60ca7690-4020-11e4-b789-4961958e51bd"); -Subscription.ping(subscription); - -// list subscriptions -SubscriptionCollection list = Subscription.list(); -while(list.hasNext()) { - Subscription sub = list.next(); - String appID = sub.getAppID(); - String serviceType = sub.getServiceType(); - List topics = sub.getTopics(); - String hubSecret = sub.getHubSecret(); -} - -// notification sent feed -NotificationCollection sent = Subscription.sentFeed(subscription.getId()); -while(sent.hasNext()) { - Notification notification = sent.next(); - String id = notification.getId(); - String topic = notification.getTopic(); - NotificationData data = notification.getData(); - String type = data.getType(); - // raw map representation of the payload - Map item = data.getItem(); -} - -// notification error feed -NotificationErrorCollection errors = Subscription.errorFeed(subscription.getId()); -while (errors.hasNext()) { - NotificationError notificationError = errors.next(); - RequestResponseCapture capture = notificationError.getCapture(); - URI requestURI = capture.getRequestURI(); - String requestMethod = capture.getRequestMethod(); - Map requestHeaders = capture.getRequestHeaders(); - String requestEntity = capture.getRequestEntity(); - int statusCode = capture.getResponseStatusCode(); - Map responseHeaders = capture.getResponseHeaders(); - String responseEntity = capture.getResponseEntity(); -} - -// consume a webhook notification -InputStream jsonStream = ...; -final Notification notification = Notification.readJSON(jsonStream); - -String jsonString = ...; -final Notification notification = Notification.readJSON(jsonString); -``` - -### Counts - -```java -// app totals -Counts.Totals totals = Counts.appTotals(); -System.out.println("companies: " + totals.getCompany().getValue()); -System.out.println("segments: :" + totals.getSegment().getValue()); -System.out.println("tags: :" + totals.getTag().getValue()); -System.out.println("users: :" + totals.getUser().getValue()); - -// conversation totals -Counts.Conversation conversationTotals = Counts.conversationTotals(); -System.out.println("assigned: " + conversationTotals.getAssigned()); -System.out.println("closed: :" + conversationTotals.getClosed()); -System.out.println("open: :" + conversationTotals.getOpen()); -System.out.println("unassigned: :" + conversationTotals.getUnassigned()); - -// admin open/close counts -Counts.Conversation adminCounts = Counts.conversationAdmins(); -List admins = adminCounts.getAdmins(); -for (Admin admin : admins) { - System.out.println(admin.getName() + ": " + admin.getClosed() + ", " + admin.getOpen()); -} - -// tag user counts -System.out.println("tag user counts: "); -List tags = Counts.userTags(); -for (Counts.CountItem tag : tags) { - System.out.println(tag.getName()+": " +tag.getValue()); -} - -// segment user counts -List segments = Counts.userSegments(); -for (Counts.CountItem segment : segments) { - System.out.println(segment.getName()+": " +segment.getValue()); -} - -// company user counts -List companyUsers = Counts.companyUsers(); -for (Counts.CountItem company : companyUsers) { - System.out.println(company.getName()+": " +company.getValue()); -} - -// company tag counts -List companyTags = Counts.companyTags(); -for (Counts.CountItem tag : companyTags) { - System.out.println(tag.getName()+": " +tag.getValue()); -} -``` - -## Idioms - -### HTTP requests - -To signal local versus remote methods, calls that result in HTTP requests are performed -using static methods, for example `User.find()`. The objects returned by static methods -are built from server responses. The exception to the static idiom is where the `next()`, -`hasNext()` and `nextPage()` methods on Collections are used to abstract over pagination. - -### Pagination - -Some API classes have static `list()` methods that correspond to paginated API responses. -These return a Collection object (eg `UserCollection`) which can be iterated in two - ways - -- The collection's `getPage()`, `hasNextPage()` and `nextPage()` methods - these are useful when you want to fetch one or just a few pages directly. - -- Java's inbuilt iterator methods `next()` and `hasNext()` - these are useful when you want to fetch data without manually handling pagination. - -- User and Contact listing only works up to 10k records. To retrieve all records use the Scroll API via `scroll()` - -### Error handling - -You do not need to deal with the HTTP response from an API call directly. -If there is an unsuccessful response then an IntercomException or a subclass -of IntercomException will be thrown. The exception will have Error objects - that can be examined via `getErrorCollection` and `getFirstError` for more detail. - -The API throws the following runtime exceptions - - -- AuthorizationException: for a 401 or 403 response -- InvalidException: for a 422 response or a local validation failure -- RateLimitException: for a 429 rate limit exceeded response -- ClientException: for a general 4xx response -- ServerException: for a 500 or 503 response -- IntercomException: general exception - -## Configuration - -### HTTP - -The client can be configured to accept any http stack that implements -`java.net.HttpURLConnection` by implementing the `HttpConnectorSupplier` - interface. - -For example, to use [OkHttp](https://square.github.io/okhttp/) as a connection -supplier, create a supplier class - - -```java -public class OkHttpSupplier implements HttpConnectorSupplier { - private final OkUrlFactory urlFactory; - - public OkHttpSupplier(OkUrlFactory urlFactory) { - this.urlFactory = urlFactory; - } - - @Override - public HttpURLConnection connect(URI uri) throws IOException { - return urlFactory.open(uri.toURL()); - } -} -``` - -and hand a supplier to the Intercom object - - -```java -final OkHttpClient client = new OkHttpClient(); -final OkUrlFactory factory = new OkUrlFactory(client); -final OkHttpSupplier supplier = new OkHttpSupplier(factory); -Intercom.setHttpConnectorSupplier(supplier); -``` - -#### Timeouts - -The default connection and request timeouts can be set in milliseconds using the -`Intercom.setConnectionTimeout` and `Intercom.setRequestTimeout` methods. - -### Target API Server - -The base URI to target can be changed for testing purposes - -```java -URI baseURI = new URI("https://example.org/server"); -Intercom.setApiBaseURI(baseURI); -``` diff --git a/build.gradle b/build.gradle index d7e82c26..d311e1f8 100644 --- a/build.gradle +++ b/build.gradle @@ -1,41 +1,51 @@ plugins { - id 'idea' - id 'signing' + id 'java-library' + id 'maven-publish' + id 'com.diffplug.spotless' version '6.11.0' } -subprojects { - repositories { +repositories { mavenCentral() - } - - ext { - jacksonVersion = '2.9.10' - jacksonDatabindVersion = "$jacksonVersion.8" - powermockVersion = '1.6.6' - } - - apply plugin: 'maven' - apply plugin: 'maven-publish' - apply plugin: 'java' - apply plugin: 'signing' - - sourceCompatibility = 1.7 - targetCompatibility = 1.7 - - //noinspection GroovyAssignabilityCheck - dependencies { - compile "com.fasterxml.jackson.core:jackson-core:$jacksonVersion" - compile "com.fasterxml.jackson.core:jackson-annotations:$jacksonVersion" - compile "com.fasterxml.jackson.core:jackson-databind:$jacksonDatabindVersion" - compile "com.google.guava:guava:17.0" - compile "org.slf4j:slf4j-api:2.0.17" - compile "commons-codec:commons-codec:1.18.0" - testCompile "junit:junit:4.13.2" - testCompile "org.powermock:powermock-module-junit4:$powermockVersion" - testCompile "org.powermock:powermock-api-mockito:$powermockVersion" - } + maven { + url 'https://s01.oss.sonatype.org/content/repositories/releases/' + } } -wrapper { - gradleVersion = '4.9' +dependencies { + api 'com.squareup.okhttp3:okhttp:4.12.0' + api 'com.fasterxml.jackson.core:jackson-databind:2.17.2' + api 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.17.2' + api 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.17.2' + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2' + testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.8.2' } + + +sourceCompatibility = 1.8 +targetCompatibility = 1.8 + +tasks.withType(Javadoc) { + failOnError false + options.addStringOption('Xdoclint:none', '-quiet') +} + +spotless { + java { + palantirJavaFormat() + } +} + + +java { + withSourcesJar() + withJavadocJar() +} + + +test { + useJUnitPlatform() + testLogging { + showStandardStreams = true + } +} + diff --git a/gradle.properties b/gradle.properties deleted file mode 100644 index 57c50ded..00000000 --- a/gradle.properties +++ /dev/null @@ -1,8 +0,0 @@ -version: 2.8.2 - -groupId: io.intercom - -modules: \ - intercom-java - -org.gradle.daemon: true diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 0d4a9516871afd710a9d84d89e31ba77745607bd..9bbc975c742b298b441bfb90dbc124400a3751b9 100644 GIT binary patch literal 43705 zcma&Obx`DOvL%eWOXJW;V64viP??$)@wHcsJ68)>bJS6*&iHnskXE8MjvIPVl|FrmV}Npeql07fCw6`pw`0s zGauF(<*@v{3t!qoUU*=j)6;|-(yg@jvDx&fV^trtZt27?4Tkn729qrItVh@PMwG5$ z+oXHSPM??iHZ!cVP~gYact-CwV`}~Q+R}PPNRy+T-geK+>fHrijpllon_F4N{@b-} z1M0=a!VbVmJM8Xk@NRv)m&aRYN}FSJ{LS;}2ArQ5baSjfy40l@T5)1r-^0fAU6f_} zzScst%$Nd-^ElV~H0TetQhMc%S{}Q4lssln=|;LG?Ulo}*mhg8YvBAUY7YFdXs~vv zv~{duzVw%C#GxkBwX=TYp1Dh*Uaum2?RmsvPaLlzO^fIJ`L?&OV?Y&kKj~^kWC`Ly zfL-}J^4a0Ojuz9O{jUbIS;^JatJ5+YNNHe}6nG9Yd6P-lJiK2ms)A^xq^H2fKrTF) zp!6=`Ece~57>^9(RA4OB9;f1FAhV%zVss%#rDq$9ZW3N2cXC7dMz;|UcRFecBm`DA z1pCO!#6zKp#@mx{2>Qcme8y$Qg_gnA%(`Vtg3ccwgb~D(&@y8#Jg8nNYW*-P{_M#E zZ|wCsQoO1(iIKd-2B9xzI}?l#Q@G5d$m1Lfh0q;iS5FDQ&9_2X-H)VDKA*fa{b(sV zL--krNCXibi1+*C2;4qVjb0KWUVGjjRT{A}Q*!cFmj0tRip2ra>WYJ>ZK4C|V~RYs z6;~+*)5F^x^aQqk9tjh)L;DOLlD8j+0<>kHc8MN|68PxQV`tJFbgxSfq-}b(_h`luA0&;Vk<@51i0 z_cu6{_*=vlvYbKjDawLw+t^H?OV00_73Cn3goU5?})UYFuoSX6Xqw;TKcrsc|r# z$sMWYl@cs#SVopO$hpHZ)cdU-+Ui%z&Sa#lMI~zWW@vE%QDh@bTe0&V9nL>4Et9`N zGT8(X{l@A~loDx}BDz`m6@tLv@$mTlVJ;4MGuj!;9Y=%;;_kj#o8n5tX%@M)2I@}u z_{I!^7N1BxW9`g&Z+K#lZ@7_dXdsqp{W9_`)zgZ=sD~%WS5s$`7z#XR!Lfy(4se(m zR@a3twgMs19!-c4jh`PfpJOSU;vShBKD|I0@rmv_x|+ogqslnLLOepJpPMOxhRb*i zGHkwf#?ylQ@k9QJL?!}MY4i7joSzMcEhrDKJH&?2v{-tgCqJe+Y0njl7HYff z{&~M;JUXVR$qM1FPucIEY(IBAuCHC@^~QG6O!dAjzQBxDOR~lJEr4KS9R*idQ^p{D zS#%NQADGbAH~6wAt}(1=Uff-1O#ITe)31zCL$e9~{w)gx)g>?zFE{Bc9nJT6xR!i8 z)l)~9&~zSZTHk{?iQL^MQo$wLi}`B*qnvUy+Y*jEraZMnEhuj`Fu+>b5xD1_Tp z)8|wedv42#3AZUL7x&G@p@&zcUvPkvg=YJS6?1B7ZEXr4b>M+9Gli$gK-Sgh{O@>q7TUg+H zNJj`6q#O@>4HpPJEHvNij`sYW&u%#=215HKNg;C!0#hH1vlO5+dFq9& zS)8{5_%hz?#D#wn&nm@aB?1_|@kpA@{%jYcs{K%$a4W{k@F zPyTav?jb;F(|GaZhm6&M#g|`ckO+|mCtAU)5_(hn&Ogd z9Ku}orOMu@K^Ac>eRh3+0-y^F`j^noa*OkS3p^tLV`TY$F$cPXZJ48!xz1d7%vfA( zUx2+sDPqHfiD-_wJDb38K^LtpN2B0w=$A10z%F9f_P2aDX63w7zDG5CekVQJGy18I zB!tI`6rZr7TK10L(8bpiaQ>S@b7r_u@lh^vakd0e6USWw7W%d_Ob%M!a`K>#I3r-w zo2^+9Y)Sb?P9)x0iA#^ns+Kp{JFF|$09jb6ZS2}_<-=$?^#IUo5;g`4ICZknr!_aJ zd73%QP^e-$%Xjt|28xM}ftD|V@76V_qvNu#?Mt*A-OV{E4_zC4Ymo|(cb+w^`Wv== z>)c%_U0w`d$^`lZQp@midD89ta_qTJW~5lRrIVwjRG_9aRiQGug%f3p@;*%Y@J5uQ|#dJ+P{Omc`d2VR)DXM*=ukjVqIpkb<9gn9{*+&#p)Ek zN=4zwNWHF~=GqcLkd!q0p(S2_K=Q`$whZ}r@ec_cb9hhg9a z6CE=1n8Q;hC?;ujo0numJBSYY6)GTq^=kB~`-qE*h%*V6-ip=c4+Yqs*7C@@b4YAi zuLjsmD!5M7r7d5ZPe>4$;iv|zq=9=;B$lI|xuAJwi~j~^Wuv!Qj2iEPWjh9Z&#+G>lZQpZ@(xfBrhc{rlLwOC;optJZDj4Xfu3$u6rt_=YY0~lxoy~fq=*L_&RmD7dZWBUmY&12S;(Ui^y zBpHR0?Gk|`U&CooNm_(kkO~pK+cC%uVh^cnNn)MZjF@l{_bvn4`Jc}8QwC5_)k$zs zM2qW1Zda%bIgY^3NcfL)9ug`05r5c%8ck)J6{fluBQhVE>h+IA&Kb}~$55m-^c1S3 zJMXGlOk+01qTQUFlh5Jc3xq|7McY$nCs$5=`8Y;|il#Ypb{O9}GJZD8!kYh{TKqs@ z-mQn1K4q$yGeyMcryHQgD6Ra<6^5V(>6_qg`3uxbl|T&cJVA*M_+OC#>w(xL`RoPQ zf1ZCI3G%;o-x>RzO!mc}K!XX{1rih0$~9XeczHgHdPfL}4IPi~5EV#ZcT9 zdgkB3+NPbybS-d;{8%bZW^U+x@Ak+uw;a5JrZH!WbNvl!b~r4*vs#he^bqz`W93PkZna2oYO9dBrKh2QCWt{dGOw)%Su%1bIjtp4dKjZ^ zWfhb$M0MQiDa4)9rkip9DaH0_tv=XxNm>6MKeWv>`KNk@QVkp$Lhq_~>M6S$oliq2 zU6i7bK;TY)m>-}X7hDTie>cc$J|`*}t=MAMfWIALRh2=O{L57{#fA_9LMnrV(HrN6 zG0K_P5^#$eKt{J|#l~U0WN_3)p^LLY(XEqes0OvI?3)GTNY&S13X+9`6PLVFRf8K) z9x@c|2T72+-KOm|kZ@j4EDDec>03FdgQlJ!&FbUQQH+nU^=U3Jyrgu97&#-W4C*;_ z(WacjhBDp@&Yon<9(BWPb;Q?Kc0gR5ZH~aRNkPAWbDY!FiYVSu!~Ss^9067|JCrZk z-{Rn2KEBR|Wti_iy) zXnh2wiU5Yz2L!W{{_#LwNWXeNPHkF=jjXmHC@n*oiz zIoM~Wvo^T@@t!QQW?Ujql-GBOlnB|HjN@x~K8z)c(X}%%5Zcux09vC8=@tvgY>czq z3D(U&FiETaN9aP}FDP3ZSIXIffq>M3{~eTB{uauL07oYiM=~K(XA{SN!rJLyXeC+Y zOdeebgHOc2aCIgC=8>-Q>zfuXV*=a&gp{l#E@K|{qft@YtO>xaF>O7sZz%8);e86? z+jJlFB{0fu6%8ew^_<+v>>%6eB8|t*_v7gb{x=vLLQYJKo;p7^o9!9A1)fZZ8i#ZU z<|E?bZakjkEV8xGi?n+{Xh3EgFKdM^;4D;5fHmc04PI>6oU>>WuLy6jgpPhf8$K4M zjJo*MbN0rZbZ!5DmoC^@hbqXiP^1l7I5;Wtp2i9Jkh+KtDJoXP0O8qmN;Sp(+%upX zAxXs*qlr(ck+-QG_mMx?hQNXVV~LT{$Q$ShX+&x?Q7v z@8t|UDylH6@RZ?WsMVd3B0z5zf50BP6U<&X_}+y3uJ0c5OD}+J&2T8}A%2Hu#Nt_4 zoOoTI$A!hQ<2pk5wfZDv+7Z{yo+Etqry=$!*pvYyS+kA4xnJ~3b~TBmA8Qd){w_bE zqDaLIjnU8m$wG#&T!}{e0qmHHipA{$j`%KN{&#_Kmjd&#X-hQN+ju$5Ms$iHj4r?) z&5m8tI}L$ih&95AjQ9EDfPKSmMj-@j?Q+h~C3<|Lg2zVtfKz=ft{YaQ1i6Om&EMll zzov%MsjSg=u^%EfnO+W}@)O6u0LwoX709h3Cxdc2Rwgjd%LLTChQvHZ+y<1q6kbJXj3_pq1&MBE{8 zd;aFotyW>4WHB{JSD8Z9M@jBitC1RF;!B8;Rf-B4nOiVbGlh9w51(8WjL&e{_iXN( zAvuMDIm_>L?rJPxc>S`bqC|W$njA0MKWa?V$u6mN@PLKYqak!bR!b%c^ze(M`ec(x zv500337YCT4gO3+9>oVIJLv$pkf`01S(DUM+4u!HQob|IFHJHm#>eb#eB1X5;bMc| z>QA4Zv}$S?fWg~31?Lr(C>MKhZg>gplRm`2WZ--iw%&&YlneQYY|PXl;_4*>vkp;I z$VYTZq|B*(3(y17#@ud@o)XUZPYN*rStQg5U1Sm2gM}7hf_G<>*T%6ebK*tF(kbJc zNPH4*xMnJNgw!ff{YXrhL&V$6`ylY={qT_xg9znQWw9>PlG~IbhnpsG_94Kk_(V-o&v7#F znra%uD-}KOX2dkak**hJnZZQyp#ERyyV^lNe!Qrg=VHiyr7*%j#PMvZMuYNE8o;JM zGrnDWmGGy)(UX{rLzJ*QEBd(VwMBXnJ@>*F8eOFy|FK*Vi0tYDw;#E zu#6eS;%Nm2KY+7dHGT3m{TM7sl=z8|V0e!DzEkY-RG8vTWDdSQFE|?+&FYA146@|y zV(JP>LWL;TSL6rao@W5fWqM1-xr$gRci#RQV2DX-x4@`w{uEUgoH4G|`J%H!N?*Qn zy~rjzuf(E7E!A9R2bSF|{{U(zO+;e29K_dGmC^p7MCP!=Bzq@}&AdF5=rtCwka zTT1A?5o}i*sXCsRXBt)`?nOL$zxuP3i*rm3Gmbmr6}9HCLvL*45d|(zP;q&(v%}S5yBmRVdYQQ24zh z6qL2<2>StU$_Ft29IyF!6=!@;tW=o8vNzVy*hh}XhZhUbxa&;9~woye<_YmkUZ)S?PW{7t; zmr%({tBlRLx=ffLd60`e{PQR3NUniWN2W^~7Sy~MPJ>A#!6PLnlw7O0(`=PgA}JLZ ztqhiNcKvobCcBel2 z-N82?4-()eGOisnWcQ9Wp23|ybG?*g!2j#>m3~0__IX1o%dG4b;VF@^B+mRgKx|ij zWr5G4jiRy}5n*(qu!W`y54Y*t8g`$YrjSunUmOsqykYB4-D(*(A~?QpuFWh;)A;5= zPl|=x+-w&H9B7EZGjUMqXT}MkcSfF}bHeRFLttu!vHD{Aq)3HVhvtZY^&-lxYb2%` zDXk7>V#WzPfJs6u{?ZhXpsMdm3kZscOc<^P&e&684Rc1-d=+=VOB)NR;{?0NjTl~D z1MXak$#X4{VNJyD$b;U~Q@;zlGoPc@ny!u7Pe;N2l4;i8Q=8>R3H{>HU(z z%hV2?rSinAg6&wuv1DmXok`5@a3@H0BrqsF~L$pRYHNEXXuRIWom0l zR9hrZpn1LoYc+G@q@VsFyMDNX;>_Vf%4>6$Y@j;KSK#g)TZRmjJxB!_NmUMTY(cAV zmewn7H{z`M3^Z& z2O$pWlDuZHAQJ{xjA}B;fuojAj8WxhO}_9>qd0|p0nBXS6IIRMX|8Qa!YDD{9NYYK z%JZrk2!Ss(Ra@NRW<7U#%8SZdWMFDU@;q<}%F{|6n#Y|?FaBgV$7!@|=NSVoxlJI4G-G(rn}bh|?mKkaBF$-Yr zA;t0r?^5Nz;u6gwxURapQ0$(-su(S+24Ffmx-aP(@8d>GhMtC5x*iEXIKthE*mk$` zOj!Uri|EAb4>03C1xaC#(q_I<;t}U7;1JqISVHz3tO{) zD(Yu@=>I9FDmDtUiWt81;BeaU{_=es^#QI7>uYl@e$$lGeZ~Q(f$?^3>$<<{n`Bn$ zn8bamZlL@6r^RZHV_c5WV7m2(G6X|OI!+04eAnNA5=0v1Z3lxml2#p~Zo57ri;4>;#16sSXXEK#QlH>=b$inEH0`G#<_ zvp;{+iY)BgX$R!`HmB{S&1TrS=V;*5SB$7*&%4rf_2wQS2ed2E%Wtz@y$4ecq4w<) z-?1vz_&u>s?BMrCQG6t9;t&gvYz;@K@$k!Zi=`tgpw*v-#U1Pxy%S9%52`uf$XMv~ zU}7FR5L4F<#9i%$P=t29nX9VBVv)-y7S$ZW;gmMVBvT$BT8d}B#XV^@;wXErJ-W2A zA=JftQRL>vNO(!n4mcd3O27bHYZD!a0kI)6b4hzzL9)l-OqWn)a~{VP;=Uo|D~?AY z#8grAAASNOkFMbRDdlqVUfB;GIS-B-_YXNlT_8~a|LvRMVXf!<^uy;)d$^OR(u)!) zHHH=FqJF-*BXif9uP~`SXlt0pYx|W&7jQnCbjy|8b-i>NWb@!6bx;1L&$v&+!%9BZ z0nN-l`&}xvv|wwxmC-ZmoFT_B#BzgQZxtm|4N+|;+(YW&Jtj^g!)iqPG++Z%x0LmqnF875%Ry&2QcCamx!T@FgE@H zN39P6e#I5y6Yl&K4eUP{^biV`u9{&CiCG#U6xgGRQr)zew;Z%x+ z-gC>y%gvx|dM=OrO`N@P+h2klPtbYvjS!mNnk4yE0+I&YrSRi?F^plh}hIp_+OKd#o7ID;b;%*c0ES z!J))9D&YufGIvNVwT|qsGWiZAwFODugFQ$VsNS%gMi8OJ#i${a4!E3<-4Jj<9SdSY z&xe|D0V1c`dZv+$8>(}RE|zL{E3 z-$5Anhp#7}oO(xm#}tF+W=KE*3(xxKxhBt-uuJP}`_K#0A< zE%rhMg?=b$ot^i@BhE3&)bNBpt1V*O`g?8hhcsV-n#=|9wGCOYt8`^#T&H7{U`yt2 z{l9Xl5CVsE=`)w4A^%PbIR6uG_5Ww9k`=q<@t9Bu662;o{8PTjDBzzbY#tL;$wrpjONqZ{^Ds4oanFm~uyPm#y1Ll3(H57YDWk9TlC zq;kebC!e=`FU&q2ojmz~GeLxaJHfs0#F%c(i+~gg$#$XOHIi@1mA72g2pFEdZSvp}m0zgQb5u2?tSRp#oo!bp`FP}< zaK4iuMpH+Jg{bb7n9N6eR*NZfgL7QiLxI zk6{uKr>xxJ42sR%bJ%m8QgrL|fzo9@?9eQiMW8O`j3teoO_R8cXPe_XiLnlYkE3U4 zN!^F)Z4ZWcA8gekEPLtFqX-Q~)te`LZnJK_pgdKs)Dp50 zdUq)JjlJeELskKg^6KY!sIou-HUnSFRsqG^lsHuRs`Z{f(Ti9eyd3cwu*Kxp?Ws7l z3cN>hGPXTnQK@qBgqz(n*qdJ2wbafELi?b90fK~+#XIkFGU4+HihnWq;{{)1J zv*Txl@GlnIMOjzjA1z%g?GsB2(6Zb-8fooT*8b0KF2CdsIw}~Hir$d3TdVHRx1m3c z4C3#h@1Xi@{t4zge-#B6jo*ChO%s-R%+9%-E|y<*4;L>$766RiygaLR?X%izyqMXA zb|N=Z-0PSFeH;W6aQ3(5VZWVC>5Ibgi&cj*c%_3=o#VyUJv* zM&bjyFOzlaFq;ZW(q?|yyi|_zS%oIuH^T*MZ6NNXBj;&yM3eQ7!CqXY?`7+*+GN47 zNR#%*ZH<^x{(0@hS8l{seisY~IE*)BD+R6^OJX}<2HRzo^fC$n>#yTOAZbk4%=Bei=JEe=o$jm`or0YDw*G?d> z=i$eEL7^}_?UI^9$;1Tn9b>$KOM@NAnvWrcru)r`?LodV%lz55O3y(%FqN;cKgj7t zlJ7BmLTQ*NDX#uelGbCY>k+&H*iSK?x-{w;f5G%%!^e4QT9z<_0vHbXW^MLR} zeC*jezrU|{*_F`I0mi)9=sUj^G03i@MjXx@ePv@(Udt2CCXVOJhRh4yp~fpn>ssHZ z?k(C>2uOMWKW5FVsBo#Nk!oqYbL`?#i~#!{3w^qmCto05uS|hKkT+iPrC-}hU_nbL zO622#mJupB21nChpime}&M1+whF2XM?prT-Vv)|EjWYK(yGYwJLRRMCkx;nMSpu?0 zNwa*{0n+Yg6=SR3-S&;vq=-lRqN`s9~#)OOaIcy3GZ&~l4g@2h| zThAN#=dh{3UN7Xil;nb8@%)wx5t!l z0RSe_yJQ+_y#qEYy$B)m2yDlul^|m9V2Ia$1CKi6Q19~GTbzqk*{y4;ew=_B4V8zw zScDH&QedBl&M*-S+bH}@IZUSkUfleyM45G>CnYY{hx8J9q}ME?Iv%XK`#DJRNmAYt zk2uY?A*uyBA=nlYjkcNPMGi*552=*Q>%l?gDK_XYh*Rya_c)ve{=ps`QYE0n!n!)_$TrGi_}J|>1v}(VE7I~aP-wns#?>Y zu+O7`5kq32zM4mAQpJ50vJsUDT_^s&^k-llQMy9!@wRnxw@~kXV6{;z_wLu3i=F3m z&eVsJmuauY)8(<=pNUM5!!fQ4uA6hBkJoElL1asWNkYE#qaP?a+biwWw~vB48PRS7 zY;DSHvgbIB$)!uJU)xA!yLE*kP0owzYo`v@wfdux#~f!dv#uNc_$SF@Qq9#3q5R zfuQnPPN_(z;#X#nRHTV>TWL_Q%}5N-a=PhkQ^GL+$=QYfoDr2JO-zo#j;mCsZVUQ) zJ96e^OqdLW6b-T@CW@eQg)EgIS9*k`xr$1yDa1NWqQ|gF^2pn#dP}3NjfRYx$pTrb zwGrf8=bQAjXx*8?du*?rlH2x~^pXjiEmj^XwQo{`NMonBN=Q@Y21!H)D( zA~%|VhiTjaRQ%|#Q9d*K4j~JDXOa4wmHb0L)hn*;Eq#*GI}@#ux4}bt+olS(M4$>c z=v8x74V_5~xH$sP+LZCTrMxi)VC%(Dg!2)KvW|Wwj@pwmH6%8zd*x0rUUe$e(Z%AW z@Q{4LL9#(A-9QaY2*+q8Yq2P`pbk3!V3mJkh3uH~uN)+p?67d(r|Vo0CebgR#u}i? zBxa^w%U|7QytN%L9bKaeYhwdg7(z=AoMeP0)M3XZA)NnyqL%D_x-(jXp&tp*`%Qsx z6}=lGr;^m1<{;e=QQZ!FNxvLcvJVGPkJ63at5%*`W?46!6|5FHYV0qhizSMT>Zoe8 zsJ48kb2@=*txGRe;?~KhZgr-ZZ&c0rNV7eK+h$I-UvQ=552@psVrvj#Ys@EU4p8`3 zsNqJu-o=#@9N!Pq`}<=|((u)>^r0k^*%r<{YTMm+mOPL>EoSREuQc-e2~C#ZQ&Xve zZ}OUzmE4{N-7cqhJiUoO_V#(nHX11fdfVZJT>|6CJGX5RQ+Ng$Nq9xs-C86-)~`>p zW--X53J`O~vS{WWjsAuGq{K#8f#2iz` zzSSNIf6;?5sXrHig%X(}0q^Y=eYwvh{TWK-fT>($8Ex>!vo_oGFw#ncr{vmERi^m7lRi%8Imph})ZopLoIWt*eFWSPuBK zu>;Pu2B#+e_W|IZ0_Q9E9(s@0>C*1ft`V{*UWz^K<0Ispxi@4umgGXW!j%7n+NC~* zBDhZ~k6sS44(G}*zg||X#9Weto;u*Ty;fP!+v*7be%cYG|yEOBomch#m8Np!Sw`L)q+T` zmrTMf2^}7j=RPwgpO9@eXfb{Q>GW#{X=+xt`AwTl!=TgYm)aS2x5*`FSUaaP_I{Xi zA#irF%G33Bw>t?^1YqX%czv|JF0+@Pzi%!KJ?z!u$A`Catug*tYPO`_Zho5iip0@! z;`rR0-|Ao!YUO3yaujlSQ+j-@*{m9dHLtve!sY1Xq_T2L3&=8N;n!!Eb8P0Z^p4PL zQDdZ?An2uzbIakOpC|d@=xEA}v-srucnX3Ym{~I#Ghl~JZU(a~Ppo9Gy1oZH&Wh%y zI=KH_s!Lm%lAY&`_KGm*Ht)j*C{-t}Nn71drvS!o|I|g>ZKjE3&Mq0TCs6}W;p>%M zQ(e!h*U~b;rsZ1OPigud>ej=&hRzs@b>>sq6@Yjhnw?M26YLnDH_Wt#*7S$-BtL08 zVyIKBm$}^vp?ILpIJetMkW1VtIc&7P3z0M|{y5gA!Yi5x4}UNz5C0Wdh02!h zNS>923}vrkzl07CX`hi)nj-B?#n?BJ2Vk0zOGsF<~{Fo7OMCN_85daxhk*pO}x_8;-h>}pcw26V6CqR-=x2vRL?GB#y%tYqi;J}kvxaz}*iFO6YO0ha6!fHU9#UI2Nv z_(`F#QU1B+P;E!t#Lb)^KaQYYSewj4L!_w$RH%@IL-M($?DV@lGj%3ZgVdHe^q>n(x zyd5PDpGbvR-&p*eU9$#e5#g3-W_Z@loCSz}f~{94>k6VRG`e5lI=SE0AJ7Z_+=nnE zTuHEW)W|a8{fJS>2TaX zuRoa=LCP~kP)kx4L+OqTjtJOtXiF=y;*eUFgCn^Y@`gtyp?n14PvWF=zhNGGsM{R- z^DsGxtoDtx+g^hZi@E2Y(msb-hm{dWiHdoQvdX88EdM>^DS#f}&kCGpPFDu*KjEpv$FZtLpeT>@)mf|z#ZWEsueeW~hF78Hu zfY9a+Gp?<)s{Poh_qdcSATV2oZJo$OH~K@QzE2kCADZ@xX(; z)0i=kcAi%nvlsYagvUp(z0>3`39iKG9WBDu3z)h38p|hLGdD+Khk394PF3qkX!02H z#rNE`T~P9vwNQ_pNe0toMCRCBHuJUmNUl)KFn6Gu2je+p>{<9^oZ4Gfb!)rLZ3CR3 z-o&b;Bh>51JOt=)$-9+Z!P}c@cKev_4F1ZZGs$I(A{*PoK!6j@ZJrAt zv2LxN#p1z2_0Ox|Q8PVblp9N${kXkpsNVa^tNWhof)8x8&VxywcJz#7&P&d8vvxn` zt75mu>yV=Dl#SuiV!^1BPh5R)`}k@Nr2+s8VGp?%Le>+fa{3&(XYi~{k{ z-u4#CgYIdhp~GxLC+_wT%I*)tm4=w;ErgmAt<5i6c~)7JD2olIaK8by{u-!tZWT#RQddptXRfEZxmfpt|@bs<*uh?Y_< zD>W09Iy4iM@@80&!e^~gj!N`3lZwosC!!ydvJtc0nH==K)v#ta_I}4Tar|;TLb|+) zSF(;=?$Z0?ZFdG6>Qz)6oPM}y1&zx_Mf`A&chb znSERvt9%wdPDBIU(07X+CY74u`J{@SSgesGy~)!Mqr#yV6$=w-dO;C`JDmv=YciTH zvcrN1kVvq|(3O)NNdth>X?ftc`W2X|FGnWV%s})+uV*bw>aoJ#0|$pIqK6K0Lw!@- z3pkPbzd`ljS=H2Bt0NYe)u+%kU%DWwWa>^vKo=lzDZHr>ruL5Ky&#q7davj-_$C6J z>V8D-XJ}0cL$8}Xud{T_{19#W5y}D9HT~$&YY-@=Th219U+#nT{tu=d|B)3K`pL53 zf7`I*|L@^dPEIDJkI3_oA9vsH7n7O}JaR{G~8 zfi$?kmKvu20(l`dV7=0S43VwVKvtF!7njv1Q{Ju#ysj=|dASq&iTE8ZTbd-iiu|2& zmll%Ee1|M?n9pf~?_tdQ<7%JA53!ulo1b^h#s|Su2S4r{TH7BRB3iIOiX5|vc^;5( zKfE1+ah18YA9o1EPT(AhBtve5(%GMbspXV)|1wf5VdvzeYt8GVGt0e*3|ELBhwRaO zE|yMhl;Bm?8Ju3-;DNnxM3Roelg`^!S%e({t)jvYtJCKPqN`LmMg^V&S z$9OIFLF$%Py~{l?#ReyMzpWixvm(n(Y^Am*#>atEZ8#YD&?>NUU=zLxOdSh0m6mL? z_twklB0SjM!3+7U^>-vV=KyQZI-6<(EZiwmNBzGy;Sjc#hQk%D;bay$v#zczt%mFCHL*817X4R;E$~N5(N$1Tv{VZh7d4mhu?HgkE>O+^-C*R@ zR0ima8PsEV*WFvz`NaB+lhX3&LUZcWWJJrG7ZjQrOWD%_jxv=)`cbCk zMgelcftZ%1-p9u!I-Zf_LLz{hcn5NRbxkWby@sj2XmYfAV?iw^0?hM<$&ZDctdC`; zsL|C-7d;w$z2Gt0@hsltNlytoPnK&$>ksr(=>!7}Vk#;)Hp)LuA7(2(Hh(y3LcxRY zim!`~j6`~B+sRBv4 z<#B{@38kH;sLB4eH2+8IPWklhd25r5j2VR}YK$lpZ%7eVF5CBr#~=kUp`i zlb+>Z%i%BJH}5dmfg1>h7U5Q(-F{1d=aHDbMv9TugohX5lq#szPAvPE|HaokMQIi_ zTcTNsO53(oX=hg2w!XA&+qP}nwr$(C)pgG8emS@Mf7m0&*kiA!wPLS`88c=aD$niJ zp?3j%NI^uy|5*MzF`k4hFbsyQZ@wu!*IY+U&&9PwumdmyfL(S0#!2RFfmtzD3m9V7 zsNOw9RQofl-XBfKBF^~~{oUVouka#r3EqRf=SnleD=r1Hm@~`y8U7R)w16fgHvK-6?-TFth)f3WlklbZh+}0 zx*}7oDF4U^1tX4^$qd%987I}g;+o0*$Gsd=J>~Uae~XY6UtbdF)J8TzJXoSrqHVC) zJ@pMgE#;zmuz?N2MIC+{&)tx=7A%$yq-{GAzyz zLzZLf=%2Jqy8wGHD;>^x57VG)sDZxU+EMfe0L{@1DtxrFOp)=zKY1i%HUf~Dro#8} zUw_Mj10K7iDsX}+fThqhb@&GI7PwONx!5z;`yLmB_92z0sBd#HiqTzDvAsTdx+%W{ z2YL#U=9r!@3pNXMp_nvximh+@HV3psUaVa-lOBekVuMf1RUd26~P*|MLouQrb}XM-bEw(UgQxMI6M&l3Nha z{MBcV=tl(b_4}oFdAo}WX$~$Mj-z70FowdoB{TN|h2BdYs?$imcj{IQpEf9q z)rzpttc0?iwopSmEoB&V!1aoZqEWEeO-MKMx(4iK7&Fhc(94c zdy}SOnSCOHX+A8q@i>gB@mQ~Anv|yiUsW!bO9hb&5JqTfDit9X6xDEz*mQEiNu$ay zwqkTV%WLat|Ar+xCOfYs0UQNM`sdsnn*zJr>5T=qOU4#Z(d90!IL76DaHIZeWKyE1 zqwN%9+~lPf2d7)vN2*Q?En?DEPcM+GQwvA<#;X3v=fqsxmjYtLJpc3)A8~*g(KqFx zZEnqqruFDnEagXUM>TC7ngwKMjc2Gx%#Ll#=N4qkOuK|;>4%=0Xl7k`E69@QJ-*Vq zk9p5!+Ek#bjuPa<@Xv7ku4uiWo|_wy)6tIr`aO!)h>m5zaMS-@{HGIXJ0UilA7*I} z?|NZ!Tp8@o-lnyde*H+@8IHME8VTQOGh96&XX3E+}OB zA>VLAGW+urF&J{H{9Gj3&u+Gyn?JAVW84_XBeGs1;mm?2SQm9^!3UE@(_FiMwgkJI zZ*caE={wMm`7>9R?z3Ewg!{PdFDrbzCmz=RF<@(yQJ_A6?PCd_MdUf5vv6G#9Mf)i#G z($OxDT~8RNZ>1R-vw|nN699a}MQN4gJE_9gA-0%>a?Q<9;f3ymgoi$OI!=aE6Elw z2I`l!qe-1J$T$X&x9Zz#;3!P$I);jdOgYY1nqny-k=4|Q4F!mkqACSN`blRji>z1` zc8M57`~1lgL+Ha%@V9_G($HFBXH%k;Swyr>EsQvg%6rNi){Tr&+NAMga2;@85531V z_h+h{jdB&-l+%aY{$oy2hQfx`d{&?#psJ78iXrhrO)McOFt-o80(W^LKM{Zw93O}m z;}G!51qE?hi=Gk2VRUL2kYOBRuAzktql%_KYF4>944&lJKfbr+uo@)hklCHkC=i)E zE*%WbWr@9zoNjumq|kT<9Hm*%&ahcQ)|TCjp@uymEU!&mqqgS;d|v)QlBsE0Jw|+^ zFi9xty2hOk?rlGYT3)Q7i4k65@$RJ-d<38o<`}3KsOR}t8sAShiVWevR8z^Si4>dS z)$&ILfZ9?H#H&lumngpj7`|rKQQ`|tmMmFR+y-9PP`;-425w+#PRKKnx7o-Rw8;}*Ctyw zKh~1oJ5+0hNZ79!1fb(t7IqD8*O1I_hM;o*V~vd_LKqu7c_thyLalEF8Y3oAV=ODv z$F_m(Z>ucO(@?+g_vZ`S9+=~Msu6W-V5I-V6h7->50nQ@+TELlpl{SIfYYNvS6T6D z`9cq=at#zEZUmTfTiM3*vUamr!OB~g$#?9$&QiwDMbSaEmciWf3O2E8?oE0ApScg38hb&iN%K+kvRt#d))-tr^ zD+%!d`i!OOE3in0Q_HzNXE!JcZ<0;cu6P_@;_TIyMZ@Wv!J z)HSXAYKE%-oBk`Ye@W3ShYu-bfCAZ}1|J16hFnLy z?Bmg2_kLhlZ*?`5R8(1%Y?{O?xT)IMv{-)VWa9#1pKH|oVRm4!lLmls=u}Lxs44@g^Zwa0Z_h>Rk<(_mHN47=Id4oba zQ-=qXGz^cNX(b*=NT0<^23+hpS&#OXzzVO@$Z2)D`@oS=#(s+eQ@+FSQcpXD@9npp zlxNC&q-PFU6|!;RiM`?o&Sj&)<4xG3#ozRyQxcW4=EE;E)wcZ&zUG*5elg;{9!j}I z9slay#_bb<)N!IKO16`n3^@w=Y%duKA-{8q``*!w9SW|SRbxcNl50{k&CsV@b`5Xg zWGZ1lX)zs_M65Yt&lO%mG0^IFxzE_CL_6$rDFc&#xX5EXEKbV8E2FOAt>Ka@e0aHQ zMBf>J$FLrCGL@$VgPKSbRkkqo>sOXmU!Yx+Dp7E3SRfT`v~!mjU3qj-*!!YjgI*^) z+*05x78FVnVwSGKr^A|FW*0B|HYgc{c;e3Ld}z4rMI7hVBKaiJRL_e$rxDW^8!nGLdJ<7ex9dFoyj|EkODflJ#Xl`j&bTO%=$v)c+gJsLK_%H3}A_} z6%rfG?a7+k7Bl(HW;wQ7BwY=YFMSR3J43?!;#~E&)-RV_L!|S%XEPYl&#`s!LcF>l zn&K8eemu&CJp2hOHJKaYU#hxEutr+O161ze&=j3w12)UKS%+LAwbjqR8sDoZHnD=m0(p62!zg zxt!Sj65S?6WPmm zL&U9c`6G}T`irf=NcOiZ!V)qhnvMNOPjVkyO2^CGJ+dKTnNAPa?!AxZEpO7yL_LkB zWpolpaDfSaO-&Uv=dj7`03^BT3_HJOAjn~X;wz-}03kNs@D^()_{*BD|0mII!J>5p z1h06PTyM#3BWzAz1FPewjtrQfvecWhkRR=^gKeFDe$rmaYAo!np6iuio3>$w?az$E zwGH|zy@OgvuXok}C)o1_&N6B3P7ZX&-yimXc1hAbXr!K&vclCL%hjVF$yHpK6i_Wa z*CMg1RAH1(EuuA01@lA$sMfe*s@9- z$jNWqM;a%d3?(>Hzp*MiOUM*?8eJ$=(0fYFis!YA;0m8s^Q=M0Hx4ai3eLn%CBm14 zOb8lfI!^UAu_RkuHmKA-8gx8Z;##oCpZV{{NlNSe<i;9!MfIN!&;JI-{|n{(A19|s z9oiGesENcLf@NN^9R0uIrgg(46r%kjR{0SbnjBqPq()wDJ@LC2{kUu_j$VR=l`#RdaRe zxx;b7bu+@IntWaV$si1_nrQpo*IWGLBhhMS13qH zTy4NpK<-3aVc;M)5v(8JeksSAGQJ%6(PXGnQ-g^GQPh|xCop?zVXlFz>42%rbP@jg z)n)% zM9anq5(R=uo4tq~W7wES$g|Ko z1iNIw@-{x@xKxSXAuTx@SEcw(%E49+JJCpT(y=d+n9PO0Gv1SmHkYbcxPgDHF}4iY zkXU4rkqkwVBz<{mcv~A0K|{zpX}aJcty9s(u-$je2&=1u(e#Q~UA{gA!f;0EAaDzdQ=}x7g(9gWrWYe~ zV98=VkHbI!5Rr;+SM;*#tOgYNlfr7;nLU~MD^jSdSpn@gYOa$TQPv+e8DyJ&>aInB zDk>JmjH=}<4H4N4z&QeFx>1VPY8GU&^1c&71T*@2#dINft%ibtY(bAm%<2YwPL?J0Mt{ z7l7BR718o5=v|jB!<7PDBafdL>?cCdVmKC;)MCOobo5edt%RTWiReAMaIU5X9h`@El0sR&Z z7Ed+FiyA+QAyWn zf7=%(8XpcS*C4^-L24TBUu%0;@s!Nzy{e95qjgkzElf0#ou`sYng<}wG1M|L? zKl6ITA1X9mt6o@S(#R3B{uwJI8O$&<3{+A?T~t>Kapx6#QJDol6%?i-{b1aRu?&9B z*W@$T*o&IQ&5Kc*4LK_)MK-f&Ys^OJ9FfE?0SDbAPd(RB)Oju#S(LK)?EVandS1qb#KR;OP|86J?;TqI%E8`vszd&-kS%&~;1Als=NaLzRNnj4q=+ zu5H#z)BDKHo1EJTC?Cd_oq0qEqNAF8PwU7fK!-WwVEp4~4g z3SEmE3-$ddli))xY9KN$lxEIfyLzup@utHn=Q{OCoz9?>u%L^JjClW$M8OB`txg4r6Q-6UlVx3tR%%Z!VMb6#|BKRL`I))#g zij8#9gk|p&Iwv+4s+=XRDW7VQrI(+9>DikEq!_6vIX8$>poDjSYIPcju%=qluSS&j zI-~+ztl1f71O-B+s7Hf>AZ#}DNSf`7C7*)%(Xzf|ps6Dr7IOGSR417xsU=Rxb z1pgk9vv${17h7mZ{)*R{mc%R=!i}8EFV9pl8V=nXCZruBff`$cqN3tpB&RK^$yH!A8RL zJ5KltH$&5%xC7pLZD}6wjD2-uq3&XL8CM$@V9jqalF{mvZ)c4Vn?xXbvkB(q%xbSdjoXJXanVN@I;8I`)XlBX@6BjuQKD28Jrg05} z^ImmK-Ux*QMn_A|1ionE#AurP8Vi?x)7jG?v#YyVe_9^up@6^t_Zy^T1yKW*t* z&Z0+0Eo(==98ig=^`he&G^K$I!F~1l~gq}%o5#pR6?T+ zLmZu&_ekx%^nys<^tC@)s$kD`^r8)1^tUazRkWEYPw0P)=%cqnyeFo3nW zyV$^0DXPKn5^QiOtOi4MIX^#3wBPJjenU#2OIAgCHPKXv$OY=e;yf7+_vI7KcjKq% z?RVzC24ekYp2lEhIE^J$l&wNX0<}1Poir8PjM`m#zwk-AL0w6WvltT}*JN8WFmtP_ z6#rK7$6S!nS!}PSFTG6AF7giGJw5%A%14ECde3x95(%>&W3zUF!8x5%*h-zk8b@Bz zh`7@ixoCVCZ&$$*YUJpur90Yg0X-P82>c~NMzDy7@Ed|6(#`;{)%t7#Yb>*DBiXC3 zUFq(UDFjrgOsc%0KJ_L;WQKF0q!MINpQzSsqwv?#Wg+-NO; z84#4nk$+3C{2f#}TrRhin=Erdfs77TqBSvmxm0P?01Tn@V(}gI_ltHRzQKPyvQ2=M zX#i1-a(>FPaESNx+wZ6J{^m_q3i})1n~JG80c<%-Ky!ZdTs8cn{qWY%x%X^27-Or_ z`KjiUE$OG9K4lWS16+?aak__C*)XA{ z6HmS*8#t_3dl}4;7ZZgn4|Tyy1lOEM1~6Qgl(|BgfQF{Mfjktch zB5kc~4NeehRYO%)3Z!FFHhUVVcV@uEX$eft5Qn&V3g;}hScW_d)K_h5i)vxjKCxcf zL>XlZ^*pQNuX*RJQn)b6;blT3<7@Ap)55)aK3n-H08GIx65W zO9B%gE%`!fyT`)hKjm-&=on)l&!i-QH+mXQ&lbXg0d|F{Ac#U;6b$pqQcpqWSgAPo zmr$gOoE*0r#7J=cu1$5YZE%uylM!i3L{;GW{ae9uy)+EaV>GqW6QJ)*B2)-W`|kLL z)EeeBtpgm;79U_1;Ni5!c^0RbG8yZ0W98JiG~TC8rjFRjGc6Zi8BtoC);q1@8h7UV zFa&LRzYsq%6d!o5-yrqyjXi>jg&c8bu}{Bz9F2D(B%nnuVAz74zmBGv)PAdFXS2(A z=Z?uupM2f-ar0!A)C6l2o8a|+uT*~huH)!h3i!&$ zr>76mt|lwexD(W_+5R{e@2SwR15lGxsnEy|gbS-s5?U}l*kcfQlfnQKo5=LZXizrL zM=0ty+$#f_qGGri-*t@LfGS?%7&LigUIU#JXvwEdJZvIgPCWFBTPT`@Re5z%%tRDO zkMlJCoqf2A=hkU7Ih=IxmPF~fEL90)u76nfFRQwe{m7b&Ww$pnk~$4Lx#s9|($Cvt ze|p{Xozhb^g1MNh-PqS_dLY|Fex4|rhM#lmzq&mhebD$5P>M$eqLoV|z=VQY{)7&sR#tW zl(S1i!!Rrg7kv+V@EL51PGpm511he%MbX2-Jl+DtyYA(0gZyZQjPZP@`SAH{n&25@ zd)emg(p2T3$A!Nmzo|%=z%AhLX)W4hsZNFhmd4<1l6?b3&Fg)G(Zh%J{Cf8Q;?_++ zgO7O<(-)H|Es@QqUgcXNJEfC-BCB~#dhi6ADVZtL!)Mx|u7>ukD052z!QZ5UC-+rd zYXWNRpCmdM{&?M9OMa;OiN{Y#0+F>lBQ=W@M;OXq;-7v3niC$pM8p!agNmq7F04;| z@s-_98JJB&s`Pr6o$KZ=8}qO*7m6SMp7kVmmh$jfnG{r@O(auI7Z^jj!x}NTLS9>k zdo}&Qc2m4Ws3)5qFw#<$h=g%+QUKiYog33bE)e4*H~6tfd42q+|FT5+vmr6Y$6HGC zV!!q>B`1Ho|6E|D<2tYE;4`8WRfm2#AVBBn%_W)mi(~x@g;uyQV3_)~!#A6kmFy0p zY~#!R1%h5E{5;rehP%-#kjMLt*{g((o@0-9*8lKVu+t~CtnOxuaMgo2ssI6@kX09{ zkn~q8Gx<6T)l}7tWYS#q0&~x|-3ho@l}qIr79qOJQcm&Kfr7H54=BQto0)vd1A_*V z)8b2{xa5O^u95~TS=HcJF5b9gMV%&M6uaj<>E zPNM~qGjJ~xbg%QTy#(hPtfc46^nN=Y_GmPYY_hTL{q`W3NedZyRL^kgU@Q$_KMAjEzz*eip`3u6AhPDcWXzR=Io5EtZRPme>#K9 z4lN&87i%YYjoCKN_z9YK+{fJu{yrriba#oGM|2l$ir017UH86Eoig3x+;bz32R*;n zt)Eyg#PhQbbGr^naCv0?H<=@+Poz)Xw*3Gn00qdSL|zGiyYKOA0CP%qk=rBAlt~hr zEvd3Z4nfW%g|c`_sfK$z8fWsXTQm@@eI-FpLGrW<^PIjYw)XC-xFk+M<6>MfG;WJr zuN}7b;p^`uc0j(73^=XJcw;|D4B(`)Flm|qEbB?>qBBv2V?`mWA?Q3yRdLkK7b}y& z+!3!JBI{+&`~;%Pj#n&&y+<;IQzw5SvqlbC+V=kLZLAHOQb zS{{8E&JXy1p|B&$K!T*GKtSV^{|Uk;`oE*F;?@q1dX|>|KWb@|Dy*lbGV0Gx;gpA$ z*N16`v*gQ?6Skw(f^|SL;;^ox6jf2AQ$Zl?gvEV&H|-ep*hIS@0TmGu1X1ZmEPY&f zKCrV{UgRAiNU*=+Uw%gjIQhTAC@67m)6(_D+N>)(^gK74F%M2NUpWpho}aq|Kxh$3 zz#DWOmQV4Lg&}`XTU41Z|P~5;wN2c?2L{a=)Xi~!m#*=22c~&AW zgG#yc!_p##fI&E{xQD9l#^x|9`wSyCMxXe<3^kDIkS0N>=oAz7b`@M>aT?e$IGZR; zS;I{gnr4cS^u$#>D(sjkh^T6_$s=*o%vNLC5+6J=HA$&0v6(Y1lm|RDn&v|^CTV{= zjVrg_S}WZ|k=zzp>DX08AtfT@LhW&}!rv^);ds7|mKc5^zge_Li>FTNFoA8dbk@K$ zuuzmDQRL1leikp%m}2_`A7*7=1p2!HBlj0KjPC|WT?5{_aa%}rQ+9MqcfXI0NtjvXz1U)|H>0{6^JpHspI4MfXjV%1Tc1O!tdvd{!IpO+@ z!nh()i-J3`AXow^MP!oVLVhVW&!CDaQxlD9b|Zsc%IzsZ@d~OfMvTFXoEQg9Nj|_L zI+^=(GK9!FGck+y8!KF!nzw8ZCX>?kQr=p@7EL_^;2Mlu1e7@ixfZQ#pqpyCJ```(m;la2NpJNoLQR};i4E;hd+|QBL@GdQy(Cc zTSgZ)4O~hXj86x<7&ho5ePzDrVD`XL7{7PjjNM1|6d5>*1hFPY!E(XDMA+AS;_%E~ z(dOs)vy29&I`5_yEw0x{8Adg%wvmoW&Q;x?5`HJFB@KtmS+o0ZFkE@f)v>YYh-z&m z#>ze?@JK4oE7kFRFD%MPC@x$^p{aW}*CH9Y_(oJ~St#(2)4e-b34D>VG6giMGFA83 zpZTHM2I*c8HE}5G;?Y7RXMA2k{Y?RxHb2 zZFQv?!*Kr_q;jt3`{?B5Wf}_a7`roT&m1BN9{;5Vqo6JPh*gnN(gj}#=A$-F(SRJj zUih_ce0f%K19VLXi5(VBGOFbc(YF zLvvOJl+W<}>_6_4O?LhD>MRGlrk;~J{S#Q;Q9F^;Cu@>EgZAH=-5fp02(VND(v#7n zK-`CfxEdonk!!65?3Ry(s$=|CvNV}u$5YpUf?9kZl8h@M!AMR7RG<9#=`_@qF@})d ztJDH>=F!5I+h!4#^DN6C$pd6^)_;0Bz7|#^edb9_qFg&eI}x{Roovml5^Yf5;=ehZ zGqz-x{I`J$ejkmGTFipKrUbv-+1S_Yga=)I2ZsO16_ye@!%&Op^6;#*Bm;=I^#F;? z27Sz-pXm4x-ykSW*3`)y4$89wy6dNOP$(@VYuPfb97XPDTY2FE{Z+{6=}LLA23mAc zskjZJ05>b)I7^SfVc)LnKW(&*(kP*jBnj>jtph`ZD@&30362cnQpZW8juUWcDnghc zy|tN1T6m?R7E8iyrL%)53`ymXX~_;#r${G`4Q(&7=m7b#jN%wdLlS0lb~r9RMdSuU zJ{~>>zGA5N`^QmrzaqDJ(=9y*?@HZyE!yLFONJO!8q5Up#2v>fR6CkquE$PEcvw5q zC8FZX!15JgSn{Gqft&>A9r0e#be^C<%)psE*nyW^e>tsc8s4Q}OIm})rOhuc{3o)g1r>Q^w5mas) zDlZQyjQefhl0PmH%cK05*&v{-M1QCiK=rAP%c#pdCq_StgDW}mmw$S&K6ASE=`u4+ z5wcmtrP27nAlQCc4qazffZoFV7*l2=Va}SVJD6CgRY^=5Ul=VYLGqR7H^LHA;H^1g}ekn=4K8SPRCT+pel*@jUXnLz+AIePjz@mUsslCN2 z({jl?BWf&DS+FlE5Xwp%5zXC7{!C=k9oQLP5B;sLQxd`pg+B@qPRqZ6FU(k~QkQu{ zF~5P=kLhs+D}8qqa|CQo2=cv$wkqAzBRmz_HL9(HRBj&73T@+B{(zZahlkkJ>EQmQ zenp59dy+L;sSWYde!z_W+I~-+2Xnm;c;wI_wH=RTgxpMlCW@;Us*0}L74J#E z8XbDWJGpBscw?W$&ZxZNxUq(*DKDwNzW7_}AIw$HF6Ix|;AJ3t6lN=v(c9=?n9;Y0 zK9A0uW4Ib9|Mp-itnzS#5in=Ny+XhGO8#(1_H4%Z6yEBciBiHfn*h;^r9gWb^$UB4 zJtN8^++GfT`1!WfQt#3sXGi-p<~gIVdMM<#ZZ0e_kdPG%Q5s20NNt3Jj^t$(?5cJ$ zGZ#FT(Lt>-0fP4b5V3az4_byF12k%}Spc$WsRydi&H|9H5u1RbfPC#lq=z#a9W(r1 z!*}KST!Yhsem0tO#r!z`znSL-=NnP~f(pw-sE+Z$e7i7t9nBP^5ts1~WFmW+j+<@7 zIh@^zKO{1%Lpx^$w8-S+T_59v;%N;EZtJzcfN%&@(Ux5 z@YzX^MwbbXESD*d(&qT7-eOHD6iaH-^N>p2sVdq&(`C$;?#mgBANIc5$r| z^A$r)@c{Z}N%sbfo?T`tTHz9-YpiMW?6>kr&W9t$Cuk{q^g1<$I~L zo++o2!!$;|U93cI#p4hyc!_Mv2QKXxv419}Ej#w#%N+YIBDdnn8;35!f2QZkUG?8O zpP47Wf9rnoI^^!9!dy~XsZ&!DU4bVTAi3Fc<9$_krGR&3TI=Az9uMgYU5dd~ksx+} zP+bs9y+NgEL>c@l>H1R%@>5SWg2k&@QZL(qNUI4XwDl6(=!Q^U%o984{|0e|mR$p+ z9BcwttR#7?As?@Q{+j?K6H7R71PuiA^Dl$=f47nUKL|koCwutc_P<-m{|Al3C~o7w z=4S=}s5LcJFT1zjS)+10X_r$74`K78pz!nGGH%JV%w75!YSIt#hT7}}K>+@{{a+Im z5p#6%^X*txY?}|T17xWW*sa^?G2QHt#@tlcw0GIcy;|NR2vaCBDvn=`h)1il7E5Rx z%)mA4$`$OZx)NF5vXZnaJ1)*cA6ryx6Ll~t!LzhxvcTedxT;>JS&e=?-&DXUPaQ2~ zH*69ezE`hgV{K-|0z|m~ld}=X^-Ob={wpex&}*+Rz{gx)G}gn!C_VN{UN=>^EV=Xc zr$-HO09cW&p4^M}V3yBjTP_xrVcc8iU_^Y-JD~(bgw*@GXGB1gYKz5DWO+O`>})|N zWrC)MR93yA)3{&27-M)TJB6Ml3~?zZg#mYsF=#OSTaw&K z@hBftpt+2l@)YK@|3DvTjl(8wZtpLp9Ik!6G$CSL_idZ$Ti?R)4toe8bb)l|)lNb}?K;O2K9vyn1QG zd=v#y-Ld49UVkmfRU>Egc+(Y$^-;6vW;3Lcu*6~etz}0|@+b|+!UCal)DEYGLbHWJ zll5Wi^$Y<6@S%^y%hdjRh6&{!z1Py|lZ|q&Wub3l41uN2zEF8E&5H5?PL*&V}?*a}Lp% zCYi{ghjpRNT^^B+_U59No50Ghih5qn(W5`RkrsDWr{~A1dgtv{sRkH4RU2^A{jb&0 zxVRnrm|u<;$iI;M6A>$POP)TWGU-gSjAERk*EGmVT(aw$!XUSe~7Ql-oRA54^4V(JWS6Q1mG?!vZ zx+pE!FEtvqr|Xrcb3oR`%LHFLmU_&{=p%mGy6MRe2Yz_5WJ8p@IgU2 zdVvvhhQtiQkChK%*&PsiPCBL9oDOoJX8!$S(V>R}+1M}wzK*U*A{KJ`r=lM;mPrKU zQDqqN(W*u-5-?$(SIk<6A0E}34y&@-IVC%S!a1F4kz<3bIKjlyD)ooO_7ftl%S_(6w`!vX&1PZ!K`@D@L6JR)6zO@Dl!YF{RY}d3HZ7?Q5E>w=$ ze)H_)48Ds*Ov4?zoGb2fe3}{!5Ooc|KCIni1o)(Gj+CO?`*7jsV`hIv@8J(22o4Q? zu?Bvi)zDG(me?7XKeL|iF9ZRgZdT*}Ffsl62Cu;{Gv9j6dO zPt*H2GqC)-C`V`ceuu=tM{7!2yTEj=*5+T~5DYiZ)Hy)*PARYI6R2lZXoOj;v8M4W z*O-NX(7_~Q&A3>Oaw&1lBH_H%SwmISX-i3)HfHvBOeVwTT{LUM3}ZuZmg<(>)KE;d zbs2!0v6>J;1nQ0UJkUxnkE@Ibi~Q}M=-=Rk;hcOnxO$luOKEVxZc|!XECgex(2`}T z3Y;Q_6rL)e+SrOZhQj5_e}Lv>w7n*Pep$yWZNQl>ubBgb_NIWWDn3kNpn+MPQXV;8 zV|_Ba5jsQ(w&Ey^IM|@|y!AqcJ#3m0#Q6_qvgCG~eoF#mnGmbO(;DP+bW%_aOs1R_ z@9p#7X2UA^--#Nwx_Hvk2l1`eO{P*#j@q2UELtH|Uh6hxR`h_847wIJo0=5CQQ`6it|%a-I$^&a@we1rc&*;QIu5Ck^?) zx*5eSd*mG#=6Hi(5!;5uUi&{HfnT1S8X-)?gE5CZ6KWoqM5|CyrULmuFBKOU8SOp* z{IB1$OCcq`S-k*xs;4fmhKsIGZ;GYAY*%(@875NxhMq|j*m4CNLI(Vho|N|F);!E0cS5y^$H^Izje?z}oTgyr`9x9G&rlJZw&uqIoBMtz zzhU0(9;w02?m#0!)cFi*r+8YvooQ;(s2lLVvyLqAE%Xqe!vtWbIs!l1Bpp(FIht-Z zPn#CN-2C|J*GhA2fuHqYQ2mJiXlGTzD}mkr2;ia8Wp}h^;OS7+N^Mw|en!1${vN6 z-x{8N*4UekA~`IV2&K-GzhAqau|}d*pEQ$1MH$cFi03OG^1NetZ_jW^STaEzr&Xho zB452St%v3ez2#TFm~`gZh$vi=in+y2d!z<{OZ~Kty-5bQ;0O=k_ESi8Nx9{*T`LJy6jqR>&|+>OZ;+=0hA04 zE25t^sE9HG)3^KKR_A5WDkqispweP9!I-@dCO&N!JrD@i{WBHnfQ z95o8;d$`AFnca3;N-0iX-CmbbAp5yQ!GoH;h7Cn?m{ammZJI8igP{U73lFnl2&gCs zqJ4(Vo~^j`{zOAzScL5B_Sm?Mjtek1d(A6X5ObcZi$;aOYy|g$}BY z$GEP3#i60Ju_&3SHzryH!gUFwC9-295u??cf+aYRQ1$+!rc#42YNattd6mZEFI@?C zqFM>6+zxEunIHDZ>{Z15u##>N(28Dw!>G(k*dB{NHvip@aP}f`@=Q;!o;zRMWo{Cx zo?kyzh8n7#f1g0&g>Cd>O-2g?uPwy8sy8hZbHSsXPmU;@l=HL=zm7mN(=@*|D$i+u zs~TllkCTvD$f&-#b9B?}#Lg*-ibK13R_a$RyoN3m5`10tdhAq{+VW)K#Bht-ra1*J z+n$N%V>u0rVtx`aKJDwXXrxaD7nS<>$=c82v7@KVx^S@vT;h=SZE37K>iahpx3;VDzEr9GY=2(%uaqM;^76eSP0QLzo4sI z>p_Eei*T$K;|qK`sq;?Hesp}(@VvX2Q4sAMYAJ}b&d$htDMC{FG-$o4k9ApECi1$a zXdamjiOGKHBh(4M<3(2x6n-CrmZMCknkQxdSS!qlis#I}btfX;J`JU3RlvtLdrymP zG0ZzrsGXVFiq+Wk1=BFay&9ZiCE#(`h~CL+c-Hs@iGTU@YxM%vlg;)`Tf~IknA^02 zXkN#Txo6aR{j$wP5T#|UH#5AP2{rSY8p?jKFv zG3kn3y`FaV!*Jq%m39_TQEhD>M@l*bhEPGe1{ft3q#K5AknT=F2_=T^l#ou5ln@D# z5Tzs(kRG@qNDa~HLNvfv7Z0g=bSlb?`QAx|Gfoni|iHJ%K0cy z;~Nsaa+{8HP_qrb{nj+xzkdYhSI@W4N_1`z(eSGIkbDP)!Ko|M%}Rqp(~KI2hl~eE zvJ!j4m6iwMgKy>fkCLC)`M$z9EV}B+sq1}}kVf$(ig0pWTY?rHz1Sm=4srTGNb^JG z=2$9wz-C@aZZZ2!HY#HNejqZRmE=pN(D$Kui$NpfhU`!y_s{@MIxiJdHb1|{6xb`> zE74_@QtgtG{4=3P1$^vn&m}7Aw8!1DnT$2thO#~44wl(N#ao8S0@t@m+Z!KD2CfK; z)n5DAPKV_etmH1aLDK$?`;sL91iVt$D z*SG}=-LIAg(*+JON!-5ivqOMQ1S!OQUgHglDsKik&Mwg;vva523`JwQH6SRz9eTY# zTIi23145~kc3r1mSWC_RzD%hs$S#!pkI9!BU80jJCJcwo*FZolQG$q`8C1d9pP@ND zG^&-ZraIvhg_FDVSfKGwkcI=avIan%2sK4coUs~Nr8jC*&!G0#?}_^s3r-c}-uAqi zM-Lw>Y}I``T;IS%Y|qH;s{F*ZefM!4{I5awr!K+T@uPd*Vu*iPWI}>(-D{zxsN>LG z=@747a_Rb2>q?y8xYf?dq2HM5tFO8Y5e4N;Y=xy8yAhI zsm>oy%R5;7)7T3V_b2%`aH^tNlsQpFxIFW#iV#8?{6{^cGr{A0@1bA)|K z>MMTuZD(pd2t|7vmHtywGXb%%=)S<`OG~}U+jm#xd%H8 z$v8-C%F?ah3$;hn?{G3(LT!SgvCVi$vwsZssAQvUwT`Q%qSw!LSd!(I!64w1=%Sc1Mck)q1@pZ@)=SY zoX}d+L3-RA|c?G3_BQNm&( z!i$AZ7cI(z7q|e9VM##6T3Xorj1JG(9os$;(I$y%mBy(#8{|3l4|x*oBAQL^XhZ0g zy1FR1teRrpKq{uLAibTLx#n({qwjlkOvR{OdSAeT5ah4-sNN)n4Clg1T9lzF)&yj; zyal1%+s4n1IG;^VPWJ;#olpk8Z42Gj-tjFeQ&PlxB)`oCNoUYKj4U$AeG8rYiD{pK zndDf&2;2;)D|KvOZP+e7fcPU9k4M2sfhr@vC~Ly0?S-4dz)ZGAYpCsAhChgbxLd4g zhTrbIPkO5SEp_kD>Ha0m12h5n3s;mE8kn515&nzSf+^D= zyE{JnJ;43l&BH55CL<=W%CF;6iUI)V5C*6!`**KqvzR2=Fj*3Y4`HYwx}TYD445(K z-QtXwtL?m*(F=LVH*H4oM>dXHBW=38q_dZ-_Vr&qpEPxd9Fs95P5W~@Z|Rt+WZP6l zPSQ}~Dh4V?Pp1g&Hk*Px?lm16C@X6M29Vrk%Rw@E||E-v~$ zb_E~{z<}#8i`Mx9mkqtd#Z1lZ-E_J8I+2oumc#x1)jdvh{W76NKm6x-RYpM~v!P8$ zw3e|YVf|}Hse9~oC@N7^j}Fi$hNpyaYnu1}bdXsD=^oI*%WKvbme|BI}$G3>smu#6y)ls|j? zF7Bhu9Z)j)C;3cZb+I>0stSK^WLOYV^U{pUYkgv>?+Nt^5j*CUB=eGw-CvU&40>y~ zGoHLXxY^7k5Xgv62{iQy|5jJQuq0|LU`}lE@flQ2Z*Zn*VWcQjm4FTb>LSVox^S4q zLn`LfS@mrjKCmg$nb^af?d?0&$aX6#2u(JyzIJvuJ*lwPrh|0~aEnSACCTezSdG%h zmSQg`17j@$Iq)r1&?+eR@1nlX|H`<}_!?BQSF&N+QQnvEAqZe+mIFui!0V49R?|9*$ zv!K1A01{8xq;L()Tv*Qk0-$Oj6+vCT*TUD{HvxO@3JjxBwM!4g3ydy&eaJw4CoQBF zJtULJ!YxgNR7_Ls%LmogyI7uIs=!B&?=MYY^yX+v;j@D_xGeZg>eZk0C;4e|HRNSi z6KlD9>q=3v-$4Zik&^ZDhNm1X)+7LCH1k!s+T3tn zUn@={1U&NJLq@K?~w|(=Y<4W{ucX}FdRr6pLw(l2$iK)At%t3gYBMlJz#(K0Nqm;=KAML!&MMSNz=%k=j*zh77r34Rs37iCY` z=_kva_41bdrj(b=4Wc5MO0~q^z#pIWJ>)vDSgIQF=3JVJe1iDy%h)8oNy{s_r&;m` zL{DYKSB_5xRb9xKNOS{qAY3qv5sSXVrrf%~*q5HO|CQ&lbKMePa$M5D{vlJcoGrCZ zD?fKbZN$6rWwz)w7`9h4DAmh1ij2}EO|bO#A9L0_RW6l*$sPPUJrUbhLC75L9%W5iO$Iw5~Yut-qBeu~hF|xD7-eQ%l z412vpq_;t%^F*pYDk%Q35c-erK|6Ve=FxQbAv~ikZ4c9$Y4;ee#ciOD9{yRqf55Qk zumv}#+JciT|Gj$uFOxBUze)=?l{B}qaC0_7m`t82<$K53!4Xvi9Tr)ADp3Off?O8o zVDG0Yx|tfn@r((m?Nxrh(b0DGjg)$;DfO&$6uY;4&F!4jnxkhP}Y3x zS?WFFt>=HWzqlQhffVfvM$Ta8Sg*r3j!Eo&rUOW7SCL2~lG7<+XZ;+{&8h5g8ElI+P>>yR2U%S93NN!Xhm|C682t6ysH-=o1=Bd*N*VlnG%l+KZFtjG`UkL;%65qn0UYQ`h zh0{9jDQx(`aBe7J0Aj3Z)4}`A|4OMM0a;?{j}qkYwi)~O8$9D}ITiMH2buiU>ixYp zhL${nwj6X($*OwmpVG`y5b6v45tX*J8?og}Qju6eJ9H}`X87iEd%BUo7<`2q(HJx+ zMR}d-J4oAf{V1W^a2~`M-YAdZ81dd4o6NPO{cmZaAS@RS4ir#Sr zfFZO-VIL|VN<%nEXr2` z$0FK2L#8O_f1w~c@G70JrB@N}r(gJ!Vmkk6{r68w!o$qO?HrFcjeU0_3F5;*!E2%( zTx>4?gP8w z1B?3UVZmz^%d_dIps>>0{cB~mp3{9UoPR6uQFecVq&} zY{ebB?AlPAD_}(ll{fK99;Wh1cgRbnw)maD^F>*J!R}eHM*W0VYN1TADWMy9H=$00 z5bHY${oDgwX7(W9LZw?}{!8(_{JB~Xkje6{0x4fgC4kUmpfJ+LT1DYD*TWu4#h{Y7 zFLronmc=hS=W=j1ar3r1JNjQoWo2hMWsqW*e?TF%#&{GpsaLp}iN~$)ar+7Ti}E&X z-nq~+Gkp(`qF0F_4A22>VZn-x>I$?PDZSeG8h_ifoWf^DxIb5%T7UytYo3}F|4#RC zUHpg$=)qVqD~=m(!~?XwocuxU1u}9qhhM7d^eqmJPi_e-!IO`*{u7A zbu*?L$Mbj-X9n3G2>+Kc#l`@d8}Xb9{l*IN{#M*d;s+3Pdr8FO$EBELR=8{ zd?LJbSv9fI`{OqTH)5{b?WulgMb)psp+W|@cSp=jtl-&5C}9lw@*0H+gEW(}mAWNz zf{~U;;N}|wdSaphgqnH{FWUy!{y3^=AC*c?RJ5Eb<^ zCgH_v7^axIUVmHSFL^zlj2R$zow$|y#7>%#U7d#Vp_ezcp3lefMyd5ES=q$>4pWyA zp_Zso^^NP~lu2=S6nD(3Z5u=Uy&B&F1i$J*3;3KhEkD_lgscHGR*;T;U!9vgQa(hI}oh9IzEf_PU_8F+i77t-~gDX z490Sb)LyVZmf18N6w{+37$aO<2!Av0 ztLaPOv^J<2@p{WnMiDudoghX_`luFZt_4eNU}*~cF5i%eEcNLs;D>QVIwr8mH;=dc z09`}JV;aaF;13@&iS(w>Jc=k~|d_1hcpM(l|O zu>!@}me%isTT$xT#hNUvh(ATd0wT4fbv=6htcHNEZIw9%E6wlYmwfu2{j0kh1y=$;Yf!|NldgB9ul zB{dbE&LfRnr8ITm@;-68wo#VV?8lG3ed&9k1}QBS3}WGV9%26?A1rBkkDR9Z3o+g+ z)eQg8BY3y(Dh5&z?VLLNdDV`C=muUvCPpGg!oYxIgOI3^%4>5d7jTh~ni!Fg2;fhx z(*c%H6Je84kmQh;5tC3*l~7khLxK-e|Cz?FLh!yYe7g|*LwqU?2wv^_ZyKT$fYVkGJo@AK0$+ml?}zJeB~deT2WL1vz}dxB z)y??t!}%M@)u$_IyW~)6u1SttJ!awd6N5lx|xBrmyrBh>tb&D*=C+Z3nPfq$1%WgY0bY*?PZ#Hk|=xn zGM#0*w4CaB^y0G(J4q=;5NeM@m-P}#mv7QZNF)M!dK^w{mk_!n0`+Y3PQutu-%NBt zzgPXug?JLEbUL{e_dk;Vd896&yPe(hliVK!lj%5+@BKdcrEZ2Nc_*i@ve*2lB>u~{ zFozd2FM|_0+nAGR4TLNHanQn_Oeb!JrUcvzJ?7p9TTNB}ocO3j$7ij!li8#k6 z@2tSd1>K03K9A#_-MIq)S;T#oE^;>U$)&}okIvDf3lm?kI{d80$>~xKUoS!%q1Pi?WpsUUt(tI ztjNjY*y&Rm9(S(DC2GuPHBJs@5M{RGm`c1z<6nwyN^)rMo-AS{M2$oM9|y%fM|}G~ DHx0+F literal 54413 zcmafaV|Zr4wq`oEZQHiZj%|LijZQlLf{tz5M#r{o+fI6V=G-$g=gzrzeyqLskF}nv zRZs0&c;EUi2L_G~0s;*U0szbL-0C3_3~ zRZ#mYf6f1oqJoH`jHHCB8l!^by~4z}yc`4LEP@;Z?bO6{g9`Hk+s@(L1jC5Tq{1Yf z4E;CQvrx0-gF+peRxFC*gF=&$zNYjO?K|gN=WqXMz`tYs@0o%B{dRD+{C_6(f9t^g zhmNJQv6-#;f2)f2uc{u-#*U8W&i{|ewYN^n_1~cv|1J!}zc&$eaBy{T{cEpa46s*q zHFkD2cV;xTHFj}{*3kBt*FgS4A5SI|$F%$gB@It9FlC}D3y`sbZG{2P6gGwC$U`6O zb_cId9AhQl#A<&=x>-xDD%=Ppt$;y71@Lwsl{x943#T@8*?cbR<~d`@@}4V${+r$jICUIOzgZJy_9I zu*eA(F)$~J07zX%tmQN}1^wj+RM|9bbwhQA=xrPE*{vB_P!pPYT5{Or^m*;Qz#@Bl zRywCG_RDyM6bf~=xn}FtiFAw|rrUxa1+z^H`j6e|GwKDuq}P)z&@J>MEhsVBvnF|O zOEm)dADU1wi8~mX(j_8`DwMT_OUAnjbWYer;P*^Uku_qMu3}qJU zTAkza-K9aj&wcsGuhQ>RQoD?gz~L8RwCHOZDzhBD$az*$TQ3!uygnx_rsXG`#_x5t zn*lb(%JI3%G^MpYp-Y(KI4@_!&kBRa3q z|Fzn&3R%ZsoMNEn4pN3-BSw2S_{IB8RzRv(eQ1X zyBQZHJ<(~PfUZ~EoI!Aj`9k<+Cy z2DtI<+9sXQu!6&-Sk4SW3oz}?Q~mFvy(urUy<)x!KQ>#7yIPC)(ORhKl7k)4eSy~} z7#H3KG<|lt68$tk^`=yjev%^usOfpQ#+Tqyx|b#dVA(>fPlGuS@9ydo z!Cs#hse9nUETfGX-7lg;F>9)+ml@M8OO^q|W~NiysX2N|2dH>qj%NM`=*d3GvES_# zyLEHw&1Fx<-dYxCQbk_wk^CI?W44%Q9!!9aJKZW-bGVhK?N;q`+Cgc*WqyXcxZ%U5QXKu!Xn)u_dxeQ z;uw9Vysk!3OFzUmVoe)qt3ifPin0h25TU zrG*03L~0|aaBg7^YPEW^Yq3>mSNQgk-o^CEH?wXZ^QiPiuH}jGk;75PUMNquJjm$3 zLcXN*uDRf$Jukqg3;046b;3s8zkxa_6yAlG{+7{81O3w96i_A$KcJhD&+oz1<>?lun#C3+X0q zO4JxN{qZ!e#FCl@e_3G?0I^$CX6e$cy7$BL#4<`AA)Lw+k`^15pmb-447~5lkSMZ` z>Ce|adKhb-F%yy!vx>yQbXFgHyl(an=x^zi(!-~|k;G1=E(e@JgqbAF{;nv`3i)oi zDeT*Q+Mp{+NkURoabYb9@#Bi5FMQnBFEU?H{~9c;g3K%m{+^hNe}(MdpPb?j9`?2l z#%AO!|2QxGq7-2Jn2|%atvGb(+?j&lmP509i5y87`9*BSY++<%%DXb)kaqG0(4Eft zj|2!Od~2TfVTi^0dazAIeVe&b#{J4DjN6;4W;M{yWj7#+oLhJyqeRaO;>?%mX>Ec{Mp~;`bo}p;`)@5dA8fNQ38FyMf;wUPOdZS{U*8SN6xa z-kq3>*Zos!2`FMA7qjhw-`^3ci%c91Lh`;h{qX1r;x1}eW2hYaE*3lTk4GwenoxQ1kHt1Lw!*N8Z%DdZSGg5~Bw}+L!1#d$u+S=Bzo7gi zqGsBV29i)Jw(vix>De)H&PC; z-t2OX_ak#~eSJ?Xq=q9A#0oaP*dO7*MqV;dJv|aUG00UX=cIhdaet|YEIhv6AUuyM zH1h7fK9-AV)k8sr#POIhl+?Z^r?wI^GE)ZI=H!WR<|UI(3_YUaD#TYV$Fxd015^mT zpy&#-IK>ahfBlJm-J(n(A%cKV;)8&Y{P!E|AHPtRHk=XqvYUX?+9po4B$0-6t74UUef${01V{QLEE8gzw* z5nFnvJ|T4dlRiW9;Ed_yB{R@)fC=zo4hCtD?TPW*WJmMXYxN_&@YQYg zBQ$XRHa&EE;YJrS{bn7q?}Y&DH*h;){5MmE(9A6aSU|W?{3Ox%5fHLFScv7O-txuRbPG1KQtI`Oay=IcEG=+hPhlnYC;`wSHeo|XGio0aTS6&W($E$ z?N&?TK*l8;Y^-xPl-WVZwrfdiQv10KdsAb9u-*1co*0-Z(h#H)k{Vc5CT!708cs%sExvPC+7-^UY~jTfFq=cj z!Dmy<+NtKp&}}$}rD{l?%MwHdpE(cPCd;-QFPk1`E5EVNY2i6E`;^aBlx4}h*l42z zpY#2cYzC1l6EDrOY*ccb%kP;k8LHE3tP>l3iK?XZ%FI<3666yPw1rM%>eCgnv^JS_ zK7c~;g7yXt9fz@(49}Dj7VO%+P!eEm& z;z8UXs%NsQ%@2S5nve)@;yT^61BpVlc}=+i6{ZZ9r7<({yUYqe==9*Z+HguP3`sA& z{`inI4G)eLieUQ*pH9M@)u7yVnWTQva;|xq&-B<>MoP(|xP(HqeCk1&h>DHNLT>Zi zQ$uH%s6GoPAi0~)sC;`;ngsk+StYL9NFzhFEoT&Hzfma1f|tEnL0 zMWdX4(@Y*?*tM2@H<#^_l}BC&;PYJl%~E#veQ61{wG6!~nyop<^e)scV5#VkGjYc2 z$u)AW-NmMm%T7WschOnQ!Hbbw&?`oMZrJ&%dVlN3VNra1d0TKfbOz{dHfrCmJ2Jj= zS#Gr}JQcVD?S9X!u|oQ7LZ+qcq{$40 ziG5=X^+WqeqxU00YuftU7o;db=K+Tq!y^daCZgQ)O=M} zK>j*<3oxs=Rcr&W2h%w?0Cn3);~vqG>JO_tTOzuom^g&^vzlEjkx>Sv!@NNX%_C!v zaMpB>%yVb}&ND9b*O>?HxQ$5-%@xMGe4XKjWh7X>CYoRI2^JIwi&3Q5UM)?G^k8;8 zmY$u;(KjZx>vb3fe2zgD7V;T2_|1KZQW$Yq%y5Ioxmna9#xktcgVitv7Sb3SlLd6D zfmBM9Vs4rt1s0M}c_&%iP5O{Dnyp|g1(cLYz^qLqTfN6`+o}59Zlu%~oR3Q3?{Bnr zkx+wTpeag^G12fb_%SghFcl|p2~<)Av?Agumf@v7y-)ecVs`US=q~=QG%(_RTsqQi z%B&JdbOBOmoywgDW|DKR5>l$1^FPhxsBrja<&}*pfvE|5dQ7j-wV|ur%QUCRCzBR3q*X`05O3U@?#$<>@e+Zh&Z&`KfuM!0XL& zI$gc@ZpM4o>d&5)mg7+-Mmp98K^b*28(|Ew8kW}XEV7k^vnX-$onm9OtaO@NU9a|as7iA%5Wrw9*%UtJYacltplA5}gx^YQM` zVkn`TIw~avq)mIQO0F0xg)w$c)=8~6Jl|gdqnO6<5XD)&e7z7ypd3HOIR+ss0ikSVrWar?548HFQ*+hC)NPCq*;cG#B$7 z!n?{e9`&Nh-y}v=nK&PR>PFdut*q&i81Id`Z<0vXUPEbbJ|<~_D!)DJMqSF~ly$tN zygoa)um~xdYT<7%%m!K8+V(&%83{758b0}`b&=`))Tuv_)OL6pf=XOdFk&Mfx9y{! z6nL>V?t=#eFfM$GgGT8DgbGRCF@0ZcWaNs_#yl+6&sK~(JFwJmN-aHX{#Xkpmg;!} zgNyYYrtZdLzW1tN#QZAh!z5>h|At3m+ryJ-DFl%V>w?cmVTxt^DsCi1ZwPaCe*D{) z?#AZV6Debz{*D#C2>44Czy^yT3y92AYDcIXtZrK{L-XacVl$4i=X2|K=Fy5vAzhk{ zu3qG=qSb_YYh^HirWf~n!_Hn;TwV8FU9H8+=BO)XVFV`nt)b>5yACVr!b98QlLOBDY=^KS<*m9@_h3;64VhBQzb_QI)gbM zSDto2i*iFrvxSmAIrePB3i`Ib>LdM8wXq8(R{-)P6DjUi{2;?}9S7l7bND4w%L2!; zUh~sJ(?Yp}o!q6)2CwG*mgUUWlZ;xJZo`U`tiqa)H4j>QVC_dE7ha0)nP5mWGB268 zn~MVG<#fP#R%F=Ic@(&Va4dMk$ysM$^Avr1&hS!p=-7F>UMzd(M^N9Ijb|364}qcj zcIIh7suk$fQE3?Z^W4XKIPh~|+3(@{8*dSo&+Kr(J4^VtC{z*_{2}ld<`+mDE2)S| zQ}G#Q0@ffZCw!%ZGc@kNoMIdQ?1db%N1O0{IPPesUHI;(h8I}ETudk5ESK#boZgln z(0kvE`&6z1xH!s&={%wQe;{^&5e@N0s7IqR?L*x%iXM_czI5R1aU?!bA7)#c4UN2u zc_LZU+@elD5iZ=4*X&8%7~mA;SA$SJ-8q^tL6y)d150iM)!-ry@TI<=cnS#$kJAS# zq%eK**T*Wi2OlJ#w+d_}4=VN^A%1O+{?`BK00wkm)g8;u?vM;RR+F1G?}({ENT3i= zQsjJkp-dmJ&3-jMNo)wrz0!g*1z!V7D(StmL(A}gr^H-CZ~G9u?*Uhcx|x7rb`v^X z9~QGx;wdF4VcxCmEBp$F#sms@MR?CF67)rlpMxvwhEZLgp2?wQq|ci#rLtrYRV~iR zN?UrkDDTu114&d~Utjcyh#tXE_1x%!dY?G>qb81pWWH)Ku@Kxbnq0=zL#x@sCB(gs zm}COI(!{6-XO5li0>1n}Wz?w7AT-Sp+=NQ1aV@fM$`PGZjs*L+H^EW&s!XafStI!S zzgdntht=*p#R*o8-ZiSb5zf6z?TZr$^BtmIfGAGK;cdg=EyEG)fc*E<*T=#a?l=R5 zv#J;6C(umoSfc)W*EODW4z6czg3tXIm?x8{+8i^b;$|w~k)KLhJQnNW7kWXcR^sol z1GYOp?)a+}9Dg*nJ4fy*_riThdkbHO37^csfZRGN;CvQOtRacu6uoh^gg%_oEZKDd z?X_k67s$`|Q&huidfEonytrq!wOg07H&z@`&BU6D114p!rtT2|iukF}>k?71-3Hk< zs6yvmsMRO%KBQ44X4_FEYW~$yx@Y9tKrQ|rC1%W$6w}-9!2%4Zk%NycTzCB=nb)r6*92_Dg+c0;a%l1 zsJ$X)iyYR2iSh|%pIzYV1OUWER&np{w1+RXb~ zMUMRymjAw*{M)UtbT)T!kq5ZAn%n=gq3ssk3mYViE^$paZ;c^7{vXDJ`)q<}QKd2?{r9`X3mpZ{AW^UaRe2^wWxIZ$tuyKzp#!X-hXkHwfD zj@2tA--vFi3o_6B?|I%uwD~emwn0a z+?2Lc1xs(`H{Xu>IHXpz=@-84uw%dNV;{|c&ub|nFz(=W-t4|MME(dE4tZQi?0CE|4_?O_dyZj1)r zBcqB8I^Lt*#)ABdw#yq{OtNgf240Jvjm8^zdSf40 z;H)cp*rj>WhGSy|RC5A@mwnmQ`y4{O*SJ&S@UFbvLWyPdh)QnM=(+m3p;0&$^ysbZ zJt!ZkNQ%3hOY*sF2_~-*`aP|3Jq7_<18PX*MEUH*)t{eIx%#ibC|d&^L5FwoBN}Oe z?!)9RS@Zz%X1mqpHgym75{_BM4g)k1!L{$r4(2kL<#Oh$Ei7koqoccI3(MN1+6cDJ zp=xQhmilz1?+ZjkX%kfn4{_6K_D{wb~rdbkh!!k!Z@cE z^&jz55*QtsuNSlGPrU=R?}{*_8?4L7(+?>?(^3Ss)f!ou&{6<9QgH>#2$?-HfmDPN z6oIJ$lRbDZb)h-fFEm^1-v?Slb8udG{7GhbaGD_JJ8a9f{6{TqQN;m@$&)t81k77A z?{{)61za|e2GEq2)-OqcEjP`fhIlUs_Es-dfgX-3{S08g`w=wGj2{?`k^GD8d$}6Z zBT0T1lNw~fuwjO5BurKM593NGYGWAK%UCYiq{$p^GoYz^Uq0$YQ$j5CBXyog8(p_E znTC+$D`*^PFNc3Ih3b!2Lu|OOH6@46D)bbvaZHy%-9=$cz}V^|VPBpmPB6Ivzlu&c zPq6s7(2c4=1M;xlr}bkSmo9P`DAF>?Y*K%VPsY`cVZ{mN&0I=jagJ?GA!I;R)i&@{ z0Gl^%TLf_N`)`WKs?zlWolWvEM_?{vVyo(!taG$`FH2bqB`(o50pA=W34kl-qI62lt z1~4LG_j%sR2tBFteI{&mOTRVU7AH>>-4ZCD_p6;-J<=qrod`YFBwJz(Siu(`S}&}1 z6&OVJS@(O!=HKr-Xyzuhi;swJYK*ums~y1ePdX#~*04=b9)UqHHg;*XJOxnS6XK#j zG|O$>^2eW2ZVczP8#$C`EpcWwPFX4^}$omn{;P(fL z>J~%-r5}*D3$Kii z34r@JmMW2XEa~UV{bYP=F;Y5=9miJ+Jw6tjkR+cUD5+5TuKI`mSnEaYE2=usXNBs9 zac}V13%|q&Yg6**?H9D620qj62dM+&&1&a{NjF}JqmIP1I1RGppZ|oIfR}l1>itC% zl>ed${{_}8^}m2^br*AIX$L!Vc?Sm@H^=|LnpJg`a7EC+B;)j#9#tx-o0_e4!F5-4 zF4gA;#>*qrpow9W%tBzQ89U6hZ9g=-$gQpCh6Nv_I0X7t=th2ajJ8dBbh{i)Ok4{I z`Gacpl?N$LjC$tp&}7Sm(?A;;Nb0>rAWPN~@3sZ~0_j5bR+dz;Qs|R|k%LdreS3Nn zp*36^t#&ASm=jT)PIjNqaSe4mTjAzlAFr*@nQ~F+Xdh$VjHWZMKaI+s#FF#zjx)BJ zufxkW_JQcPcHa9PviuAu$lhwPR{R{7CzMUi49=MaOA%ElpK;A)6Sgsl7lw)D$8FwE zi(O6g;m*86kcJQ{KIT-Rv&cbv_SY4 zpm1|lSL*o_1LGOlBK0KuU2?vWcEcQ6f4;&K=&?|f`~X+s8H)se?|~2HcJo{M?Ity) zE9U!EKGz2^NgB6Ud;?GcV*1xC^1RYIp&0fr;DrqWLi_Kts()-#&3|wz{wFQsKfnnsC||T?oIgUp z{O(?Df7&vW!i#_~*@naguLLjDAz+)~*_xV2iz2?(N|0y8DMneikrT*dG`mu6vdK`% z=&nX5{F-V!Reau}+w_V3)4?}h@A@O)6GCY7eXC{p-5~p8x{cH=hNR;Sb{*XloSZ_%0ZKYG=w<|!vy?spR4!6mF!sXMUB5S9o_lh^g0!=2m55hGR; z-&*BZ*&;YSo474=SAM!WzrvjmNtq17L`kxbrZ8RN419e=5CiQ-bP1j-C#@@-&5*(8 zRQdU~+e(teUf}I3tu%PB1@Tr{r=?@0KOi3+Dy8}+y#bvgeY(FdN!!`Kb>-nM;7u=6 z;0yBwOJ6OdWn0gnuM{0`*fd=C(f8ASnH5aNYJjpbY1apTAY$-%)uDi$%2)lpH=#)=HH z<9JaYwPKil@QbfGOWvJ?cN6RPBr`f+jBC|-dO|W@x_Vv~)bmY(U(!cs6cnhe0z31O z>yTtL4@KJ*ac85u9|=LFST22~!lb>n7IeHs)_(P_gU}|8G>{D_fJX)8BJ;Se? z67QTTlTzZykb^4!{xF!=C}VeFd@n!9E)JAK4|vWVwWop5vSWcD<;2!88v-lS&ve7C zuYRH^85#hGKX(Mrk};f$j_V&`Nb}MZy1mmfz(e`nnI4Vpq(R}26pZx?fq%^|(n~>* z5a5OFtFJJfrZmgjyHbj1`9||Yp?~`p2?4NCwu_!!*4w8K`&G7U_|np&g7oY*-i;sI zu)~kYH;FddS{7Ri#Z5)U&X3h1$Mj{{yk1Q6bh4!7!)r&rqO6K~{afz@bis?*a56i& zxi#(Ss6tkU5hDQJ0{4sKfM*ah0f$>WvuRL zunQ-eOqa3&(rv4kiQ(N4`FO6w+nko_HggKFWx@5aYr}<~8wuEbD(Icvyl~9QL^MBt zSvD)*C#{2}!Z55k1ukV$kcJLtW2d~%z$t0qMe(%2qG`iF9K_Gsae7OO%Tf8E>ooch ztAw01`WVv6?*14e1w%Wovtj7jz_)4bGAqqo zvTD|B4)Ls8x7-yr6%tYp)A7|A)x{WcI&|&DTQR&2ir(KGR7~_RhNOft)wS<+vQ*|sf;d>s zEfl&B^*ZJp$|N`w**cXOza8(ARhJT{O3np#OlfxP9Nnle4Sto)Fv{w6ifKIN^f1qO*m8+MOgA1^Du!=(@MAh8)@wU8t=Ymh!iuT_lzfm za~xEazL-0xwy9$48!+?^lBwMV{!Gx)N>}CDi?Jwax^YX@_bxl*+4itP;DrTswv~n{ zZ0P>@EB({J9ZJ(^|ptn4ks^Z2UI&87d~J_^z0&vD2yb%*H^AE!w= zm&FiH*c%vvm{v&i3S>_hacFH${|(2+q!`X~zn4$aJDAry>=n|{C7le(0a)nyV{kAD zlud4-6X>1@-XZd`3SKKHm*XNn_zCyKHmf*`C_O509$iy$Wj`Sm3y?nWLCDy>MUx1x zl-sz7^{m(&NUk*%_0(G^>wLDnXW90FzNi$Tu6* z<+{ePBD`%IByu977rI^x;gO5M)Tfa-l*A2mU-#IL2?+NXK-?np<&2rlF;5kaGGrx2 zy8Xrz`kHtTVlSSlC=nlV4_oCsbwyVHG4@Adb6RWzd|Otr!LU=% zEjM5sZ#Ib4#jF(l!)8Na%$5VK#tzS>=05GpV?&o* z3goH1co0YR=)98rPJ~PuHvkA59KUi#i(Mq_$rApn1o&n1mUuZfFLjx@3;h`0^|S##QiTP8rD`r8P+#D@gvDJh>amMIl065I)PxT6Hg(lJ?X7*|XF2Le zv36p8dWHCo)f#C&(|@i1RAag->5ch8TY!LJ3(+KBmLxyMA%8*X%_ARR*!$AL66nF= z=D}uH)D)dKGZ5AG)8N-;Il*-QJ&d8u30&$_Q0n1B58S0ykyDAyGa+BZ>FkiOHm1*& zNOVH;#>Hg5p?3f(7#q*dL74;$4!t?a#6cfy#}9H3IFGiCmevir5@zXQj6~)@zYrWZ zRl*e66rjwksx-)Flr|Kzd#Bg>We+a&E{h7bKSae9P~ z(g|zuXmZ zD?R*MlmoZ##+0c|cJ(O{*h(JtRdA#lChYhfsx25(Z`@AK?Q-S8_PQqk z>|Z@Ki1=wL1_c6giS%E4YVYD|Y-{^ZzFwB*yN8-4#+TxeQ`jhks7|SBu7X|g=!_XL z`mY=0^chZfXm%2DYHJ4z#soO7=NONxn^K3WX={dV>$CTWSZe@<81-8DVtJEw#Uhd3 zxZx+($6%4a&y_rD8a&E`4$pD6-_zZJ%LEE*1|!9uOm!kYXW< zOBXZAowsX-&$5C`xgWkC43GcnY)UQt2Qkib4!!8Mh-Q!_M%5{EC=Gim@_;0+lP%O^ zG~Q$QmatQk{Mu&l{q~#kOD;T-{b1P5u7)o-QPPnqi?7~5?7%IIFKdj{;3~Hu#iS|j z)Zoo2wjf%+rRj?vzWz(6JU`=7H}WxLF*|?WE)ci7aK?SCmd}pMW<{#1Z!_7BmVP{w zSrG>?t}yNyCR%ZFP?;}e8_ zRy67~&u11TN4UlopWGj6IokS{vB!v!n~TJYD6k?~XQkpiPMUGLG2j;lh>Eb5bLTkX zx>CZlXdoJsiPx=E48a4Fkla>8dZYB%^;Xkd(BZK$z3J&@({A`aspC6$qnK`BWL;*O z-nRF{XRS`3Y&b+}G&|pE1K-Ll_NpT!%4@7~l=-TtYRW0JJ!s2C-_UsRBQ=v@VQ+4> z*6jF0;R@5XLHO^&PFyaMDvyo?-lAD(@H61l-No#t@at@Le9xOgTFqkc%07KL^&iss z!S2Ghm)u#26D(e1Q7E;L`rxOy-N{kJ zTgfw}az9=9Su?NEMMtpRlYwDxUAUr8F+P=+9pkX4%iA4&&D<|=B|~s*-U+q6cq`y* zIE+;2rD7&D5X;VAv=5rC5&nP$E9Z3HKTqIFCEV%V;b)Y|dY?8ySn|FD?s3IO>VZ&&f)idp_7AGnwVd1Z znBUOBA}~wogNpEWTt^1Rm-(YLftB=SU|#o&pT7vTr`bQo;=ZqJHIj2MP{JuXQPV7% z0k$5Ha6##aGly<}u>d&d{Hkpu?ZQeL_*M%A8IaXq2SQl35yW9zs4^CZheVgHF`%r= zs(Z|N!gU5gj-B^5{*sF>;~fauKVTq-Ml2>t>E0xl9wywD&nVYZfs1F9Lq}(clpNLz z4O(gm_i}!k`wUoKr|H#j#@XOXQ<#eDGJ=eRJjhOUtiKOG;hym-1Hu)1JYj+Kl*To<8( za1Kf4_Y@Cy>eoC59HZ4o&xY@!G(2p^=wTCV>?rQE`Upo^pbhWdM$WP4HFdDy$HiZ~ zRUJFWTII{J$GLVWR?miDjowFk<1#foE3}C2AKTNFku+BhLUuT>?PATB?WVLzEYyu+ zM*x((pGdotzLJ{}R=OD*jUexKi`mb1MaN0Hr(Wk8-Uj0zA;^1w2rmxLI$qq68D>^$ zj@)~T1l@K|~@YJ6+@1vlWl zHg5g%F{@fW5K!u>4LX8W;ua(t6YCCO_oNu}IIvI6>Fo@MilYuwUR?9p)rKNzDmTAN zzN2d>=Za&?Z!rJFV*;mJ&-sBV80%<-HN1;ciLb*Jk^p?u<~T25%7jjFnorfr={+wm zzl5Q6O>tsN8q*?>uSU6#xG}FpAVEQ_++@}G$?;S7owlK~@trhc#C)TeIYj^N(R&a} zypm~c=fIs;M!YQrL}5{xl=tUU-Tfc0ZfhQuA-u5(*w5RXg!2kChQRd$Fa8xQ0CQIU zC`cZ*!!|O!*y1k1J^m8IIi|Sl3R}gm@CC&;4840^9_bb9%&IZTRk#=^H0w%`5pMDCUef5 zYt-KpWp2ijh+FM`!zZ35>+7eLN;s3*P!bp%-oSx34fdTZ14Tsf2v7ZrP+mitUx$rS zW(sOi^CFxe$g3$x45snQwPV5wpf}>5OB?}&Gh<~i(mU&ss#7;utaLZ!|KaTHniGO9 zVC9OTzuMKz)afey_{93x5S*Hfp$+r*W>O^$2ng|ik!<`U1pkxm3*)PH*d#>7md1y} zs7u^a8zW8bvl92iN;*hfOc-=P7{lJeJ|3=NfX{(XRXr;*W3j845SKG&%N zuBqCtDWj*>KooINK1 zFPCsCWr!-8G}G)X*QM~34R*k zmRmDGF*QE?jCeNfc?k{w<}@29e}W|qKJ1K|AX!htt2|B`nL=HkC4?1bEaHtGBg}V( zl(A`6z*tck_F$4;kz-TNF%7?=20iqQo&ohf@S{_!TTXnVh}FaW2jxAh(DI0f*SDG- z7tqf5X@p#l?7pUNI(BGi>n_phw=lDm>2OgHx-{`T>KP2YH9Gm5ma zb{>7>`tZ>0d5K$j|s2!{^sFWQo3+xDb~#=9-jp(1ydI3_&RXGB~rxWSMgDCGQG)oNoc#>)td zqE|X->35U?_M6{^lB4l(HSN|`TC2U*-`1jSQeiXPtvVXdN-?i1?d#;pw%RfQuKJ|e zjg75M+Q4F0p@8I3ECpBhGs^kK;^0;7O@MV=sX^EJLVJf>L;GmO z3}EbTcoom7QbI(N8ad!z(!6$!MzKaajSRb0c+ZDQ($kFT&&?GvXmu7+V3^_(VJx1z zP-1kW_AB&_A;cxm*g`$ z#Pl@Cg{siF0ST2-w)zJkzi@X)5i@)Z;7M5ewX+xcY36IaE0#flASPY2WmF8St0am{ zV|P|j9wqcMi%r-TaU>(l*=HxnrN?&qAyzimA@wtf;#^%{$G7i4nXu=Pp2#r@O~wi)zB>@25A*|axl zEclXBlXx1LP3x0yrSx@s-kVW4qlF+idF+{M7RG54CgA&soDU-3SfHW@-6_ z+*;{n_SixmGCeZjHmEE!IF}!#aswth_{zm5Qhj0z-@I}pR?cu=P)HJUBClC;U+9;$#@xia30o$% zDw%BgOl>%vRenxL#|M$s^9X}diJ9q7wI1-0n2#6>@q}rK@ng(4M68(t52H_Jc{f&M9NPxRr->vj-88hoI?pvpn}llcv_r0`;uN>wuE{ z&TOx_i4==o;)>V4vCqG)A!mW>dI^Ql8BmhOy$6^>OaUAnI3>mN!Zr#qo4A>BegYj` zNG_)2Nvy2Cqxs1SF9A5HHhL7sai#Umw%K@+riaF+q)7&MUJvA&;$`(w)+B@c6!kX@ zzuY;LGu6|Q2eu^06PzSLspV2v4E?IPf`?Su_g8CX!75l)PCvyWKi4YRoRThB!-BhG zubQ#<7oCvj@z`^y&mPhSlbMf0<;0D z?5&!I?nV-jh-j1g~&R(YL@c=KB_gNup$8abPzXZN`N|WLqxlN)ZJ+#k4UWq#WqvVD z^|j+8f5uxTJtgcUscKTqKcr?5g-Ih3nmbvWvvEk})u-O}h$=-p4WE^qq7Z|rLas0$ zh0j&lhm@Rk(6ZF0_6^>Rd?Ni-#u1y`;$9tS;~!ph8T7fLlYE{P=XtWfV0Ql z#z{_;A%p|8+LhbZT0D_1!b}}MBx9`R9uM|+*`4l3^O(>Mk%@ha>VDY=nZMMb2TnJ= zGlQ+#+pmE98zuFxwAQcVkH1M887y;Bz&EJ7chIQQe!pgWX>(2ruI(emhz@_6t@k8Z zqFEyJFX2PO`$gJ6p$=ku{7!vR#u+$qo|1r;orjtp9FP^o2`2_vV;W&OT)acRXLN^m zY8a;geAxg!nbVu|uS8>@Gvf@JoL&GP`2v4s$Y^5vE32&l;2)`S%e#AnFI-YY7_>d#IKJI!oL6e z_7W3e=-0iz{bmuB*HP+D{Nb;rn+RyimTFqNV9Bzpa0?l`pWmR0yQOu&9c0S*1EPr1 zdoHMYlr>BycjTm%WeVuFd|QF8I{NPT&`fm=dITj&3(M^q ze2J{_2zB;wDME%}SzVWSW6)>1QtiX)Iiy^p2eT}Ii$E9w$5m)kv(3wSCNWq=#DaKZ zs%P`#^b7F-J0DgQ1?~2M`5ClYtYN{AlU|v4pEg4z03=g6nqH`JjQuM{k`!6jaIL_F zC;sn?1x?~uMo_DFg#ypNeie{3udcm~M&bYJ1LI zE%y}P9oCX3I1Y9yhF(y9Ix_=8L(p)EYr&|XZWCOb$7f2qX|A4aJ9bl7pt40Xr zXUT#NMBB8I@xoIGSHAZkYdCj>eEd#>a;W-?v4k%CwBaR5N>e3IFLRbDQTH#m_H+4b zk2UHVymC`%IqwtHUmpS1!1p-uQB`CW1Y!+VD!N4TT}D8(V0IOL|&R&)Rwj@n8g@=`h&z9YTPDT+R9agnwPuM!JW~=_ya~% zIJ*>$Fl;y7_`B7G4*P!kcy=MnNmR`(WS5_sRsvHF42NJ;EaDram5HwQ4Aw*qbYn0j;#)bh1lyKLg#dYjN*BMlh+fxmCL~?zB;HBWho;20WA==ci0mAqMfyG>1!HW zO7rOga-I9bvut1Ke_1eFo9tbzsoPTXDW1Si4}w3fq^Z|5LGf&egnw%DV=b11$F=P~ z(aV+j8S}m=CkI*8=RcrT>GmuYifP%hCoKY22Z4 zmu}o08h3YhcXx-v-QC??8mDn<+}+*X{+gZH-I;G^|7=1fBveS?J$27H&wV5^V^P$! z84?{UeYSmZ3M!@>UFoIN?GJT@IroYr;X@H~ax*CQ>b5|Xi9FXt5j`AwUPBq`0sWEJ z3O|k+g^JKMl}L(wfCqyMdRj9yS8ncE7nI14Tv#&(?}Q7oZpti{Q{Hw&5rN-&i|=fWH`XTQSu~1jx(hqm$Ibv zRzFW9$xf@oZAxL~wpj<0ZJ3rdPAE=0B>G+495QJ7D>=A&v^zXC9)2$$EnxQJ<^WlV zYKCHb1ZzzB!mBEW2WE|QG@&k?VXarY?umPPQ|kziS4{EqlIxqYHP!HN!ncw6BKQzKjqk!M&IiOJ9M^wc~ZQ1xoaI z;4je%ern~?qi&J?eD!vTl__*kd*nFF0n6mGEwI7%dI9rzCe~8vU1=nE&n4d&8}pdL zaz`QAY?6K@{s2x%Sx%#(y+t6qLw==>2(gb>AksEebXv=@ht>NBpqw=mkJR(c?l7vo z&cV)hxNoYPGqUh9KAKT)kc(NqekzE6(wjjotP(ac?`DJF=Sb7^Xet-A3PRl%n&zKk zruT9cS~vV1{%p>OVm1-miuKr<@rotj*5gd$?K`oteNibI&K?D63RoBjw)SommJ5<4 zus$!C8aCP{JHiFn2>XpX&l&jI7E7DcTjzuLYvON2{rz<)#$HNu(;ie-5$G<%eLKnTK7QXfn(UR(n+vX%aeS6!q6kv z!3nzY76-pdJp339zsl_%EI|;ic_m56({wdc(0C5LvLULW=&tWc5PW-4;&n+hm1m`f zzQV0T>OPSTjw=Ox&UF^y< zarsYKY8}YZF+~k70=olu$b$zdLaozBE|QE@H{_R21QlD5BilYBTOyv$D5DQZ8b1r- zIpSKX!SbA0Pb5#cT)L5!KpxX+x+8DRy&`o-nj+nmgV6-Gm%Fe91R1ca3`nt*hRS|^ z<&we;TJcUuPDqkM7k0S~cR%t7a`YP#80{BI$e=E!pY}am)2v3-Iqk2qvuAa1YM>xj#bh+H2V z{b#St2<;Gg>$orQ)c2a4AwD5iPcgZ7o_}7xhO86(JSJ(q(EWKTJDl|iBjGEMbX8|P z4PQHi+n(wZ_5QrX0?X_J)e_yGcTM#E#R^u_n8pK@l5416`c9S=q-e!%0RjoPyTliO zkp{OC@Ep^#Ig-n!C)K0Cy%8~**Vci8F1U(viN{==KU0nAg2(+K+GD_Gu#Bx!{tmUm zCwTrT(tCr6X8j43_n96H9%>>?4akSGMvgd+krS4wRexwZ1JxrJy!Uhz#yt$-=aq?A z@?*)bRZxjG9OF~7d$J0cwE_^CLceRK=LvjfH-~{S><^D;6B2&p-02?cl?|$@>`Qt$ zP*iaOxg<+(rbk>34VQDQpNQ|a9*)wScu!}<{oXC87hRPqyrNWpo?#=;1%^D2n2+C* zKKQH;?rWn-@%Y9g%NHG&lHwK9pBfV1a`!TqeU_Fv8s6_(@=RHua7`VYO|!W&WL*x= zIWE9eQaPq3zMaXuf)D0$V`RIZ74f)0P73xpeyk4)-?8j;|K%pD$eq4j2%tL=;&+E91O(2p91K|85b)GQcbRe&u6Ilu@SnE={^{Ix1Eqgv8D z4=w65+&36|;5WhBm$!n*!)ACCwT9Sip#1_z&g~E1kB=AlEhO0lu`Ls@6gw*a)lzc# zKx!fFP%eSBBs)U>xIcQKF(r_$SWD3TD@^^2Ylm=kC*tR+I@X>&SoPZdJ2fT!ysjH% z-U%|SznY8Fhsq7Vau%{Ad^Pvbf3IqVk{M2oD+w>MWimJA@VSZC$QooAO3 zC=DplXdkyl>mSp^$zk7&2+eoGQ6VVh_^E#Z3>tX7Dmi<2aqlM&YBmK&U}m>a%8)LQ z8v+c}a0QtXmyd%Kc2QNGf8TK?_EK4wtRUQ*VDnf5jHa?VvH2K(FDZOjAqYufW8oIZ z31|o~MR~T;ZS!Lz%8M0*iVARJ>_G2BXEF8(}6Dmn_rFV~5NI`lJjp`Mi~g7~P%H zO`S&-)Fngo3VXDMo7ImlaZxY^s!>2|csKca6!|m7)l^M0SQT1_L~K29%x4KV8*xiu zwP=GlyIE9YPSTC0BV`6|#)30=hJ~^aYeq7d6TNfoYUkk-^k0!(3qp(7Mo-$|48d8Z2d zrsfsRM)y$5)0G`fNq!V?qQ+nh0xwFbcp{nhW%vZ?h);=LxvM(pWd9FG$Bg1;@Bv)mKDW>AP{ol zD(R~mLzdDrBv$OSi{E%OD`Ano=F^vwc)rNb*Bg3-o)bbAgYE=M7Gj2OHY{8#pM${_^ zwkU|tnTKawxUF7vqM9UfcQ`V49zg78V%W)$#5ssR}Rj7E&p(4_ib^?9luZPJ%iJTvW&-U$nFYky>KJwHpEHHx zVEC;!ETdkCnO|${Vj#CY>LLut_+c|(hpWk8HRgMGRY%E--%oKh@{KnbQ~0GZd}{b@ z`J2qHBcqqjfHk^q=uQL!>6HSSF3LXL*cCd%opM|k#=xTShX~qcxpHTW*BI!c3`)hQq{@!7^mdUaG7sFsFYnl1%blslM;?B8Q zuifKqUAmR=>33g~#>EMNfdye#rz@IHgpM$~Z7c5@bO@S>MyFE3_F}HVNLnG0TjtXU zJeRWH^j5w_qXb$IGs+E>daTa}XPtrUnnpTRO9NEx4g6uaFEfHP9gW;xZnJi{oqAH~ z5dHS(ch3^hbvkv@u3QPLuWa}ImaElDrmIc%5HN<^bwej}3+?g) z-ai7D&6Iq_P(}k`i^4l?hRLbCb>X9iq2UYMl=`9U9Rf=3Y!gnJbr?eJqy>Zpp)m>Ae zcQ4Qfs&AaE?UDTODcEj#$_n4KeERZHx-I+E5I~E#L_T3WI3cj$5EYR75H7hy%80a8Ej?Y6hv+fR6wHN%_0$-xL!eI}fdjOK7(GdFD%`f%-qY@-i@fTAS&ETI99jUVg8 zslPSl#d4zbOcrgvopvB2c2A6r^pEr&Sa5I5%@1~BpGq`Wo|x=&)WnnQjE+)$^U-wW zr2Kv?XJby(8fcn z8JgPn)2_#-OhZ+;72R6PspMfCVvtLxFHeb7d}fo(GRjm_+R(*?9QRBr+yPF(iPO~ zA4Tp1<0}#fa{v0CU6jz}q9;!3Pew>ikG1qh$5WPRTQZ~ExQH}b1hDuzRS1}65uydS z~Te*3@?o8fih=mZ`iI!hL5iv3?VUBLQv0X zLtu58MIE7Jbm?)NFUZuMN2_~eh_Sqq*56yIo!+d_zr@^c@UwR&*j!fati$W<=rGGN zD$X`$lI%8Qe+KzBU*y3O+;f-Csr4$?3_l+uJ=K@dxOfZ?3APc5_x2R=a^kLFoxt*_ z4)nvvP+(zwlT5WYi!4l7+HKqzmXKYyM9kL5wX$dTSFSN&)*-&8Q{Q$K-})rWMin8S zy*5G*tRYNqk7&+v;@+>~EIQgf_SB;VxRTQFcm5VtqtKZ)x=?-f+%OY(VLrXb^6*aP zP&0Nu@~l2L!aF8i2!N~fJiHyxRl?I1QNjB)`uP_DuaU?2W;{?0#RGKTr2qH5QqdhK zP__ojm4WV^PUgmrV)`~f>(769t3|13DrzdDeXxqN6XA|_GK*;zHU()a(20>X{y-x| z2P6Ahq;o=)Nge`l+!+xEwY`7Q(8V=93A9C+WS^W%p&yR)eiSX+lp)?*7&WSYSh4i> zJa6i5T9o;Cd5z%%?FhB?J{l+t_)c&_f86gZMU{HpOA=-KoU5lIL#*&CZ_66O5$3?# ztgjGLo`Y7bj&eYnK#5x1trB_6tpu4$EomotZLb*9l6P(JmqG`{z$?lNKgq?GAVhkA zvw!oFhLyX=$K=jTAMwDQ)E-8ZW5$X%P2$YB5aq!VAnhwGv$VR&;Ix#fu%xlG{|j_K zbEYL&bx%*YpXcaGZj<{Y{k@rsrFKh7(|saspt?OxQ~oj_6En(&!rTZPa7fLCEU~mA zB7tbVs=-;cnzv*#INgF_9f3OZhp8c5yk!Dy1+`uA7@eJfvd~g34~wKI1PW%h(y&nA zRwMni12AHEw36)C4Tr-pt6s82EJa^8N#bjy??F*rg4fS@?6^MbiY3;7x=gd~G|Hi& zwmG+pAn!aV>>nNfP7-Zn8BLbJm&7}&ZX+$|z5*5{{F}BRSxN=JKZTa#{ut$v0Z0Fs za@UjXo#3!wACv+p9k*^9^n+(0(YKIUFo`@ib@bjz?Mh8*+V$`c%`Q>mrc5bs4aEf4 zh0qtL1qNE|xQ9JrM}qE>X>Y@dQ?%` zBx(*|1FMzVY&~|dE^}gHJ37O9bjnk$d8vKipgcf+As(kt2cbxAR3^4d0?`}}hYO*O z{+L&>G>AYaauAxE8=#F&u#1YGv%`d*v+EyDcU2TnqvRE33l1r}p#Vmcl%n>NrYOqV z2Car_^^NsZ&K=a~bj%SZlfxzHAxX$>=Q|Zi;E0oyfhgGgqe1Sd5-E$8KV9=`!3jWZCb2crb;rvQ##iw}xm7Da za!H${ls5Ihwxkh^D)M<4Yy3bp<-0a+&KfV@CVd9X6Q?v)$R3*rfT@jsedSEhoV(vqv?R1E8oWV;_{l_+_6= zLjV^-bZU$D_ocfSpRxDGk*J>n4G6s-e>D8JK6-gA>aM^Hv8@)txvKMi7Pi#DS5Y?r zK0%+L;QJdrIPXS2 ztjWAxkSwt2xG$L)Zb7F??cjs!KCTF+D{mZ5e0^8bdu_NLgFHTnO*wx!_8#}NO^mu{FaYeCXGjnUgt_+B-Ru!2_Ue-0UPg2Y)K3phLmR<4 zqUCWYX!KDU!jYF6c?k;;vF@Qh^q(PWwp1ez#I+0>d7V(u_h|L+kX+MN1f5WqMLn!L z!c(pozt7tRQi&duH8n=t-|d)c^;%K~6Kpyz(o53IQ_J+aCapAif$Ek#i0F9U>i+94 zFb=OH5(fk-o`L(o|DyQ(hlozl*2cu#)Y(D*zgNMi1Z!DTex#w#)x(8A-T=S+eByJW z%-k&|XhdZOWjJ&(FTrZNWRm^pHEot_MRQ_?>tKQ&MB~g(&D_e>-)u|`Ot(4j=UT6? zQ&YMi2UnCKlBpwltP!}8a2NJ`LlfL=k8SQf69U)~=G;bq9<2GU&Q#cHwL|o4?ah1` z;fG)%t0wMC;DR?^!jCoKib_iiIjsxCSxRUgJDCE%0P;4JZhJCy)vR1%zRl>K?V6#) z2lDi*W3q9rA zo;yvMujs+)a&00~W<-MNj=dJ@4%tccwT<@+c$#CPR%#aE#Dra+-5eSDl^E>is2v^~ z8lgRwkpeU$|1LW4yFwA{PQ^A{5JY!N5PCZ=hog~|FyPPK0-i;fCl4a%1 z?&@&E-)b4cK)wjXGq|?Kqv0s7y~xqvSj-NpOImt{Riam*Z!wz-coZIMuQU>M%6ben z>P@#o^W;fizVd#?`eeEPs#Gz^ySqJn+~`Pq%-Ee6*X+E>!PJGU#rs6qu0z5{+?`-N zxf1#+JNk7e6AoJTdQwxs&GMTq?Djch_8^xL^A;9XggtGL>!@0|BRuIdE&j$tzvt7I zr@I@0<0io%lpF697s1|qNS|BsA>!>-9DVlgGgw2;;k;=7)3+&t!);W3ulPgR>#JiV zUerO;WxuJqr$ghj-veVGfKF?O7si#mzX@GVt+F&atsB@NmBoV4dK|!owGP005$7LN7AqCG(S+={YA- zn#I{UoP_$~Epc=j78{(!2NLN)3qSm-1&{F&1z4Dz&7Mj_+SdlR^Q5{J=r822d4A@?Rj~xATaWewHUOus{*C|KoH`G zHB8SUT06GpSt)}cFJ18!$Kp@r+V3tE_L^^J%9$&fcyd_AHB)WBghwqBEWW!oh@StV zDrC?ttu4#?Aun!PhC4_KF1s2#kvIh~zds!y9#PIrnk9BWkJpq}{Hlqi+xPOR&A1oP zB0~1tV$Zt1pQuHpJw1TAOS=3$Jl&n{n!a+&SgYVe%igUtvE>eHqKY0`e5lwAf}2x( zP>9Wz+9uirp7<7kK0m2&Y*mzArUx%$CkV661=AIAS=V=|xY{;$B7cS5q0)=oq0uXU z_roo90&gHSfM6@6kmB_FJZ)3y_tt0}7#PA&pWo@_qzdIMRa-;U*Dy>Oo#S_n61Fn! z%mrH%tRmvQvg%UqN_2(C#LSxgQ>m}FKLGG=uqJQuSkk=S@c~QLi4N+>lr}QcOuP&% zQCP^cRk&rk-@lpa0^Lcvdu`F*qE)-0$TnxJlwZf|dP~s8cjhL%>^+L~{umxl5Xr6@ z^7zVKiN1Xg;-h+kr4Yt2BzjZs-Mo54`pDbLc}fWq{34=6>U9@sBP~iWZE`+FhtU|x zTV}ajn*Hc}Y?3agQ+bV@oIRm=qAu%|zE;hBw7kCcDx{pm!_qCxfPX3sh5^B$k_2d` z6#rAeUZC;e-LuMZ-f?gHeZogOa*mE>ffs+waQ+fQl4YKoAyZii_!O0;h55EMzD{;) z8lSJvv((#UqgJ?SCQFqJ-UU?2(0V{;7zT3TW`u6GH6h4m3}SuAAj_K(raGBu>|S&Q zZGL?r9@caTbmRm7p=&Tv?Y1)60*9At38w)$(1c?4cpFY2RLyw9c<{OwQE{b@WI}FQ zTT<2HOF4222d%k70yL~x_d#6SNz`*%@4++8gYQ8?yq0T@w~bF@aOHL2)T4xj`AVps9k z?m;<2ClJh$B6~fOYTWIV*T9y1BpB1*C?dgE{%lVtIjw>4MK{wP6OKTb znbPWrkZjYCbr`GGa%Xo0h;iFPNJBI3fK5`wtJV?wq_G<_PZ<`eiKtvN$IKfyju*^t zXc}HNg>^PPZ16m6bfTpmaW5=qoSsj>3)HS}teRa~qj+Y}mGRE?cH!qMDBJ8 zJB!&-=MG8Tb;V4cZjI_#{>ca0VhG_P=j0kcXVX5)^Sdpk+LKNv#yhpwC$k@v^Am&! z_cz2^4Cc{_BC!K#zN!KEkPzviUFPJ^N_L-kHG6}(X#$>Q=9?!{$A(=B3)P?PkxG9gs#l! zo6TOHo$F|IvjTC3MW%XrDoc7;m-6wb9mL(^2(>PQXY53hE?%4FW$rTHtN`!VgH72U zRY)#?Y*pMA<)x3B-&fgWQ(TQ6S6nUeSY{9)XOo_k=j$<*mA=f+ghSALYwBw~!Egn!jtjubOh?6Cb-Zi3IYn*fYl()^3u zRiX0I{5QaNPJ9w{yh4(o#$geO7b5lSh<5ZaRg9_=aFdZjxjXv(_SCv^v-{ZKQFtAA}kw=GPC7l81GY zeP@0Da{aR#{6`lbI0ON0y#K=t|L*}MG_HSl$e{U;v=BSs{SU3(e*qa(l%rD;(zM^3 zrRgN3M#Sf(Cr9>v{FtB`8JBK?_zO+~{H_0$lLA!l{YOs9KQd4Zt<3*Ns7dVbT{1Ut z?N9{XkN(96?r(4BH~3qeiJ_CAt+h1}O_4IUF$S(5EyTyo=`{^16P z=VhDY!NxkDukQz>T`0*H=(D3G7Np*2P`s(6M*(*ZJa;?@JYj&_z`d5bap=KK37p3I zr5#`%aC)7fUo#;*X5k7g&gQjxlC9CF{0dz*m2&+mf$Sc1LnyXn9lpZ!!Bl!@hnsE5px};b-b-`qne0Kh;hziNC zXV|zH%+PE!2@-IrIq!HM2+ld;VyNUZiDc@Tjt|-1&kq}>muY;TA3#Oy zWdYGP3NOZWSWtx6?S6ES@>)_Yz%%nLG3P>Z7`SrhkZ?shTfrHkYI;2zAn8h65wV3r z^{4izW-c9!MTge3eN=~r5aTnz6*6l#sD68kJ7Nv2wMbL~Ojj0H;M`mAvk*`Q!`KI? z7nCYBqbu$@MSNd+O&_oWdX()8Eh|Z&v&dJPg*o-sOBb2hriny)< zd(o&&kZM^NDtV=hufp8L zCkKu7)k`+czHaAU567$?GPRGdkb4$37zlIuS&<&1pgArURzoWCbyTEl9OiXZBn4p<$48-Gekh7>e)v*?{9xBt z=|Rx!@Y3N@ffW5*5!bio$jhJ7&{!B&SkAaN`w+&3x|D^o@s{ZAuqNss8K;211tUWIi1B!%-ViYX+Ys6w)Q z^o1{V=hK#+tt&aC(g+^bt-J9zNRdv>ZYm9KV^L0y-yoY7QVZJ_ivBS02I|mGD2;9c zR%+KD&jdXjPiUv#t1VmFOM&=OUE2`SNm4jm&a<;ZH`cYqBZoAglCyixC?+I+}*ScG#;?SEAFob{v0ZKw{`zw*tX}<2k zoH(fNh!>b5w8SWSV}rQ*E24cO=_eQHWy8J!5;Y>Bh|p;|nWH|nK9+ol$k`A*u*Y^Uz^%|h4Owu}Cb$zhIxlVJ8XJ0xtrErT zcK;34CB;ohd|^NfmVIF=XlmB5raI}nXjFz;ObQ4Mpl_`$dUe7sj!P3_WIC~I`_Xy@ z>P5*QE{RSPpuV=3z4p3}dh>Dp0=We@fdaF{sJ|+_E*#jyaTrj-6Y!GfD@#y@DUa;& zu4Iqw5(5AamgF!2SI&WT$rvChhIB$RFFF|W6A>(L9XT{0%DM{L`knIQPC$4F`8FWb zGlem_>>JK-Fib;g*xd<-9^&_ue95grYH>5OvTiM;#uT^LVmNXM-n8chJBD2KeDV7t zbnv3CaiyN>w(HfGv86K5MEM{?f#BTR7**smpNZ}ftm+gafRSt=6fN$(&?#6m3hF!>e$X)hFyCF++Qvx(<~q3esTI zH#8Sv!WIl2<&~=B)#sz1x2=+KTHj=0v&}iAi8eD=M->H|a@Qm|CSSzH#eVIR3_Tvu zG8S**NFbz%*X?DbDuP(oNv2;Lo@#_y4k$W+r^#TtJ8NyL&&Rk;@Q}~24`BB)bgwcp z=a^r(K_NEukZ*|*7c2JKrm&h&NP)9<($f)eTN}3|Rt`$5uB0|!$Xr4Vn#i;muSljn zxG?zbRD(M6+8MzGhbOn%C`M#OcRK!&ZHihwl{F+OAnR>cyg~No44>vliu$8^T!>>*vYQJCJg=EF^lJ*3M^=nGCw`Yg@hCmP(Gq^=eCEE1!t-2>%Al{w@*c% zUK{maww*>K$tu;~I@ERb9*uU@LsIJ|&@qcb!&b zsWIvDo4#9Qbvc#IS%sV1_4>^`newSxEcE08c9?rHY2%TRJfK2}-I=Fq-C)jc`gzV( zCn?^noD(9pAf2MP$>ur0;da`>Hr>o>N@8M;X@&mkf;%2A*2CmQBXirsJLY zlX21ma}mKH_LgYUM-->;tt;6F?E5=fUWDwQhp*drQ%hH0<5t2m)rFP%=6aPIC0j$R znGI0hcV~}vk?^&G`v~YCKc7#DrdMM3TcPBmxx#XUC_JVEt@k=%3-+7<3*fTcQ>f~?TdLjv96nb66xj=wVQfpuCD(?kzs~dUV<}P+Fpd)BOTO^<*E#H zeE80(b~h<*Qgez(iFFOkl!G!6#9NZAnsxghe$L=Twi^(Q&48 zD0ohTj)kGLD){xu%pm|}f#ZaFPYpHtg!HB30>F1c=cP)RqzK2co`01O5qwAP zUJm0jS0#mci>|Nu4#MF@u-%-4t>oUTnn_#3K09Hrwnw13HO@9L;wFJ*Z@=gCgpA@p zMswqk;)PTXWuMC-^MQxyNu8_G-i3W9!MLd2>;cM+;Hf&w| zLv{p*hArp9+h2wsMqT5WVqkkc0>1uokMox{AgAvDG^YJebD-czexMB!lJKWllLoBI zetW2;;FKI1xNtA(ZWys!_un~+834+6y|uV&Lo%dKwhcoDzRADYM*peh{o`-tHvwWIBIXW`PKwS3|M>CW37Z2dr!uJWNFS5UwY4;I zNIy1^sr+@8Fob%DHRNa&G{lm?KWU7sV2x9(Ft5?QKsLXi!v6@n&Iyaz5&U*|hCz+d z9vu60IG<v6+^ZmBs_aN!}p|{f(ikVl&LcB+UY;PPz* zj84Tm>g5~-X=GF_4JrVmtEtm=3mMEL1#z+pc~t^Iify^ft~cE=R0TymXu*iQL+XLX zdSK$~5pglr3f@Lrcp`>==b5Z6r7c=p=@A5nXNacsPfr(5m;~ks@*Wu7A z%WyY$Pt*RAKHz_7cghHuQqdU>hq$vD?plol_1EU(Fkgyo&Q2&2e?FT3;H%!|bhU~D z>VX4-6}JLQz8g3%Bq}n^NhfJur~v5H0dbB^$~+7lY{f3ES}E?|JnoLsAG%l^%eu_PM zEl0W(sbMRB3rFeYG&tR~(i2J0)RjngE`N_Jvxx!UAA1mc7J>9)`c=`}4bVbm8&{A` z3sMPU-!r-8de=P(C@7-{GgB<5I%)x{WfzJwEvG#hn3ict8@mexdoTz*(XX!C&~}L* z^%3eYQ8{Smsmq(GIM4d5ilDUk{t@2@*-aevxhy7yk(wH?8yFz%gOAXRbCYzm)=AsM z?~+vo2;{-jkA%Pqwq&co;|m{=y}y2lN$QPK>G_+jP`&?U&Ubq~T`BzAj1TlC`%8+$ zzdwNf<3suPnbh&`AI7RAYuQ<#!sD|A=ky2?hca{uHsB|0VqShI1G3lG5g}9~WSvy4 zX3p~Us^f5AfXlBZ0hA;mR6aj~Q8yb^QDaS*LFQwg!!<|W!%WX9Yu}HThc7>oC9##H zEW`}UQ%JQ38UdsxEUBrA@=6R-v1P6IoIw8$8fw6F{OSC7`cOr*u?p_0*Jvj|S)1cd z-9T);F8F-Y_*+h-Yt9cQQq{E|y^b@r&6=Cd9j0EZL}Pj*RdyxgJentY49AyC@PM<< zl&*aq_ubX%*pqUkQ^Zsi@DqhIeR&Ad)slJ2g zmeo&+(g!tg$z1ao1a#Qq1J022mH4}y?AvWboI4H028;trScqDQrB36t!gs|uZS9}KG0}DD$ zf2xF}M*@VJSzEJ5>ucf+L_AtN-Ht=34g&C?oPP>W^bwoigIncKUyf61!ce!2zpcNT zj&;rPGI~q2!Sy>Q7_lRX*DoIs-1Cei=Cd=+Xv4=%bn#Yqo@C=V`|QwlF0Y- zONtrwpHQ##4}VCL-1ol(e<~KU9-ja^kryz!g!})y-2S5z2^gE$Isj8l{%tF=Rzy`r z^RcP7vu`jHgHLKUE957n3j+BeE(bf;f)Zw($XaU6rZ26Upl#Yv28=8Y`hew{MbH>* z-sGI6dnb5D&dUCUBS`NLAIBP!Vi!2+~=AU+)^X^IpOEAn#+ab=`7c z%7B|mZ>wU+L;^&abXKan&N)O;=XI#dTV|9OMYxYqLbtT#GY8PP$45Rm2~of+J>>HIKIVn(uQf-rp09_MwOVIp@6!8bKV(C#(KxcW z;Pesq(wSafCc>iJNV8sg&`!g&G55<06{_1pIoL`2<7hPvAzR1+>H6Rx0Ra%4j7H-<-fnivydlm{TBr06;J-Bq8GdE^Amo)ptV>kS!Kyp*`wUx=K@{3cGZnz53`+C zLco1jxLkLNgbEdU)pRKB#Pq(#(Jt>)Yh8M?j^w&RPUueC)X(6`@@2R~PV@G(8xPwO z^B8^+`qZnQr$8AJ7<06J**+T8xIs)XCV6E_3W+al18!ycMqCfV>=rW0KBRjC* zuJkvrv;t&xBpl?OB3+Li(vQsS(-TPZ)Pw2>s8(3eF3=n*i0uqv@RM^T#Ql7(Em{(~%f2Fw|Reg@eSCey~P zBQlW)_DioA*yxxDcER@_=C1MC{UswPMLr5BQ~T6AcRyt0W44ffJG#T~Fk}wU^aYoF zYTayu-s?)<`2H(w+1(6X&I4?m3&8sok^jpXBB<|ZENso#?v@R1^DdVvKoD?}3%@{}}_E7;wt9USgrfR3(wabPRhJ{#1es81yP!o4)n~CGsh2_Yj2F^z|t zk((i&%nDLA%4KFdG96pQR26W>R2^?C1X4+a*hIzL$L=n4M7r$NOTQEo+k|2~SUI{XL{ynLSCPe%gWMMPFLO{&VN2pom zBUCQ(30qj=YtD_6H0-ZrJ46~YY*A;?tmaGvHvS^H&FXUG4)%-a1K~ly6LYaIn+4lG zt=wuGLw!%h=Pyz?TP=?6O-K-sT4W%_|Nl~;k~YA^_`gqfe{Xw=PWn#9f1mNz)sFuL zJbrevo(DPgpirvGMb6ByuEPd=Rgn}fYXqeUKyM+!n(cKeo|IY%p!#va6`D8?A*{u3 zEeWw0*oylJ1X!L#OCKktX2|>-z3#>`9xr~azOH+2dXHRwdfnpri9|xmK^Q~AuY!Fg z`9Xx?hxkJge~)NVkPQ(VaW(Ce2pXEtgY*cL8i4E)mM(iz_vdm|f@%cSb*Lw{WbShh41VGuplex9E^VvW}irx|;_{VK=N_WF39^ zH4<*peWzgc)0UQi4fBk2{FEzldDh5+KlRd!$_*@eYRMMRb1gU~9lSO_>Vh-~q|NTD zL}X*~hgMj$*Gp5AEs~>Bbjjq7G>}>ki1VxA>@kIhLe+(EQS0mjNEP&eXs5)I;7m1a zmK0Ly*!d~Dk4uxRIO%iZ!1-ztZxOG#W!Q_$M7_DKND0OwI+uC;PQCbQ#k#Y=^zQve zTZVepdX>5{JSJb;DX3%3g42Wz2D@%rhIhLBaFmx#ZV8mhya}jo1u{t^tzoiQy=jJp zjY2b7D2f$ZzJx)8fknqdD6fd5-iF8e(V}(@xe)N=fvS%{X$BRvW!N3TS8jn=P%;5j zShSbzsLs3uqycFi3=iSvqH~}bQn1WQGOL4?trj(kl?+q2R23I42!ipQ&`I*&?G#i9 zWvNh8xoGKDt>%@i0+}j?Ykw&_2C4!aYEW0^7)h2Hi7$;qgF3;Go?bs=v)kHmvd|`R z%(n94LdfxxZ)zh$ET8dH1F&J#O5&IcPH3=8o;%>OIT6w$P1Yz4S!}kJHNhMQ1(prc zM-jSA-7Iq=PiqxKSWb+YbLB-)lSkD6=!`4VL~`ExISOh2ud=TI&SKfR4J08Bad&rj zcXxMpcNgOB?w$~L7l^wPcXxw$0=$oV?)`I44)}b#ChS`_lBQhvb6ks?HDr3tFgkg&td19?b8=!sETXtp=&+3T$cCwZe z0nAET-7561gsbBws$TVjP7QxY(NuBYXVn9~9%vyN-B#&tJhWgtL1B<%BTS*-2$xB` zO)cMDHoWsm%JACZF--Pa7oP;f!n%p`*trlpvZ!HKoB={l+-(8O;;eYv2A=ra z3U7rSMCkP_6wAy`l|Se(&5|AefXvV1E#XA(LT!% zjj4|~xlZ-kPLNeQLFyXb%$K}YEfCBvHA-Znw#dZSI6V%3YD{Wj2@utT5Hieyofp6Qi+lz!u)htnI1GWzvQsA)baEuw9|+&(E@p8M+#&fsX@Kf`_YQ>VM+40YLv`3-(!Z7HKYg@+l00WGr779i-%t`kid%e zDtbh8UfBVT3|=8FrNian@aR3*DTUy&u&05x%(Lm3yNoBZXMHWS7OjdqHp>cD>g!wK z#~R{1`%v$IP;rBoP0B0P><;dxN9Xr+fp*s_EK3{EZ94{AV0#Mtv?;$1YaAdEiq5)g zYME;XN9cZs$;*2p63Q9^x&>PaA1p^5m7|W?hrXp2^m;B@xg0bD?J;wIbm6O~Nq^^K z2AYQs@7k)L#tgUkTOUHsh&*6b*EjYmwngU}qesKYPWxU-z_D> zDWr|K)XLf_3#k_9Rd;(@=P^S^?Wqlwert#9(A$*Y$s-Hy)BA0U0+Y58zs~h=YtDKxY0~BO^0&9{?6Nny;3=l59(6ec9j(79M?P1cE zex!T%$Ta-KhjFZLHjmPl_D=NhJULC}i$}9Qt?nm6K6-i8&X_P+i(c*LI3mtl3 z*B+F+7pnAZ5}UU_eImDj(et;Khf-z^4uHwrA7dwAm-e4 zwP1$Ov3NP5ts+e(SvM)u!3aZMuFQq@KE-W;K6 zag=H~vzsua&4Sb$4ja>&cSJ)jjVebuj+?ivYqrwp3!5>ul`B*4hJGrF;!`FaE+wKo z#};5)euvxC1zX0-G;AV@R(ZMl=q_~u8mQ5OYl;@BAkt)~#PynFX#c1K zUQ1^_N8g+IZwUl*n0Bb-vvliVtM=zuMGU-4a8|_8f|2GEd(2zSV?aSHUN9X^GDA8M zgTZW06m*iAy@7l>F3!7+_Y3mj^vjBsAux3$%U#d$BT^fTf-7{Y z_W0l=7$ro5IDt7jp;^cWh^Zl3Ga1qFNrprdu#g=n9=KH!CjLF#ucU5gy6*uASO~|b z7gcqm90K@rqe({P>;ww_q%4}@bq`ST8!0{V08YXY)5&V!>Td)?j7#K}HVaN4FU4DZ z%|7OppQq-h`HJ;rw-BAfH* z1H$ufM~W{%+b@9NK?RAp-$(P0N=b<(;wFbBN0{u5vc+>aoZ|3&^a866X@el7E8!E7 z=9V(Ma**m_{DKZit2k;ZOINI~E$|wO99by=HO{GNc1t?nl8soP@gxk8)WfxhIoxTP zoO`RA0VCaq)&iRDN9yh_@|zqF+f07Esbhe!e-j$^PS57%mq2p=+C%0KiwV#t^%_hH zoO?{^_yk5x~S)haR6akK6d|#2TN& zfWcN zc7QAWl)E9`!KlY>7^DNw$=yYmmRto>w0L(~fe?|n6k2TBsyG@sI)goigj=mn)E)I* z4_AGyEL7?(_+2z=1N@D}9$7FYdTu;%MFGP_mEJXc2OuXEcY1-$fpt8m_r2B|<~Xfs zX@3RQi`E-1}^9N{$(|YS@#{ZWuCxo)91{k>ESD54g_LYhm~vlOK_CAJHeYFfuIVB^%cqCfvpy#sU8Do8u}# z>>%PLKOZ^+$H54o@brtL-hHorSKcsjk_ZibBKBgyHt~L z=T6?e0oLX|h!Z3lbkPMO27MM?xn|uZAJwvmX?Yvp#lE3sQFY)xqet>`S2Y@1t)Z*& z;*I3;Ha8DFhk=YBt~{zp=%%*fEC}_8?9=(-k7HfFeN^GrhNw4e?vx*#oMztnO*&zY zmRT9dGI@O)t^=Wj&Og1R3b%(m*kb&yc;i`^-tqY9(0t!eyOkH<$@~1lXmm!SJllE_ zr~{a&w|8*LI>Z^h!m%YLgKv06Js7j7RaoX}ZJGYirR<#4Mghd{#;38j3|V+&=ZUq#1$ zgZb-7kV)WJUko?{R`hpSrC;w2{qa`(Z4gM5*ZL`|#8szO=PV^vpSI-^K_*OQji^J2 zZ_1142N}zG$1E0fI%uqHOhV+7%Tp{9$bAR=kRRs4{0a`r%o%$;vu!_Xgv;go)3!B#;hC5qD-bcUrKR&Sc%Zb1Y($r78T z=eG`X#IpBzmXm(o6NVmZdCQf6wzqawqI63v@e%3TKuF!cQ#NQbZ^?6K-3`_b=?ztW zA>^?F#dvVH=H-r3;;5%6hTN_KVZ=ps4^YtRk>P1i>uLZ)Ii2G7V5vy;OJ0}0!g>j^ z&TY&E2!|BDIf1}U(+4G5L~X6sQ_e7In0qJmWYpn!5j|2V{1zhjZt9cdKm!we6|Pp$ z07E+C8=tOwF<<}11VgVMzV8tCg+cD_z?u+$sBjwPXl^(Ge7y8-=c=fgNg@FxI1i5Y-HYQMEH z_($je;nw`Otdhd1G{Vn*w*u@j8&T=xnL;X?H6;{=WaFY+NJfB2(xN`G)LW?4u39;x z6?eSh3Wc@LR&yA2tJj;0{+h6rxF zKyHo}N}@004HA(adG~0solJ(7>?LoXKoH0~bm+xItnZ;3)VJt!?ue|~2C=ylHbPP7 zv2{DH()FXXS_ho-sbto)gk|2V#;BThoE}b1EkNYGT8U#0ItdHG>vOZx8JYN*5jUh5Fdr9#12^ zsEyffqFEQD(u&76zA^9Jklbiz#S|o1EET$ujLJAVDYF znX&4%;vPm-rT<8fDutDIPC@L=zskw49`G%}q#l$1G3atT(w70lgCyfYkg7-=+r7$%E`G?1NjiH)MvnKMWo-ivPSQHbk&_l5tedNp|3NbU^wk0SSXF9ohtM zUqXiOg*8ERKx{wO%BimK)=g^?w=pxB1Vu_x<9jKOcU7N;(!o3~UxyO+*ZCw|jy2}V*Z22~KhmvxoTszc+#EMWXTM6QF*ks% zW47#2B~?wS)6>_ciKe1Fu!@Tc6oN7e+6nriSU;qT7}f@DJiDF@P2jXUv|o|Wh1QPf zLG31d>@CpThA+Ex#y)ny8wkC4x-ELYCXGm1rFI=1C4`I5qboYgDf322B_Nk@#eMZ% znluCKW2GZ{r9HR@VY`>sNgy~s+D_GkqFyz6jgXKD)U|*eKBkJRRIz{gm3tUd*yXmR z(O4&#ZA*us6!^O*TzpKAZ#}B5@}?f=vdnqnRmG}xyt=)2o%<9jj>-4wLP1X-bI{(n zD9#|rN#J;G%LJ&$+Gl2eTRPx6BQC6Uc~YK?nMmktvy^E8#Y*6ZJVZ>Y(cgsVnd!tV z!%twMNznd)?}YCWyy1-#P|2Fu%~}hcTGoy>_uawRTVl=(xo5!%F#A38L109wyh@wm zdy+S8E_&$Gjm=7va-b7@Hv=*sNo0{i8B7=n4ex-mfg`$!n#)v@xxyQCr3m&O1Jxg! z+FXX^jtlw=utuQ+>Yj$`9!E<5-c!|FX(~q`mvt6i*K!L(MHaqZBTtuSA9V~V9Q$G? zC8wAV|#XY=;TQD#H;;dcHVb9I7Vu2nI0hHo)!_{qIa@|2}9d ztpC*Q{4Py~2;~6URN^4FBCBip`QDf|O_Y%iZyA0R`^MQf$ce0JuaV(_=YA`knEMXw zP6TbjYSGXi#B4eX=QiWqb3bEw-N*a;Yg?dsVPpeYFS*&AsqtW1j2D$h$*ZOdEb$8n0 zGET4Igs^cMTXWG{2#A7w_usx=KMmNfi4oAk8!MA8Y=Rh9^*r>jEV(-{I0=rc);`Y) zm+6KHz-;MIy|@2todN&F+Yv1e&b&ZvycbTHpDoZ>FIiUn+M-=%A2C(I*^Yx@VKf(Z zxJOny&WoWcyKodkeN^5))aV|-UBFw{?AGo?;NNFFcKzk+6|gYfA#FR=y@?;3IoQ zUMI=7lwo9gV9fRvYi}Nd)&gQw7(K3=a0#p27u6Q)7JlP#A)piUUF8B3Li&38Xk$@| z9OR+tU~qgd3T3322E))eV)hAAHYIj$TmhH#R+C-&E-}5Qd{3B}gD{MXnsrS;{Erv1 z6IyQ=S2qD>Weqqj#Pd65rDSdK54%boN+a?=CkR|agnIP6;INm0A*4gF;G4PlA^3%b zN{H%#wYu|!3fl*UL1~f+Iu|;cqDax?DBkZWSUQodSDL4Es@u6zA>sIm>^Aq-&X#X8 zI=#-ucD|iAodfOIY4AaBL$cFO@s(xJ#&_@ZbtU+jjSAW^g;_w`FK%aH_hAY=!MTjI zwh_OEJ_25zTQv$#9&u0A11x_cGd92E74AbOrD`~f6Ir9ENNQAV2_J2Ig~mHWhaO5a zc>fYG$zke^S+fBupw+klDkiljJAha z6DnTemhkf>hv`8J*W_#wBj-2w(cVtXbkWWtE(3j@!A-IfF?`r$MhVknTs3D1N`rYN zKth9jZtX#>v#%U@^DVN!;ni#n1)U&H_uB{6pcq7$TqXJX!Q0P7U*JUZyclb~)l*DS zOLpoQfW_3;a0S$#V0SOwVeeqE$Hd^L`$;l_~2giLYd?7!gUYIpOs!jqSL~pI)4`YuB_692~A z^T#YYQ_W3Rakk}$SL&{`H8mc{>j+3eKprw6BK`$vSSIn;s31M~YlJLApJ)+Gi1{^- zw96WnT9M0Vr_D=e=a}${raR{(35Q!g+8`}vOFj1e&Or(_wp2U2aVQP0_jP57 z2(R4E(E$n!xl<}Zx38wO;27wuQ`P#_j!}L2 z2qr;As4D4n2X$-Jd_-!fsbu_D(64i;c4cJnP576x_>Q4WNushFwkBV!kVd(AYFXe{ zaqO5`Qfr!#ETmE(B;u_&FITotv~W}QYFCI!&ENKIb1p4fg*Yv1)EDMb==EjHHWM#{ zGMpqb2-LXdHB@D~pE3|+B392Gh4q)y9jBd$a^&cJM60VEUnLtHQD5i-X6PVF>9m_k zDvG3P(?CzdaIrC8s4cu~N9MEb!Tt(g*GK~gIp1Gyeaw3b7#YPx_1T6i zRi#pAMr~PJKe9P~I+ARa$a!K~)t(4LaVbjva1yd;b1Yz2$7MMc`aLmMl(a^DgN(u? zq2o9&Gif@Tq~Yq+qDfx^F*nCnpuPv%hRFc$I!p74*quLt^M}D_rwl10uMTr!)(*=7 zSC5ea@#;l(h87k4T4x)(o^#l76P-GYJA(pOa&F9YT=fS<*O{4agzba^dIrh0hjls<~APlIz9{ zgRY{OMv2s|`;VCoYVj?InYoq^QWuA&*VDyOn@pPvK8l~g#1~~MGVVvtLDt}>id_Z` zn(ihfL?Y}Y4YX335m*Xx(y+bbukchHrM zycIGp#1*K3$!(tgTsMD2VyUSg^yvCwB8*V~sACE(yq2!MS6f+gsxv^GR|Q7R_euYx z&X+@@H?_oQddGxJYS&ZG-9O(X+l{wcw;W7srpYjZZvanY(>Q1utSiyuuonkjh5J0q zGz6`&meSuxixIPt{UoHVupUbFKIA+3V5(?ijn}(C(v>=v?L*lJF8|yRjl-m#^|krg zLVbFV6+VkoEGNz6he;EkP!Z6|a@n8?yCzX9>FEzLnp21JpU0x!Qee}lwVKA})LZJq zlI|C??|;gZ8#fC3`gzDU%7R87KZyd)H__0c^T^$zo@TBKTP*i{)Gp3E0TZ}s3mKSY zix@atp^j#QnSc5K&LsU38#{lUdwj%xF zcx&l^?95uq9on1m*0gp$ruu||5MQo)XaN>|ngV5Jb#^wWH^5AdYcn_1>H~XtNwJd3 zd9&?orMSSuj=lhO?6)Ay7;gdU#E}pTBa5wFu`nejq##Xd71BHzH2XqLA5 zeLEo;9$}~u0pEu@(?hXB_l;{jQ=7m?~mwj-ME~Tw-OHPrR7K2Xq9eCNwQO$hR z3_A?=`FJctNXA#yQEorVoh{RWxJbdQga zU%K##XEPgy?E|K(=o#IPgnbk7E&5%J=VHube|2%!Qp}@LznjE%VQhJ?L(XJOmFVY~ zo-az+^5!Ck7Lo<7b~XC6JFk>17*_dY;=z!<0eSdFD2L?CSp_XB+?;N+(5;@=_Ss3& zXse>@sA7hpq;IAeIp3hTe9^$DVYf&?)={zc9*hZAV)|UgKoD!1w{UVo8D)Htwi8*P z%#NAn+8sd@b{h=O)dy9EGKbpyDtl@NBZw0}+Wd=@65JyQ2QgU}q2ii;ot1OsAj zUI&+Pz+NvuRv#8ugesT<<@l4L$zso0AQMh{we$tkeG*mpLmOTiy8|dNYhsqhp+q*yfZA`Z)UC*(oxTNPfOFk3RXkbzAEPofVUy zZ3A%mO?WyTRh@WdXz+zD!ogo}gbUMV!YtTNhr zrt@3PcP%5F;_SQ>Ui`Gq-lUe&taU4*h2)6RDh@8G1$o!){k~3)DT87%tQeHYdO?B` zAmoJvG6wWS?=0(Cj?Aqj59`p(SIEvYyPGJ^reI z`Hr?3#U2zI7k0=UmqMD35l`>3xMcWlDv$oo6;b`dZq3d!~)W z=4Qk)lE8&>#HV>?kRLOHZYz83{u7?^KoXmM^pazj8`7OwQ=5I!==; zA!uN`Q#n=Drmzg}@^nG!mJp9ml3ukWk96^6*us*;&>s+7hWfLXtl?a}(|-#=P12>A zon1}yqh^?9!;on?tRd6Fk0knQSLl4vBGb87A_kJNDGyrnpmn48lz_%P{* z_G*3D#IR<2SS54L5^h*%=)4D9NPpji7DZ5&lHD|99W86QN_(|aJ<5C~PX%YB`Qt_W z>jF_Os@kI6R!ub4n-!orS(G6~mKL7()1g=Lf~{D!LR7#wRHfLxTjYr{*c{neyhz#U zbm@WBKozE+kTd+h-mgF+ELWqTKin57P;0b){ zii5=(B%S(N!Z=rAFGnM6iePtvpxB_Q9-oq_xH!URn2_d-H~i;lro8r{-g!k-Ydb6_w5K@FOV?zPF_hi z%rlxBv$lQi%bjsu^7KT~@u#*c$2-;AkuP)hVEN?W5MO8C9snj*EC&|M!aK6o12q3+ z8e?+dH17E!A$tRlbJW~GtMDkMPT=m1g-v67q{sznnWOI$`g(8E!Pf!#KpO?FETxLK z2b^8^@mE#AR1z(DT~R3!nnvq}LG2zDGoE1URR=A2SA z%lN$#V@#E&ip_KZL}Q6mvm(dsS?oHoRf8TWL~1)4^5<3JvvVbEsQqSa3(lF*_mA$g zv`LWarC79G)zR0J+#=6kB`SgjQZ2460W zN%lZt%M@=EN>Wz4I;eH>C0VnDyFe)DBS_2{h6=0ZJ*w%s)QFxLq+%L%e~UQ0mM9ud zm&|r){_<*Om%vlT(K9>dE(3AHjSYro5Y1I?ZjMqWyHzuCE0nyCn`6eq%MEt(aY=M2rIzHeMds)4^Aub^iTIT|%*izG4YH;sT`D9MR(eND-SB+e66LZT z2VX)RJsn${O{D48aUBl|(>ocol$1@glsxisc#GE*=DXHXA?|hJT#{;X{i$XibrA}X zFHJa+ssa2$F_UC(o2k2Z0vwx%Wb(<6_bdDO#=a$0gK2NoscCr;vyx?#cF)JjM%;a| z$^GIlIzvz%Hx3WVU481}_e4~aWcyC|j&BZ@uWW1`bH1y9EWXOxd~f-VE5DpueNofN zv7vZeV<*!A^|36hUE;`#x%MHhL(~?eZ5fhA9Ql3KHTWoAeO-^7&|2)$IcD1r5X#-u zN~N0$6pHPhop@t1_d`dO3#TC0>y5jm>8;$F5_A2& zt#=^IDfYv?JjPPTPNx2TL-Lrl82VClQSLWW_$3=XPbH}xM34)cyW5@lnxy=&h%eRq zv29&h^fMoxjsDnmua(>~OnX{Cq!7vM0M4Mr@_18|YuSKPBKUTV$s^So zc}JlAW&bVz|JY#Eyup6Ny{|P_s0Pq;5*tinH+>5Xa--{ z2;?2PBs((S4{g=G`S?B3Ien`o#5DmUVwzpGuABthYG~OKIY`2ms;33SN9u^I8i_H5`BQ%yOfW+N3r|ufHS_;U;TWT5z;b14n1gX%Pn`uuO z6#>Vl)L0*8yl|#mICWQUtgzeFp9$puHl~m&O+vj3Ox#SxQUa?fY*uK?A;00RiFg(G zK?g=7b5~U4QIK`C*um%=Sw=OJ1eeaV@WZ%hh-3<=lR#(Xesk%?)l4p(EpTwPvN99V@TT)!A8SeFTV+frN=r|5l?K#odjijx2nFgc3kI zC$hVs1S-!z9>xn9MZcRk0YXdYlf~8*LfH$IHKD59H&gLz%6 z#mAYSRJufbRi~LRadwM*G!O2>&U<^d`@<)otXZJJxT@G}4kTx0zPDVhVXwiU)$}5Y z`0iV`8EEh&GlUk&VY9m0Mqr*U&|^Bc?FB`<%{x-o0ATntwIA%(YDcxWs$C)%a%d_@ z?fx!Co+@3p7ha$|pWYD}p6#(PG%_h8K7sQjT_P~|3ZEH0DRxa3~bP&&lPMj3C~!H2QD zq>(f^RUFSqf6K3BMBFy$jiuoSE+DhEq$xLDb7{57 z0B|1pSjYJ5F@cHG%qDZ{ogL$P!BK&sR%zD`gbK#9gRZX17EtAJxN% zys^gb2=X9=7HP}N(iRqt(tot2yyeE%s;L}AcMh;~-W~s_eAe!gIUYdQz5j~T)0trh z>#1U$uOyyl%!Pi(gD&)uHe9Q^27_kHyFCC}n^-KL(=OxHqUfex1YS__RJh0m-S>eM zqAk`aSev*z1lI&-?CycgDm=bdQCp}RqS0_d-4Mf&>u2KyGFxKe8JM1N{GNWw0n$FL z1UDp(h0(1I2Jh9I`?IS}h4R~n zRwRz>8?$fFMB2{UPe^$Ifl;Oc>}@Q9`|8DCeR{?LUQLPfaMsxs8ps=D_aAXORZH~< zdcIOca-F;+D3~M+)Vi4h)I4O3<)$65yI)goQ_vk#fb;Uim>UI4Dv9#2b1;N_Wg>-F zNwKeMKY+su#~NL0uE%_$mw1%ddX2Qs2P!ncM+>wnz}OCQX1!q~oS?OqYU;&ESAAwP z452QWL0&u^mraF#=j_ZeBWhm&F|d!QjwRl^7=Bl7@(43=BkN=3{BRv#QHIk>Umc_w zvP>q|q{lJ=zs|W9%a@8%W>C@MYN1D5{(=Af31+pR#kB`cd0-YlQQTg}+ zL|_h=F9JQ|Gux5c0ehaffHNYLf8VwF+qnM6IjBEI_eceee;o;FY@#~FFVsZjBSp!j z8V*Bgmn{RK!!zqGc;jy)z@Zjo>5{%m1?K}fLEL$l6Dl4f=ye0wNI#)2L=^K(&18Gb zJoj8@WBB;P^T#V)I0`aDSy?$rJU{+-5472NyFp>;Vw43j@3Z=;D2eSfyw5*0Q+&ML zsV&&*3c3$pa`qcaGbEB0*CA~Wp3%PkF?B87FV&rWNb|@GU$LB;l|;YutU*k za1hjUL_BX%G^s;BuzRi4Hl?eqC2z&ZrKh1tZDwnufG$g$LX(j!h%F5(n8D@in3lnX z(*8+3ZT6TVYRcSpM1eMeCps=Fz8q%gyM&B=a7(Vf`4k3dN$IM+`BO^_7HZq4BR|7w z+5kOJ;9_$X%-~arA@qmXSzD|+NMh--%5-9u6t(M=f%&z$<_V#Y_lzn{E$MZZG)+A> zu2E`_Y(MBJ2l*AqvCUmU;yBT}#oQ{V=((mC-QGJwsCOH*a;{1JRTKv7DBNG+M!XL7(^jbv&Qy-o9HNFrmN)-`D3WFtXs>1vBOJpI(=x; zKhJlFdfMf^G#oU(w1+ucMKYPZaDp>$kt=wiYsBCjUY-uz<4JziB>6fXDSLH*2Y z&Px5y`#3!fF=c4>fCMdg-tX582pemU@ZxyFbznL8-=TTo1Sybg9>7h*J^9^~XxXJO z`k9v~=4amxl<;FCV9h2k%?^-ZUzQy^#{JleyH23o1S{r<+t#z6jKS<9rbAM96^1iY zi6{IjauB)UwBhC-_L(MzGCxhhv`?ryc zja_Uwi7$8l!}*vjJppGyp#Wz=*?;jC*xQ&J894rql5A$2giJRtV&DWQh#(+Vs3-5_ z69_tj(>8%z1VtVp>a74r5}j2rG%&;uaTQ|fr&r%ew-HO}76i8`&ki%#)~}q4Y|d$_ zfNp9uc#$#OEca>>MaY6rF`dB|5#S)bghf>>TmmE&S~IFw;PF0UztO6+R-0!TSC?QP z{b(RA_;q3QAPW^XN?qQqu{h<}Vfiv}Rr!lA$C79^1=U>+ng9Dh>v{`?AOZt>CrQ=o zI}=mSnR))8fJpO->rcX?H);oqSQUZ?sR!fH2SoFdcPm5*2y<_u;4h;BqcF*XbwWSv zcJN%!g|L(22Xp!^1?c;T&qm%rpkP&2EQC3JF+SENm$+@7#e!UKD1uQ{TDw43?!b!3 zUooS_rt=xJfa&h?c^hfV>YwQXre3qosz_^c#)FO~d!<)2o}Oxz5HWtr<)1Yw012v4 zhv0w(RfJspDnA^-6Jmr;GkWt%{mAYOm6yPb&Vl&rv@D^K&;#?=X{kaK5FhScNJ_3> z#5u(Saisq2(~pVlrfG#@kLM#Ot~5rZZc%B&h1=gen?R+#t^1bYKf zVvtefX=D$*)39e^2@!~A_}9c${Gf0?1;dk=!Itp#s%0>Io%k`9(bDeI-udd&E6Zfu zcaiv(h`DM3W3Mfda)fYwhB=8RAPkotVt5-z21Ij~Ot9A^SK-1u*zFVK&mF?q1;|wy zrF+XWs^5Q-%Z6I62gTwrRe#F>riVM#fv_TihxSJ6to1X7NVszgivoTa!fPfBBYj94 zuc2m zL_k-<1FoORng1aL{Zx(P7JmUiH zlmTHdzkn75=mS{V=o$V;gzhEaunoJzJ3uq>0_w~77eID^U*w+v0po_N8=sS-DL~!V z%-~rL<0V7PCEWPCpNgpfsein`Fr)+8=N}mUn2x=K`z%efnhSs#23&N1fjdO`M>s%z zP3(;v93%lLq>ZfqBi#QI-aCXAP8-may8x5s`G)KA;{HSYe2szWINWf^b*fc{jl0KecD zRTle?)%_YzJJcVb>;VJ>P?3Lu2S)vCJZlF>Jxj~~X2U5-NNNy(H?8%XD~yFUxNKs&hwWx^)iF@ zGmEv<|7Q7hGrY_+`iz+d_=^9c(_c}UCzq2#%A0|5WjzCXjZUOxOX zU&-^smw$iwKPe;r`&{rP{L35^&+wk6f2-Sn;D2Ww@sjAJj{Gwbp4H!o{#5_}qALFq z{-q%LGklZvKf%A4D!+t%sRRBDi(>mvuz&V4yu^GdD*KFy?fg%ef5ZU%w=d&M`POGt zNSEJ0{qJI~FRTAjlJc1-+x>Tm{%D?m3sk-&cq#w)OpxI98wCF#2KbWcrAXK_(}M4B zF#VQf*h|irx=+uXZUMi+`A;fPFR5M%Wjs^Wh5rWCKgedhWO^w|@XS;b^&3oom;>K0 zB??|ry^IBarYem6Z7RU`#rDs-ZZAn*hSollv?csD$sh0QpTtI9vb>Dpd}e7*`fZj! zM|8d{~YM@vfW-r0z8vJ z<^6B6Ur(}L?ms_c9@hO0^Iy&J_uc51^?d33e#Y!-``?)VG)BGjCq5$&0G8A*r!2qk zUHscGc;VxE=1KqbH=dW%&Ogl({>L!>((m$2W8M9KQ@a1=h51jN|KoG{v(x0K&*iy% e1c3cF4~(n?C}6GmGu)3JNC)6=LGAhZ*Z%`+-T+_# diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a95009c3..37f853b1 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index cccdd3d5..faf93008 100755 --- a/gradlew +++ b/gradlew @@ -1,78 +1,129 @@ -#!/usr/bin/env sh +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -81,92 +132,120 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=$((i+1)) + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" fi +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index e95643d6..9b42019c 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,4 +1,22 @@ -@if "%DEBUG%" == "" @echo off +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem + +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -9,25 +27,29 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init +if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -35,48 +57,36 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/intercom-java/.gitignore b/intercom-java/.gitignore deleted file mode 100644 index ae3c1726..00000000 --- a/intercom-java/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/bin/ diff --git a/intercom-java/build.gradle b/intercom-java/build.gradle deleted file mode 100644 index 9ce44ea4..00000000 --- a/intercom-java/build.gradle +++ /dev/null @@ -1,134 +0,0 @@ -import java.text.SimpleDateFormat - -final publicationVersion = new Version(version) -def rawVersion = version - -group = 'io.intercom' -version = publicationVersion -status = version.status - -ext { - mvnUser = System.getenv('MVN_REPO_USER') ?: "dev" - mvnPass = System.getenv('MVN_REPO_PASS') ?: "dev" -} - -task sourcesJar(type: Jar, dependsOn: classes) { - classifier = 'sources' - from sourceSets.main.allSource -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir -} - -artifacts { - archives sourcesJar, javadocJar -} - -publishing { - publications { - mavenJava(MavenPublication) { - from components.java - - artifact sourcesJar { - classifier "sources" - } - - artifact javadocJar { - classifier "javadoc" - } - } - } -} - -signing { - if (project.hasProperty('signing.keyId') && project.hasProperty('signing.secretKeyRingFile')) { - sign configurations.archives - } -} - -task printVersion { - doLast { - println "publication version: ${publicationVersion}" - println "raw version: ${rawVersion}" - } -} - -uploadArchives { - repositories.mavenDeployer { - beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } - - repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") { - authentication(userName: mvnUser, password: mvnPass) - } - - snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") { - authentication(userName: mvnUser, password: mvnPass) - } - - pom.project { - name 'intercom-java' - artifactId 'intercom-java' - packaging 'jar' - description 'Java bindings for the Intercom API' - url 'https://github.com/intercom/intercom-java' - - scm { - url 'http://github.com/intercom/intercom-java/tree/master' - } - - licenses { - license { - name 'The Apache License, Version 2.0' - url 'http://www.apache.org/licenses/LICENSE-2.0.txt' - } - } - - developers { - developer { - id 'intercom' - name 'Intercom' - email 'team-dp@intercom.io' - } - } - } - } -} - -/** - * A version object for use in the publication and tagging tasks. - * If the version ends with SNAPSHOT, that will be replaced with a timestamp. - * - * Based on https://github.com/bintray/bintray-examples - */ -class Version { - // - String originalVersion - String thisVersion - String status - Date buildTime - - Version(String versionValue) { - buildTime = new Date() - originalVersion = versionValue - if (originalVersion.endsWith('-SNAPSHOT')) { - status = 'integration' - thisVersion = originalVersion.substring(0, originalVersion.length() - 'SNAPSHOT'.length()) + getTimestamp() - } else { - status = 'release' - thisVersion = versionValue - } - } - - String getTimestamp() { - // Convert local file timestamp to UTC - def format = new SimpleDateFormat('yyyyMMddHHmmss') - format.setCalendar(Calendar.getInstance(TimeZone.getTimeZone('UTC'))); - return format.format(buildTime) - } - - String toString() { - thisVersion - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/Admin.java b/intercom-java/src/main/java/io/intercom/api/Admin.java deleted file mode 100644 index 18302c5a..00000000 --- a/intercom-java/src/main/java/io/intercom/api/Admin.java +++ /dev/null @@ -1,233 +0,0 @@ -package io.intercom.api; - - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.google.common.collect.Maps; - -import java.net.URI; -import java.util.List; -import java.util.Map; - - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(JsonInclude.Include.NON_EMPTY) -public class Admin extends TypedData implements Replier { - - private static final Map SENTINEL = Maps.newHashMap(); - - public static final String TYPE_NOBODY = "nobody_admin"; - - // don't make public for now - static AdminCollection list(Map params) - throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException { - return DataResource.list(params, "admins", AdminCollection.class); - } - - public static AdminCollection list() - throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException { - return DataResource.list(SENTINEL, "admins", AdminCollection.class); - } - - public static Admin find(String id) - throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException { - final HttpClient resource = new HttpClient(UriBuilder.newBuilder().path("admins").path(id).build()); - return resource.get(Admin.class); - } - - public static Admin setAwayMode(String id, boolean away_mode_enabled, boolean away_mode_reassign) { - final URI uri = UriBuilder.newBuilder() - .path("admins") - .path(id) - .path("away") - .build(); - return new HttpClient(uri) - .put(Admin.class, new AdminAwayMode(id, away_mode_enabled, away_mode_reassign)); - } - - @SuppressWarnings("FieldCanBeLocal") - @JsonProperty("type") - private String type = "admin"; - - @JsonProperty("id") - private String id; - - @JsonProperty("name") - private String name; - - @JsonProperty("email") - private String email; - - @JsonProperty("created_at") - private long createdAt; - - @JsonProperty("updated_at") - private long updatedAt; - - @JsonProperty("open") - private long open; - - @JsonProperty("closed") - private long closed; - - @JsonProperty("away_mode_enabled") - private boolean awayModeEnabled; - - @JsonProperty("away_mode_reassign") - private boolean awayModeReassign; - - @JsonProperty("has_inbox_seat") - private boolean hasInboxSeat; - - @JsonProperty("avatar") - private Avatar avatar; - - @JsonProperty("team_ids") - private List teamIds; - - @JsonProperty("admin_ids") - private List adminIds; - - public Admin() { - } - - @JsonIgnore - public String getReplyType() { - return getType() + "_reply"; - } - - public String getType() { - return type; - } - - @JsonIgnore - public boolean isNobody() { - return TYPE_NOBODY.equalsIgnoreCase(getType()); - } - - @JsonIgnore - public boolean isSomebody() { - return (!isNobody()) && (getId() != null); - } - - public String getId() { - return id; - } - - public Admin setId(String id) { - this.id = id; - return this; - } - - public String getName() { - return name; - } - - public String getEmail() { - return email; - } - - public long getCreatedAt() { - return createdAt; - } - - public long getUpdatedAt() { - return updatedAt; - } - - public long getOpen() { - return open; - } - - public long getClosed() { - return closed; - } - - public boolean getAwayModeEnabled(){ - return awayModeEnabled; - } - - public boolean getAwayModeReassign(){ - return awayModeReassign; - } - - public boolean getHasInboxSeat(){ - return hasInboxSeat; - } - - public Avatar getAvatar(){ - return avatar; - } - - public List getTeamIds(){ - return teamIds; - } - public List getAdminIds(){ - return adminIds; - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Admin admin = (Admin) o; - - if (closed != admin.closed) return false; - if (createdAt != admin.createdAt) return false; - if (open != admin.open) return false; - if (updatedAt != admin.updatedAt) return false; - if (email != null ? !email.equals(admin.email) : admin.email != null) return false; - if (id != null ? !id.equals(admin.id) : admin.id != null) return false; - if (name != null ? !name.equals(admin.name) : admin.name != null) return false; - if (awayModeEnabled != admin.awayModeEnabled) return false; - if (awayModeReassign != admin.awayModeReassign) return false; - if (avatar != null ? !avatar.equals(admin.avatar) : admin.avatar != null) return false; - if (teamIds != null ? !teamIds.equals(admin.teamIds) : admin.teamIds != null) return false; - if (adminIds != null ? !adminIds.equals(admin.adminIds) : admin.adminIds != null) return false; - - //noinspection RedundantIfStatement - if (!type.equals(admin.type)) return false; - - return true; - } - - @Override - public int hashCode() { - int result = type.hashCode(); - result = 31 * result + (id != null ? id.hashCode() : 0); - result = 31 * result + (name != null ? name.hashCode() : 0); - result = 31 * result + (email != null ? email.hashCode() : 0); - result = 31 * result + (int) (createdAt ^ (createdAt >>> 32)); - result = 31 * result + (int) (updatedAt ^ (updatedAt >>> 32)); - result = 31 * result + (int) (open ^ (open >>> 32)); - result = 31 * result + (int) (closed ^ (closed >>> 32)); - result = 31 * result + (awayModeEnabled ? 1 : 0); - result = 31 * result + (awayModeReassign ? 1 : 0); - result = 31 * result + (avatar != null ? avatar.hashCode() : 0); - result = 31 * result + (teamIds != null ? teamIds.hashCode() : 0); - result = 31 * result + (adminIds != null ? adminIds.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "Admin{" + - "id='" + id + '\'' + - ", name='" + name + '\'' + - ", email='" + email + '\'' + - ", createdAt=" + createdAt + - ", updatedAt=" + updatedAt + - ", awayModeEnabled=" + awayModeEnabled + - ", awayModeReassign=" + awayModeReassign + - ", teamIds=" + teamIds + - ", adminIds=" + adminIds+ - ", avatar=" + avatar+ - "} " + super.toString(); - } - -} diff --git a/intercom-java/src/main/java/io/intercom/api/AdminAwayMode.java b/intercom-java/src/main/java/io/intercom/api/AdminAwayMode.java deleted file mode 100644 index 280fe191..00000000 --- a/intercom-java/src/main/java/io/intercom/api/AdminAwayMode.java +++ /dev/null @@ -1,44 +0,0 @@ -package io.intercom.api; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(JsonInclude.Include.NON_EMPTY) -public class AdminAwayMode extends TypedData { - - @JsonProperty("id") - private String id; - - @JsonProperty("away_mode_enabled") - private boolean awayModeEnabled; - - @JsonProperty("away_mode_reassign") - private boolean awayModeReassign; - - public AdminAwayMode(String Id, boolean awayModeEnabled, boolean awayModeReassign) { - this.id = id; - this.awayModeEnabled = awayModeEnabled; - this.awayModeReassign = awayModeReassign; - } - String getId() { - return id; - } - public boolean getAwayModeEnabled(){ - return awayModeEnabled; - } - - public boolean getAwayModeReassign(){ - return awayModeReassign; - } - - @Override - public String toString() { - return "AdminAwayMode{" + - "id='" + id + '\'' + - ", awayModeEnabled=" + awayModeEnabled + - ", awayModeReassign=" + awayModeReassign + - "} " + super.toString(); - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/AdminCollection.java b/intercom-java/src/main/java/io/intercom/api/AdminCollection.java deleted file mode 100644 index a9978dc6..00000000 --- a/intercom-java/src/main/java/io/intercom/api/AdminCollection.java +++ /dev/null @@ -1,29 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(JsonInclude.Include.NON_EMPTY) -public class AdminCollection extends TypedDataCollection { - - public AdminCollection() { - type = "company.list"; - } - - @Override - public AdminCollection nextPage() { - return fetchNextPage(AdminCollection.class); - } - - @SuppressWarnings("EmptyMethod") - @JsonProperty("admins") - @Override - public List getPage() { - return super.getPage(); - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/AdminMessage.java b/intercom-java/src/main/java/io/intercom/api/AdminMessage.java deleted file mode 100644 index 47ec3325..00000000 --- a/intercom-java/src/main/java/io/intercom/api/AdminMessage.java +++ /dev/null @@ -1,173 +0,0 @@ -package io.intercom.api; - - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.google.common.annotations.VisibleForTesting; - - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(JsonInclude.Include.NON_EMPTY) -public class AdminMessage extends TypedData { - - @JsonProperty("type") - private final String type = "admin_message"; - - @JsonProperty("id") - private String id; - - @JsonProperty("message_type") - private String messageType; - - @JsonProperty("subject") - private String subject=""; // Set default to blank string so null pointer exception won't thrown if messageType = inapp and subject not set - - @JsonProperty("body") - private String body; - - @JsonProperty("template") - private String template="plain"; // Set default to plain so null pointer exception won't thrown if messageType = inapp and template not set - - @JsonProperty("created_at") - private long createdAt; - - @JsonProperty("from") - private Admin admin; - - @JsonProperty("to") - private User user; - - public AdminMessage() { - } - - public String getType() { - return type; - } - - public String getId() { - return id; - } - - @SuppressWarnings("UnusedReturnValue") - @VisibleForTesting - AdminMessage setId(String id) { - this.id = id; - return this; - } - - public String getMessageType() { - return messageType; - } - - public AdminMessage setMessageType(String messageType) { - this.messageType = messageType; - return this; - } - - public String getSubject() { - return subject; - } - - public AdminMessage setSubject(String subject) { - this.subject = subject; - return this; - } - - public String getBody() { - return body; - } - - public AdminMessage setBody(String body) { - this.body = body; - return this; - } - - public String getTemplate() { - return template; - } - - public AdminMessage setTemplate(String template) { - this.template = template; - return this; - } - - public long getCreatedAt() { - return createdAt; - } - - @SuppressWarnings("UnusedReturnValue") - public AdminMessage setCreatedAt(long createdAt) { - this.createdAt = createdAt; - return this; - } - - public Admin getAdmin() { - return admin; - } - - public AdminMessage setAdmin(Admin admin) { - this.admin = admin; - return this; - } - - public User getUser() { - return user; - } - - public AdminMessage setUser(User user) { - this.user = user; - return this; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - AdminMessage message = (AdminMessage) o; - - if (createdAt != message.createdAt) return false; - if (admin != null ? !admin.equals(message.admin) : message.admin != null) return false; - if (body != null ? !body.equals(message.body) : message.body != null) return false; - if (id != null ? !id.equals(message.id) : message.id != null) return false; - if (messageType != null ? !messageType.equals(message.messageType) : message.messageType != null) return false; - if (subject != null ? !subject.equals(message.subject) : message.subject != null) return false; - if (template != null ? !template.equals(message.template) : message.template != null) return false; - if (!type.equals(message.type)) return false; - //noinspection RedundantIfStatement - if (user != null ? !user.equals(message.user) : message.user != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = type.hashCode(); - result = 31 * result + (id != null ? id.hashCode() : 0); - result = 31 * result + (messageType != null ? messageType.hashCode() : 0); - result = 31 * result + (subject != null ? subject.hashCode() : 0); - result = 31 * result + (body != null ? body.hashCode() : 0); - result = 31 * result + (template != null ? template.hashCode() : 0); - result = 31 * result + (int) (createdAt ^ (createdAt >>> 32)); - result = 31 * result + (admin != null ? admin.hashCode() : 0); - result = 31 * result + (user != null ? user.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "AdminMessage{" + - "id='" + id + '\'' + - ", messageType='" + messageType + '\'' + - ", subject='" + subject + '\'' + - ", body='" + body + '\'' + - ", template='" + template + '\'' + - ", createdAt=" + createdAt + - ", admin=" + admin + - ", user=" + user + - "} " + super.toString(); - } - -} diff --git a/intercom-java/src/main/java/io/intercom/api/AdminMessageResponse.java b/intercom-java/src/main/java/io/intercom/api/AdminMessageResponse.java deleted file mode 100644 index 9e55d20e..00000000 --- a/intercom-java/src/main/java/io/intercom/api/AdminMessageResponse.java +++ /dev/null @@ -1,129 +0,0 @@ -package io.intercom.api; - - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(JsonInclude.Include.NON_EMPTY) -class AdminMessageResponse extends TypedData { - - @JsonProperty("id") - private String id; - - @JsonProperty("message_type") - private String messageType; - - @JsonProperty("subject") - private String subject; - - @JsonProperty("body") - private String body; - - @JsonProperty("template") - private String template; - - @JsonProperty("created_at") - private long createdAt; - - @JsonProperty("updated_at") - private long updatedAt; - - @JsonProperty("owner") - private Admin admin; - - @JsonProperty("to") - private User user; - - public AdminMessageResponse() { - } - - public String getType() { - return "admin_message"; - } - - public String getId() { - return id; - } - - public AdminMessageResponse setId(String id) { - this.id = id; - return this; - } - - public String getMessageType() { - return messageType; - } - - public AdminMessageResponse setMessageType(String messageType) { - this.messageType = messageType; - return this; - } - - public String getSubject() { - return subject; - } - - public AdminMessageResponse setSubject(String subject) { - this.subject = subject; - return this; - } - - public String getBody() { - return body; - } - - public AdminMessageResponse setBody(String body) { - this.body = body; - return this; - } - - public String getTemplate() { - return template; - } - - public AdminMessageResponse setTemplate(String template) { - this.template = template; - return this; - } - - public long getCreatedAt() { - return createdAt; - } - - public AdminMessageResponse setCreatedAt(long createdAt) { - this.createdAt = createdAt; - return this; - } - - public long getUpdatedAt() { - return updatedAt; - } - - public AdminMessageResponse setUpdatedAt(long updatedAt) { - this.updatedAt = updatedAt; - return this; - } - - public Admin getAdmin() { - return admin; - } - - public AdminMessageResponse setAdmin(Admin admin) { - this.admin = admin; - return this; - } - - public User getUser() { - return user; - } - - public AdminMessageResponse setUser(User user) { - this.user = user; - return this; - } - -} diff --git a/intercom-java/src/main/java/io/intercom/api/AdminReply.java b/intercom-java/src/main/java/io/intercom/api/AdminReply.java deleted file mode 100644 index f2040ad6..00000000 --- a/intercom-java/src/main/java/io/intercom/api/AdminReply.java +++ /dev/null @@ -1,99 +0,0 @@ -package io.intercom.api; - - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(JsonInclude.Include.NON_EMPTY) -public class AdminReply extends Reply { - - @SuppressWarnings("UnusedDeclaration") - @JsonIgnoreProperties(ignoreUnknown = true) - @JsonInclude(JsonInclude.Include.NON_EMPTY) - static class AdminStringReply { - - private AdminReply reply; - - public AdminStringReply(AdminReply reply) { - this.reply = reply; - } - - @JsonProperty("type") - public String getType() { - return reply.getType(); - } - - @JsonProperty("message_type") - public String getMessageType() { - return reply.getMessageType(); - } - - @JsonProperty("snoozed_until") - public long getSnoozedUntil() { - return reply.getSnoozedUntil(); - } - - @JsonProperty("body") - public String getBody() { - return reply.getBody(); - } - - @JsonProperty("admin_id") - public String getAdminID() { - return reply.getFrom().getId(); - } - - @JsonProperty("assignee_id") - public String getAssigneeID() { - return reply.getAssigneeID(); - } - - @JsonProperty("attachment_urls") - private String[] getAttachmentUrls() { - return reply.getAttachmentUrls(); - } - } - - @JsonProperty("assignee_id") - private String assigneeID; - - @JsonProperty("snoozed_until") - private long snoozedUntil; - - public AdminReply(Admin admin) { - this.from = admin; - } - - public Reply setMessageType(String messageType) { - return setMessageReplyType(messageType); - } - - public String getAssigneeID() { - return assigneeID; - } - - public Reply setAssigneeID(String assigneeID) { - this.assigneeID = assigneeID; - this.setMessageType(Conversation.MESSAGE_TYPE_ASSIGNMENT); - return this; - } - - public long getSnoozedUntil() { - return snoozedUntil; - } - - public Reply setSnoozedUntil(long snoozedUntil) { - this.snoozedUntil = snoozedUntil; - this.setMessageType(Conversation.MESSAGE_TYPE_SNOOZED); - return this; - } - - @Override - public String toString() { - return "AdminReply{} " + super.toString(); - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/Attachment.java b/intercom-java/src/main/java/io/intercom/api/Attachment.java deleted file mode 100644 index 86af659a..00000000 --- a/intercom-java/src/main/java/io/intercom/api/Attachment.java +++ /dev/null @@ -1,100 +0,0 @@ -package io.intercom.api; - - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(JsonInclude.Include.NON_DEFAULT) -public class Attachment extends TypedData { - - @JsonProperty("type") - private final String type = "upload"; - @JsonProperty("name") - private String name; - @JsonProperty("url") - private String url; - @JsonProperty("content_type") - private String contentType; - @JsonProperty("filesize") - private long filesize; - @JsonProperty("width") - private long width; - @JsonProperty("height") - private long height; - - public Attachment() { - } - - public String getType() { - return type; - } - - public String getName() { - return name; - } - - public String getUrl() { - return url; - } - - public String getContentType() { - return contentType; - } - - public long getFilesize() { - return filesize; - } - - public long getWidth() { - return width; - } - - public long getHeight() { - return height; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Attachment attachment = (Attachment) o; - - if (name != null ? !name.equals(attachment.name) : attachment.name != null) return false; - if (url != null ? !url.equals(attachment.url) : attachment.url != null) return false; - if (contentType != null ? !contentType.equals(attachment.contentType) : attachment.contentType != null) return false; - if (filesize != attachment.filesize) return false; - if (height != attachment.height) return false; - if (width != attachment.width) return false; - - return true; - } - - @Override - public int hashCode() { - int result = type.hashCode(); - result = 31 * result + (name != null ? name.hashCode() : 0); - result = 31 * result + (url != null ? url.hashCode() : 0); - result = 31 * result + (contentType != null ? contentType.hashCode() : 0); - result = 31 * result + (int) (filesize ^ (filesize >>> 32)); - result = 31 * result + (int) (height ^ (height>>> 32)); - result = 31 * result + (int) (width ^ (width>>> 32)); - return result; - } - - @Override - public String toString() { - return "Avatar{" + - "type='" + type + '\'' + - ", name='" + name + '\'' + - ", url='" + url + '\'' + - ", content_type'=" + contentType + '\'' + - ", filesize=" + filesize + - ", height=" + height + - ", widht=" + width + - "} " + super.toString(); - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/Author.java b/intercom-java/src/main/java/io/intercom/api/Author.java deleted file mode 100644 index 204c84b9..00000000 --- a/intercom-java/src/main/java/io/intercom/api/Author.java +++ /dev/null @@ -1,117 +0,0 @@ -package io.intercom.api; - - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(JsonInclude.Include.NON_EMPTY) -public class Author extends TypedData { - - @JsonProperty("type") - private String type; - - @JsonProperty("id") - private String id; - - @JsonProperty("name") - private String name; - - @JsonProperty("email") - private String email; - - @JsonProperty("user_id") - private String userId; - - public Author() { - } - - public String getType() { - return type; - } - - @JsonIgnore - public boolean isUser() { - return "user".equalsIgnoreCase(getType()); - } - - @JsonIgnore - public boolean isAdmin() { - return "admin".equalsIgnoreCase(getType()); - } - - public String getId() { - return id; - } - - public Author setId(String id) { - this.id = id; - return this; - } - - public String getName() { - return name; - } - - public Author setName(String name) { - this.name = name; - return this; - } - - public String getEmail() { - return email; - } - - public Author setEmail(String email) { - this.email = email; - return this; - } - - public String getUserId() { - return userId; - } - - public Author setUserId(String userId) { - this.userId = userId; - return this; - } - - @Override - public int hashCode() { - int result = id != null ? id.hashCode() : 0; - result = 31 * result + (name != null ? name.hashCode() : 0); - result = 31 * result + (email != null ? email.hashCode() : 0); - result = 31 * result + (userId != null ? userId.hashCode() : 0); - return result; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Author author = (Author) o; - - if (email != null ? !email.equals(author.email) : author.email != null) return false; - if (id != null ? !id.equals(author.id) : author.id != null) return false; - if (name != null ? !name.equals(author.name) : author.name != null) return false; - //noinspection RedundantIfStatement - if (userId != null ? !userId.equals(author.userId) : author.userId != null) return false; - - return true; - } - - @Override - public String toString() { - return "Author{" + - "id='" + id + '\'' + - ", name='" + name + '\'' + - ", email='" + email + '\'' + - ", userId='" + userId + '\'' + - "} " + super.toString(); - } - -} diff --git a/intercom-java/src/main/java/io/intercom/api/AuthorizationException.java b/intercom-java/src/main/java/io/intercom/api/AuthorizationException.java deleted file mode 100644 index 4ecc7584..00000000 --- a/intercom-java/src/main/java/io/intercom/api/AuthorizationException.java +++ /dev/null @@ -1,22 +0,0 @@ -package io.intercom.api; - -public class AuthorizationException extends IntercomException { - - private static final long serialVersionUID = 2917082281352001861L; - - public AuthorizationException(String message) { - super(message); - } - - public AuthorizationException(String message, Throwable cause) { - super(message, cause); - } - - public AuthorizationException(ErrorCollection errorCollection) { - super(errorCollection); - } - - public AuthorizationException(ErrorCollection errorCollection, Throwable cause) { - super(errorCollection, cause); - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/Avatar.java b/intercom-java/src/main/java/io/intercom/api/Avatar.java deleted file mode 100644 index ab700ec1..00000000 --- a/intercom-java/src/main/java/io/intercom/api/Avatar.java +++ /dev/null @@ -1,67 +0,0 @@ -package io.intercom.api; - - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.net.URI; - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(JsonInclude.Include.NON_DEFAULT) -public class Avatar extends TypedData { - - @JsonProperty("type") - private final String type = "avatar"; - - @JsonProperty("image_url") - private URI imageURL; - - public Avatar() { - } - - public String getType() { - return type; - } - - public URI getImageURL() { - return imageURL; - } - - public Avatar setImageURL(String imageURL) { - if(imageURL != null) { - this.imageURL = URI.create(imageURL); - } - return this; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Avatar avatar = (Avatar) o; - - if (imageURL != null ? !imageURL.equals(avatar.imageURL) : avatar.imageURL != null) return false; - //noinspection RedundantIfStatement - if (!type.equals(avatar.type)) return false; - - return true; - } - - @Override - public int hashCode() { - int result = type.hashCode(); - result = 31 * result + (imageURL != null ? imageURL.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "Avatar{" + - "type='" + type + '\'' + - ", imageURL=" + imageURL + - "} " + super.toString(); - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/ClientException.java b/intercom-java/src/main/java/io/intercom/api/ClientException.java deleted file mode 100644 index e670983f..00000000 --- a/intercom-java/src/main/java/io/intercom/api/ClientException.java +++ /dev/null @@ -1,22 +0,0 @@ -package io.intercom.api; - -public class ClientException extends IntercomException { - - private static final long serialVersionUID = -2111295679006526646L; - - public ClientException(String message) { - super(message); - } - - public ClientException(String message, Throwable cause) { - super(message, cause); - } - - public ClientException(ErrorCollection errorCollection) { - super(errorCollection); - } - - public ClientException(ErrorCollection errorCollection, Throwable cause) { - super(errorCollection, cause); - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/Company.java b/intercom-java/src/main/java/io/intercom/api/Company.java deleted file mode 100644 index 2b9328a0..00000000 --- a/intercom-java/src/main/java/io/intercom/api/Company.java +++ /dev/null @@ -1,444 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.google.common.annotations.VisibleForTesting; -import com.google.common.collect.Maps; - -import java.net.URI; -import java.util.Map; - -@SuppressWarnings("UnusedDeclaration") -@JsonInclude(JsonInclude.Include.NON_DEFAULT) -@JsonIgnoreProperties(ignoreUnknown = true) -public class Company extends TypedData { - - private static final Map SENTINEL = Maps.newHashMap(); - - public static Company find(String id) throws InvalidException, AuthorizationException { - final HttpClient resource = new HttpClient(UriBuilder.newBuilder().path("companies").path(id).build()); - return resource.get(Company.class); - } - - public static Company find(Map params) throws InvalidException, AuthorizationException { - if (!params.containsKey("company_id") && !params.containsKey("name")) { - throw new InvalidException("a company find must include a company_id or name parameter"); - } - return DataResource.find(params, "companies", Company.class); - } - - public static Company create(Company company) throws InvalidException, AuthorizationException { - return update(company); - } - - public static Company update(Company company) throws InvalidException, AuthorizationException { - // because the data is asymmetric on the plan field - final CompanyWithStringPlan entity = new CompanyWithStringPlan(); - entity.setCompanyID(company.getCompanyID()); - entity.setName(company.getName()); - entity.setMonthlySpend(company.getMonthlySpend()); - entity.setRemoteCreatedAt(company.getRemoteCreatedAt()); - entity.setIndustry(company.getIndustry()); - entity.setSize(company.getSize()); - entity.setWebsite(company.getWebsite()); - if(company.getCustomAttributes() != null) { - entity.getCustomAttributes().putAll(company.getCustomAttributes()); - } - if(company.getPlan() !=null ) { - entity.setPlan(company.getPlan().getName()); - } - return DataResource.update(entity, "companies", Company.class); - } - - public static CompanyCollection list(Map params) throws InvalidException, AuthorizationException { - return DataResource.list(params, "companies", CompanyCollection.class); - } - - public static CompanyCollection list() throws InvalidException, AuthorizationException { - return DataResource.list(SENTINEL, "companies", CompanyCollection.class); - } - - public static ScrollableCompanyCollection scroll() - throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException { - return DataResource.scroll(null, "companies", ScrollableCompanyCollection.class); - } - - public static UserCollection listUsers(Map params) throws InvalidException, AuthorizationException { - URI usersURI; - if (params.containsKey("company_id")) { - usersURI = UriBuilder.newBuilder() - .path("companies") - .query("company_id", params.get("company_id")) - .query("type", "users") - .build(); - } else if (params.containsKey("id")) { - usersURI = UriBuilder.newBuilder() - .path("companies") - .path(params.get("id")) - .path("users") - .build(); - } else { - throw new InvalidException("a company user list query must supply a company_id or id parameter"); - } - final HttpClient resource = new HttpClient(usersURI); - return resource.get(UserCollection.class); - } - - @SuppressWarnings("UnusedDeclaration") - @JsonInclude(JsonInclude.Include.NON_DEFAULT) - @JsonIgnoreProperties(ignoreUnknown = true) - public static class Plan extends TypedData { - - @JsonProperty("type") - protected String type; - - @JsonProperty("id") - private String id; - - @JsonProperty("name") - private String name; - - public Plan() { - type = "plan"; - } - - public Plan(String name) { - this(); - this.name = name; - } - - public String getId() { - return id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getType() { - return type; - } - - @Override - public int hashCode() { - int result = id != null ? id.hashCode() : 0; - result = 31 * result + (name != null ? name.hashCode() : 0); - return result; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Plan plan = (Plan) o; - - if (id != null ? !id.equals(plan.id) : plan.id != null) return false; - //noinspection RedundantIfStatement - if (name != null ? !name.equals(plan.name) : plan.name != null) return false; - - return true; - } - - - @Override - public String toString() { - return "Plan{" + - "id='" + id + '\'' + - ", name='" + name + '\'' + - "} " + super.toString(); - } - - - } - - @SuppressWarnings("FieldCanBeLocal") - @JsonProperty("type") - private final String type = "company"; - - @JsonProperty("id") - private String id; - - @JsonProperty("name") - private String name; - - @JsonProperty("company_id") - private String companyID; - - @JsonProperty("session_count") - private int sessionCount; - - @JsonProperty("monthly_spend") - private float monthlySpend; - - @JsonProperty("remote_created_at") - private long remoteCreatedAt; - - @JsonProperty("last_request_at") - private long lastRequestAt; - - @JsonProperty("created_at") - private long createdAt; - - @JsonProperty("updated_at") - private long updatedAt; - - @JsonProperty("plan") - private Plan plan; - - @JsonProperty("user_count") - private Integer userCount; - - @JsonProperty("size") - private int size; - - @JsonProperty("website") - private String website; - - @JsonProperty("industry") - private String industry; - - @JsonIgnoreProperties(ignoreUnknown = false) - @JsonProperty("custom_attributes") - private Map customAttributes = Maps.newHashMap(); - - @JsonProperty("segments") - private SegmentCollection segmentCollection = new SegmentCollection(); - - @JsonProperty("tags") - private TagCollection tagCollection = new TagCollection(); - - private Boolean untag; - - public Company() { - } - - public Company untag() { - untag = Boolean.TRUE; - return this; - } - - public String getType() { - return type; - } - - public String getId() { - return id; - } - - @VisibleForTesting - Company setId(String id) { - this.id = id; - return this; - } - - public String getName() { - return name; - } - - public Company setName(String name) { - this.name = name; - return this; - } - - public int getSize() { - return size; - } - - public Company setSize(int size) { - this.size = size; - return this; - } - - public String getWebsite() { - return website; - } - - public Company setWebsite(String website) { - this.website = website; - return this; - } - - public String getIndustry() { - return industry; - } - - public Company setIndustry(String industry) { - this.industry = industry; - return this; - } - - public long getCreatedAt() { - return createdAt; - } - - public long getUpdatedAt() { - return updatedAt; - } - - public String getCompanyID() { - return companyID; - } - - public Company setCompanyID(String companyID) { - this.companyID = companyID; - return this; - } - - public int getSessionCount() { - return sessionCount; - } - - public long getRemoteCreatedAt() { - return remoteCreatedAt; - } - - public Company setRemoteCreatedAt(long remoteCreatedAt) { - this.remoteCreatedAt = remoteCreatedAt; - return this; - } - - public long getLastRequestAt() { - return lastRequestAt; - } - - public Company setLastRequestAt(long lastRequestAt) { - this.lastRequestAt = lastRequestAt; - return this; - } - - public Map getCustomAttributes() { - return customAttributes; - } - - public Company setCustomAttributes(Map customAttributes) { - this.customAttributes = customAttributes; - return this; - } - - public Company addCustomAttribute(CustomAttribute customAttribute) { - this.customAttributes.put(customAttribute.getName(), customAttribute); - return this; - } - - public Plan getPlan() { - return plan; - } - - public Company setPlan(Plan plan) { - this.plan = plan; - return this; - } - - public Integer getUserCount() { - return userCount; - } - - public float getMonthlySpend() { - return monthlySpend; - } - - public Company setMonthlySpend(float monthlySpend) { - this.monthlySpend = monthlySpend; - return this; - } - - public SegmentCollection getSegmentCollection() { - return segmentCollection; - } - - public TagCollection getTagCollection() { - return tagCollection; - } - - boolean isUntag() { - return untag == null ? false : untag; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Company company = (Company) o; - - if (createdAt != company.createdAt) return false; - if (Float.compare(company.monthlySpend, monthlySpend) != 0) return false; - if (remoteCreatedAt != company.remoteCreatedAt) return false; - if (sessionCount != company.sessionCount) return false; - if (updatedAt != company.updatedAt) return false; - if (lastRequestAt != company.lastRequestAt) return false; - if (companyID != null ? !companyID.equals(company.companyID) : company.companyID != null) return false; - if (customAttributes != null ? !customAttributes.equals(company.customAttributes) : company.customAttributes != null) - return false; - if (id != null ? !id.equals(company.id) : company.id != null) return false; - if (name != null ? !name.equals(company.name) : company.name != null) return false; - if (plan != null ? !plan.equals(company.plan) : company.plan != null) return false; - if (segmentCollection != null ? !segmentCollection.equals(company.segmentCollection) : company.segmentCollection != null) - return false; - if (tagCollection != null ? !tagCollection.equals(company.tagCollection) : company.tagCollection != null) - return false; - if (!type.equals(company.type)) return false; - if (untag != null ? !untag.equals(company.untag) : company.untag != null) return false; - //noinspection RedundantIfStatement - if (userCount != null ? !userCount.equals(company.userCount) : company.userCount != null) return false; - if (size != company.size) return false; - if (website != null ? !website.equals(company.website) : company.website != null) return false; - if (industry != null ? !industry.equals(company.industry) : company.industry != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = type.hashCode(); - result = 31 * result + (id != null ? id.hashCode() : 0); - result = 31 * result + (name != null ? name.hashCode() : 0); - result = 31 * result + (companyID != null ? companyID.hashCode() : 0); - result = 31 * result + sessionCount; - result = 31 * result + (monthlySpend != +0.0f ? Float.floatToIntBits(monthlySpend) : 0); - result = 31 * result + (int) (remoteCreatedAt ^ (remoteCreatedAt >>> 32)); - result = 31 * result + (int) (createdAt ^ (createdAt >>> 32)); - result = 31 * result + (int) (updatedAt ^ (updatedAt >>> 32)); - result = 31 * result + (int) (lastRequestAt ^ (lastRequestAt >>> 32)); - result = 31 * result + (plan != null ? plan.hashCode() : 0); - result = 31 * result + (userCount != null ? userCount.hashCode() : 0); - result = 31 * result + (customAttributes != null ? customAttributes.hashCode() : 0); - result = 31 * result + (segmentCollection != null ? segmentCollection.hashCode() : 0); - result = 31 * result + (tagCollection != null ? tagCollection.hashCode() : 0); - result = 31 * result + (untag != null ? untag.hashCode() : 0); - result = 31 * result + size; - result = 31 * result + (website != null ? website.hashCode() : 0); - result = 31 * result + (industry != null ? industry.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "Company{" + - "id='" + id + '\'' + - ", name='" + name + '\'' + - ", companyID='" + companyID + '\'' + - ", sessionCount=" + sessionCount + - ", monthlySpend=" + monthlySpend + - ", remoteCreatedAt=" + remoteCreatedAt + - ", createdAt=" + createdAt + - ", lastRequestAt=" + lastRequestAt + - ", updatedAt=" + updatedAt + - ", plan=" + plan + - ", customAttributes=" + customAttributes + - ", segmentCollection=" + segmentCollection + - ", tagCollection=" + tagCollection + - ", size=" + size + - ", website='" + website + '\'' + - ", industry='" + industry + '\'' + - "} " + super.toString(); - } - - -} diff --git a/intercom-java/src/main/java/io/intercom/api/CompanyCollection.java b/intercom-java/src/main/java/io/intercom/api/CompanyCollection.java deleted file mode 100644 index 57b7bdc8..00000000 --- a/intercom-java/src/main/java/io/intercom/api/CompanyCollection.java +++ /dev/null @@ -1,50 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(ignoreUnknown = true) -public class CompanyCollection extends TypedDataCollection { - - @JsonProperty("total_count") - private long totalCount; - - public CompanyCollection() { - type = "company.list"; - } - - public CompanyCollection(List companies) { - this(); - this.page = companies; - } - - @SuppressWarnings("EmptyMethod") - @JsonProperty("companies") - @Override - public List getPage() { - return super.getPage(); - } - - public long getTotalCount() { - return totalCount; - } - - @Override - public CompanyCollection nextPage() { - return fetchNextPage(CompanyCollection.class); - } - - @Override - public String toString() { - return "CompanyCollection{" + - ", totalCount=" + totalCount + - "} " + super.toString(); - } - - void addCompany(Company company) { - page.add(company); - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/CompanyUpdateBuilder.java b/intercom-java/src/main/java/io/intercom/api/CompanyUpdateBuilder.java deleted file mode 100644 index 2608c686..00000000 --- a/intercom-java/src/main/java/io/intercom/api/CompanyUpdateBuilder.java +++ /dev/null @@ -1,69 +0,0 @@ -package io.intercom.api; - -import com.google.common.base.Objects; -import com.google.common.base.Predicate; -import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; - -import java.util.List; - -class CompanyUpdateBuilder { - - /** - * Provide restrictions on the company data that can be sent via a user update - */ - static List buildUserUpdateCompanies(CompanyCollection add, CompanyCollection remove) { - - final List updatableCompanies = Lists.newArrayList(); - if (add != null) { - final List companies = add.getPage(); - for (Company company : companies) { - if (!isCompanyInList(company, remove)) { - updatableCompanies.add(prepareUpdatableCompany(company)); - } - } - } - - if (remove != null) { - final List companies = remove.getPage(); - for (Company company : companies) { - updatableCompanies.add(prepareUpdatableCompany(company).setRemove(Boolean.TRUE)); - } - } - - return updatableCompanies; - } - - private static boolean isCompanyInList(final Company company, CompanyCollection companyCollection) { - if (companyCollection == null) { - return false; - } - - return Iterables.any(companyCollection.getPage(), new Predicate() { - @Override - public boolean apply(Company e) { - return Objects.equal(company.getCompanyID(), e.getCompanyID()) - || Objects.equal(company.getId(), e.getId()); - } - }); - } - - private static CompanyWithStringPlan prepareUpdatableCompany(Company company) { - final CompanyWithStringPlan updatableCompany = new CompanyWithStringPlan(); - updatableCompany.setId(company.getId()); - updatableCompany.setCompanyID(company.getCompanyID()); - updatableCompany.setName(company.getName()); - updatableCompany.setMonthlySpend(company.getMonthlySpend()); - updatableCompany.setRemoteCreatedAt(company.getRemoteCreatedAt()); - updatableCompany.setIndustry(company.getIndustry()); - updatableCompany.setSize(company.getSize()); - updatableCompany.setWebsite(company.getWebsite()); - if (company.getCustomAttributes() != null) { - updatableCompany.getCustomAttributes().putAll(company.getCustomAttributes()); - } - if (company.getPlan() != null) { - updatableCompany.setPlan(company.getPlan().getName()); - } - return updatableCompany; - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/CompanyWithStringPlan.java b/intercom-java/src/main/java/io/intercom/api/CompanyWithStringPlan.java deleted file mode 100644 index 8f1d8296..00000000 --- a/intercom-java/src/main/java/io/intercom/api/CompanyWithStringPlan.java +++ /dev/null @@ -1,156 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.google.common.collect.Maps; - -import java.util.Map; - -@SuppressWarnings("UnusedDeclaration") -@JsonInclude(JsonInclude.Include.NON_DEFAULT) -@JsonIgnoreProperties(ignoreUnknown = true) -class CompanyWithStringPlan extends TypedData { - - @JsonProperty("id") - private String id; - - @JsonProperty("name") - private String name; - - @JsonProperty("company_id") - private String companyID; - - @JsonProperty("session_count") - private int sessionCount; - - @JsonProperty("monthly_spend") - private float monthlySpend; - - @JsonProperty("remote_created_at") - private long remoteCreatedAt; - - @JsonProperty("plan") - private String plan; - - @JsonProperty("size") - private int size; - - @JsonProperty("website") - private String website; - - @JsonProperty("industry") - private String industry; - - @JsonIgnoreProperties(ignoreUnknown = false) - @JsonProperty("custom_attributes") - private Map customAttributes = Maps.newHashMap(); - - @JsonProperty("remove") - @JsonInclude(JsonInclude.Include.NON_NULL) - private Boolean remove; - - public CompanyWithStringPlan() { - } - - public String getType() { - return "company"; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getCompanyID() { - return companyID; - } - - public void setCompanyID(String companyID) { - this.companyID = companyID; - } - - public Integer getSessionCount() { - return sessionCount; - } - - public void setSessionCount(Integer sessionCount) { - this.sessionCount = sessionCount; - } - - public float getMonthlySpend() { - return monthlySpend; - } - - public void setMonthlySpend(float monthlySpend) { - this.monthlySpend = monthlySpend; - } - - public long getRemoteCreatedAt() { - return remoteCreatedAt; - } - - public void setRemoteCreatedAt(long remoteCreatedAt) { - this.remoteCreatedAt = remoteCreatedAt; - } - - public int getSize() { - return size; - } - - public void setSize(int size) { - this.size = size; - } - - public String getWebsite() { - return website; - } - - public void setWebsite(String website) { - this.website = website; - } - - public String getIndustry() { - return industry; - } - - public void setIndustry(String industry) { - this.industry = industry; - } - - public String getPlan() { - return plan; - } - - public void setPlan(String plan) { - this.plan = plan; - } - - public Map getCustomAttributes() { - return customAttributes; - } - - public void setCustomAttributes(Map customAttributes) { - this.customAttributes = customAttributes; - } - - public Boolean getRemove() { - return remove; - } - - public CompanyWithStringPlan setRemove(Boolean remove) { - this.remove = remove; - return this; - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/Conditions.java b/intercom-java/src/main/java/io/intercom/api/Conditions.java deleted file mode 100644 index 6e92f32b..00000000 --- a/intercom-java/src/main/java/io/intercom/api/Conditions.java +++ /dev/null @@ -1,26 +0,0 @@ -package io.intercom.api; - -import com.google.common.collect.Lists; - -class Conditions { - - /** - * Ensures that an object reference passed as a parameter to the calling - * method is not null. Variant of Guava's Preconditions that returns an - * InvalidException containing an ErrorCollection - * - * @param reference an object reference - * @param errorMessage the exception message to use if the check fails - * @return the non-null reference that was validated - * @throws InvalidException if {@code reference} is null - */ - public static T checkNotNull(T reference, String errorMessage) { - if (reference == null) { - throw new InvalidException( - new ErrorCollection( - Lists.newArrayList( - new Error("invalid", "item method must be supplied")))); - } - return reference; - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/Contact.java b/intercom-java/src/main/java/io/intercom/api/Contact.java deleted file mode 100644 index 392e6488..00000000 --- a/intercom-java/src/main/java/io/intercom/api/Contact.java +++ /dev/null @@ -1,678 +0,0 @@ -package io.intercom.api; - - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Strings; -import com.google.common.collect.Maps; - -import java.net.URI; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(JsonInclude.Include.NON_DEFAULT) -public class Contact extends TypedData implements Replier { - - private static final Map SENTINEL = Maps.newHashMap(); - - public static Contact findByID(String id) - throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException { - return new HttpClient(contactURI(id)).get(Contact.class); - } - - public static Contact findByUserID(String userID) - throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException { - final Map params = Maps.newHashMap(); - params.put("user_id", userID); - return DataResource.find(params, "contacts", Contact.class); - } - - public static ContactCollection listByEmail(String email) - throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException { - final Map params = Maps.newHashMap(); - params.put("email", email); - return list(params); - } - - public static ContactCollection list(Map params) - throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException { - return DataResource.list(params, "contacts", ContactCollection.class); - } - - public static ContactCollection list() - throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException { - return DataResource.list(SENTINEL, "contacts", ContactCollection.class); - } - - public static ScrollableContactCollection scroll() - throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException { - return DataResource.scroll(null, "contacts", ScrollableContactCollection.class); - } - - public static Contact create(Contact c) - throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException { - return DataResource.create(ContactUpdate.buildFrom(c), "contacts", Contact.class); - } - - public static Contact update(Contact c) - throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException { - return DataResource.update(ContactUpdate.buildFrom(c), "contacts", Contact.class); - } - - public static Contact delete(Contact c) - throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException { - if(!Strings.isNullOrEmpty(c.getID())) { - return delete(c.getID()); - } - else if(!Strings.isNullOrEmpty(c.getUserID())) { - return deleteByUserID(c.getUserID()); - } - else { - throw new InvalidException("to delete a contact you must provide a id or user_id value"); - } - } - - public static Contact delete(String id) - throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException { - return DataResource.delete(id, "contacts", Contact.class); - } - - public static Contact deleteByUserID(String user_id) - throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException { - Map params = new HashMap(); - params.put("user_id", user_id); - return DataResource.delete(params, "contacts", Contact.class); - } - - public static User convert(Contact c, User u) - throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException { - return DataResource.post(ContactConvertBuilder.buildConvert(c, u), convertURI(), User.class); - } - - private static URI contactURI(String id) { - return UriBuilder.newBuilder().path("contacts").path(id).build(); - } - - private static URI convertURI() { - return UriBuilder.newBuilder().path("contacts").path("convert").build(); - } - - static class ContactConvertBuilder { - - static ContactConvert buildConvert(Contact c, User u) throws InvalidException { - return new ContactConvertBuilder().build(c, u); - } - - ContactConvert build(Contact c, User u) throws InvalidException { - return new ContactConvert(buildConvertContact(c), buildConvertUser(u)); - } - - HashMap buildConvertUser(User u) { - final HashMap convertUser = Maps.newHashMap(); - - if (u.getId() != null) { - convertUser.put("id", u.getId()); - } - - if (u.getUserId() != null) { - convertUser.put("user_id", u.getUserId()); - } - - if (u.getEmail() != null) { - convertUser.put("email", u.getEmail()); - } - - checkValidConvertContact(convertUser); - - return convertUser; - } - - void checkValidConvertContact(HashMap convertUser) { - if ((!convertUser.containsKey("id")) && (!convertUser.containsKey("user_id")) && (!convertUser.containsKey("email"))) { - throw new InvalidException("a convert user must include at least one of, an id, user_id or email parameter"); - } - } - - HashMap buildConvertContact(Contact c) { - final HashMap convertContact = Maps.newHashMap(); - - if (c.getID() != null) { - convertContact.put("id", c.getID()); - } - - if (c.getUserID() != null) { - convertContact.put("user_id", c.getUserID()); - } - - checkValidConvertUser(convertContact); - - return convertContact; - } - - void checkValidConvertUser(HashMap convertContact) { - if ((!convertContact.containsKey("id")) && (!convertContact.containsKey("user_id"))) { - throw new InvalidException("a convert contact must include at least one of, an id or a user_id parameter"); - } - } - } - - - @SuppressWarnings("UnusedDeclaration") - @JsonIgnoreProperties(ignoreUnknown = true) - @JsonInclude(JsonInclude.Include.NON_DEFAULT) - static class ContactConvert { - - @JsonProperty("contact") - private Map contact; - - @JsonProperty("user") - private Map user; - - public ContactConvert() { - } - - public ContactConvert(Map contact, Map user) { - this.contact = contact; - this.user = user; - } - - public Map getContact() { - return contact; - } - - public void setContact(Map contact) { - this.contact = contact; - } - - public Map getUser() { - return user; - } - - public void setUser(Map user) { - this.user = user; - } - } - - @SuppressWarnings("UnusedDeclaration") - @JsonIgnoreProperties(ignoreUnknown = true) - @JsonInclude(JsonInclude.Include.NON_DEFAULT) - static class ContactUpdate extends TypedData { - - static ContactUpdate buildFrom(Contact c) { - final ContactUpdate contactUpdate = new ContactUpdate(); - contactUpdate.id = c.getID(); // propagated, noset - contactUpdate.userID = c.getUserID(); // propagated, noset - contactUpdate.email = c.getEmail(); - contactUpdate.phone = c.getPhone(); - contactUpdate.name = c.getName(); - contactUpdate.lastSeenIP = c.getLastSeenIP(); - contactUpdate.customAttributes = c.getCustomAttributes(); - contactUpdate.avatar = c.getAvatar(); - contactUpdate.lastRequestAt = c.getLastRequestAt(); - contactUpdate.unsubscribedFromEmails = c.getUnsubscribedFromEmails(); - return contactUpdate; - } - - @JsonProperty("type") - @JsonInclude(JsonInclude.Include.NON_DEFAULT) - private String type; - - @JsonProperty("id") - private String id; - - @JsonProperty("user_id") - private String userID; - - @JsonProperty("email") - private String email; - - @JsonProperty("phone") - private String phone; - - @JsonProperty("name") - private String name; - - @JsonProperty("last_seen_ip") - private String lastSeenIP; - - @JsonProperty("avatar") - private Avatar avatar; - - @JsonIgnoreProperties(ignoreUnknown = false) - @JsonProperty("custom_attributes") - private Map customAttributes = Maps.newHashMap(); - - @JsonProperty("last_seen_user_agent") - private String lastSeenUserAgent; - - @JsonProperty("companies") - private List companyCollection; - - @JsonProperty("last_request_at") - private long lastRequestAt; - - @JsonProperty("signed_up_at") - private long signedUpAt; - - /* - * Making these Booleans allows us to send true or false as set - * values leaving null the ignored field for NON_DEFAULT. A - * primitive would result in false not being sent - */ - - @JsonProperty("unsubscribed_from_emails") - @JsonInclude(JsonInclude.Include.NON_DEFAULT) - private Boolean unsubscribedFromEmails; - - @JsonProperty("update_last_request_at") - @JsonInclude(JsonInclude.Include.NON_DEFAULT) - private Boolean updateLastRequestAt; - - @JsonProperty("new_session") - @JsonInclude(JsonInclude.Include.NON_DEFAULT) - private Boolean newSession; - - public ContactUpdate() { - } - - public String getType() { - return type; - } - - public String getID() { - return id; - } - - public String getUserID() { - return userID; - } - - public String getEmail() { - return email; - } - - public String getPhone() { - return phone; - } - - public String getName() { - return name; - } - - public String getLastSeenIP() { - return lastSeenIP; - } - - public Map getCustomAttributes() { - return customAttributes; - } - - public String getLastSeenUserAgent() { - return lastSeenUserAgent; - } - - public List getCompanyCollection() { - return companyCollection; - } - - public long getLastRequestAt() { - return lastRequestAt; - } - - public Boolean getUnsubscribedFromEmails() { - return unsubscribedFromEmails; - } - - public Boolean isUpdateLastRequestAt() { - return updateLastRequestAt; - } - - public Boolean isNewSession() { - return newSession; - } - } - - @JsonProperty("type") - @JsonInclude(JsonInclude.Include.ALWAYS) - private final String type = "contact"; - - @JsonProperty("id") - private String id; - - @JsonProperty("user_id") - private String userID; - - @JsonProperty("email") - private String email; - - @JsonProperty("phone") - private String phone; - - @JsonProperty("name") - private String name; - - @JsonProperty("pseudonym") - private String pseudonym; - - @JsonProperty("avatar") - private Avatar avatar; - - @JsonProperty("created_at") - private long createdAt; - - @JsonProperty("updated_at") - private long updatedAt; - - @JsonProperty("unsubscribed_from_emails") - private Boolean unsubscribedFromEmails; - - @JsonProperty("session_count") - private int sessionCount; - - @JsonProperty("last_request_at") - private long lastRequestAt; - - @JsonProperty("last_seen_ip") - private String lastSeenIP; - - @JsonIgnoreProperties(ignoreUnknown = false) - @JsonProperty("custom_attributes") - private Map customAttributes = Maps.newHashMap(); - - @JsonProperty("user_agent_data") - private String userAgentData; - - @JsonProperty("location_data") - private LocationData locationData; - - @JsonIgnoreProperties(ignoreUnknown = false) - @JsonProperty("companies") - private CompanyCollection companyCollection = new CompanyCollection(); - - @JsonProperty("social_profiles") - private SocialProfileCollection socialProfileCollection = new SocialProfileCollection(); - - @JsonProperty("segments") - private SegmentCollection segmentCollection = new SegmentCollection(); - - @JsonProperty("tags") - private TagCollection tagCollection = new TagCollection(); - - @JsonProperty("update_last_request_at") - private Boolean updateLastRequestAt; - - @JsonProperty("new_session") - private Boolean newSession; - - private Boolean untag; - - public Contact() { - } - - public Contact untag() { - untag = Boolean.TRUE; - return this; - } - - boolean isUntag() { - return untag == null ? false : untag; - } - - @JsonIgnore - public String getReplyType() { - return getType() + "_reply"; - } - - public String getType() { - return type; - } - - public String getID() { - return id; - } - - public Contact setID(String id) { - this.id = id; - return this; - } - - public String getName() { - return name; - } - - public Contact setName(String name) { - this.name = name; - return this; - } - - public String getPseudonym() { - return pseudonym; - } - - public String getEmail() { - return email; - } - - public Contact setEmail(String email) { - this.email = email; - return this; - } - - public String getPhone() { - return phone; - } - - public Contact setPhone(String phone) { - this.phone = phone; - return this; - } - - public String getUserID() { - return userID; - } - - public Contact setUserID(String userID) { - this.userID = userID; - return this; - } - - public Avatar getAvatar() { - return avatar; - } - - public Contact setAvatar(Avatar avatar) { - this.avatar = avatar; - return this; - } - - public long getCreatedAt() { - return createdAt; - } - - public long getUpdatedAt() { - return updatedAt; - } - - public Boolean getUnsubscribedFromEmails() { - return unsubscribedFromEmails; - } - - public Contact setUnsubscribedFromEmails(boolean unsubscribedFromEmails) { - this.unsubscribedFromEmails = unsubscribedFromEmails; - return this; - } - - public int getSessionCount() { - return sessionCount; - } - - public long getLastRequestAt() { - return lastRequestAt; - } - - public Contact setLastRequestAt(long lastRequestAt) { - this.lastRequestAt = lastRequestAt; - return this; - } - - public String getLastSeenIP() { - return lastSeenIP; - } - - public Contact setLastSeenIP(String lastSeenIP) { - this.lastSeenIP = lastSeenIP; - return this; - } - - public Map getCustomAttributes() { - return customAttributes; - } - - public Contact setCustomAttributes(Map customAttributes) { - this.customAttributes = customAttributes; - return this; - } - - public Contact addCustomAttribute(CustomAttribute customAttribute) { - this.customAttributes.put(customAttribute.getName(), customAttribute); - return this; - } - - public String getUserAgentData() { - return userAgentData; - } - - public LocationData getLocationData() { - return locationData; - } - - public CompanyCollection getCompanyCollection() { - return companyCollection; - } - - public SocialProfileCollection getSocialProfileCollection() { - return socialProfileCollection; - } - - public SegmentCollection getSegmentCollection() { - return segmentCollection; - } - - public TagCollection getTagCollection() { - return tagCollection; - } - - public Boolean isUpdateLastRequestAt() { - return updateLastRequestAt; - } - - public Boolean isNewSession() { - return newSession; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Contact contact = (Contact) o; - - if (createdAt != contact.createdAt) return false; - if (updatedAt != contact.updatedAt) return false; - if (sessionCount != contact.sessionCount) return false; - if (lastRequestAt != contact.lastRequestAt) return false; - if (!type.equals(contact.type)) return false; - if (id != null ? !id.equals(contact.id) : contact.id != null) return false; - if (name != null ? !name.equals(contact.name) : contact.name != null) return false; - if (email != null ? !email.equals(contact.email) : contact.email != null) return false; - if (phone != null ? !phone.equals(contact.phone) : contact.phone != null) return false; - if (userID != null ? !userID.equals(contact.userID) : contact.userID != null) return false; - if (avatar != null ? !avatar.equals(contact.avatar) : contact.avatar != null) return false; - if (unsubscribedFromEmails != null ? !unsubscribedFromEmails.equals(contact.unsubscribedFromEmails) : contact.unsubscribedFromEmails != null) - return false; - if (lastSeenIP != null ? !lastSeenIP.equals(contact.lastSeenIP) : contact.lastSeenIP != null) return false; - if (customAttributes != null ? !customAttributes.equals(contact.customAttributes) : contact.customAttributes != null) - return false; - if (userAgentData != null ? !userAgentData.equals(contact.userAgentData) : contact.userAgentData != null) - return false; - if (locationData != null ? !locationData.equals(contact.locationData) : contact.locationData != null) - return false; - if (companyCollection != null ? !companyCollection.equals(contact.companyCollection) : contact.companyCollection != null) - return false; - if (socialProfileCollection != null ? !socialProfileCollection.equals(contact.socialProfileCollection) : contact.socialProfileCollection != null) - return false; - if (segmentCollection != null ? !segmentCollection.equals(contact.segmentCollection) : contact.segmentCollection != null) - return false; - if (tagCollection != null ? !tagCollection.equals(contact.tagCollection) : contact.tagCollection != null) - return false; - if (updateLastRequestAt != null ? !updateLastRequestAt.equals(contact.updateLastRequestAt) : contact.updateLastRequestAt != null) - return false; - //noinspection SimplifiableIfStatement - if (newSession != null ? !newSession.equals(contact.newSession) : contact.newSession != null) return false; - return !(untag != null ? !untag.equals(contact.untag) : contact.untag != null); - - } - - @Override - public int hashCode() { - int result = type.hashCode(); - result = 31 * result + (id != null ? id.hashCode() : 0); - result = 31 * result + (name != null ? name.hashCode() : 0); - result = 31 * result + (email != null ? email.hashCode() : 0); - result = 31 * result + (phone != null ? phone.hashCode() : 0); - result = 31 * result + (userID != null ? userID.hashCode() : 0); - result = 31 * result + (avatar != null ? avatar.hashCode() : 0); - result = 31 * result + (int) (createdAt ^ (createdAt >>> 32)); - result = 31 * result + (int) (updatedAt ^ (updatedAt >>> 32)); - result = 31 * result + (unsubscribedFromEmails != null ? unsubscribedFromEmails.hashCode() : 0); - result = 31 * result + sessionCount; - result = 31 * result + (int) (lastRequestAt ^ (lastRequestAt >>> 32)); - result = 31 * result + (lastSeenIP != null ? lastSeenIP.hashCode() : 0); - result = 31 * result + (customAttributes != null ? customAttributes.hashCode() : 0); - result = 31 * result + (userAgentData != null ? userAgentData.hashCode() : 0); - result = 31 * result + (locationData != null ? locationData.hashCode() : 0); - result = 31 * result + (companyCollection != null ? companyCollection.hashCode() : 0); - result = 31 * result + (socialProfileCollection != null ? socialProfileCollection.hashCode() : 0); - result = 31 * result + (segmentCollection != null ? segmentCollection.hashCode() : 0); - result = 31 * result + (tagCollection != null ? tagCollection.hashCode() : 0); - result = 31 * result + (updateLastRequestAt != null ? updateLastRequestAt.hashCode() : 0); - result = 31 * result + (newSession != null ? newSession.hashCode() : 0); - result = 31 * result + (untag != null ? untag.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "Contact{" + - "type='" + type + '\'' + - ", id='" + id + '\'' + - ", name='" + name + '\'' + - ", email='" + email + '\'' + - ", phone='" + phone + '\'' + - ", userID='" + userID + '\'' + - ", avatar=" + avatar + - ", createdAt=" + createdAt + - ", updatedAt=" + updatedAt + - ", unsubscribedFromEmails=" + unsubscribedFromEmails + - ", sessionCount=" + sessionCount + - ", lastRequestAt=" + lastRequestAt + - ", lastSeenIP='" + lastSeenIP + '\'' + - ", customAttributes=" + customAttributes + - ", userAgentData='" + userAgentData + '\'' + - ", locationData=" + locationData + - ", companyCollection=" + companyCollection + - ", socialProfileCollection=" + socialProfileCollection + - ", segmentCollection=" + segmentCollection + - ", tagCollection=" + tagCollection + - ", updateLastRequestAt=" + updateLastRequestAt + - ", newSession=" + newSession + - ", untag=" + untag + - "} " + super.toString(); - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/ContactCollection.java b/intercom-java/src/main/java/io/intercom/api/ContactCollection.java deleted file mode 100644 index dbd2de08..00000000 --- a/intercom-java/src/main/java/io/intercom/api/ContactCollection.java +++ /dev/null @@ -1,33 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Iterator; -import java.util.List; - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(ignoreUnknown = true) -public class ContactCollection extends TypedDataCollection { - - - public ContactCollection() { - } - - public ContactCollection(List contacts) { - this(); - this.page = contacts; - } - - @SuppressWarnings("EmptyMethod") - @JsonProperty("contacts") - @Override - public List getPage() { - return super.getPage(); - } - - @Override - public ContactCollection nextPage() { - return fetchNextPage(ContactCollection.class); - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/ContactMessage.java b/intercom-java/src/main/java/io/intercom/api/ContactMessage.java deleted file mode 100644 index b79539b9..00000000 --- a/intercom-java/src/main/java/io/intercom/api/ContactMessage.java +++ /dev/null @@ -1,21 +0,0 @@ -package io.intercom.api; - - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; - - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(JsonInclude.Include.NON_EMPTY) -public class ContactMessage extends TypedMessage { - - public ContactMessage() { - } - - @Override - public String toString() { - return "ContactMessage{} " + super.toString(); - } - -} diff --git a/intercom-java/src/main/java/io/intercom/api/Conversation.java b/intercom-java/src/main/java/io/intercom/api/Conversation.java deleted file mode 100644 index 1bf47a1a..00000000 --- a/intercom-java/src/main/java/io/intercom/api/Conversation.java +++ /dev/null @@ -1,435 +0,0 @@ -package io.intercom.api; - - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.google.common.base.Joiner; -import com.google.common.base.Optional; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; - -import java.net.URI; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(ignoreUnknown = true) -public class Conversation extends TypedData { - - @SuppressWarnings("UnusedDeclaration") - @JsonIgnoreProperties(ignoreUnknown = true) - private static class ConversationRead extends TypedData { - - @JsonProperty("read") - private boolean read; - - public ConversationRead() { - this.read = true; - } - } - - private static final HashMap SENTINEL = Maps.newHashMap(); - private static final List DISPLAY_AS_FORMATS = Lists.newArrayList("plaintext", "html"); - static final String MESSAGE_TYPE_ASSIGNMENT = "assignment"; - static final String MESSAGE_TYPE_COMMENT = "comment"; - static final String MESSAGE_TYPE_NOTE = "note"; - static final String MESSAGE_TYPE_CLOSE = "close"; - static final String MESSAGE_TYPE_OPEN = "open"; - static final String MESSAGE_TYPE_SNOOZED = "snoozed"; - static final List MESSAGE_TYPES = Lists.newArrayList( - MESSAGE_TYPE_ASSIGNMENT, - MESSAGE_TYPE_COMMENT, - MESSAGE_TYPE_NOTE, - MESSAGE_TYPE_CLOSE, - MESSAGE_TYPE_OPEN, - MESSAGE_TYPE_SNOOZED - ); - - public static Conversation find(String id) throws InvalidException, AuthorizationException { - final HttpClient resource = new HttpClient(UriBuilder.newBuilder().path("conversations").path(id).build()); - return resource.get(Conversation.class); - } - - public static Conversation find(String id, Map params) throws InvalidException, AuthorizationException { - final HttpClient resource = new HttpClient(UriBuilder.newBuilder().path("conversations").path(id).query(params).build()); - return resource.get(Conversation.class); - } - - public static ConversationCollection list() throws InvalidException, AuthorizationException { - return DataResource.list(SENTINEL, "conversations", ConversationCollection.class); - } - - public static ConversationCollection list(Map params) throws InvalidException, AuthorizationException { - validateListRequest(params); - - return DataResource.list(params, "conversations", ConversationCollection.class); - } - - public static Conversation reply(String id, UserReply reply) { - validateUserReplyRequest(reply); - - final URI uri = UriBuilder.newBuilder() - .path("conversations") - .path(id) - .path("reply") - .build(); - return new HttpClient(uri) - .post(Conversation.class, new UserReply.UserStringReply(reply)); - } - - public static Conversation reply(String id, AdminReply reply) { - validateAdminReplyRequest(reply); - - final URI uri = UriBuilder.newBuilder() - .path("conversations") - .path(id) - .path("reply") - .build(); - return new HttpClient(uri) - .post(Conversation.class, new AdminReply.AdminStringReply(reply)); - } - - public static Conversation markAsRead(String id) { - final URI uri = UriBuilder.newBuilder() - .path("conversations") - .path(id) - .build(); - - return new HttpClient(uri) - .put(Conversation.class, new ConversationRead()); - } - - public static UserMessage create(UserMessage message) { - return DataResource.create(message, "messages", UserMessage.class); - } - - public static ContactMessage create(ContactMessage message) { - return DataResource.create(message, "messages", ContactMessage.class); - } - - public static AdminMessage create(AdminMessage message) throws InvalidException { - if ((!message.getTemplate().equals("plain")) && (!message.getTemplate().equals("personal"))) { - throw new InvalidException("The template must be either personal or plain"); - } - if ((!message.getMessageType().equals("email")) && (!message.getMessageType().equals("inapp"))) { - throw new InvalidException("The message type must be either email or inapp"); - } - /* - the message api is asymmetric because reasons. this wraps the response - type so we only expose AdminMessage in the client surface - */ - final AdminMessageResponse adminMessageResponse = - DataResource.create(message, "messages", AdminMessageResponse.class); - AdminMessage response = new AdminMessage(); - response.setAdmin(adminMessageResponse.getAdmin()); - response.setBody(adminMessageResponse.getBody()); - response.setCreatedAt(adminMessageResponse.getCreatedAt()); - response.setId(adminMessageResponse.getId()); - response.setMessageType(adminMessageResponse.getMessageType()); - response.setSubject(adminMessageResponse.getSubject()); - response.setTemplate(adminMessageResponse.getTemplate()); - // user returns null - // response.setUser(adminMessageResponse.getFrom()); - return response; - } - - public static Conversation runAssignmentRules(String id) { - final HttpClient resource = new HttpClient(UriBuilder.newBuilder().path("conversations").path(id).path("run_assignment_rules").build()); - return resource.post(Conversation.class, null); - } - - static void validateAdminReplyRequest(AdminReply reply) { - - validateMessageType(reply); - - if (reply.getAssigneeID() != null - && !"assignment".equals(reply.getMessageType())) { - throw new InvalidException("an assignee id can be set only for a message type of assignment"); - } - - if (("note".equals(reply.getMessageType()) || "comment".equals(reply.getMessageType())) - && (isNullOrBlank(reply.getBody())) - ) { - throw new InvalidException("a comment or note reply must have a body"); - } - } - - static boolean isNullOrBlank(String s) { - return s == null || s.trim().length() == 0; - - } - - static void validateUserReplyRequest(UserReply reply) { - if (! "comment".equals(reply.getMessageType())) { - throw new InvalidException("a user reply must have a message type of comment"); - } - } - - static void validateMessageType(Reply reply) { - if(! MESSAGE_TYPES.contains(reply.getMessageType())) { - throw new InvalidException( - "A reply message type must be one of " - + Joiner.on(", ").join(MESSAGE_TYPES)); - } - } - - static void validateListRequest(Map params) { - - if (isAdminQuery(params) - && !(params.containsKey("admin_id"))) { - throw new InvalidException("an admin_id must be supplied for an admin conversation query"); - } - - if (params.containsKey("display_as")) { - if (!DISPLAY_AS_FORMATS.contains(params.get("display_as"))) { - throw new InvalidException( - "A display_as parameter must have one of the values " - + Joiner.on(", ").join(DISPLAY_AS_FORMATS)); - } - } - - if (isUserQuery(params) - && (!params.containsKey("intercom_user_id") - && !params.containsKey("user_id") - && !params.containsKey("email"))) { - throw new InvalidException( - "One of intercom_user_id, user_id or email must be supplied for a user conversation query"); - } - } - - private static boolean isUserQuery(Map params) { - return params.containsKey("type") && params.get("type").equals("user"); - } - - private static boolean isAdminQuery(Map params) { - return params.containsKey("type") && params.get("type").equals("admin"); - } - - @JsonProperty("type") - private final String type = "conversation"; - - @JsonProperty("id") - private String id; - - @JsonProperty("conversation_message") - private ConversationMessage conversationMessage; - - @JsonProperty("customer_first_reply") - private CustomerFirstReply customerFirstReply; - - @JsonProperty("conversation_rating") - private ConversationRating conversationRating; - - @JsonProperty("user") - private User user; - - @JsonProperty("assignee") - private Admin assignee; - - @JsonProperty("created_at") - private long createdAt; - - @JsonProperty("updated_at") - private long updatedAt; - - @JsonProperty("waiting_since") - private long waitingSince; - - @JsonProperty("snoozed_until") - private long snoozedUntil; - - @JsonProperty("conversation_parts") - private ConversationPartCollection conversationPartCollection; - - @JsonProperty("tags") - private TagCollection tagCollection; - - @JsonProperty("open") - private boolean open; - - @JsonProperty("read") - private boolean read; - - @JsonProperty("state") - private String state; - - @JsonProperty("links") - private Map links; - - public Conversation() { - } - - public String getType() { - return type; - } - - public Admin getCurrentAssignee() { - Admin assignee = null; - if (getAssignee() != null) { - assignee = getAssignee(); - } else if (getMostRecentConversationPart() != null && getMostRecentConversationPart().getAssignedTo() != null) { - assignee = getMostRecentConversationPart().getAssignedTo(); - } - - return assignee; - } - - public Optional getFirstConversationPart() { - return Optional.fromNullable(getConversationPartCollection().getPage().get(0)); - } - - public ConversationPart getMostRecentConversationPart() { - final ConversationPartCollection conversationParts = getConversationPartCollection(); - final List items = conversationParts.getPage(); - if (items.isEmpty()) { - return null; - } else { - return items.get(items.size() - 1); - } - } - - public String getId() { - return id; - } - - public ConversationMessage getConversationMessage() { - return conversationMessage; - } - - public CustomerFirstReply getCustomerFirstReply() { - return customerFirstReply; - } - - public ConversationRating getConversationRating() { - return conversationRating; - } - - public User getUser() { - return user; - } - - public Admin getAssignee() { - return assignee; - } - - public long getCreatedAt() { - return createdAt; - } - - public long getUpdatedAt() { - return updatedAt; - } - - public long getWaitingSince() { - return waitingSince; - } - - public long getSnoozedUntil() { - return snoozedUntil; - } - - public ConversationPartCollection getConversationPartCollection() { - if (conversationPartCollection == null) { - conversationPartCollection = find(this.getId()).getConversationPartCollection(); - } - - return conversationPartCollection; - } - - public TagCollection getTagCollection() { - if (tagCollection == null) { - tagCollection = find(this.getId()).getTagCollection(); - } - - return tagCollection; - } - - public boolean getOpen() { - return open; - } - - public boolean getRead() { - return read; - } - - public String getState() { - return state; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Conversation that = (Conversation) o; - - if (createdAt != that.createdAt) return false; - if (open != that.open) return false; - if (read != that.read) return false; - if (updatedAt != that.updatedAt) return false; - if (waitingSince != that.waitingSince) return false; - if (snoozedUntil != that.snoozedUntil) return false; - if (assignee != null ? !assignee.equals(that.assignee) : that.assignee != null) return false; - if (conversationMessage != null ? !conversationMessage.equals(that.conversationMessage) : that.conversationMessage != null) - return false; - if (conversationRating != null ? !conversationRating.equals(that.conversationRating) : that.conversationRating != null) - return false; - if (conversationPartCollection != null ? !conversationPartCollection.equals(that.conversationPartCollection) : that.conversationPartCollection != null) - return false; - if (tagCollection != null ? !tagCollection.equals(that.tagCollection) : that.tagCollection != null) - return false; - if (id != null ? !id.equals(that.id) : that.id != null) return false; - if (links != null ? !links.equals(that.links) : that.links != null) return false; - if (!state.equals(that.state)) return false; - if (!type.equals(that.type)) return false; - //noinspection RedundantIfStatement - if (user != null ? !user.equals(that.user) : that.user != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = type.hashCode(); - result = 31 * result + (id != null ? id.hashCode() : 0); - result = 31 * result + (state != null ? state.hashCode() : 0); - result = 31 * result + (conversationMessage != null ? conversationMessage.hashCode() : 0); - result = 31 * result + (conversationRating != null ? conversationRating.hashCode() : 0); - result = 31 * result + (user != null ? user.hashCode() : 0); - result = 31 * result + (assignee != null ? assignee.hashCode() : 0); - result = 31 * result + (int) (createdAt ^ (createdAt >>> 32)); - result = 31 * result + (int) (updatedAt ^ (updatedAt >>> 32)); - result = 31 * result + (int) (waitingSince ^ (waitingSince >>> 32)); - result = 31 * result + (int) (snoozedUntil ^ (snoozedUntil >>> 32)); - result = 31 * result + (conversationPartCollection != null ? conversationPartCollection.hashCode() : 0); - result = 31 * result + (tagCollection != null ? tagCollection.hashCode() : 0); - result = 31 * result + (open ? 1 : 0); - result = 31 * result + (read ? 1 : 0); - result = 31 * result + (links != null ? links.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "Conversation{" + - "type='" + type + '\'' + - ", id='" + id + '\'' + - ", conversationMessage=" + conversationMessage + - ", user=" + user + - ", assignee=" + assignee + - ", createdAt=" + createdAt + - ", updatedAt=" + updatedAt + - ", waitingSince=" + waitingSince + - ", snoozedUntil=" + snoozedUntil + - ", conversationPartCollection=" + conversationPartCollection + - ", tagCollection=" + tagCollection + - ", open=" + open + - ", state=" + state + - ", read=" + read + - ", links=" + links + - ", conversationRating=" + conversationRating + - "} " + super.toString(); - } -} - diff --git a/intercom-java/src/main/java/io/intercom/api/ConversationCollection.java b/intercom-java/src/main/java/io/intercom/api/ConversationCollection.java deleted file mode 100644 index 33965186..00000000 --- a/intercom-java/src/main/java/io/intercom/api/ConversationCollection.java +++ /dev/null @@ -1,28 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Iterator; -import java.util.List; - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(ignoreUnknown = true) -public class ConversationCollection extends TypedDataCollection { - - - public ConversationCollection() { - type = "conversation.list"; - } - - @SuppressWarnings("EmptyMethod") - @JsonProperty("conversations") - public List getPage() { - return super.getPage(); - } - - @Override - public ConversationCollection nextPage() { - return fetchNextPage(ConversationCollection.class); - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/ConversationMessage.java b/intercom-java/src/main/java/io/intercom/api/ConversationMessage.java deleted file mode 100644 index c225ced3..00000000 --- a/intercom-java/src/main/java/io/intercom/api/ConversationMessage.java +++ /dev/null @@ -1,117 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(ignoreUnknown = true) -public class ConversationMessage extends TypedData { - - @SuppressWarnings("FieldCanBeLocal") - @JsonProperty("type") - private final String type = "conversation_message"; - - @JsonProperty - private String id; - - @JsonProperty - private String subject; - - @JsonProperty - private String body; - - @JsonProperty - private Author author; - - @JsonProperty - private String url; - - @JsonProperty("delivered_as") - private String deliveredAs; - - @JsonProperty("attachments") - private List attachments; - - public ConversationMessage() { - } - - public String getType() { - return type; - } - - public String getId() { - return id; - } - - public String getSubject() { - return subject; - } - - public String getBody() { - return body; - } - - public Author getAuthor() { - return author; - } - - public String getUrl() { - return url; - } - - public String getDeliveredAs() { - return deliveredAs; - } - - public List getAttachments() { - return attachments; - } - - @Override - public int hashCode() { - int result = subject != null ? subject.hashCode() : 0; - result = 31 * result + (body != null ? body.hashCode() : 0); - result = 31 * result + (author != null ? author.hashCode() : 0); - result = 31 * result + (deliveredAs != null ? deliveredAs.hashCode() : 0); - result = 31 * result + (id != null ? id.hashCode() : 0); - result = 31 * result + (url != null ? url.hashCode() : 0); - result = 31 * result + (attachments != null ? attachments.hashCode() : 0); - - return result; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - ConversationMessage that = (ConversationMessage) o; - - if (author != null ? !author.equals(that.author) : that.author != null) return false; - if (body != null ? !body.equals(that.body) : that.body != null) return false; - //noinspection RedundantIfStatement - if (subject != null ? !subject.equals(that.subject) : that.subject != null) return false; - if (id != null ? !id.equals(that.id) : that.id != null) return false; - if (url != null ? !url.equals(that.url) : that.url != null) return false; - if (deliveredAs != null ? !deliveredAs.equals(that.deliveredAs) : that.deliveredAs != null) return false; - if (attachments != null ? !attachments.equals(that.attachments) : that.attachments != null) return false; - - return true; - } - - @Override - public String toString() { - return "ConversationMessage{" + - "type='" + type + '\'' + - ", id='" + id + '\'' + - ", subject='" + subject + '\'' + - ", body='" + body + '\'' + - ", author=" + author + - ", url=" + url + - ", deliveredAs=" + deliveredAs + - ", attachments=" + attachments + - "} " + super.toString(); - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/ConversationPart.java b/intercom-java/src/main/java/io/intercom/api/ConversationPart.java deleted file mode 100644 index 74240721..00000000 --- a/intercom-java/src/main/java/io/intercom/api/ConversationPart.java +++ /dev/null @@ -1,125 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(ignoreUnknown = true) -public class ConversationPart extends TypedData { - - @JsonProperty("type") - private final String type = "conversation_part"; - - @JsonProperty - private String id; - - @JsonProperty("part_type") - private String partType; - - @JsonProperty - private String body; - - @JsonProperty - private Author author; - - @JsonProperty("assigned_to") - private Admin assignedTo; - - @JsonProperty("created_at") - private long createdAt; - - @JsonProperty("updated_at") - private long updatedAt; - - @JsonProperty("notified_at") - private long NotifiedAt; - - public ConversationPart() { - } - - public String getType() { - return type; - } - - public String getId() { - return id; - } - - public String getPartType() { - return partType; - } - - public String getBody() { - return body; - } - - public Author getAuthor() { - return author; - } - - public Admin getAssignedTo() { - return assignedTo; - } - - public long getCreatedAt() { - return createdAt; - } - - public long getUpdatedAt() { - return updatedAt; - } - - public long getNotifiedAt() { - return NotifiedAt; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - ConversationPart that = (ConversationPart) o; - - if (NotifiedAt != that.NotifiedAt) return false; - if (createdAt != that.createdAt) return false; - if (updatedAt != that.updatedAt) return false; - if (assignedTo != null ? !assignedTo.equals(that.assignedTo) : that.assignedTo != null) return false; - if (author != null ? !author.equals(that.author) : that.author != null) return false; - if (body != null ? !body.equals(that.body) : that.body != null) return false; - if (id != null ? !id.equals(that.id) : that.id != null) return false; - if (partType != null ? !partType.equals(that.partType) : that.partType != null) return false; - //noinspection RedundantIfStatement - if (!type.equals(that.type)) return false; - - return true; - } - - @Override - public int hashCode() { - int result = type.hashCode(); - result = 31 * result + (id != null ? id.hashCode() : 0); - result = 31 * result + (partType != null ? partType.hashCode() : 0); - result = 31 * result + (body != null ? body.hashCode() : 0); - result = 31 * result + (author != null ? author.hashCode() : 0); - result = 31 * result + (assignedTo != null ? assignedTo.hashCode() : 0); - result = 31 * result + (int) (createdAt ^ (createdAt >>> 32)); - result = 31 * result + (int) (updatedAt ^ (updatedAt >>> 32)); - result = 31 * result + (int) (NotifiedAt ^ (NotifiedAt >>> 32)); - return result; - } - - @Override - public String toString() { - return "ConversationPart{" + - "type='" + type + '\'' + - ", id='" + id + '\'' + - ", partType='" + partType + '\'' + - ", body='" + body + '\'' + - ", author=" + author + - ", assignedTo=" + assignedTo + - ", createdAt=" + createdAt + - ", updatedAt=" + updatedAt + - ", NotifiedAt=" + NotifiedAt + - "} " + super.toString(); - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/ConversationPartCollection.java b/intercom-java/src/main/java/io/intercom/api/ConversationPartCollection.java deleted file mode 100644 index 0a67e617..00000000 --- a/intercom-java/src/main/java/io/intercom/api/ConversationPartCollection.java +++ /dev/null @@ -1,26 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(ignoreUnknown = true) -public class ConversationPartCollection extends TypedDataCollection { - - public ConversationPartCollection() { - type = "conversation_part.list"; - } - - @SuppressWarnings("EmptyMethod") - @JsonProperty("conversation_parts") - public List getPage() { - return super.getPage(); - } - - @Override - public ConversationPartCollection nextPage() { - return new ConversationPartCollection(); - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/ConversationRating.java b/intercom-java/src/main/java/io/intercom/api/ConversationRating.java deleted file mode 100644 index c1a893cb..00000000 --- a/intercom-java/src/main/java/io/intercom/api/ConversationRating.java +++ /dev/null @@ -1,87 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(ignoreUnknown = true) -public class ConversationRating extends TypedData { - - @JsonProperty - private int rating; - - @JsonProperty - private String remark; - - @JsonProperty("created_at") - private long createdAt; - - @JsonProperty - private Customer customer; - - @JsonProperty - private Teammate teammate; - - public ConversationRating() { - } - - public int getRating() { - return rating; - } - - public String getRemark() { - return remark; - } - - public long getCreatedAt() { - return createdAt; - } - - public Customer getCustomer() { - return customer; - } - - public Teammate getTeammate() { - return teammate; - } - - @Override - public int hashCode() { - int result = remark != null ? remark.hashCode() : 0; - result = 31 * result + (customer != null ? customer.hashCode() : 0); - result = 31 * result + (teammate != null ? teammate.hashCode() : 0); - result = 31 * result + (int) (createdAt ^ (createdAt >>> 32)); - result = 31 * result + rating; - - return result; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - ConversationRating that = (ConversationRating) o; - - if (customer != null ? !customer.equals(that.customer) : that.customer != null) return false; - if (teammate != null ? !teammate.equals(that.teammate) : that.teammate != null) return false; - if (remark != null ? !remark.equals(that.remark) : that.remark != null) return false; - if (createdAt != that.createdAt) return false; - if (rating != that.rating) return false; - - return true; - } - - @Override - public String toString() { - return "ConversationRating{" + - "rating='" + rating + '\'' + - ", remark='" + remark + '\'' + - ", created_at='" + createdAt + '\'' + - ", customer=" + customer + - ", teammate=" + teammate + - "} " + super.toString(); - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/CountItemDeserializer.java b/intercom-java/src/main/java/io/intercom/api/CountItemDeserializer.java deleted file mode 100644 index e991d642..00000000 --- a/intercom-java/src/main/java/io/intercom/api/CountItemDeserializer.java +++ /dev/null @@ -1,27 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.TreeNode; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.fasterxml.jackson.databind.node.ObjectNode; - -import java.io.IOException; -import java.util.Map; - -class CountItemDeserializer extends StdDeserializer { - - private static final long serialVersionUID = 8226175715446656115L; - - public CountItemDeserializer() { - super(Counts.CountItem.class); - } - - @Override - public Counts.CountItem deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { - final TreeNode treeNode = jp.getCodec().readTree(jp); - final Map.Entry next = ((ObjectNode) treeNode).fields().next(); - return new Counts.CountItem(next.getKey(), next.getValue().asLong()); - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/CountItemSerializer.java b/intercom-java/src/main/java/io/intercom/api/CountItemSerializer.java deleted file mode 100644 index bdd581b0..00000000 --- a/intercom-java/src/main/java/io/intercom/api/CountItemSerializer.java +++ /dev/null @@ -1,22 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.ser.std.StdSerializer; - -import java.io.IOException; - -class CountItemSerializer extends StdSerializer { - - public CountItemSerializer() { - super(Counts.CountItem.class); - } - - @Override - public void serialize(Counts.CountItem value, JsonGenerator jgen, SerializerProvider provider) - throws IOException { - jgen.writeStartObject(); - jgen.writeNumberField(value.getName(), value.getValue()); - jgen.writeEndObject(); - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/Counts.java b/intercom-java/src/main/java/io/intercom/api/Counts.java deleted file mode 100644 index 170687de..00000000 --- a/intercom-java/src/main/java/io/intercom/api/Counts.java +++ /dev/null @@ -1,340 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.google.common.collect.Maps; - -import java.net.URI; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(JsonInclude.Include.NON_EMPTY) -public class Counts { - - static Counts countQuery(Map query) { - final URI build = UriBuilder.newBuilder() - .path("counts") - .query(query) - .build(); - final HttpClient resource = new HttpClient(build); - return resource.get(Counts.class); - } - - public static Counts.Totals appTotals() throws InvalidException, AuthorizationException { - final HttpClient resource = new HttpClient(UriBuilder.newBuilder().path("counts").build()); - return resource.get(Totals.class); - } - -// public static Long userCount() throws InvalidException, AuthorizationException{ -// final HashMap params = Maps.newHashMap(); -// params.put("type", "user"); -// return countQuery(params).getUser().getUser(); -// } - - public static List userTags() throws InvalidException, AuthorizationException { - final HashMap params = Maps.newHashMap(); - params.put("type", "user"); - params.put("count", "tag"); - return countQuery(params).getUser().getTags(); - } - - public static List userSegments() throws InvalidException, AuthorizationException { - final HashMap params = Maps.newHashMap(); - params.put("type", "user"); - params.put("count", "segment"); - return countQuery(params).getUser().getSegments(); - } - - public static Counts.Conversation conversationTotals() throws InvalidException, AuthorizationException { - final HashMap params = Maps.newHashMap(); - params.put("type", "conversation"); - return countQuery(params).getConversation(); - } - - public static Counts.Conversation conversationAdmins() throws InvalidException, AuthorizationException { - final HashMap params = Maps.newHashMap(); - params.put("type", "conversation"); - params.put("count", "admin"); - return countQuery(params).getConversation(); - } - -// public static Long companyCount() throws InvalidException, AuthorizationException{ -// final HashMap params = Maps.newHashMap(); -// params.put("type", "company"); -// return countQuery(params).getCompany().getCompanies(); -// } - - public static List companySegments() throws InvalidException, AuthorizationException { - final HashMap params = Maps.newHashMap(); - params.put("type", "company"); - params.put("count", "segment"); - return countQuery(params).getCompany().getSegments(); - } - - public static List companyTags() throws InvalidException, AuthorizationException { - final HashMap params = Maps.newHashMap(); - params.put("type", "company"); - params.put("count", "tag"); - return countQuery(params).getCompany().getTags(); - } - - public static List companyUsers() throws InvalidException, AuthorizationException { - final HashMap params = Maps.newHashMap(); - params.put("type", "company"); - params.put("count", "user"); - return countQuery(params).getCompany().getUsers(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - @JsonInclude(JsonInclude.Include.NON_EMPTY) - public static class Totals { - - @JsonProperty("company") - private CountItem company; - - @JsonProperty("segment") - private CountItem segment; - - @JsonProperty("tag") - private CountItem tag; - - @JsonProperty("user") - private CountItem user; - - public CountItem getCompany() { - return company; - } - - public CountItem getSegment() { - return segment; - } - - public CountItem getTag() { - return tag; - } - - public CountItem getUser() { - return user; - } - - @Override - public String toString() { - return "Totals{" + - "company=" + company + - ", segment=" + segment + - ", tag=" + tag + - ", user=" + user + - '}'; - } - } - - @JsonIgnoreProperties(ignoreUnknown = true) - @JsonInclude(JsonInclude.Include.NON_EMPTY) - public static class CountItem { - - private String name; - - private long value; - - public CountItem(String name, long value) { - this.name = name; - this.value = value; - } - - public String getName() { - return name; - } - - public long getValue() { - return value; - } - - @Override - public String toString() { - return "CountItem{" + - "name='" + name + '\'' + - ", value=" + value + - '}'; - } - } - - @JsonIgnoreProperties(ignoreUnknown = true) - @JsonInclude(JsonInclude.Include.NON_EMPTY) - public static class Conversation { - - @JsonProperty("admin") - List admins; - - @JsonProperty("assigned") - private long assigned; - - @JsonProperty("closed") - private long closed; - - @JsonProperty("open") - private long open; - - @JsonProperty("unassigned") - private long unassigned; - - Conversation() { - } - - public List getAdmins() { - return admins; - } - - public long getAssigned() { - return assigned; - } - - public long getClosed() { - return closed; - } - - public long getOpen() { - return open; - } - - public long getUnassigned() { - return unassigned; - } - - @Override - public String toString() { - return "Conversation{" + - "assigned=" + assigned + - ", closed=" + closed + - ", open=" + open + - ", unassigned=" + unassigned + - ", admins=" + admins + - '}'; - } - } - - @JsonIgnoreProperties(ignoreUnknown = true) - @JsonInclude(JsonInclude.Include.NON_EMPTY) - public static class User { - - @JsonProperty("user") - private long user; - - @JsonProperty("tag") - private List tags; - - @JsonProperty("segment") - private List segments; - - User() { - } - - public long getUser() { - return user; - } - - public List getTags() { - return tags; - } - - public List getSegments() { - return segments; - } - - @Override - public String toString() { - return "User{" + - "user=" + user + - ", tags=" + tags + - ", segments=" + segments + - '}'; - } - } - - @JsonIgnoreProperties(ignoreUnknown = true) - @JsonInclude(JsonInclude.Include.NON_EMPTY) - public static class Company { - - @JsonProperty("company") - private long companies; - - @JsonProperty("tag") - private List tags; - - @JsonProperty("user") - private List users; - - @JsonProperty("segment") - private List segments; - - Company() { - } - - public long getCompanies() { - return companies; - } - - public List getTags() { - return tags; - } - - public List getUsers() { - return users; - } - - public List getSegments() { - return segments; - } - - @Override - public String toString() { - return "Company{" + - "companies=" + companies + - ", tags=" + tags + - ", users=" + users + - ", segments=" + segments + - '}'; - } - } - - @JsonProperty("type") - private String type = "count"; - - @JsonProperty("company") - private Counts.Company company; - - @JsonProperty("user") - private Counts.User user; - - @JsonProperty("conversation") - private Counts.Conversation conversation; - - public String getType() { - return type; - } - - public Company getCompany() { - return company; - } - - public User getUser() { - return user; - } - - public Conversation getConversation() { - return conversation; - } - - @Override - public String toString() { - return "Counts{" + - "type='" + type + '\'' + - ", company=" + company + - ", user=" + user + - ", conversation=" + conversation + - '}'; - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/CustomAttribute.java b/intercom-java/src/main/java/io/intercom/api/CustomAttribute.java deleted file mode 100644 index 1415fa32..00000000 --- a/intercom-java/src/main/java/io/intercom/api/CustomAttribute.java +++ /dev/null @@ -1,202 +0,0 @@ -package io.intercom.api; - -import com.google.common.collect.Lists; - -import java.io.Serializable; -import java.util.ArrayList; - -@SuppressWarnings("UnusedDeclaration") -public class CustomAttribute { - - @SuppressWarnings("unchecked") - private static final ArrayList> CLASSES = Lists.newArrayList(String.class, Long.class, Float.class, Double.class, Boolean.class, Integer.class); - - public static StringAttribute newStringAttribute(String name, String value) { - return new StringAttribute(name, value); - } - - public static BooleanAttribute newBooleanAttribute(String name, boolean value) { - return new BooleanAttribute(name, value); - } - - public static DoubleAttribute newDoubleAttribute(String name, double value) { - return new DoubleAttribute(name, value); - } - - public static LongAttribute newLongAttribute(String name, long value) { - return new LongAttribute(name, value); - } - - public static IntegerAttribute newIntegerAttribute(String name, int value) { - return new IntegerAttribute(name, value); - } - - public static FloatAttribute newFloatAttribute(String name, float value) { - return new FloatAttribute(name, value); - } - - public static class StringAttribute extends CustomAttribute { - - private StringAttribute(String name, String value) { - super(name, value, String.class); - } - - private StringAttribute(String name, String value, Class clazz) { - super(name, value, clazz); - } - } - - public static class BooleanAttribute extends CustomAttribute { - - private BooleanAttribute(String name, boolean value) { - super(name, value, Boolean.class); - } - - private BooleanAttribute(String name, boolean value, Class clazz) { - super(name, value, clazz); - } - } - - public static class DoubleAttribute extends CustomAttribute { - - private DoubleAttribute(String name, double value, Class clazz) { - super(name, value, clazz); - } - - private DoubleAttribute(String name, double value) { - super(name, value, Double.class); - } - } - - public static class FloatAttribute extends CustomAttribute { - - private FloatAttribute(String name, float value, Class clazz) { - super(name, value, clazz); - } - - private FloatAttribute(String name, float value) { - super(name, value, Float.class); - } - } - - public static class IntegerAttribute extends CustomAttribute { - - private IntegerAttribute(String name, int value) { - super(name, value, Integer.class); - } - - private IntegerAttribute(String name, int value, Class clazz) { - super(name, value, clazz); - } - } - - public static class LongAttribute extends CustomAttribute { - - public LongAttribute(String name, long value, Class clazz) { - super(name, value, clazz); - } - - public LongAttribute(String name, long value) { - super(name, value, Long.class); - } - - } - - private String name; - - private T value; - - private Class clazz; - - public CustomAttribute(String name, T value, Class clazz) { - //noinspection SuspiciousMethodCalls - if (!CLASSES.contains(clazz)) { - throw new InvalidException(String.format("cannot accept class type [%s] for custom attribute", clazz.getName())); - } - this.name = name; - this.value = value; - this.clazz = clazz; - - } - - public Class getValueClass() { - return clazz; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public T getValue() { - return value; - } - - public void setValue(T value) { - this.value = value; - } - - public C as(Class c) { - //noinspection unchecked - return (C) getValue(); - } - - public long longValue() { - return as(Long.class); - } - - public String textValue() { - return as(String.class); - } - - public boolean booleanValue() { - return as(Boolean.class); - } - - public float floatValue() { - return as(Float.class); - } - - public double doubleValue() { - return as(Double.class); - } - - public int integerValue() { - return as(Integer.class); - } - - @Override - public int hashCode() { - int result = name != null ? name.hashCode() : 0; - result = 31 * result + (value != null ? value.hashCode() : 0); - result = 31 * result + (clazz != null ? clazz.hashCode() : 0); - return result; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - CustomAttribute that = (CustomAttribute) o; - - if (clazz != null ? !clazz.equals(that.clazz) : that.clazz != null) return false; - if (name != null ? !name.equals(that.name) : that.name != null) return false; - //noinspection RedundantIfStatement - if (value != null ? !value.equals(that.value) : that.value != null) return false; - - return true; - } - - @Override - public String toString() { - return "CustomAttribute{" + - "name='" + name + '\'' + - ", value=" + value + - ", clazz=" + clazz + - '}'; - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/CustomAttributeDeserializer.java b/intercom-java/src/main/java/io/intercom/api/CustomAttributeDeserializer.java deleted file mode 100644 index 4756b257..00000000 --- a/intercom-java/src/main/java/io/intercom/api/CustomAttributeDeserializer.java +++ /dev/null @@ -1,53 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.fasterxml.jackson.databind.node.JsonNodeType; -import com.fasterxml.jackson.databind.node.NumericNode; -import com.fasterxml.jackson.databind.node.ValueNode; - -import java.io.IOException; - -class CustomAttributeDeserializer extends StdDeserializer { - - private static final long serialVersionUID = 5069924730975394938L; - - public CustomAttributeDeserializer() { - super(CustomAttribute.class); - } - - @Override - public CustomAttribute deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { - CustomAttribute cda = null; - final String currentName = jp.getParsingContext().getCurrentName(); - final ObjectMapper mapper = (ObjectMapper) jp.getCodec(); - final ValueNode vNode = mapper.readTree(jp); - if (vNode.asToken().isScalarValue()) { - if (vNode.getNodeType() == JsonNodeType.BOOLEAN) { - cda = new CustomAttribute(currentName, vNode.asBoolean(), Boolean.class); - } else if (vNode.getNodeType() == JsonNodeType.STRING) { - cda = new CustomAttribute(currentName, vNode.asText(), String.class); - } else if (vNode.getNodeType() == JsonNodeType.NUMBER) { - final NumericNode nNode = (NumericNode) vNode; - if (currentName.endsWith("_at")) { - cda = new CustomAttribute(currentName, vNode.longValue(), Long.class); - } else if (nNode.isInt()) { - cda = new CustomAttribute(currentName, vNode.intValue(), Integer.class); - } else if (nNode.isFloat()) { - cda = new CustomAttribute(currentName, vNode.floatValue(), Float.class); - } else if (nNode.isDouble()) { - cda = new CustomAttribute(currentName, vNode.doubleValue(), Double.class); - } else if (nNode.isLong()) { - cda = new CustomAttribute(currentName, vNode.longValue(), Long.class); - } else { - cda = new CustomAttribute(currentName, vNode.asText(), String.class); - } - } else { - cda = new CustomAttribute(currentName, vNode.asText(), String.class); - } - } - return cda; - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/CustomAttributeSerializer.java b/intercom-java/src/main/java/io/intercom/api/CustomAttributeSerializer.java deleted file mode 100644 index 07c2cf08..00000000 --- a/intercom-java/src/main/java/io/intercom/api/CustomAttributeSerializer.java +++ /dev/null @@ -1,21 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.ser.std.StdSerializer; - -import java.io.IOException; - -class CustomAttributeSerializer extends StdSerializer { - - public CustomAttributeSerializer() { - super(CustomAttribute.class); - } - - @Override - public void serialize(CustomAttribute value, JsonGenerator jgen, SerializerProvider provider) - throws IOException { - // the field name has already been written - jgen.writeObject(value.getValue()); - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/Customer.java b/intercom-java/src/main/java/io/intercom/api/Customer.java deleted file mode 100644 index 8ac92b4e..00000000 --- a/intercom-java/src/main/java/io/intercom/api/Customer.java +++ /dev/null @@ -1,69 +0,0 @@ -package io.intercom.api; - - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(JsonInclude.Include.NON_EMPTY) -public class Customer extends TypedData { - - @JsonProperty("type") - private String type; - - @JsonProperty("id") - private String id; - - public Customer() { - } - - public String getType() { - return type; - } - - public Customer setType(String type) { - this.type = type; - return this; - } - - public String getId() { - return id; - } - - public Customer setId(String id) { - this.id = id; - return this; - } - - @Override - public int hashCode() { - int result = id != null ? id.hashCode() : 0; - result = 31 * result + (type != null ? type.hashCode() : 0); - return result; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Customer customer = (Customer) o; - - if (id != null ? !id.equals(customer.id) : customer.id != null) return false; - if (type != null ? !type.equals(customer.type) : customer.type != null) return false; - - return true; - } - - @Override - public String toString() { - return "Customer{" + - "type='" + type + '\'' + - ", id='" + id+ '\'' + - "} " + super.toString(); - } - -} diff --git a/intercom-java/src/main/java/io/intercom/api/CustomerFirstReply.java b/intercom-java/src/main/java/io/intercom/api/CustomerFirstReply.java deleted file mode 100644 index 7336259c..00000000 --- a/intercom-java/src/main/java/io/intercom/api/CustomerFirstReply.java +++ /dev/null @@ -1,85 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(ignoreUnknown = true) -public class CustomerFirstReply extends TypedData { - - @JsonProperty - private String type; - - @JsonProperty - private String url; - - @JsonProperty("created_at") - private long createdAt; - - public CustomerFirstReply() { - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public long getCreatedAt() { - return createdAt; - } - - public void setCreatedAt(long createdAt) { - this.createdAt = createdAt; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + (int) (createdAt ^ (createdAt >>> 32)); - result = prime * result + ((type == null) ? 0 : type.hashCode()); - result = prime * result + ((url == null) ? 0 : url.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - CustomerFirstReply other = (CustomerFirstReply) obj; - if (createdAt != other.createdAt) - return false; - if (type == null) { - if (other.type != null) - return false; - } else if (!type.equals(other.type)) - return false; - if (url == null) { - if (other.url != null) - return false; - } else if (!url.equals(other.url)) - return false; - return true; - } - - - @Override - public String toString() { - return "CustomerFirstReply{" + "type='" + type + '\'' + ", url='" + url + '\'' + ", created_at='" + createdAt + '\'' + "} " + super.toString(); - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/DataResource.java b/intercom-java/src/main/java/io/intercom/api/DataResource.java deleted file mode 100644 index 88c49ef7..00000000 --- a/intercom-java/src/main/java/io/intercom/api/DataResource.java +++ /dev/null @@ -1,78 +0,0 @@ -package io.intercom.api; - -import com.google.common.base.Strings; -import com.google.common.collect.Maps; - -import java.net.URI; -import java.util.List; -import java.util.Map; - -abstract class DataResource { - - @SuppressWarnings("SameParameterValue") - public static T find(String id, String collectionPath, Class c) { - final HttpClient resource = new HttpClient(UriBuilder.newBuilder().path(collectionPath).path(id).build()); - return resource.get(c); - } - - public static T find(Map params, String collectionPath, Class c) { - final HttpClient resource = new HttpClient(UriBuilder.newBuilder().path(collectionPath).query(params).build()); - return resource.get(c); - } - - public static R create(T entity, String collectionPath, Class response) { - final HttpClient resource = new HttpClient(UriBuilder.newBuilder().path(collectionPath).build()); - return resource.post(response, entity); - } - - public static R create(T entity, List paths, Class response) { - final HttpClient resource = new HttpClient(UriBuilder.newBuilder().path(paths).build()); - return resource.post(response, entity); - } - - public static R update(T entity, String collectionPath, Class response) { - final HttpClient resource = new HttpClient(UriBuilder.newBuilder().path(collectionPath).build()); - return resource.post(response, entity); - } - - public static R post(T entity, URI path, Class response) { - final HttpClient resource = new HttpClient(path); - return resource.post(response, entity); - } - - public static R updatePut(T entity, URI collectionPath, Class response) { - final HttpClient resource = new HttpClient(collectionPath); - return resource.put(response, entity); - } - - @SuppressWarnings("SameParameterValue") - public static R update(T entity, String collectionPath, String id, Class response) { - final HttpClient resource = new HttpClient(UriBuilder.newBuilder().path(collectionPath).path(id).build()); - return resource.post(response, entity); - } - - public static T delete(String id, String collectionPath, Class c) { - final HttpClient resource = new HttpClient(UriBuilder.newBuilder().path(collectionPath).path(id).build()); - return resource.delete(c); - } - - public static T delete(Map params, String collectionPath, Class c) { - final HttpClient resource = new HttpClient(UriBuilder.newBuilder().path(collectionPath).query(params).build()); - return resource.delete(c); - } - - public static C list(Map params, String collectionPath, Class c) { - final HttpClient resource = new HttpClient(UriBuilder.newBuilder().path(collectionPath).query(params).build()); - return resource.get(c); - } - - public static C scroll(String scrollParam, String collectionPath, Class c) { - Map params = Maps.newHashMap(); - if (!Strings.isNullOrEmpty(scrollParam)) { - params.put("scroll_param", scrollParam); - } - final HttpClient resource = new HttpClient(UriBuilder.newBuilder().path(collectionPath).path("scroll").query(params).build()); - return resource.get(c); - } - -} diff --git a/intercom-java/src/main/java/io/intercom/api/Error.java b/intercom-java/src/main/java/io/intercom/api/Error.java deleted file mode 100644 index 10beabd2..00000000 --- a/intercom-java/src/main/java/io/intercom/api/Error.java +++ /dev/null @@ -1,77 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(ignoreUnknown = true) -public class Error extends TypedData { - - @SuppressWarnings("FieldCanBeLocal") - @JsonProperty("type") - private final String type = "error"; - - @JsonProperty("code") - private String code; - - @JsonProperty("message") - private String message; - - public Error() { - } - - public Error(String code, String message) { - this.code = code; - this.message = message; - } - - public String getType() { - return type; - } - - public String getCode() { - return code; - } - - public void setCode(String code) { - this.code = code; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - @Override - public int hashCode() { - int result = code != null ? code.hashCode() : 0; - result = 31 * result + (message != null ? message.hashCode() : 0); - return result; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Error error = (Error) o; - - if (code != null ? !code.equals(error.code) : error.code != null) return false; - //noinspection RedundantIfStatement - if (message != null ? !message.equals(error.message) : error.message != null) return false; - - return true; - } - - @Override - public String toString() { - return getType() + "{" + - "code='" + code + '\'' + - ", message='" + message + '\'' + - "} " + super.toString(); - } - -} diff --git a/intercom-java/src/main/java/io/intercom/api/ErrorCollection.java b/intercom-java/src/main/java/io/intercom/api/ErrorCollection.java deleted file mode 100644 index d9720516..00000000 --- a/intercom-java/src/main/java/io/intercom/api/ErrorCollection.java +++ /dev/null @@ -1,33 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.google.common.base.Preconditions; - -import java.util.List; - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(ignoreUnknown = true) -public final class ErrorCollection { - - @JsonProperty("errors") - private List errors; - - // for jackson - ErrorCollection() { - } - - public ErrorCollection(List errors) { - Preconditions.checkNotNull(errors, "cannot create an error collection with a null error list"); - Preconditions.checkArgument(errors.size() > 0, "cannot create an error collection with an empty error list"); - this.errors = errors; - } - - public List getErrors() { - return errors; - } - - public String getType() { - return "error.list"; - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/Event.java b/intercom-java/src/main/java/io/intercom/api/Event.java deleted file mode 100644 index 70227cb0..00000000 --- a/intercom-java/src/main/java/io/intercom/api/Event.java +++ /dev/null @@ -1,271 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Strings; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(JsonInclude.Include.NON_DEFAULT) -public class Event extends TypedData { - - private static final List BULK_METHODS = Lists.newArrayList("post"); - private static final ArrayList BULK_PATHS = Lists.newArrayListWithExpectedSize(2); - - static { - BULK_PATHS.add("bulk"); - BULK_PATHS.add("events"); - } - - public static void create(Event event) throws InvalidException, AuthorizationException { - - validateCreateEvent(event); - - if (event.getCreatedAt() == 0L) { - event.setCreatedAt(System.currentTimeMillis() / 1000); - } - DataResource.create(event, "events", Void.class); - } - - public static Job submit(List> items) - throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException { - return submit(items, null); - } - - public static Job submit(List> items, Job job) - throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException { - return Job.submit(validateJobItems(items), job, BULK_PATHS); - } - - public static JobItemCollection listJobErrorFeed(String jobID) - throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException { - return Job.listJobErrorFeed(jobID, Event.class); - } - - public static EventCollection list(Map params) throws InvalidException, AuthorizationException { - if ((!params.containsKey("email")) && (!params.containsKey("user_id")) && (!params.containsKey("intercom_user_id"))) { - throw new InvalidException("an event query must include an email, user_id or intercom_user_id parameter"); - } - return DataResource.list(params, "events", EventCollection.class); - } - - public static EventSummaryCollection listSummary(Map params) throws InvalidException, AuthorizationException { - if ((!params.containsKey("email")) && (!params.containsKey("user_id")) && (!params.containsKey("intercom_user_id"))) { - throw new InvalidException("an event query must include an email, user_id or intercom_user_id parameter"); - } - params.put("summary", "true"); - return DataResource.list(params, "events", EventSummaryCollection.class); - } - - @VisibleForTesting - static List> validateJobItems(List> items) { - final JobSupport jobSupport = new JobSupport(); - for (JobItem item : items) { - jobSupport.validateJobItem(item, BULK_METHODS); - validateCreateEvent(item.getData()); - } - - return items; - } - - private static final ErrorCollection INVALID_NAME = new ErrorCollection( - Lists.newArrayList( - new Error("invalid", "an event must supply an event name"))); - - private static final ErrorCollection INVALID_USER = new ErrorCollection( - Lists.newArrayList( - new Error("invalid", "an event must supply either an email or a user id"))); - - @VisibleForTesting - static void validateCreateEvent(Event event) { - if (Strings.isNullOrEmpty(event.getEventName())) { - throw new InvalidException(INVALID_NAME); - } - - if (Strings.isNullOrEmpty(event.getUserID()) - && Strings.isNullOrEmpty(event.getId()) - && Strings.isNullOrEmpty(event.getEmail())) { - throw new InvalidException(INVALID_USER); - } - } - - @SuppressWarnings("FieldCanBeLocal") - @JsonProperty("type") - private final String type = "event"; - - @JsonProperty("event_name") - private String eventName; - - @JsonProperty("created_at") - private long createdAt; - - @JsonProperty("email") - private String email; - - @JsonProperty("id") - private String id; - - @JsonProperty("user_id") - private String userID; - - @JsonProperty("intercom_user_id") - private String intercomUserID; - - @JsonProperty("metadata") - private Map metadata = Maps.newHashMap(); - - public Event() { - } - - public String getType() { - return type; - } - - public String getEventName() { - return eventName; - } - - public Event setEventName(String eventName) { - this.eventName = eventName; - return this; - } - - public long getCreatedAt() { - return createdAt; - } - - @SuppressWarnings("UnusedReturnValue") - public Event setCreatedAt(long createdAt) { - this.createdAt = createdAt; - return this; - } - - public String getEmail() { - return email; - } - - public Event setEmail(String email) { - this.email = email; - return this; - } - - public String getId() { - return id; - } - - public Event setId(String id) { - this.id = id; - return this; - } - - public String getUserID() { - return userID; - } - - public Event setUserID(String userID) { - this.userID = userID; - return this; - } - - public String getIntercomUserID() { - return intercomUserID ; - } - - public Event setIntercomUserID(String intercomUserID ) { - this.intercomUserID = intercomUserID ; - return this; - } - - public Event putMetadata(String name, String value) { - metadata.put(name, value); - return this; - } - - public Event putMetadata(String name, boolean value) { - metadata.put(name, value); - return this; - } - - public Event putMetadata(String name, int value) { - metadata.put(name, value); - return this; - } - - public Event putMetadata(String name, double value) { - metadata.put(name, value); - return this; - } - - public Event putMetadata(String name, long value) { - metadata.put(name, value); - return this; - } - - public Event putMetadata(String name, float value) { - metadata.put(name, value); - return this; - } - - public Map getMetadata() { - return metadata; - } - - public Event setMetadata(Map metadata) { - this.metadata = metadata; - return this; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Event event = (Event) o; - - if (createdAt != event.createdAt) return false; - if (email != null ? !email.equals(event.email) : event.email != null) return false; - if (eventName != null ? !eventName.equals(event.eventName) : event.eventName != null) return false; - if (metadata != null ? !metadata.equals(event.metadata) : event.metadata != null) return false; - if (!type.equals(event.type)) return false; - //noinspection RedundantIfStatement - if (userID != null ? !userID.equals(event.userID) : event.userID != null) return false; - if (id != null ? !id.equals(event.id) : event.id != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = type.hashCode(); - result = 31 * result + (eventName != null ? eventName.hashCode() : 0); - result = 31 * result + (int) (createdAt ^ (createdAt >>> 32)); - result = 31 * result + (email != null ? email.hashCode() : 0); - result = 31 * result + (userID != null ? userID.hashCode() : 0); - result = 31 * result + (id != null ? id.hashCode() : 0); - result = 31 * result + (metadata != null ? metadata.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "Event{" + - "type='" + type + '\'' + - ", eventName='" + eventName + '\'' + - ", createdAt=" + createdAt + - ", email='" + email + '\'' + - ", id='" + id + '\'' + - ", userID='" + userID + '\'' + - ", metadata=" + metadata + - "} " + super.toString(); - } -} - - diff --git a/intercom-java/src/main/java/io/intercom/api/EventCollection.java b/intercom-java/src/main/java/io/intercom/api/EventCollection.java deleted file mode 100644 index 70a74fba..00000000 --- a/intercom-java/src/main/java/io/intercom/api/EventCollection.java +++ /dev/null @@ -1,32 +0,0 @@ -package io.intercom.api; - -import java.util.Iterator; -import java.util.List; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(ignoreUnknown = true) -public class EventCollection extends TypedDataCollection { - - public EventCollection() { - } - - public EventCollection(List events) { - this(); - this.page = events; - } - - @SuppressWarnings("EmptyMethod") - @JsonProperty("events") - @Override - public List getPage() { - return super.getPage(); - } - - @Override - public EventCollection nextPage() { - return fetchNextPage(EventCollection.class); - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/EventSummary.java b/intercom-java/src/main/java/io/intercom/api/EventSummary.java deleted file mode 100644 index 81892755..00000000 --- a/intercom-java/src/main/java/io/intercom/api/EventSummary.java +++ /dev/null @@ -1,101 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(JsonInclude.Include.NON_DEFAULT) -public class EventSummary { - - @JsonProperty("name") - private String name; - - @JsonProperty("first") - private String first; - - @JsonProperty("last") - private String last; - - @JsonProperty("count") - private int count; - - @JsonProperty("description") - private String description; - - public EventSummary() { - } - - public String getName() { - return name; - } - - public String getFirstOccurredAtString() { - return first; - } - - public Date getFirstOccurredAt() throws ParseException { - return stringToDate(first); - } - - public String getLastOccurredAtString() { - return last; - } - - public Date getLastOccurredAt() throws ParseException { - return stringToDate(last); - } - - public int getCount() { - return count; - } - - public String getDescription() { - return description; - } - - private Date stringToDate(String dateString) throws ParseException { - return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSX").parse(dateString); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - EventSummary eventSummary = (EventSummary) o; - - if (name != null ? !name.equals(eventSummary.name) : eventSummary.name != null) return false; - if (first != null ? !first.equals(eventSummary.first) : eventSummary.first != null) return false; - if (last != null ? !last.equals(eventSummary.last) : eventSummary.last != null) return false; - if (count != eventSummary.count) return false; - if (description != null ? !description.equals(eventSummary.description) : eventSummary.description != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = (name!= null ? name.hashCode() : 0); - result = 31 * result + (description != null ? description.hashCode() : 0); - result = 31 * result + (first != null ? first.hashCode() : 0); - result = 31 * result + (last != null ? last.hashCode() : 0); - result = 31 * result + count; - return result; - } - @Override - public String toString() { - return "EventSummaryCollection{" + - "name='" + name+ '\'' + - ", count=" + count + - ", description='" + description + '\'' + - ", first='" + first + '\'' + - ", last='" + last + '\'' + - "} " + super.toString(); - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/EventSummaryCollection.java b/intercom-java/src/main/java/io/intercom/api/EventSummaryCollection.java deleted file mode 100644 index 2e17903e..00000000 --- a/intercom-java/src/main/java/io/intercom/api/EventSummaryCollection.java +++ /dev/null @@ -1,88 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(JsonInclude.Include.NON_DEFAULT) -public class EventSummaryCollection extends TypedData { - - @JsonProperty("type") - private final String type = "event.summary"; - - @JsonProperty("email") - private String email; - - @JsonProperty("user_id") - private String userID; - - @JsonProperty("intercom_user_id") - private String intercomUserID; - - @JsonProperty("events") - private List eventSummaries; - - public EventSummaryCollection() { - } - - public String getType() { - return type; - } - - public String getEmail() { - return email; - } - - public String getUserID() { - return userID; - } - - public String getIntercomUserID() { - return intercomUserID ; - } - - public List getEventSummaries() { - return eventSummaries; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - EventSummaryCollection eventSummaryCollection = (EventSummaryCollection) o; - - if (email != null ? !email.equals(eventSummaryCollection.email) : eventSummaryCollection.email != null) return false; - if (userID != null ? !userID.equals(eventSummaryCollection.userID) : eventSummaryCollection.userID != null) return false; - if (intercomUserID!= null ? !intercomUserID.equals(eventSummaryCollection.intercomUserID) : eventSummaryCollection.intercomUserID != null) return false; - if (eventSummaries!= null ? !eventSummaries.equals(eventSummaryCollection.eventSummaries) : eventSummaryCollection.eventSummaries != null) return false; - if (!type.equals(eventSummaryCollection.type)) return false; - - return true; - } - - @Override - public int hashCode() { - int result = type.hashCode(); - result = 31 * result + (email != null ? email.hashCode() : 0); - result = 31 * result + (userID != null ? userID.hashCode() : 0); - result = 31 * result + (intercomUserID != null ? intercomUserID.hashCode() : 0); - result = 31 * result + (eventSummaries != null ? eventSummaries.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "Event{" + - "type='" + type + '\'' + - ", email='" + email + '\'' + - ", userID='" + userID + '\'' + - ", intercomUserID='" + intercomUserID + '\'' + - ", eventSummaries=" + eventSummaries + - "} " + super.toString(); - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/HttpClient.java b/intercom-java/src/main/java/io/intercom/api/HttpClient.java deleted file mode 100644 index 99056439..00000000 --- a/intercom-java/src/main/java/io/intercom/api/HttpClient.java +++ /dev/null @@ -1,268 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; -import com.google.common.io.CharStreams; -import com.google.common.primitives.Ints; -import com.google.common.primitives.Longs; - -import org.apache.commons.codec.binary.Base64; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.net.HttpURLConnection; -import java.net.URI; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.ThreadLocalRandom; - -class HttpClient { - - private static final Logger logger = LoggerFactory.getLogger("intercom-java"); - - private static final String CLIENT_AGENT_DETAILS = clientAgentDetails(); - - private static final String USER_AGENT = Intercom.USER_AGENT; - - private static final String UTF_8 = "UTF-8"; - - private static final String APPLICATION_JSON = "application/json"; - - public static final String RATE_LIMIT_HEADER = "X-RateLimit-Limit"; - public static final String RATE_LIMIT_REMAINING_HEADER = "X-RateLimit-Remaining"; - public static final String RATE_LIMIT_RESET_HEADER = "X-RateLimit-Reset"; - - private static String clientAgentDetails() { - final HashMap map = Maps.newHashMap(); - final ArrayList propKeys = Lists.newArrayList( - "os.arch", "os.name", "os.version", - "user.language", "user.timezone", - "java.class.version", "java.runtime.version", "java.version", - "java.vm.name", "java.vm.vendor", "java.vm.version"); - for (String propKey : propKeys) { - map.put(propKey, System.getProperty(propKey)); - } - final ByteArrayOutputStream baos = new ByteArrayOutputStream(); - try { - MapperSupport.objectMapper().disable(SerializationFeature.INDENT_OUTPUT).writeValue(baos, map); - } catch (IOException e) { - logger.warn(String.format("could not serialize client agent details [%s]", e.getMessage()), e); - } - return baos.toString(); - } - - private final ObjectMapper objectMapper; - - private final URI uri; - - private final Map headers; - - private final HttpConnectorSupplier connection = Intercom.getHttpConnectorSupplier(); - - public HttpClient(URI uri) { - this(uri, Maps.newHashMap()); - } - - private HttpClient(URI uri, Map headers) { - this.uri = uri; - this.headers = headers; - this.objectMapper = MapperSupport.objectMapper(); - } - - public T get(Class reqres) throws IntercomException { - return get(getJavaType(reqres)); - } - - T get(JavaType responseType) throws IntercomException { - return executeHttpMethod("GET", null, responseType); - } - - public T delete(Class reqres) { - return executeHttpMethod("DELETE", null, getJavaType(reqres)); - } - - public T put(Class reqres, E entity) { - headers.put("Content-Type", APPLICATION_JSON); - return executeHttpMethod("PUT", (E) entity, getJavaType(reqres)); - } - - public T post(Class reqres, E entity) { - headers.put("Content-Type", APPLICATION_JSON); - return executeHttpMethod("POST", entity, getJavaType(reqres)); - } - - private T executeHttpMethod(String method, E entity, JavaType responseType) { - HttpURLConnection conn = null; - try { - conn = initializeConnection(uri, method); - if(entity != null) { - prepareRequestEntity(entity, conn); - } - return runRequest(uri, responseType, conn); - } catch (IOException e) { - return throwLocalException(e); - } finally { - IOUtils.disconnectQuietly(conn); - } - } - - private JavaType getJavaType(Class reqres) { - return objectMapper.getTypeFactory().constructType(reqres); - } - - // trick java with a dummy return - private T throwLocalException(IOException e) { - throw new IntercomException(String.format("Local exception calling [%s]. Check connectivity and settings. [%s]", uri.toASCIIString(), e.getMessage()), e); - } - - private void prepareRequestEntity(Object entity, HttpURLConnection conn) throws IOException { - conn.setDoOutput(true); - OutputStream stream = null; - try { - stream = conn.getOutputStream(); - if (logger.isDebugEnabled()) { - logger.info(String.format("api server request --\n%s\n-- ", objectMapper.writeValueAsString(entity))); - } - objectMapper.writeValue(stream, entity); - } finally { - IOUtils.closeQuietly(stream); - } - } - - private HttpURLConnection initializeConnection(URI uri, String method) throws IOException { - HttpURLConnection conn = connection.connect(uri); - conn.setRequestMethod(method); - conn = prepareConnection(conn); - conn = applyHeaders(conn); - return conn; - } - - private T runRequest(URI uri, JavaType javaType, HttpURLConnection conn) throws IOException { - conn.connect(); - final int responseCode = conn.getResponseCode(); - if (responseCode >= 200 && responseCode < 300) { - return handleSuccess(javaType, conn, responseCode); - } else { - return handleError(uri, conn, responseCode); - } - } - - private T handleError(URI uri, HttpURLConnection conn, int responseCode) throws IOException { - ErrorCollection errors; - try { - errors = objectMapper.readValue(conn.getErrorStream(), ErrorCollection.class); - } catch (IOException e) { - errors = createUnprocessableErrorResponse(e); - } - if (logger.isDebugEnabled()) { - logger.debug("error json follows --\n{}\n-- ", objectMapper.writeValueAsString(errors)); - } - return throwException(responseCode, errors, conn); - } - - private T handleSuccess(JavaType javaType, HttpURLConnection conn, int responseCode) throws IOException { - if (shouldSkipResponseEntity(javaType, conn, responseCode)) { - return null; - } else { - return readEntity(conn, responseCode, javaType); - } - } - - private boolean shouldSkipResponseEntity(JavaType javaType, HttpURLConnection conn, int responseCode) { - return responseCode == 204 || Void.class.equals(javaType.getRawClass()); - } - - private T readEntity(HttpURLConnection conn, int responseCode, JavaType javaType) throws IOException { - final InputStream entityStream = conn.getInputStream(); - try { - final String text = CharStreams.toString(new InputStreamReader(entityStream)); - if (logger.isDebugEnabled()) { - logger.debug("api server response status[{}] --\n{}\n-- ", responseCode, text); - } - if (text.isEmpty()) return null; - return objectMapper.readValue(text, javaType); - } finally { - IOUtils.closeQuietly(entityStream); - } - } - - private T throwException(int responseCode, ErrorCollection errors, HttpURLConnection conn) { - // bind some well known response codes to exceptions - if (responseCode == 403 || responseCode == 401) { - throw new AuthorizationException(errors); - } else if (responseCode == 429) { - throw new RateLimitException(errors, Ints.tryParse(conn.getHeaderField(RATE_LIMIT_HEADER)), - Ints.tryParse(conn.getHeaderField(RATE_LIMIT_REMAINING_HEADER)), - Longs.tryParse(conn.getHeaderField(RATE_LIMIT_RESET_HEADER))); - } else if (responseCode == 404) { - throw new NotFoundException(errors); - } else if (responseCode == 422) { - throw new InvalidException(errors); - } else if (responseCode == 400 || responseCode == 405 || responseCode == 406) { - throw new ClientException(errors); - } else if (responseCode == 500 || responseCode == 503) { - throw new ServerException(errors); - } else { - throw new IntercomException(errors); - } - } - - private HttpURLConnection applyHeaders(HttpURLConnection conn) { - for (Map.Entry entry : createHeaders().entrySet()) { - conn.setRequestProperty(entry.getKey(), entry.getValue()); - } - for (Map.Entry entry : createAuthorizationHeaders().entrySet()) { - conn.setRequestProperty(entry.getKey(), entry.getValue()); - } - return conn; - } - - // todo: expose this config - private HttpURLConnection prepareConnection(HttpURLConnection conn) { - conn.setConnectTimeout(Intercom.getConnectionTimeout()); - conn.setReadTimeout(Intercom.getRequestTimeout()); - conn.setUseCaches(Intercom.isRequestUsingCaches()); - return conn; - } - - private Map createAuthorizationHeaders() { - headers.put("Authorization", "Basic " + generateAuthString(Intercom.getToken(),"")); - return headers; - } - - private String generateAuthString(String username, String password) { - return Base64.encodeBase64String((username + ":" + password).getBytes()); - } - - private Map createHeaders() { - headers.put("User-Agent", USER_AGENT); - headers.put("X-Client-Platform-Details", CLIENT_AGENT_DETAILS); - headers.put("Accept-Charset", UTF_8); - headers.put("Accept", APPLICATION_JSON); - return headers; - } - - private ErrorCollection createUnprocessableErrorResponse(IOException e) { - ErrorCollection errors; - final long grepCode = getGrepCode(); - final String msg = String.format("could not parse error response: [%s]", e.getLocalizedMessage()); - logger.error(String.format("[%016x] %s", grepCode, msg), e); - Error err = new Error("unprocessable_entity", String.format("%s logged with code [%016x]", msg, grepCode)); - errors = new ErrorCollection(Lists.newArrayList(err)); - return errors; - } - - private long getGrepCode() { - return ThreadLocalRandom.current().nextLong(); - } - -} diff --git a/intercom-java/src/main/java/io/intercom/api/HttpConnectorSupplier.java b/intercom-java/src/main/java/io/intercom/api/HttpConnectorSupplier.java deleted file mode 100644 index de02df36..00000000 --- a/intercom-java/src/main/java/io/intercom/api/HttpConnectorSupplier.java +++ /dev/null @@ -1,16 +0,0 @@ -package io.intercom.api; - -import java.io.IOException; -import java.net.HttpURLConnection; -import java.net.URI; - -public interface HttpConnectorSupplier { - - HttpURLConnection connect(URI uri) throws IOException; - - HttpConnectorSupplier defaultSupplier = new HttpConnectorSupplier() { - public HttpURLConnection connect(URI uri) throws IOException { - return (HttpURLConnection) uri.toURL().openConnection(); - } - }; -} diff --git a/intercom-java/src/main/java/io/intercom/api/IOUtils.java b/intercom-java/src/main/java/io/intercom/api/IOUtils.java deleted file mode 100644 index b6f5966d..00000000 --- a/intercom-java/src/main/java/io/intercom/api/IOUtils.java +++ /dev/null @@ -1,47 +0,0 @@ -package io.intercom.api; - -import org.slf4j.LoggerFactory; - -import java.io.Closeable; -import java.net.HttpURLConnection; - -class IOUtils { - - private static final org.slf4j.Logger logger = LoggerFactory.getLogger("intercom-java"); - - /** - * Close a HttpURLConnection, ignores checked Exceptions and nulls, - * but rethrows RuntimeExceptions. - * - * @param connection the connection to disconnect - */ - public static void disconnectQuietly(HttpURLConnection connection) { - if (connection != null) { - try { - connection.disconnect(); - } catch (RuntimeException rethrow) { - throw rethrow; - } catch (Exception e) { - logger.warn(e.getMessage()); - } - } - } - - /** - * Close a stream, ignores checked Exceptions and nulls, - * but rethrows RuntimeExceptions. - * - * @param stream the object to close - */ - public static void closeQuietly(Closeable stream) { - if (stream != null) { - try { - stream.close(); - } catch (RuntimeException rethrow) { - throw rethrow; - } catch (Exception e) { - logger.warn(e.getMessage()); - } - } - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/Intercom.java b/intercom-java/src/main/java/io/intercom/api/Intercom.java deleted file mode 100644 index 22b81c1a..00000000 --- a/intercom-java/src/main/java/io/intercom/api/Intercom.java +++ /dev/null @@ -1,115 +0,0 @@ -package io.intercom.api; - -import java.net.URI; - -public class Intercom { - - static class Context { - private volatile String token; - private volatile int connectionTimeout = 3 * 1000; - private volatile int requestTimeout = 60 * 1000; - private volatile boolean requestUsingCaches = false; - } - - private static final URI API_BASE_URI = URI.create("https://api.intercom.io/"); - - private static volatile boolean useThreadLocal = false; - - private static volatile URI apiBaseURI = API_BASE_URI; - - private static final String VERSION = "2.8.2"; - - public static final String USER_AGENT = "intercom-java/" + Intercom.VERSION; - - private static ThreadLocal threadContext = newThreadLocalContext(); - - private static final Context staticContext = new Context(); - - private static Context getContext() { - if (useThreadLocal) { - return threadContext.get(); - } - return staticContext; - } - - private static volatile HttpConnectorSupplier httpConnectorSupplier = HttpConnectorSupplier.defaultSupplier; - - public static long currentTimestamp() { - return System.currentTimeMillis()/1000; - } - - public static int getConnectionTimeout() { - return getContext().connectionTimeout; - } - - @SuppressWarnings("UnusedDeclaration") - public static void setConnectionTimeout(int connectionTimeout) { - getContext().connectionTimeout = connectionTimeout; - } - - public static int getRequestTimeout() { - return getContext().requestTimeout; - } - - @SuppressWarnings("UnusedDeclaration") - public static void setRequestTimeout(int requestTimeout) { - getContext().requestTimeout = requestTimeout; - } - - public static boolean isRequestUsingCaches() { - return getContext().requestUsingCaches; - } - - public static void setRequestUsingCaches(boolean requestUsingCaches) { - getContext().requestUsingCaches = requestUsingCaches; - } - - public static HttpConnectorSupplier getHttpConnectorSupplier() { - return httpConnectorSupplier; - } - - public static void setHttpConnectorSupplier(HttpConnectorSupplier supplier) { - Intercom.httpConnectorSupplier = supplier; - } - - public static void setToken(String token) { - Context context = getContext(); - context.token = token; - } - - public static URI getApiBaseURI() { - return Intercom.apiBaseURI; - } - - public static void setApiBaseURI(URI apiBaseURI) { - Intercom.apiBaseURI = apiBaseURI; - } - - public static String getToken() { - return getContext().token; - } - - public static boolean usesThreadLocal() { - return Intercom.useThreadLocal; - } - - public static void setUseThreadLocal(boolean useThreadLocal) { - Intercom.useThreadLocal = useThreadLocal; - } - - public static void clearThreadLocalContext() { - threadContext.remove(); - } - - public static void clearThreadLocalContexts() { - threadContext = newThreadLocalContext(); - } - - private static ThreadLocal newThreadLocalContext() { - return new ThreadLocal() { - @Override protected Context initialValue() { - return new Context(); - } - }; - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/IntercomException.java b/intercom-java/src/main/java/io/intercom/api/IntercomException.java deleted file mode 100644 index b32441fc..00000000 --- a/intercom-java/src/main/java/io/intercom/api/IntercomException.java +++ /dev/null @@ -1,48 +0,0 @@ -package io.intercom.api; - -public class IntercomException extends RuntimeException { - - private static final long serialVersionUID = -2723350106062183796L; - - private ErrorCollection errorCollection; - - @SuppressWarnings("WeakerAccess") - public IntercomException(String message) { - super(message); - } - - public IntercomException(String message, Throwable cause) { - super(message, cause); - } - - public IntercomException(ErrorCollection errorCollection) { - this(getMessage(errorCollection)); - this.errorCollection = errorCollection; - } - - public static String getMessage(ErrorCollection errorCollection) { - String message = "Could not read error message from server"; - if(errorCollection!=null - && errorCollection.getErrors() != null - && errorCollection.getErrors().size() > 0 - && errorCollection.getErrors().get(0) != null - && errorCollection.getErrors().get(0).getMessage() != null){ - message = errorCollection.getErrors().get(0).getMessage(); - } - return message; - } - - @SuppressWarnings("WeakerAccess") - public IntercomException(ErrorCollection errorCollection, Throwable cause) { - this(getMessage(errorCollection), cause); - this.errorCollection = errorCollection; - } - - public ErrorCollection getErrorCollection() { - return errorCollection; - } - - public Error getFirstError() { - return errorCollection.getErrors().get(0); - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/InvalidException.java b/intercom-java/src/main/java/io/intercom/api/InvalidException.java deleted file mode 100644 index 6a4381bd..00000000 --- a/intercom-java/src/main/java/io/intercom/api/InvalidException.java +++ /dev/null @@ -1,22 +0,0 @@ -package io.intercom.api; - -public class InvalidException extends IntercomException { - - private static final long serialVersionUID = -2111295679006526646L; - - public InvalidException(String message) { - super(message); - } - - public InvalidException(String message, Throwable cause) { - super(message, cause); - } - - public InvalidException(ErrorCollection errorCollection) { - super(errorCollection); - } - - public InvalidException(ErrorCollection errorCollection, Throwable cause) { - super(errorCollection, cause); - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/Job.java b/intercom-java/src/main/java/io/intercom/api/Job.java deleted file mode 100644 index ab7f1756..00000000 --- a/intercom-java/src/main/java/io/intercom/api/Job.java +++ /dev/null @@ -1,216 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.JavaType; -import com.google.common.collect.Maps; - -import java.net.URI; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(JsonInclude.Include.NON_DEFAULT) -public class Job extends TypedData { - - private static final HashMap SENTINEL = Maps.newHashMap(); - - public static Job find(String id) - throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException { - return find(id, SENTINEL); - } - - public static Job find(String id, Map params) - throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException { - return new HttpClient( - UriBuilder.newBuilder().path("jobs").path(id).query(params).build() - ).get(Job.class); - } - - public static Job update(Job job) - throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException { - return DataResource.post( - job, - UriBuilder.newBuilder().path("jobs").path(job.getID()).build(), - Job.class); - } - - static Job submit(List> items, List bulkPaths) - throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException { - return submit(items, null, bulkPaths); - } - - static Job submit(List> items, Job job, List bulkPaths) - throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException { - return DataResource.create(new JobItemRequest(items, job), bulkPaths, Job.class); - } - - static JobItemCollection listJobErrorFeed(String jobID, Class c) - throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException { - final URI feedURI = UriBuilder.newBuilder() - .path("jobs") - .path(jobID) - .path("error") - .build(); - final HttpClient resource = new HttpClient(feedURI); - final TypeReference> typeReference = - new TypeReference>() { - }; - - final JavaType type = MapperSupport - .objectMapper() - .getTypeFactory() - .constructParametricType(JobItemCollection.class, c); - return resource.get(type); - } - - - @JsonProperty("type") - private final String type = "job"; - - @JsonProperty("id") - private String id; - - @JsonProperty("app_id") - private String appID; - - @JsonProperty("created_at") - private long createdAt; - - @JsonProperty("updated_at") - private long updatedAt; - - @JsonProperty("completed_at") - private long completedAt; - - @JsonProperty("closing_at") - private long closingAt; - - @JsonProperty("name") - private String name; - - @JsonProperty("state") - private String state; - - @JsonProperty("tasks") - private List tasks; - - @JsonProperty("links") - private Map links; - - public Job() { - } - - public String getType() { - return type; - } - - public String getID() { - return id; - } - - public Job setID(String id) { - this.id = id; - return this; - } - - public long getCreatedAt() { - return createdAt; - } - - public long getUpdatedAt() { - return updatedAt; - } - - public long getCompletedAt() { - return completedAt; - } - - public String getName() { - return name; - } - - public Job setName(String name) { - this.name = name; - return this; - } - - public String getState() { - return state; - } - - public String getAppID() { - return appID; - } - - public Map getLinks() { - return links; - } - - public long getClosingAt() { - return closingAt; - } - - public Job setClosingAt(long closingAt) { - this.closingAt = closingAt; - return this; - } - - public List getTasks() { - return tasks; - } - - @Override - public String toString() { - return "Job{" + - "type='" + type + '\'' + - ", id='" + id + '\'' + - ", appID='" + appID + '\'' + - ", createdAt=" + createdAt + - ", updatedAt=" + updatedAt + - ", completedAt=" + completedAt + - ", name='" + name + '\'' + - ", state='" + state + '\'' + - ", links=" + links + - "} " + super.toString(); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Job job = (Job) o; - - if (createdAt != job.createdAt) return false; - if (updatedAt != job.updatedAt) return false; - if (completedAt != job.completedAt) return false; - //noinspection ConstantConditions - if (type != null ? !type.equals(job.type) : job.type != null) return false; - if (id != null ? !id.equals(job.id) : job.id != null) return false; - if (appID != null ? !appID.equals(job.appID) : job.appID != null) return false; - if (name != null ? !name.equals(job.name) : job.name != null) return false; - //noinspection SimplifiableIfStatement - if (state != null ? !state.equals(job.state) : job.state != null) return false; - return !(links != null ? !links.equals(job.links) : job.links != null); - - } - - @Override - public int hashCode() { - @SuppressWarnings("ConstantConditions") int result = type != null ? type.hashCode() : 0; - result = 31 * result + (id != null ? id.hashCode() : 0); - result = 31 * result + (appID != null ? appID.hashCode() : 0); - result = 31 * result + (int) (createdAt ^ (createdAt >>> 32)); - result = 31 * result + (int) (updatedAt ^ (updatedAt >>> 32)); - result = 31 * result + (int) (completedAt ^ (completedAt >>> 32)); - result = 31 * result + (name != null ? name.hashCode() : 0); - result = 31 * result + (state != null ? state.hashCode() : 0); - result = 31 * result + (links != null ? links.hashCode() : 0); - return result; - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/JobItem.java b/intercom-java/src/main/java/io/intercom/api/JobItem.java deleted file mode 100644 index f3bc47a0..00000000 --- a/intercom-java/src/main/java/io/intercom/api/JobItem.java +++ /dev/null @@ -1,134 +0,0 @@ -package io.intercom.api; - - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(JsonInclude.Include.NON_DEFAULT) -public class JobItem extends TypedData { - - @JsonProperty("type") - private final String type = "job_item"; - - @JsonProperty("id") - private String id; - - @JsonProperty("updated_at") - private long updatedAt; - - @JsonProperty("method") - private String method; - - @JsonProperty("data_type") - private String dataType; - - @JsonProperty("error") - private Error error; - - @JsonProperty("data") - private T data; - - public JobItem() { - } - - public JobItem(String method, T data) { - this(method, data, null); - } - - JobItem(String method, T data, String dataType) { - Conditions.checkNotNull(method, "item method must be supplied"); - Conditions.checkNotNull(data, "item data must be supplied"); - this.method = method; - this.data = data; - this.dataType = dataType; - if (dataType == null) { - this.dataType = data.getType(); - } - Conditions.checkNotNull(data, "item dataType must be supplied"); - } - - public String getType() { - return type; - } - - public String getID() { - return id; - } - - public long getUpdatedAt() { - return updatedAt; - } - - public String getMethod() { - return method; - } - - public JobItem setMethod(String method) { - this.method = method; - return this; - } - - public Error getError() { - return error; - } - - public T getData() { - return data; - } - - public JobItem setData(T data) { - this.data = data; - return this; - } - - public String getDataType() { - return dataType; - } - - @Override - public String toString() { - return "JobItem{" + - "type='" + type + '\'' + - ", id='" + id + '\'' + - ", updatedAt=" + updatedAt + - ", method='" + method + '\'' + - ", dataType='" + dataType + '\'' + - ", error=" + error + - ", data=" + data + - "} " + super.toString(); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - JobItem jobItem = (JobItem) o; - - if (updatedAt != jobItem.updatedAt) return false; - //noinspection ConstantConditions - if (type != null ? !type.equals(jobItem.type) : jobItem.type != null) return false; - if (id != null ? !id.equals(jobItem.id) : jobItem.id != null) return false; - if (method != null ? !method.equals(jobItem.method) : jobItem.method != null) return false; - if (dataType != null ? !dataType.equals(jobItem.dataType) : jobItem.dataType != null) return false; - //noinspection SimplifiableIfStatement - if (error != null ? !error.equals(jobItem.error) : jobItem.error != null) return false; - return !(data != null ? !data.equals(jobItem.data) : jobItem.data != null); - - } - - @Override - public int hashCode() { - @SuppressWarnings("ConstantConditions") int result = type != null ? type.hashCode() : 0; - result = 31 * result + (id != null ? id.hashCode() : 0); - result = 31 * result + (int) (updatedAt ^ (updatedAt >>> 32)); - result = 31 * result + (method != null ? method.hashCode() : 0); - result = 31 * result + (dataType != null ? dataType.hashCode() : 0); - result = 31 * result + (error != null ? error.hashCode() : 0); - result = 31 * result + (data != null ? data.hashCode() : 0); - return result; - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/JobItemCollection.java b/intercom-java/src/main/java/io/intercom/api/JobItemCollection.java deleted file mode 100644 index 0cbd7641..00000000 --- a/intercom-java/src/main/java/io/intercom/api/JobItemCollection.java +++ /dev/null @@ -1,31 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(ignoreUnknown = true) -public class JobItemCollection extends TypedDataCollection> { - - public JobItemCollection() { - } - - public JobItemCollection(List> items) { - this(); - this.page = items; - } - - @SuppressWarnings("EmptyMethod") - @JsonProperty("items") - @Override - public List> getPage() { - return super.getPage(); - } - - @Override - public JobItemCollection nextPage() { - return fetchNextPage(JobItemCollection.class); - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/JobItemRequest.java b/intercom-java/src/main/java/io/intercom/api/JobItemRequest.java deleted file mode 100644 index 47a540d6..00000000 --- a/intercom-java/src/main/java/io/intercom/api/JobItemRequest.java +++ /dev/null @@ -1,38 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(JsonInclude.Include.NON_EMPTY) -class JobItemRequest extends TypedData { - - @JsonProperty("items") - private List> items; - - @JsonProperty("job") - @JsonInclude(JsonInclude.Include.NON_NULL) - private Job job; - - public JobItemRequest(List> items, Job job) { - this.items = items; - this.job = job; - } - - public List> getItems() { - return items; - } - - public Job getJob() { - return job; - } - - @Override - String getType() { - return "job_item.list"; - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/JobSupport.java b/intercom-java/src/main/java/io/intercom/api/JobSupport.java deleted file mode 100644 index ac5a7731..00000000 --- a/intercom-java/src/main/java/io/intercom/api/JobSupport.java +++ /dev/null @@ -1,24 +0,0 @@ -package io.intercom.api; - -import com.google.common.base.Joiner; -import com.google.common.collect.Lists; - -import java.util.List; - -class JobSupport { - - - public void validateJobItem(JobItem item, List methods) { - if (!methods.contains(item.getMethod())) { - final String message = String.format( - "job method [%s] not allowed, must be one of " - + Joiner.on(", ").join(methods), item.getMethod() - ); - throw new InvalidException( - new ErrorCollection( - Lists.newArrayList( - new Error("invalid", message)))); - } - } - -} diff --git a/intercom-java/src/main/java/io/intercom/api/JobTask.java b/intercom-java/src/main/java/io/intercom/api/JobTask.java deleted file mode 100644 index ee4896b9..00000000 --- a/intercom-java/src/main/java/io/intercom/api/JobTask.java +++ /dev/null @@ -1,47 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(JsonInclude.Include.NON_DEFAULT) -public class JobTask extends TypedData { - - @JsonProperty("type") - private final String type = "job_task"; - - @JsonProperty("id") - private String id; - - @JsonProperty("completed_at") - private Long completedAt; - - @JsonProperty("created_at") - private long createdAt; - - @JsonProperty("item_count") - private long itemCount; - - @Override - public String getType() { - return type; - } - - public String getID() { - return id; - } - - public Long getCompletedAt() { - return completedAt; - } - - public long getCreatedAt() { - return createdAt; - } - - public long getItemCount() { - return itemCount; - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/LocationData.java b/intercom-java/src/main/java/io/intercom/api/LocationData.java deleted file mode 100644 index 48cb7806..00000000 --- a/intercom-java/src/main/java/io/intercom/api/LocationData.java +++ /dev/null @@ -1,136 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(ignoreUnknown = true) -public class LocationData extends TypedData { - - @JsonProperty("type") - private final String type = "location_data"; - - @JsonProperty("city_name") - private String city_Name; - - @JsonProperty("continent_code") - private String continentCode; - - @JsonProperty("country_code") - private String countryCode; - - @JsonProperty("country_name") - private String countryName; - - @JsonProperty("latitude") - private float latitude; - - @JsonProperty("longitude") - private float longitude; - - @JsonProperty("postal_code") - private String postalCode; - - @JsonProperty("region_name") - private String regionName; - - @JsonProperty("timezone") - private String timezone; - - public LocationData() { - } - - public String getType() { - return type; - } - - public String getCity_Name() { - return city_Name; - } - - public String getContinentCode() { - return continentCode; - } - - public String getCountryCode() { - return countryCode; - } - - public String getCountryName() { - return countryName; - } - - public float getLatitude() { - return latitude; - } - - public float getLongitude() { - return longitude; - } - - public String getPostalCode() { - return postalCode; - } - - public String getRegionName() { - return regionName; - } - - public String getTimezone() { - return timezone; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - LocationData that = (LocationData) o; - - if (Float.compare(that.latitude, latitude) != 0) return false; - if (Float.compare(that.longitude, longitude) != 0) return false; - if (city_Name != null ? !city_Name.equals(that.city_Name) : that.city_Name != null) return false; - if (continentCode != null ? !continentCode.equals(that.continentCode) : that.continentCode != null) - return false; - if (countryCode != null ? !countryCode.equals(that.countryCode) : that.countryCode != null) return false; - if (countryName != null ? !countryName.equals(that.countryName) : that.countryName != null) return false; - if (postalCode != null ? !postalCode.equals(that.postalCode) : that.postalCode != null) return false; - if (regionName != null ? !regionName.equals(that.regionName) : that.regionName != null) return false; - if (timezone != null ? !timezone.equals(that.timezone) : that.timezone != null) return false; - //noinspection RedundantIfStatement - if (!type.equals(that.type)) return false; - - return true; - } - - @Override - public int hashCode() { - int result = type.hashCode(); - result = 31 * result + (city_Name != null ? city_Name.hashCode() : 0); - result = 31 * result + (continentCode != null ? continentCode.hashCode() : 0); - result = 31 * result + (countryCode != null ? countryCode.hashCode() : 0); - result = 31 * result + (countryName != null ? countryName.hashCode() : 0); - result = 31 * result + (latitude != +0.0f ? Float.floatToIntBits(latitude) : 0); - result = 31 * result + (longitude != +0.0f ? Float.floatToIntBits(longitude) : 0); - result = 31 * result + (postalCode != null ? postalCode.hashCode() : 0); - result = 31 * result + (regionName != null ? regionName.hashCode() : 0); - result = 31 * result + (timezone != null ? timezone.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "LocationData{" + - "type='" + type + '\'' + - ", city_Name='" + city_Name + '\'' + - ", continentCode='" + continentCode + '\'' + - ", countryCode='" + countryCode + '\'' + - ", countryName='" + countryName + '\'' + - ", latitude=" + latitude + - ", longitude=" + longitude + - ", postalCode='" + postalCode + '\'' + - ", regionName='" + regionName + '\'' + - ", timezone='" + timezone + '\'' + - "} " + super.toString(); - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/MapperSupport.java b/intercom-java/src/main/java/io/intercom/api/MapperSupport.java deleted file mode 100644 index 4315b794..00000000 --- a/intercom-java/src/main/java/io/intercom/api/MapperSupport.java +++ /dev/null @@ -1,40 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.core.Version; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; -import com.fasterxml.jackson.databind.module.SimpleModule; - -public class MapperSupport { - - public static ObjectMapper objectMapper() { - return Holder.INSTANCE; - } - - private static class Holder { - private static final ObjectMapper INSTANCE = new Holder().configure(new ObjectMapper()); - - private ObjectMapper configure(ObjectMapper om) { - return om.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, true) - .configure(SerializationFeature.INDENT_OUTPUT, true) - .configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, false) - .configure(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS, false) - .registerModule(customAttributeModule()); - } - - private SimpleModule customAttributeModule() { - final SimpleModule customAttributeModule = new SimpleModule( - "IntercomClientModule", - new Version(1, 0, 0, null, "", "") - ); - customAttributeModule.addDeserializer(CustomAttribute.class, new CustomAttributeDeserializer()); - customAttributeModule.addSerializer(CustomAttribute.class, new CustomAttributeSerializer()); - customAttributeModule.addDeserializer(Subscription.Topic.class, new TopicDeserializer()); - customAttributeModule.addSerializer(Subscription.Topic.class, new TopicSerializer()); - customAttributeModule.addSerializer(Counts.CountItem.class, new CountItemSerializer()); - customAttributeModule.addDeserializer(Counts.CountItem.class, new CountItemDeserializer()); - return customAttributeModule; - } - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/NotFoundException.java b/intercom-java/src/main/java/io/intercom/api/NotFoundException.java deleted file mode 100644 index e0806ad9..00000000 --- a/intercom-java/src/main/java/io/intercom/api/NotFoundException.java +++ /dev/null @@ -1,22 +0,0 @@ -package io.intercom.api; - -public class NotFoundException extends IntercomException { - - private static final long serialVersionUID = 2917082281352001861L; - - public NotFoundException(String message) { - super(message); - } - - public NotFoundException(String message, Throwable cause) { - super(message, cause); - } - - public NotFoundException(ErrorCollection errorCollection) { - super(errorCollection); - } - - public NotFoundException(ErrorCollection errorCollection, Throwable cause) { - super(errorCollection, cause); - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/Note.java b/intercom-java/src/main/java/io/intercom/api/Note.java deleted file mode 100644 index fa7b8b3e..00000000 --- a/intercom-java/src/main/java/io/intercom/api/Note.java +++ /dev/null @@ -1,133 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.google.common.collect.Maps; - -import java.util.HashMap; -import java.util.Map; - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(JsonInclude.Include.NON_EMPTY) -public class Note extends TypedData { - - private static final HashMap SENTINEL = Maps.newHashMap(); - - public static Note find(String id) throws InvalidException, AuthorizationException { - return DataResource.find(id, "notes", Note.class); - } - - public static Note create(Note note) throws InvalidException, AuthorizationException { - return DataResource.create(note, "notes", Note.class); - } - - public static NoteCollection list(Map params) throws InvalidException, AuthorizationException { - if ((!params.containsKey("email")) && (!params.containsKey("id")) && (!params.containsKey("user_id")) && (!params.containsKey("intercom_user_id"))) { - throw new InvalidException("a notes query must include an email, user_id or intercom_user_id parameter"); - } - return DataResource.list(params, "notes", NoteCollection.class); - } - - @JsonProperty("type") - private final String type = "note"; - - @JsonProperty("id") - private String id; - - @JsonProperty("body") - private String body; - - @JsonProperty("created_at") - private long createdAt; - - @JsonProperty("user") - private User user; - - @JsonProperty("author") - private Author author; - - public Note() { - } - - public String getType() { - return type; - } - - public String getId() { - return id; - } - - public String getBody() { - return body; - } - - public Note setBody(String body) { - this.body = body; - return this; - } - - public long getCreatedAt() { - return createdAt; - } - - public User getUser() { - return user; - } - - public Note setUser(User user) { - this.user = user; - return this; - } - - public Author getAuthor() { - return author; - } - - public Note setAuthor(Author author) { - this.author = author; - return this; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Note note = (Note) o; - - if (createdAt != note.createdAt) return false; - if (author != null ? !author.equals(note.author) : note.author != null) return false; - if (body != null ? !body.equals(note.body) : note.body != null) return false; - if (id != null ? !id.equals(note.id) : note.id != null) return false; - if (!type.equals(note.type)) return false; - //noinspection RedundantIfStatement - if (user != null ? !user.equals(note.user) : note.user != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = type.hashCode(); - result = 31 * result + (id != null ? id.hashCode() : 0); - result = 31 * result + (body != null ? body.hashCode() : 0); - result = 31 * result + (int) (createdAt ^ (createdAt >>> 32)); - result = 31 * result + (user != null ? user.hashCode() : 0); - result = 31 * result + (author != null ? author.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "Note{" + - "id='" + id + '\'' + - ", body='" + body + '\'' + - ", createdAt=" + createdAt + - ", user=" + user + - ", author=" + author + - "} " + super.toString(); - } - -} diff --git a/intercom-java/src/main/java/io/intercom/api/NoteCollection.java b/intercom-java/src/main/java/io/intercom/api/NoteCollection.java deleted file mode 100644 index 63d40dec..00000000 --- a/intercom-java/src/main/java/io/intercom/api/NoteCollection.java +++ /dev/null @@ -1,27 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(ignoreUnknown = true) -public class NoteCollection extends TypedDataCollection { - - - public NoteCollection() { - } - - @Override - public NoteCollection nextPage() { - return fetchNextPage(NoteCollection.class); - } - - @SuppressWarnings("EmptyMethod") - @JsonProperty("notes") - @Override - public List getPage() { - return super.getPage(); - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/Notification.java b/intercom-java/src/main/java/io/intercom/api/Notification.java deleted file mode 100644 index c7f4d093..00000000 --- a/intercom-java/src/main/java/io/intercom/api/Notification.java +++ /dev/null @@ -1,217 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.google.common.collect.Maps; - -import java.io.IOException; -import java.io.InputStream; -import java.net.URI; -import java.util.Map; - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(value = {"intercom"}, ignoreUnknown = true) -public class Notification extends TypedData { - - public static Notification readJSON(String json) throws InvalidException { - try { - return MapperSupport.objectMapper().readValue(json, Notification.class); - } catch (IOException e) { - throw new InvalidException("could not parse json string [" + e.getMessage() + "]", e); - } - } - - public static Notification readJSON(InputStream json) throws InvalidException { - try { - return MapperSupport.objectMapper().readValue(json, Notification.class); - } catch (IOException e) { - throw new InvalidException("could not parse json stream [" + e.getMessage() + "]", e); - } - } - - @JsonProperty("type") - private final String type = "notification_event"; - - @JsonProperty("id") - private String id; - - @JsonProperty("topic") - private String topic; - - @JsonProperty("app_id") - private String appID; - - @JsonProperty("data") - private NotificationData data; - - @JsonProperty("delivery_status") - private String deliveryStatus; - - @JsonProperty("delivery_attempts") - private int deliveryAttempts; - - @JsonProperty("delivered_at") - private long deliveredAt; - - @JsonProperty("first_sent_at") - private long firstSentAt; - - @JsonProperty("created_at") - private long createdAt; - - @JsonProperty - private Map links = Maps.newHashMap(); - - @JsonProperty("self") - private URI self; - - public Notification() { - } - - public String getType() { - return type; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getTopic() { - return topic; - } - - public void setTopic(String topic) { - this.topic = topic; - } - - public String getAppID() { - return appID; - } - - public void setAppID(String appID) { - this.appID = appID; - } - - public NotificationData getData() { - return data; - } - - public void setData(NotificationData data) { - this.data = data; - } - - public String getDeliveryStatus() { - return deliveryStatus; - } - - public void setDeliveryStatus(String deliveryStatus) { - this.deliveryStatus = deliveryStatus; - } - - public int getDeliveryAttempts() { - return deliveryAttempts; - } - - public void setDeliveryAttempts(int deliveryAttempts) { - this.deliveryAttempts = deliveryAttempts; - } - - public long getDeliveredAt() { - return deliveredAt; - } - - public void setDeliveredAt(long deliveredAt) { - this.deliveredAt = deliveredAt; - } - - public long getFirstSentAt() { - return firstSentAt; - } - - public void setFirstSentAt(long firstSentAt) { - this.firstSentAt = firstSentAt; - } - - - public long getCreatedAt() { - return createdAt; - } - - public Map getLinks() { - return links; - } - - public void setLinks(Map links) { - this.links = links; - } - - public URI getSelf() { - return self; - } - - public void setSelf(URI self) { - this.self = self; - } - - @Override - public int hashCode() { - int result = id != null ? id.hashCode() : 0; - result = 31 * result + (topic != null ? topic.hashCode() : 0); - result = 31 * result + (appID != null ? appID.hashCode() : 0); - result = 31 * result + (data != null ? data.hashCode() : 0); - result = 31 * result + (deliveryStatus != null ? deliveryStatus.hashCode() : 0); - result = 31 * result + deliveryAttempts; - result = 31 * result + (int) (deliveredAt ^ (deliveredAt >>> 32)); - result = 31 * result + (int) (firstSentAt ^ (firstSentAt >>> 32)); - result = 31 * result + (int) (createdAt ^ (createdAt >>> 32)); - result = 31 * result + (links != null ? links.hashCode() : 0); - result = 31 * result + (self != null ? self.hashCode() : 0); - return result; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Notification that = (Notification) o; - - if (createdAt != that.createdAt) return false; - if (deliveredAt != that.deliveredAt) return false; - if (deliveryAttempts != that.deliveryAttempts) return false; - if (firstSentAt != that.firstSentAt) return false; - if (appID != null ? !appID.equals(that.appID) : that.appID != null) return false; - if (data != null ? !data.equals(that.data) : that.data != null) return false; - if (deliveryStatus != null ? !deliveryStatus.equals(that.deliveryStatus) : that.deliveryStatus != null) - return false; - if (id != null ? !id.equals(that.id) : that.id != null) return false; - if (links != null ? !links.equals(that.links) : that.links != null) return false; - if (self != null ? !self.equals(that.self) : that.self != null) return false; - //noinspection RedundantIfStatement - if (topic != null ? !topic.equals(that.topic) : that.topic != null) return false; - - return true; - } - - @Override - public String toString() { - return "Notification{" + - "type='" + type + '\'' + - ", id='" + id + '\'' + - ", topic='" + topic + '\'' + - ", appID='" + appID + '\'' + - ", data=" + data + - ", deliveryStatus='" + deliveryStatus + '\'' + - ", deliveryAttempts=" + deliveryAttempts + - ", deliveredAt=" + deliveredAt + - ", firstSentAt=" + firstSentAt + - ", createdAt=" + createdAt + - ", links=" + links + - ", self=" + self + - "} " + super.toString(); - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/NotificationCollection.java b/intercom-java/src/main/java/io/intercom/api/NotificationCollection.java deleted file mode 100644 index e1d89de6..00000000 --- a/intercom-java/src/main/java/io/intercom/api/NotificationCollection.java +++ /dev/null @@ -1,28 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(ignoreUnknown = true) -public class NotificationCollection extends TypedDataCollection { - - - public NotificationCollection() { - type = "notification.list"; - } - - @Override - public NotificationCollection nextPage() { - return fetchNextPage(NotificationCollection.class); - } - - @SuppressWarnings("EmptyMethod") - @JsonProperty("notifications") - @Override - public List getPage() { - return super.getPage(); - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/NotificationData.java b/intercom-java/src/main/java/io/intercom/api/NotificationData.java deleted file mode 100644 index 0aa6d230..00000000 --- a/intercom-java/src/main/java/io/intercom/api/NotificationData.java +++ /dev/null @@ -1,63 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Map; - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(ignoreUnknown = true) -public class NotificationData extends TypedData { - - @JsonProperty("type") - protected String type; - - @JsonProperty - private Map item; - - public NotificationData() { - type = "notification_event_data"; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public Map getItem() { - return item; - } - - public void setItem(Map item) { - this.item = item; - } - - @Override - public int hashCode() { - return item != null ? item.hashCode() : 0; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - NotificationData that = (NotificationData) o; - - //noinspection RedundantIfStatement - if (item != null ? !item.equals(that.item) : that.item != null) return false; - - return true; - } - - @Override - public String toString() { - return "NotificationData{" + - "type='" + type + '\'' + - ", item=" + item + - "} " + super.toString(); - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/NotificationError.java b/intercom-java/src/main/java/io/intercom/api/NotificationError.java deleted file mode 100644 index d72fc2f9..00000000 --- a/intercom-java/src/main/java/io/intercom/api/NotificationError.java +++ /dev/null @@ -1,29 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(JsonInclude.Include.NON_DEFAULT) -public class NotificationError extends Notification { - - @JsonProperty("http_request") - private RequestResponseCapture capture; - - public RequestResponseCapture getCapture() { - return capture; - } - - public void setCapture(RequestResponseCapture capture) { - this.capture = capture; - } - - @Override - public String toString() { - return "NotificationError{" + - "capture=" + capture + - "} " + super.toString(); - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/NotificationErrorCollection.java b/intercom-java/src/main/java/io/intercom/api/NotificationErrorCollection.java deleted file mode 100644 index cec6d0f9..00000000 --- a/intercom-java/src/main/java/io/intercom/api/NotificationErrorCollection.java +++ /dev/null @@ -1,27 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(ignoreUnknown = true) -public class NotificationErrorCollection extends TypedDataCollection { - - public NotificationErrorCollection() { - type = "notification.list"; - } - - @SuppressWarnings("EmptyMethod") - @JsonProperty("notifications") - @Override - public List getPage() { - return super.getPage(); - } - - @Override - public NotificationErrorCollection nextPage() { - return fetchNextPage(NotificationErrorCollection.class); - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/RateLimitException.java b/intercom-java/src/main/java/io/intercom/api/RateLimitException.java deleted file mode 100644 index df1c4352..00000000 --- a/intercom-java/src/main/java/io/intercom/api/RateLimitException.java +++ /dev/null @@ -1,60 +0,0 @@ -package io.intercom.api; - -public class RateLimitException extends IntercomException { - - private static final long serialVersionUID = -6100754169056165622L; - - private int rateLimit; - - private int remainingRequests; - - private long resetTime; - - public RateLimitException(String message) { - super(message); - } - - public RateLimitException(String message, Throwable cause) { - super(message, cause); - } - - public RateLimitException(ErrorCollection errorCollection) { - super(errorCollection); - } - - public RateLimitException(ErrorCollection errorCollection, int rateLimit, - int remainingRequests, long resetTime) { - super(errorCollection); - this.rateLimit = rateLimit; - this.remainingRequests = remainingRequests; - this.resetTime = resetTime; - } - - public RateLimitException(ErrorCollection errorCollection, Throwable cause) { - super(errorCollection, cause); - } - - public int getRateLimit() { - return rateLimit; - } - - public void setRateLimit(int rateLimit) { - this.rateLimit = rateLimit; - } - - public int getRemainingRequests() { - return remainingRequests; - } - - public void setRemainingRequests(int remainingRequests) { - this.remainingRequests = remainingRequests; - } - - public long getResetTime() { - return resetTime; - } - - public void setResetTime(long resetTime) { - this.resetTime = resetTime; - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/Replier.java b/intercom-java/src/main/java/io/intercom/api/Replier.java deleted file mode 100644 index 042d322b..00000000 --- a/intercom-java/src/main/java/io/intercom/api/Replier.java +++ /dev/null @@ -1,7 +0,0 @@ -package io.intercom.api; - -interface Replier { - - String getReplyType(); - -} diff --git a/intercom-java/src/main/java/io/intercom/api/Reply.java b/intercom-java/src/main/java/io/intercom/api/Reply.java deleted file mode 100644 index f019b3d8..00000000 --- a/intercom-java/src/main/java/io/intercom/api/Reply.java +++ /dev/null @@ -1,97 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonIgnoreProperties(ignoreUnknown = true) -class Reply extends TypedData { - - @JsonProperty("message_type") - private String messageType = "comment"; - - @JsonProperty("body") - private String body; - - @JsonProperty("attachment_urls") - private String[] attachmentUrls; - - @JsonProperty("from") - T from; - - Reply() { - } - - @JsonProperty("type") - String getType() { - return from.getReplyType(); - } - - String getBody() { - return body; - } - - public Reply setBody(String body) { - this.body = body; - return this; - } - - public String[] getAttachmentUrls() { - return attachmentUrls; - } - - public Reply setAttachmentUrls(String[] attachmentUrls) { - this.attachmentUrls = attachmentUrls; - return this; - } - - T getFrom() { - return from; - } - - @SuppressWarnings("UnusedDeclaration") - public Reply setFrom(T from) { - this.from = from; - return this; - } - - String getMessageType() { - return messageType; - } - - Reply setMessageReplyType(String messageType) { - this.messageType = messageType; - return this; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Reply reply = (Reply) o; - - if (body != null ? !body.equals(reply.body) : reply.body != null) return false; - if (from != null ? !from.equals(reply.from) : reply.from != null) return false; - //noinspection RedundantIfStatement - if (!messageType.equals(reply.messageType)) return false; - - return true; - } - - @Override - public int hashCode() { - int result = messageType.hashCode(); - result = 31 * result + (body != null ? body.hashCode() : 0); - result = 31 * result + (from != null ? from.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "Reply{" + - "messageType='" + messageType + '\'' + - ", body='" + body + '\'' + - ", from=" + from + - "} " + super.toString(); - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/RequestResponseCapture.java b/intercom-java/src/main/java/io/intercom/api/RequestResponseCapture.java deleted file mode 100644 index 08e7f2dc..00000000 --- a/intercom-java/src/main/java/io/intercom/api/RequestResponseCapture.java +++ /dev/null @@ -1,68 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.google.common.collect.ImmutableMap; - -import java.net.URI; -import java.util.Map; - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(JsonInclude.Include.NON_EMPTY) -public class RequestResponseCapture { - - @JsonProperty("request_method") - private String requestMethod; - - @JsonProperty("request_uri") - private URI requestURI; - - @JsonProperty("request_headers") - private Map requestHeaders; - - @JsonProperty("response_status_code") - private int responseStatusCode; - - @JsonProperty("response_headers") - private Map responseHeaders; - - @JsonProperty("response_entity") - private String responseEntity; - - @JsonProperty("request_entity") - private String requestEntity; - - public RequestResponseCapture() { - } - - public String getRequestMethod() { - return requestMethod; - } - - public URI getRequestURI() { - return requestURI; - } - - public Map getRequestHeaders() { - return ImmutableMap.builder().putAll(requestHeaders).build(); - } - - public int getResponseStatusCode() { - return responseStatusCode; - } - - public Map getResponseHeaders() { - return ImmutableMap.builder().putAll(responseHeaders).build(); - } - - public String getResponseEntity() { - return responseEntity; - } - - public String getRequestEntity() { - return requestEntity; - } - -} \ No newline at end of file diff --git a/intercom-java/src/main/java/io/intercom/api/ScrollableCompanyCollection.java b/intercom-java/src/main/java/io/intercom/api/ScrollableCompanyCollection.java deleted file mode 100644 index e4a2f377..00000000 --- a/intercom-java/src/main/java/io/intercom/api/ScrollableCompanyCollection.java +++ /dev/null @@ -1,19 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -public class ScrollableCompanyCollection extends ScrollableTypedDataCollection { - - @Override - public ScrollableCompanyCollection scroll() { - return DataResource.scroll(getScrollParam(), "companies", ScrollableCompanyCollection.class); - } - - @JsonProperty("companies") - @Override - public List getPage() { - return super.getPage(); - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/ScrollableContactCollection.java b/intercom-java/src/main/java/io/intercom/api/ScrollableContactCollection.java deleted file mode 100644 index e97a62bb..00000000 --- a/intercom-java/src/main/java/io/intercom/api/ScrollableContactCollection.java +++ /dev/null @@ -1,19 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -public class ScrollableContactCollection extends ScrollableTypedDataCollection { - - @Override - public ScrollableContactCollection scroll() { - return DataResource.scroll(getScrollParam(), "contacts", ScrollableContactCollection.class); - } - - @JsonProperty("contacts") - @Override - public List getPage() { - return super.getPage(); - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/ScrollableTypedDataCollection.java b/intercom-java/src/main/java/io/intercom/api/ScrollableTypedDataCollection.java deleted file mode 100644 index 0d43a710..00000000 --- a/intercom-java/src/main/java/io/intercom/api/ScrollableTypedDataCollection.java +++ /dev/null @@ -1,35 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.google.common.collect.Lists; - -import java.util.List; - -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(JsonInclude.Include.NON_EMPTY) -public abstract class ScrollableTypedDataCollection extends TypedData { - - protected List page = Lists.newArrayList(); - - @JsonProperty("scroll_param") - protected String scrollParam; - - @JsonProperty("type") - protected String type; - - public String getScrollParam() { - return scrollParam; - } - - public String getType() { - return type; - } - - public abstract ScrollableTypedDataCollection scroll(); - - public List getPage() { - return page; - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/ScrollableUserCollection.java b/intercom-java/src/main/java/io/intercom/api/ScrollableUserCollection.java deleted file mode 100644 index 92bd1bb2..00000000 --- a/intercom-java/src/main/java/io/intercom/api/ScrollableUserCollection.java +++ /dev/null @@ -1,20 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -public class ScrollableUserCollection extends ScrollableTypedDataCollection { - - @Override - public ScrollableUserCollection scroll() { - return DataResource.scroll(getScrollParam(), "users", ScrollableUserCollection.class); - } - - @JsonProperty("users") - @Override - public List getPage() { - return super.getPage(); - } - -} diff --git a/intercom-java/src/main/java/io/intercom/api/Segment.java b/intercom-java/src/main/java/io/intercom/api/Segment.java deleted file mode 100644 index 0b12c019..00000000 --- a/intercom-java/src/main/java/io/intercom/api/Segment.java +++ /dev/null @@ -1,113 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.google.common.collect.Maps; - -import java.util.HashMap; - -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(JsonInclude.Include.NON_EMPTY) -public class Segment extends TypedData { - - private static final HashMap SENTINEL = Maps.newHashMap(); - - public static Segment find(String id) throws InvalidException, AuthorizationException { - final HttpClient resource = new HttpClient(UriBuilder.newBuilder().path("segments").path(id).build()); - return resource.get(Segment.class); - } - - public static SegmentCollection list() throws InvalidException, AuthorizationException { - return DataResource.list(SENTINEL, "segments", SegmentCollection.class); - } - - public static Segment update(Segment segment) throws InvalidException, AuthorizationException { - if (segment.getId() == null) { - throw new InvalidException("segment updates must supply an id"); - } - return DataResource.update(segment, "segments", Segment.class); - } - - @JsonProperty("type") - private final String type = "segment"; - - @JsonProperty("id") - private String id; - - @JsonProperty("name") - private String name; - - @JsonProperty("created_at") - private long createdAt; - - @JsonProperty("updated_at") - private long updatedAt; - - @SuppressWarnings("WeakerAccess") - public Segment() { - } - - public String getType() { - return type; - } - - public String getId() { - return id; - } - - public String getName() { - return name; - } - - public Segment setName(String name) { - this.name = name; - return this; - } - - public long getCreatedAt() { - return createdAt; - } - - public long getUpdatedAt() { - return updatedAt; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Segment segment = (Segment) o; - - if (createdAt != segment.createdAt) return false; - if (updatedAt != segment.updatedAt) return false; - if (id != null ? !id.equals(segment.id) : segment.id != null) return false; - if (name != null ? !name.equals(segment.name) : segment.name != null) return false; - //noinspection RedundantIfStatement - if (!type.equals(segment.type)) return false; - - return true; - } - - @Override - public int hashCode() { - int result = type.hashCode(); - result = 31 * result + (id != null ? id.hashCode() : 0); - result = 31 * result + (name != null ? name.hashCode() : 0); - result = 31 * result + (int) (createdAt ^ (createdAt >>> 32)); - result = 31 * result + (int) (updatedAt ^ (updatedAt >>> 32)); - return result; - } - - @Override - public String toString() { - return "Segment{" + - "id='" + id + '\'' + - ", name='" + name + '\'' + - ", createdAt=" + createdAt + - ", updatedAt=" + updatedAt + - "} " + super.toString(); - } - -} diff --git a/intercom-java/src/main/java/io/intercom/api/SegmentCollection.java b/intercom-java/src/main/java/io/intercom/api/SegmentCollection.java deleted file mode 100644 index 61283888..00000000 --- a/intercom-java/src/main/java/io/intercom/api/SegmentCollection.java +++ /dev/null @@ -1,35 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(JsonInclude.Include.NON_EMPTY) -public class SegmentCollection extends TypedDataCollection { - - public SegmentCollection() { - type = "segment.list"; - } - - @Override - public SegmentCollection nextPage() { - return fetchNextPage(SegmentCollection.class); - } - - @SuppressWarnings("EmptyMethod") - @JsonProperty("segments") - @Override - public List getPage() { - return super.getPage(); - } - - @Override - public String toString() { - return "SegmentCollection{" + - "} " + super.toString(); - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/ServerException.java b/intercom-java/src/main/java/io/intercom/api/ServerException.java deleted file mode 100644 index 66475320..00000000 --- a/intercom-java/src/main/java/io/intercom/api/ServerException.java +++ /dev/null @@ -1,22 +0,0 @@ -package io.intercom.api; - -public class ServerException extends IntercomException { - - private static final long serialVersionUID = 7823280575981918941L; - - public ServerException(String message) { - super(message); - } - - public ServerException(String message, Throwable cause) { - super(message, cause); - } - - public ServerException(ErrorCollection errorCollection) { - super(errorCollection); - } - - public ServerException(ErrorCollection errorCollection, Throwable cause) { - super(errorCollection, cause); - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/SocialProfile.java b/intercom-java/src/main/java/io/intercom/api/SocialProfile.java deleted file mode 100644 index 19b7376b..00000000 --- a/intercom-java/src/main/java/io/intercom/api/SocialProfile.java +++ /dev/null @@ -1,90 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; - -import java.net.URI; - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(JsonInclude.Include.NON_EMPTY) -public class SocialProfile extends TypedData { - - @JsonProperty("type") - private final String type = "social_profile"; - - @JsonProperty("id") - private String id; - - @JsonProperty("name") - private String name; - - @JsonProperty("username") - private String username; - - @JsonProperty("url") - @JsonDeserialize(using = URIDeserializer.class) - @JsonInclude(JsonInclude.Include.NON_NULL) - private URI url; - - public SocialProfile() { - } - - public String getType() { - return type; - } - - public String getId() { - return id; - } - - public String getName() { - return name; - } - - public String getUsername() { - return username; - } - - public URI getUrl() { - return url; - } - - @Override - public int hashCode() { - int result = id != null ? id.hashCode() : 0; - result = 31 * result + (name != null ? name.hashCode() : 0); - result = 31 * result + (username != null ? username.hashCode() : 0); - result = 31 * result + (url != null ? url.hashCode() : 0); - return result; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - SocialProfile that = (SocialProfile) o; - - if (id != null ? !id.equals(that.id) : that.id != null) return false; - if (name != null ? !name.equals(that.name) : that.name != null) return false; - if (url != null ? !url.equals(that.url) : that.url != null) return false; - //noinspection RedundantIfStatement - if (username != null ? !username.equals(that.username) : that.username != null) return false; - - return true; - } - - @Override - public String toString() { - return "SocialProfile{" + - "type='" + type + '\'' + - ", id='" + id + '\'' + - ", name='" + name + '\'' + - ", username='" + username + '\'' + - ", url=" + url + - "} " + super.toString(); - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/SocialProfileCollection.java b/intercom-java/src/main/java/io/intercom/api/SocialProfileCollection.java deleted file mode 100644 index f35cb020..00000000 --- a/intercom-java/src/main/java/io/intercom/api/SocialProfileCollection.java +++ /dev/null @@ -1,62 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; - -import java.util.List; - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(JsonInclude.Include.NON_EMPTY) -public class SocialProfileCollection extends TypedData { - - @JsonProperty("type") - private String type = "social_profile.list"; - - @JsonProperty("social_profiles") - private List socialProfiles = Lists.newArrayList(); - - SocialProfileCollection() { - } - - public String getType() { - return type; - } - - public List getSocialProfiles() { - return socialProfiles == null ? null : ImmutableList.builder().addAll(socialProfiles).build(); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - SocialProfileCollection that = (SocialProfileCollection) o; - - if (socialProfiles != null ? !socialProfiles.equals(that.socialProfiles) : that.socialProfiles != null) - return false; - //noinspection RedundantIfStatement - if (type != null ? !type.equals(that.type) : that.type != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = type != null ? type.hashCode() : 0; - result = 31 * result + (socialProfiles != null ? socialProfiles.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "SocialProfileCollection{" + - "type='" + type + '\'' + - ", socialProfiles=" + socialProfiles + - "} " + super.toString(); - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/Subscription.java b/intercom-java/src/main/java/io/intercom/api/Subscription.java deleted file mode 100644 index 4510e438..00000000 --- a/intercom-java/src/main/java/io/intercom/api/Subscription.java +++ /dev/null @@ -1,459 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.google.common.base.Preconditions; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; - -import java.net.URI; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.ArrayList; - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(JsonInclude.Include.NON_EMPTY) -public class Subscription extends TypedData { - - private static final HashMap SENTINEL = Maps.newHashMap(); - - public static Subscription create(Subscription subscription) throws InvalidException, AuthorizationException { - return DataResource.create(subscription, "subscriptions", Subscription.class); - } - - public static Subscription update(Subscription subscription) throws InvalidException, AuthorizationException { - return DataResource.update(subscription, "subscriptions", subscription.getId(), Subscription.class); - } - - public static Subscription delete(Subscription subscription) throws InvalidException, AuthorizationException { - return DataResource.delete(subscription.getId(), "subscriptions", Subscription.class); - } - - public static Subscription find(String id) throws InvalidException, AuthorizationException { - final HttpClient resource = new HttpClient(UriBuilder.newBuilder().path("subscriptions").path(id).build()); - return resource.get(Subscription.class); - } - - public static SubscriptionCollection list() throws InvalidException, AuthorizationException { - return DataResource.list(SENTINEL, "subscriptions", SubscriptionCollection.class); - } - - public static Subscription ping(String id) throws InvalidException, AuthorizationException { - final HttpClient resource = new HttpClient(UriBuilder.newBuilder().path("subscriptions").path(id).path("ping").build()); - return resource.post(Subscription.class, null); - } - - public static Subscription ping(Subscription subscription) throws InvalidException, AuthorizationException { - return ping(subscription.getId()); - } - - public static NotificationCollection sentFeed(String id) throws InvalidException, AuthorizationException { - final URI feedURI = UriBuilder.newBuilder() - .path("subscriptions") - .path(id) - .path("sent") - .build(); - final HttpClient resource = new HttpClient(feedURI); - return resource.get(NotificationCollection.class); - } - - public static NotificationErrorCollection errorFeed(String id) throws InvalidException, AuthorizationException { - final URI feedURI = UriBuilder.newBuilder() - .path("subscriptions") - .path(id) - .path("error") - .build(); - final HttpClient resource = new HttpClient(feedURI); - return resource.get(NotificationErrorCollection.class); - } - - @SuppressWarnings("UnusedDeclaration") - public static class Topic { - private static final String SUBTYPE_WILDCARD = "*"; - - private static final String TEXT = "text"; - - private final static String COMPANY_NAME = "company"; - - private final static String CONVERSATION_NAME = "conversation"; - - private final static String CONVERSATION_PART_NAME = "conversation_part"; - - private static final String USER_NAME = "user"; - - private static final String CONTACT_NAME = "contact"; - - private static final String VISITOR_NAME = "visitor"; - - private static final String EVENT_NAME = "event"; - - public static final Topic PING = new Topic("ping", SUBTYPE_WILDCARD); - - public static final Topic COMPANY = new Topic(COMPANY_NAME, SUBTYPE_WILDCARD); - - public static final Topic COMPANY_CREATED = new Topic(COMPANY_NAME, "created"); - - public static final Topic CONVERSATION = new Topic(CONVERSATION_NAME, SUBTYPE_WILDCARD); - - public static final Topic CONVERSATION_USER_CREATED = new Topic(CONVERSATION_NAME, "user.created"); - - public static final Topic CONVERSATION_USER_REPLY = new Topic(CONVERSATION_NAME, "user.replied"); - - public static final Topic CONVERSATION_ADMIN_REPLY = new Topic(CONVERSATION_NAME, "admin.replied"); - - public static final Topic CONVERSATION_ADMIN_ASSIGNED = new Topic(CONVERSATION_NAME, "admin.assigned"); - - public static final Topic CONVERSATION_ADMIN_CLOSED = new Topic(CONVERSATION_NAME, "admin.closed"); - - public static final Topic CONVERSATION_ADMIN_OPEN = new Topic(CONVERSATION_NAME, "admin.opened"); - - public static final Topic CONVERSATION_ADMIN_NOTED = new Topic(CONVERSATION_NAME, "admin.noted"); - - public static final Topic CONVERSATION_ADMIN_SINGLE_CREATED = new Topic(CONVERSATION_NAME, "admin.single.created"); - - public static final Topic CONVERSATION_PART_TAG_CREATED= new Topic(CONVERSATION_PART_NAME, "tag.created"); - - public static final Topic USER = new Topic(USER_NAME, SUBTYPE_WILDCARD); - - public static final Topic USER_CREATED = new Topic(USER_NAME, "created"); - - public static final Topic USER_DELETED = new Topic(USER_NAME, "deleted"); - - public static final Topic USER_EMAIL_UPDATED = new Topic(USER_NAME, "email.updated"); - - public static final Topic USER_UNSUBSCRIBED = new Topic(USER_NAME, "unsubscribed"); - - public static final Topic USER_TAG_CREATED = new Topic(USER_NAME, "tag.created"); - - public static final Topic USER_TAG_DELETED = new Topic(USER_NAME, "tag.deleted"); - - public static final Topic CONTACT = new Topic(CONTACT_NAME, SUBTYPE_WILDCARD); - - public static final Topic CONTACT_ADDED_EMAIL = new Topic(CONTACT_NAME, "added_email"); - - public static final Topic CONTACT_CREATED= new Topic(CONTACT_NAME, "created"); - - public static final Topic CONTACT_SIGNED_UP = new Topic(CONTACT_NAME, "signed_up"); - - public static final Topic VISITOR = new Topic(VISITOR_NAME, SUBTYPE_WILDCARD); - - public static final Topic VISITOR_SIGNED_UP = new Topic(VISITOR_NAME, "signed_up"); - - public static final Topic EVENT_CREATED = new Topic(EVENT_NAME, "created"); - - public static final Topic ALL_TOPIC = valueOf("all"); - - public static Topic valueOf(String type) throws IllegalArgumentException { - if (type.contains(".")) { - final String[] split = type.split("\\.", 2); // fragile: assume one dot - return new Topic(split[0], split[1]); - } else { - return new Topic(type); - } - } - - private String type; - - private String subType; - - private String toString; - - public Topic(String type) { - this(type, SUBTYPE_WILDCARD); - } - - public Topic(String type, String subType) { - Preconditions.checkArgument(type != null, "type part cannot be null"); - Preconditions.checkArgument(subType != null, "subType part cannot be null"); - this.type = type; - this.subType = subType; - // memo the string representation - if (SUBTYPE_WILDCARD.equals(subType)) { - toString = type; - } else { - toString = type + "." + subType; - } - } - - public String getType() { - return type; - } - - public String getSubType() { - return subType; - } - - public boolean isCompatible(String type) { - return this.isCompatible(valueOf(type)); - } - - public boolean isCompatible(Topic other) { - if (other == null) { - return false; - } - //noinspection SimplifiableIfStatement - if (type.equalsIgnoreCase(other.type) && (subType.equals(SUBTYPE_WILDCARD) || other.subType.equals(SUBTYPE_WILDCARD))) { - return true; - } else { - return this.type.equalsIgnoreCase(other.type) && this.subType.equalsIgnoreCase(other.subType); - } - } - - @Override - public int hashCode() { - int result = type != null ? type.hashCode() : 0; - result = 31 * result + (subType != null ? subType.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return toString; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - final Topic Topic = (Topic) o; - if (subType != null ? !subType.equals(Topic.subType) : Topic.subType != null) { - return false; - } - //noinspection RedundantIfStatement - if (type != null ? !type.equals(Topic.type) : Topic.type != null) { - return false; - } - return true; - } - - - } - - @SuppressWarnings("FieldCanBeLocal") - @JsonProperty("type") - private final String type = "notification_subscription"; - - @JsonProperty("id") - private String id; - - @JsonProperty("created_at") - private long createdAt; - - @JsonProperty("updated_at") - private long updatedAt; - - @JsonProperty("service_type") - private final String serviceType = "web"; - - @JsonProperty("app_id") - private String appID; - - @JsonProperty("url") - private URI url; - - @JsonProperty("self") - private URI self; - - @JsonProperty("topics") - private List topics = Lists.newArrayList(); - - @JsonProperty("metadata") - private Map> metadata = Maps.newHashMap(); - - @JsonProperty("active") - private boolean active; - - @JsonProperty("hub_secret") - private String hubSecret; - - @JsonProperty("mode") - private String mode = "point"; - - @JsonProperty("links") - private Map links = Maps.newHashMap(); - - @JsonProperty("notes") - private List notes = Lists.newArrayList(); - - public Subscription() { - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getType() { - return type; - } - - public long getCreatedAt() { - return createdAt; - } - - public long getUpdatedAt() { - return updatedAt; - } - - public String getServiceType() { - return serviceType; - } - - public String getAppID() { - return appID; - } - - public void setAppID(String appID) { - this.appID = appID; - } - - public URI getUrl() { - return url; - } - - public void setUrl(URI url) { - this.url = url; - } - - public URI getSelf() { - return self; - } - - public List getTopics() { - return topics; - } - - public void setTopics(List topics) { - this.topics = topics; - } - - public void addTopic(Topic topic) { - this.topics.add(topic); - } - - public boolean getActive() { - return active; - } - - public void setActive(boolean active) { - this.active = active; - } - - public Map> getMetadata() { - return metadata; - } - - public void setMetadata(Map> metadata) { - this.metadata = metadata; - } - - public String getHubSecret() { - return hubSecret; - } - - public void setHubSecret(String hubSecret) { - this.hubSecret = hubSecret; - } - - public String getMode() { - return mode; - } - - public List getNotes() { - return notes; - } - - public void setNotes(List notes) { - this.notes = notes; - } - - @JsonIgnore - public String getURLString() { - return url.toASCIIString(); - } - - @JsonIgnore - public boolean requiresSignature() { - return getHubSecret() != null; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Subscription that = (Subscription) o; - - if (active != that.active) return false; - if (createdAt != that.createdAt) return false; - if (updatedAt != that.updatedAt) return false; - if (appID != null ? !appID.equals(that.appID) : that.appID != null) return false; - if (hubSecret != null ? !hubSecret.equals(that.hubSecret) : that.hubSecret != null) return false; - if (id != null ? !id.equals(that.id) : that.id != null) return false; - if (links != null ? !links.equals(that.links) : that.links != null) return false; - if (metadata != null ? !metadata.equals(that.metadata) : that.metadata != null) return false; - if (mode != null ? !mode.equals(that.mode) : that.mode != null) return false; - if (notes != null ? !notes.equals(that.notes) : that.notes != null) return false; - if (self != null ? !self.equals(that.self) : that.self != null) return false; - if (!serviceType.equals(that.serviceType)) return false; - if (topics != null ? !topics.equals(that.topics) : that.topics != null) return false; - if (!type.equals(that.type)) return false; - //noinspection RedundantIfStatement - if (url != null ? !url.equals(that.url) : that.url != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = type.hashCode(); - result = 31 * result + (id != null ? id.hashCode() : 0); - result = 31 * result + (int) (createdAt ^ (createdAt >>> 32)); - result = 31 * result + (int) (updatedAt ^ (updatedAt >>> 32)); - result = 31 * result + (serviceType.hashCode()); - result = 31 * result + (appID != null ? appID.hashCode() : 0); - result = 31 * result + (url != null ? url.hashCode() : 0); - result = 31 * result + (self != null ? self.hashCode() : 0); - result = 31 * result + (topics != null ? topics.hashCode() : 0); - result = 31 * result + (metadata != null ? metadata.hashCode() : 0); - result = 31 * result + (active ? 1 : 0); - result = 31 * result + (hubSecret != null ? hubSecret.hashCode() : 0); - result = 31 * result + (mode != null ? mode.hashCode() : 0); - result = 31 * result + (links != null ? links.hashCode() : 0); - result = 31 * result + (notes != null ? notes.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "Subscription{" + - "id='" + id + '\'' + - ", createdAt=" + createdAt + - ", updatedAt=" + updatedAt + - ", serviceType='" + serviceType + '\'' + - ", appID='" + appID + '\'' + - ", url=" + url + - ", self=" + self + - ", topics=" + topics + - ", metadata=" + metadata + - ", active=" + active + - ", hubSecret='" + hubSecret + '\'' + - ", mode='" + mode + '\'' + - ", links=" + links + - ", notes=" + notes + - "} " + super.toString(); - } - - -} diff --git a/intercom-java/src/main/java/io/intercom/api/SubscriptionCollection.java b/intercom-java/src/main/java/io/intercom/api/SubscriptionCollection.java deleted file mode 100644 index cb5ca887..00000000 --- a/intercom-java/src/main/java/io/intercom/api/SubscriptionCollection.java +++ /dev/null @@ -1,34 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(JsonInclude.Include.NON_EMPTY) -public class SubscriptionCollection extends TypedDataCollection { - - public SubscriptionCollection() { - } - - @Override - public SubscriptionCollection nextPage() { - return fetchNextPage(SubscriptionCollection.class); - } - - @SuppressWarnings("EmptyMethod") - @JsonProperty("items") - @Override - public List getPage() { - return super.getPage(); - } - - @Override - public String toString() { - return "SubscriptionCollection{" + - "} " + super.toString(); - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/Tag.java b/intercom-java/src/main/java/io/intercom/api/Tag.java deleted file mode 100644 index 6ffbe6b7..00000000 --- a/intercom-java/src/main/java/io/intercom/api/Tag.java +++ /dev/null @@ -1,285 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Strings; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(JsonInclude.Include.NON_EMPTY) -public class Tag extends TypedData { - - private static final Logger logger = LoggerFactory.getLogger("intercom-java"); - private static final HashMap SENTINEL = Maps.newHashMap(); - - public static Tag tag(Tag tag, User... users) throws InvalidException, AuthorizationException { - return tag(tag, new UserCollection(Lists.newArrayList(users))); - } - - public static Tag tag(Tag tag, Contact... contacts) throws InvalidException, AuthorizationException { - return tag(tag, new ContactCollection(Lists.newArrayList(contacts))); - } - - public static Tag tag(Tag tag, Company... companies) throws InvalidException, AuthorizationException { - return tag(tag, new CompanyCollection(Lists.newArrayList(companies))); - } - - static Tag tag(Tag tag, UserCollection users) throws InvalidException, AuthorizationException { - TaggableCollection taggableCollection = createTagTypedCollection(tag, users); - return DataResource.create(taggableCollection, "tags", Tag.class); - } - - static Tag tag(Tag tag, ContactCollection contacts) throws InvalidException, AuthorizationException { - TaggableCollection taggableCollection = createTagTypedCollection(tag, contacts); - return DataResource.create(taggableCollection, "tags", Tag.class); - } - - static Tag tag(Tag tag, CompanyCollection companies) throws InvalidException, AuthorizationException { - TaggableCollection taggableCollection = createTagTypedCollection(tag, companies); - return DataResource.create(taggableCollection, "tags", Tag.class); - } - - public static Tag create(Tag tag) throws InvalidException, AuthorizationException { - return DataResource.create(tag, "tags", Tag.class); - } - - public static Tag update(Tag tag) throws InvalidException, AuthorizationException { - if (tag.getId() == null) { - throw new InvalidException("tag updates must supply an id"); - } - return DataResource.update(tag, "tags", Tag.class); - } - - public static Tag delete(String id) throws InvalidException, AuthorizationException { - return DataResource.delete(id, "tags", Tag.class); - } - - public static Tag delete(Tag tag) throws InvalidException, AuthorizationException { - return delete(tag.getId()); - } - - public static TagCollection list() throws InvalidException, AuthorizationException { - return DataResource.list(SENTINEL, "tags", TagCollection.class); - } - - @VisibleForTesting - static TaggableCollection createTagTypedCollection(Tag tag, UserCollection users) { - TaggableCollection taggableCollection = new TaggableCollection(); - taggableCollection.setName(tag.getName()); - taggableCollection.setId(tag.getId()); - final List> usersLite = Lists.newArrayList(); - final List pageItems = users.getPage(); - for (User user : pageItems) { - Map userMap = Maps.newHashMap(); - final String id = user.getId(); - final String email = user.getEmail(); - final String userId = user.getUserId(); - - if (user.isUntag()) { - userMap.put("untag", true); - } - - if (!Strings.isNullOrEmpty(id)) { - userMap.put("id", id); - usersLite.add(userMap); - } else if (!Strings.isNullOrEmpty(userId)) { - userMap.put("user_id", userId); - usersLite.add(userMap); - } else if (!Strings.isNullOrEmpty(email)) { - userMap.put("email", email); - usersLite.add(userMap); - } else { - logger.warn("no identifiers found for user tag target, skipping [" + tag + "] [" + user.toString() + "]"); - } - } - taggableCollection.setUsers(usersLite); - return taggableCollection; - } - - @VisibleForTesting - static TaggableCollection createTagTypedCollection(Tag tag, ContactCollection contacts) { - TaggableCollection taggableCollection = new TaggableCollection(); - taggableCollection.setName(tag.getName()); - taggableCollection.setId(tag.getId()); - final List> contactsLite = Lists.newArrayList(); - final List pageItems = contacts.getPage(); - for (Contact contact: pageItems) { - Map contactMap = Maps.newHashMap(); - final String id = contact.getID(); - - if (contact.isUntag()) { - contactMap.put("untag", true); - } - - if (!Strings.isNullOrEmpty(id)) { - contactMap.put("id", id); - contactsLite.add(contactMap); - } else { - logger.warn("no identifiers found for user tag target, skipping [" + tag + "] [" + contact.toString() + "]"); - } - } - taggableCollection.setUsers(contactsLite); - return taggableCollection; - } - - @VisibleForTesting - static TaggableCollection createTagTypedCollection(Tag tag, CompanyCollection companies) { - TaggableCollection taggableCollection = new TaggableCollection(); - taggableCollection.setName(tag.getName()); - taggableCollection.setId(tag.getId()); - - final List> companiesLite = Lists.newArrayList(); - final List pageItems = companies.getPage(); - for (Company company : pageItems) { - Map companyMap = Maps.newHashMap(); - final String companyID = company.getCompanyID(); - final String id = company.getId(); - final String name = company.getName(); - - if (company.isUntag()) { - companyMap.put("untag", true); - } - - if (!Strings.isNullOrEmpty(companyID)) { - companyMap.put("company_id", companyID); - companiesLite.add(companyMap); - } else if (!Strings.isNullOrEmpty(id)) { - companyMap.put("id", id); - companiesLite.add(companyMap); - } else if (!Strings.isNullOrEmpty(name)) { - companyMap.put("name", name); - companiesLite.add(companyMap); - } else { - logger.warn("no identifiers found for company tag target, skipping [" + tag + "] [" + company.toString() + "]"); - } - taggableCollection.setCompanies(companiesLite); - } - return taggableCollection; - } - - @SuppressWarnings("UnusedDeclaration") - @JsonIgnoreProperties(ignoreUnknown = true) - @JsonInclude(JsonInclude.Include.NON_DEFAULT) - static class TaggableCollection extends Tag { - - @JsonProperty("users") - private List> users; - - @JsonProperty("companies") - private List> companies; - - public List> getUsers() { - return users; - } - - public void setUsers(List> usersLite) { - this.users = usersLite; - } - - public List> getCompanies() { - return companies; - } - - public void setCompanies(List> companies) { - this.companies = companies; - } - } - - @JsonProperty("type") - private final String type = "tag"; - - @JsonProperty("id") - private String id; - - @JsonProperty("name") - private String name; - - @JsonProperty("created_at") - private long createdAt; - - @JsonProperty("updated_at") - private long updatedAt; - - public Tag() { - } - - public String getType() { - return type; - } - - public String getId() { - return id; - } - - - @SuppressWarnings("UnusedReturnValue") - @VisibleForTesting - Tag setId(String id) { - this.id = id; - return this; - } - - public String getName() { - return name; - } - - public Tag setName(String name) { - this.name = name; - return this; - } - - public long getCreatedAt() { - return createdAt; - } - - public long getUpdatedAt() { - return updatedAt; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Tag tag = (Tag) o; - - if (createdAt != tag.createdAt) return false; - if (updatedAt != tag.updatedAt) return false; - if (id != null ? !id.equals(tag.id) : tag.id != null) return false; - if (name != null ? !name.equals(tag.name) : tag.name != null) return false; - //noinspection RedundantIfStatement - if (!type.equals(tag.type)) return false; - - return true; - } - - @Override - public int hashCode() { - int result = type.hashCode(); - result = 31 * result + (id != null ? id.hashCode() : 0); - result = 31 * result + (name != null ? name.hashCode() : 0); - result = 31 * result + (int) (createdAt ^ (createdAt >>> 32)); - result = 31 * result + (int) (updatedAt ^ (updatedAt >>> 32)); - return result; - } - - @Override - public String toString() { - return "Tag{" + - "id='" + id + '\'' + - ", name='" + name + '\'' + - ", createdAt=" + createdAt + - ", updatedAt=" + updatedAt + - "} " + super.toString(); - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/TagCollection.java b/intercom-java/src/main/java/io/intercom/api/TagCollection.java deleted file mode 100644 index 57fdf6bb..00000000 --- a/intercom-java/src/main/java/io/intercom/api/TagCollection.java +++ /dev/null @@ -1,34 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(JsonInclude.Include.NON_EMPTY) -public class TagCollection extends TypedDataCollection { - - public TagCollection() { - } - - @Override - public TagCollection nextPage() { - return fetchNextPage(TagCollection.class); - } - - @SuppressWarnings("EmptyMethod") - @JsonProperty("tags") - @Override - public List getPage() { - return super.getPage(); - } - - @Override - public String toString() { - return "TagCollection{" + - "} " + super.toString(); - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/Teammate.java b/intercom-java/src/main/java/io/intercom/api/Teammate.java deleted file mode 100644 index 158e88bd..00000000 --- a/intercom-java/src/main/java/io/intercom/api/Teammate.java +++ /dev/null @@ -1,68 +0,0 @@ -package io.intercom.api; - - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(JsonInclude.Include.NON_EMPTY) -public class Teammate extends TypedData { - - @JsonProperty("type") - private String type; - - @JsonProperty("id") - private String id; - - public Teammate() { - } - - public String getType() { - return type; - } - - public Teammate setType(String type) { - this.type = type; - return this; - } - - public String getId() { - return id; - } - - public Teammate setId(String id) { - this.id = id; - return this; - } - - @Override - public int hashCode() { - int result = id != null ? id.hashCode() : 0; - result = 31 * result + (type != null ? type.hashCode() : 0); - return result; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Teammate teammate = (Teammate) o; - - if (id != null ? !id.equals(teammate.id) : teammate.id != null) return false; - if (type != null ? !type.equals(teammate.type) : teammate.type != null) return false; - - return true; - } - - @Override - public String toString() { - return "Teammate{" + - "type='" + type + '\'' + - ", id='" + id+ '\'' + - "} " + super.toString(); - } - -} diff --git a/intercom-java/src/main/java/io/intercom/api/TopicDeserializer.java b/intercom-java/src/main/java/io/intercom/api/TopicDeserializer.java deleted file mode 100644 index d622b993..00000000 --- a/intercom-java/src/main/java/io/intercom/api/TopicDeserializer.java +++ /dev/null @@ -1,25 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.fasterxml.jackson.databind.node.ValueNode; - -import java.io.IOException; - -class TopicDeserializer extends StdDeserializer { - - private static final long serialVersionUID = 7679767772794559452L; - - public TopicDeserializer() { - super(CustomAttribute.class); - } - - @Override - public Subscription.Topic deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { - final ObjectMapper mapper = (ObjectMapper) jp.getCodec(); - final ValueNode vNode = mapper.readTree(jp); - return Subscription.Topic.valueOf(vNode.asText()); - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/TopicSerializer.java b/intercom-java/src/main/java/io/intercom/api/TopicSerializer.java deleted file mode 100644 index 7f2f8846..00000000 --- a/intercom-java/src/main/java/io/intercom/api/TopicSerializer.java +++ /dev/null @@ -1,20 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.ser.std.StdSerializer; - -import java.io.IOException; - -class TopicSerializer extends StdSerializer { - - public TopicSerializer() { - super(Subscription.Topic.class); - } - - @Override - public void serialize(Subscription.Topic value, JsonGenerator jgen, SerializerProvider provider) - throws IOException { - jgen.writeObject(value.toString()); - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/TypedData.java b/intercom-java/src/main/java/io/intercom/api/TypedData.java deleted file mode 100644 index 88fc4ffd..00000000 --- a/intercom-java/src/main/java/io/intercom/api/TypedData.java +++ /dev/null @@ -1,9 +0,0 @@ -package io.intercom.api; - -class TypedData { - - String getType() { - throw new UnsupportedOperationException(); - } - -} diff --git a/intercom-java/src/main/java/io/intercom/api/TypedDataCollection.java b/intercom-java/src/main/java/io/intercom/api/TypedDataCollection.java deleted file mode 100644 index 440e8352..00000000 --- a/intercom-java/src/main/java/io/intercom/api/TypedDataCollection.java +++ /dev/null @@ -1,109 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; - -import java.net.URI; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(value={"page"}, ignoreUnknown = true) -@JsonInclude(JsonInclude.Include.NON_EMPTY) -public abstract class TypedDataCollection extends TypedData implements Iterator { - - public static final String NEXT_PAGE_REL = "next"; - - protected List page = Lists.newArrayList(); - - @JsonProperty("pages") - protected Map pages = Maps.newHashMap(); - - @JsonProperty("type") - protected String type; - - private TypedDataCollectionIterator iterator; - - { - iterator = new TypedDataCollectionIterator<>(this); - } - - public abstract TypedDataCollection nextPage(); - - public boolean hasNextPage() { - return pages.containsKey("next") && pages.get("next") != null; - } - - public List getPage() { - return ImmutableList.builder().addAll(page).build(); - } - - protected > C fetchNextPage(Class typeReference) { - if (hasNextPage()) { - final URI next = UriBuilder.newBuilder(pages.get(TypedDataCollection.NEXT_PAGE_REL)).build(); - final HttpClient resource = new HttpClient(next); - return resource.get(typeReference); - } else { - return null; - } - } - - public Map getPages() { - return ImmutableMap.builder().putAll(pages).build(); - } - - public String getType() { - return type; - } - - @Override - public boolean hasNext() { - return iterator.hasNext(); - } - - @Override - public T next() { - return iterator.next(); - } - - @Override - public void remove() { - iterator.remove(); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - TypedDataCollection that = (TypedDataCollection) o; - - if (page != null ? !page.equals(that.page) : that.page != null) return false; - if (pages != null ? !pages.equals(that.pages) : that.pages != null) return false; - //noinspection RedundantIfStatement - if (type != null ? !type.equals(that.type) : that.type != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = page != null ? page.hashCode() : 0; - result = 31 * result + (pages != null ? pages.hashCode() : 0); - result = 31 * result + (type != null ? type.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return getType() + "{" + - "page=" + page + - "} " + super.toString(); - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/TypedDataCollectionIterator.java b/intercom-java/src/main/java/io/intercom/api/TypedDataCollectionIterator.java deleted file mode 100644 index 1e2530b8..00000000 --- a/intercom-java/src/main/java/io/intercom/api/TypedDataCollectionIterator.java +++ /dev/null @@ -1,56 +0,0 @@ -package io.intercom.api; - -import java.util.Iterator; -import java.util.NoSuchElementException; - -class TypedDataCollectionIterator implements Iterator { - - private TypedDataCollection rollingCollection; - private int pos; - - public TypedDataCollectionIterator(TypedDataCollection startingCollection) { - this.rollingCollection = startingCollection; - this.pos = 0; - } - - public boolean hasNext() { - if (pos == rollingCollection.getPage().size()) { - if (rollingCollection.hasNextPage()) { - rollingCollection = rollingCollection.nextPage(); - pos = 0; - - if (rollingCollection.getPage().size() == 0) { - // if new page is empty - return false; - } - return true; - } else { - return false; - } - } else { - return pos <= rollingCollection.getPage().size(); - } - } - - public T next() { - iterate(); - final T t = rollingCollection.getPage().get(pos); - pos++; - return t; - } - - private void iterate() { - if (pos == rollingCollection.getPage().size()) { - if (rollingCollection.hasNextPage()) { - rollingCollection = rollingCollection.nextPage(); - pos = 0; - } else { - throw new NoSuchElementException(); - } - } - } - - public void remove() { - throw new UnsupportedOperationException(); - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/TypedMessage.java b/intercom-java/src/main/java/io/intercom/api/TypedMessage.java deleted file mode 100644 index ae2cd855..00000000 --- a/intercom-java/src/main/java/io/intercom/api/TypedMessage.java +++ /dev/null @@ -1,116 +0,0 @@ -package io.intercom.api; - - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(JsonInclude.Include.NON_DEFAULT) -abstract class TypedMessage extends TypedData { - - @SuppressWarnings("FieldCanBeLocal") - @JsonProperty("type") - protected final String type = "user_message"; - - @JsonProperty("message_type") - protected String messageType; - - @JsonProperty("id") - protected String id; - - @JsonProperty("body") - protected String body; - - @JsonProperty("created_at") - protected long createdAt; - - protected F from; - - public TypedMessage() { - } - - public String getType() { - return type; - } - - public F getFrom() { - return from; - } - - public T setFrom(F from) { - this.from = from; - return (T)this; - } - - public String getMessageType() { - return messageType; - } - - public void setMessageType(String messageType) { - this.messageType = messageType; - } - - public String getId() { - return id; - } - - public String getBody() { - return body; - } - - public T setBody(String body) { - this.body = body; - return (T)this; - } - - public long getCreatedAt() { - return createdAt; - } - - public T setCreatedAt(long createdAt) { - this.createdAt = createdAt; - return (T)this; - } - - @Override - public String toString() { - return "TypedMessage{" + - "type='" + type + '\'' + - ", messageType='" + messageType + '\'' + - ", id='" + id + '\'' + - ", body='" + body + '\'' + - ", createdAt=" + createdAt + - ", from=" + from + - "} " + super.toString(); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - TypedMessage that = (TypedMessage) o; - - if (createdAt != that.createdAt) return false; - if (type != null ? !type.equals(that.type) : that.type != null) return false; - if (messageType != null ? !messageType.equals(that.messageType) : that.messageType != null) return false; - if (id != null ? !id.equals(that.id) : that.id != null) return false; - if (body != null ? !body.equals(that.body) : that.body != null) return false; - return !(from != null ? !from.equals(that.from) : that.from != null); - - } - - @Override - public int hashCode() { - int result = type != null ? type.hashCode() : 0; - result = 31 * result + (messageType != null ? messageType.hashCode() : 0); - result = 31 * result + (id != null ? id.hashCode() : 0); - result = 31 * result + (body != null ? body.hashCode() : 0); - result = 31 * result + (int) (createdAt ^ (createdAt >>> 32)); - result = 31 * result + (from != null ? from.hashCode() : 0); - return result; - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/URIDeserializer.java b/intercom-java/src/main/java/io/intercom/api/URIDeserializer.java deleted file mode 100644 index ddf669b4..00000000 --- a/intercom-java/src/main/java/io/intercom/api/URIDeserializer.java +++ /dev/null @@ -1,44 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.fasterxml.jackson.databind.node.ValueNode; - -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URL; - -class URIDeserializer extends StdDeserializer { - - - public URIDeserializer() { - super(URI.class); - } - - @Override - public URI deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { - final ObjectMapper mapper = (ObjectMapper) jp.getCodec(); - final ValueNode vNode = mapper.readTree(jp); - - URI uri = null; - try { - uri = new URI(vNode.asText()); - } catch (URISyntaxException ignored) { - } - - if (uri == null) { - try { - final URL url = new URL(vNode.asText()); - uri = new URI(url.getProtocol(), url.getHost(), url.getPath(), url.getQuery(), url.getRef()); - } catch (MalformedURLException ignored) { - } catch (URISyntaxException ignored) { - } - } - - return uri; - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/UriBuilder.java b/intercom-java/src/main/java/io/intercom/api/UriBuilder.java deleted file mode 100644 index 150f7913..00000000 --- a/intercom-java/src/main/java/io/intercom/api/UriBuilder.java +++ /dev/null @@ -1,106 +0,0 @@ -package io.intercom.api; - -import com.google.common.base.Charsets; -import com.google.common.base.Joiner; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; - -import java.io.UnsupportedEncodingException; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; - -class UriBuilder { - - public static UriBuilder newBuilder() { - return new UriBuilder(Intercom.getApiBaseURI()); - } - - public static UriBuilder newBuilder(String uri) { - return new UriBuilder(uri); - } - - public static UriBuilder newBuilder(URI uri) { - return new UriBuilder(uri); - } - - private StringBuilder uri; - - private TreeMap paramsMap; // treemap to simplify testing - - private UriBuilder(String uri) { - try { - this.uri = new StringBuilder(new URI(uri).toASCIIString()); - } catch (URISyntaxException e) { - throw new RuntimeException(e); - } - } - - private UriBuilder(URI uri) { - this.uri = new StringBuilder(uri.toASCIIString()); - } - - public String buildString() { - return build().toASCIIString(); - } - - public URI build() { - if (paramsMap != null) { - uri.append("?"); - final StringBuilder sb = new StringBuilder(); - for (Map.Entry entry : paramsMap.entrySet()) { - sb.append(entry.getKey()).append("=").append(entry.getValue()).append("&"); - } - if (sb.lastIndexOf("&") == sb.length() - 1) { - sb.deleteCharAt(sb.length() - 1); - } - uri.append(sb); - } - - try { - return new URI(uri.toString()); - } catch (URISyntaxException e) { - throw new IntercomException("could not create api url", e); - } - } - - public UriBuilder path(String path) { - uri.append("/").append(urlEncode(path)); - return this; - } - - public UriBuilder path(List path) { - List urlEncoded = Lists.newArrayList(); - for (String s : path) { - urlEncoded.add(urlEncode(s)); - } - uri.append("/").append(Joiner.on("/").join(urlEncoded)); - return this; - } - - public UriBuilder query(String param, String value) { - if (paramsMap == null) { - paramsMap = Maps.newTreeMap(); - } - paramsMap.put(urlEncode(param), urlEncode(value)); - return this; - } - - public UriBuilder query(Map params) { - for (Map.Entry entry : params.entrySet()) { - query(entry.getKey(), entry.getValue()); - } - return this; - } - - private String urlEncode(String param) { - try { - // URLEncoder is a html forms encoder not a percent encoder - return java.net.URLEncoder.encode(param, Charsets.UTF_8.name()).replaceAll("\\+", "%20"); - } catch (UnsupportedEncodingException e) { - throw new IntercomException("could not encode url param " + param, e); - } - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/User.java b/intercom-java/src/main/java/io/intercom/api/User.java deleted file mode 100644 index 4964f5d5..00000000 --- a/intercom-java/src/main/java/io/intercom/api/User.java +++ /dev/null @@ -1,719 +0,0 @@ -package io.intercom.api; - - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; - -import java.net.URI; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(JsonInclude.Include.NON_DEFAULT) -public class User extends TypedData implements Replier { - - private static final Map SENTINEL = Maps.newHashMap(); - private static final ArrayList BULK_PATHS = Lists.newArrayListWithExpectedSize(2); - - static { - BULK_PATHS.add("bulk"); - BULK_PATHS.add("users"); - } - - private static List buildUserUpdateCompanies(User user) { - return CompanyUpdateBuilder.buildUserUpdateCompanies(user.getCompanyCollection(), user.getRemoveCompanyCollection()); - } - - public static User find(String id) - throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException { - final URI users = UriBuilder.newBuilder().path("users").path(id).build(); - final HttpClient resource = new HttpClient(users); - return resource.get(User.class); - } - - public static User find(Map params) - throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException { - if ((!params.containsKey("email")) && (!params.containsKey("user_id"))) { - throw new InvalidException("a user find must include an email or user_id parameter"); - } - return DataResource.find(params, "users", User.class); - } - - public static User create(User user) - throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException { - return DataResource.create(UserUpdate.buildFrom(user), "users", User.class); - } - - public static User update(User user) throws InvalidException, AuthorizationException { - // only send fields the server allows for update - return DataResource.update(UserUpdate.buildFrom(user), "users", User.class); - } - - /** - * @deprecated Replaced by {@link #archive(String)}. Renamed for consistency with API language - */ - public static User delete(String id) { - return archive(id); - } - - public static User archive(String id) - throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException { - return DataResource.delete(id, "users", User.class); - } - - public static UserPermanentDeleteResponse permanentDelete(String id) - throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException { - - final URI uri = UriBuilder.newBuilder() - .path("user_delete_requests") - .build(); - return new HttpClient(uri) - .post(UserPermanentDeleteResponse.class, new UserPermanentDeleteRequest(id)); - } - - /** - * @deprecated Replaced by {@link #archive(Map)}. Renamed for consistency with API language - */ - @Deprecated - public static User delete(Map params) - throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException { - return archive(params); - } - - public static User archive(Map params) - throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException { - return DataResource.delete(params, "users", User.class); - } - - public static UserCollection list(Map params) - throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException { - return DataResource.list(params, "users", UserCollection.class); - } - - public static UserCollection list() - throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException { - return DataResource.list(SENTINEL, "users", UserCollection.class); - } - - public static ScrollableUserCollection scroll() - throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException { - return DataResource.scroll(null, "users", ScrollableUserCollection.class); - } - - public static Job submit(final List> items) - throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException { - return submit(items, null); - } - - public static Job submit(final List> items, Job job) - throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException { - return Job.submit(UserUpdate.validateAndConvertJobItems(items), job, BULK_PATHS); - } - - public static JobItemCollection listJobErrorFeed(String jobID) - throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException { - return Job.listJobErrorFeed(jobID, User.class); - } - - @SuppressWarnings("UnusedDeclaration") - @JsonIgnoreProperties(ignoreUnknown = true) - @JsonInclude(JsonInclude.Include.NON_DEFAULT) - static class UserUpdate extends TypedData { - - private static final List BULK_METHODS = Lists.newArrayList("post", "delete"); - - static UserUpdate buildFrom(User user) { - final UserUpdate userUpdate = new UserUpdate(); - userUpdate.userId = user.getUserId(); - userUpdate.email = user.getEmail(); - userUpdate.phone = user.getPhone(); - userUpdate.id = user.getId(); - userUpdate.remoteCreatedAt = user.getRemoteCreatedAt(); - userUpdate.name = user.getName(); - userUpdate.lastSeenIp = user.getLastSeenIp(); - userUpdate.customAttributes = user.getCustomAttributes(); - userUpdate.lastSeenUserAgent = user.getUserAgentData(); - - if(! buildUserUpdateCompanies(user).isEmpty()) { - userUpdate.companyCollection = buildUserUpdateCompanies(user); - } - - userUpdate.avatar = user.getAvatar(); - userUpdate.lastRequestAt = user.getLastRequestAt(); - userUpdate.signedUpAt = user.getSignedUpAt(); - userUpdate.unsubscribedFromEmails = user.getUnsubscribedFromEmails(); - userUpdate.updateLastRequestAt = user.isUpdateLastRequestAt(); - userUpdate.newSession = user.isNewSession(); - return userUpdate; - } - - static List> validateAndConvertJobItems(List> items) { - final List> updateItems = Lists.newArrayList(); - final JobSupport jobSupport = new JobSupport(); - for (JobItem item : items) { - jobSupport.validateJobItem(item, BULK_METHODS); - final JobItem jobItem = new JobItem(item.getMethod(), buildFrom(item.getData()), item.getData().getType()); - updateItems.add(jobItem); - } - return updateItems; - } - - @JsonProperty("type") - @JsonInclude(JsonInclude.Include.NON_DEFAULT) - private String type; - - @JsonProperty("id") - private String id; - - @JsonProperty("user_id") - private String userId; - - @JsonProperty("email") - private String email; - - @JsonProperty("phone") - private String phone; - - @JsonProperty("remote_created_at") - private long remoteCreatedAt; - - @JsonProperty("name") - private String name; - - @JsonProperty("last_seen_ip") - private String lastSeenIp; - - @JsonProperty("avatar") - private Avatar avatar; - - @JsonIgnoreProperties(ignoreUnknown = false) - @JsonProperty("custom_attributes") - private Map customAttributes = Maps.newHashMap(); - - @JsonProperty("last_seen_user_agent") - private String lastSeenUserAgent; - - @JsonProperty("companies") - private List companyCollection; - - @JsonProperty("last_request_at") - private long lastRequestAt; - - @JsonProperty("signed_up_at") - private long signedUpAt; - - /** - * Making this a Boolean allows us to send true or false as set - * values leaving null the ignored field for NON_DEFAULT. A - * primitive would result in false not being sent - */ - @JsonProperty("unsubscribed_from_emails") - @JsonInclude(JsonInclude.Include.NON_DEFAULT) - private Boolean unsubscribedFromEmails; - - /** - * Making this a Boolean allows us to send true or false as set - * values leaving null the ignored field for NON_DEFAULT. A - * primitive would result in false not being sent - */ - @JsonProperty("update_last_request_at") - @JsonInclude(JsonInclude.Include.NON_DEFAULT) - private Boolean updateLastRequestAt; - - /** - * Making this a Boolean allows us to send true or false as set - * values leaving null the ignored field for NON_DEFAULT. A - * primitive would result in false not being sent - */ - @JsonProperty("new_session") - @JsonInclude(JsonInclude.Include.NON_DEFAULT) - private Boolean newSession; - - public UserUpdate() { - } - - public String getType() { - return type; - } - - public String getId() { - return id; - } - - public String getUserId() { - return userId; - } - - public String getEmail() { - return email; - } - - public String getPhone() { - return phone; - } - - public long getRemoteCreatedAt() { - return remoteCreatedAt; - } - - public String getName() { - return name; - } - - public String getLastSeenIp() { - return lastSeenIp; - } - - public Map getCustomAttributes() { - return customAttributes; - } - - public String getLastSeenUserAgent() { - return lastSeenUserAgent; - } - - public List getCompanyCollection() { - return companyCollection; - } - - public long getLastRequestAt() { - return lastRequestAt; - } - - public long getSignedUpAt() { - return signedUpAt; - } - - public Boolean getUnsubscribedFromEmails() { - return unsubscribedFromEmails; - } - - public Boolean isUpdateLastRequestAt() { - return updateLastRequestAt; - } - - public Boolean isNewSession() { - return newSession; - } - - public Avatar getAvatar() { - return avatar; - } - - } - - @JsonProperty("type") - @JsonInclude(JsonInclude.Include.ALWAYS) - private final String type = "user"; - - @JsonProperty("id") - private String id; - - @JsonProperty("name") - private String name; - - @JsonProperty("email") - private String email; - - @JsonProperty("phone") - private String phone; - - @JsonProperty("user_id") - private String userId; - - @JsonProperty("pseudonym") - private String pseudonym; - - @JsonProperty("avatar") - private Avatar avatar; - - @JsonProperty("created_at") - private long createdAt; - - @JsonProperty("updated_at") - private long updatedAt; - - @JsonProperty("remote_created_at") - private long remoteCreatedAt; - - @JsonProperty("unsubscribed_from_emails") - private Boolean unsubscribedFromEmails; - - @JsonProperty("session_count") - private int sessionCount; - - @JsonProperty("last_request_at") - private long lastRequestAt; - - @JsonProperty("signed_up_at") - private long signedUpAt; - - @JsonProperty("last_seen_ip") - private String lastSeenIp; - - @JsonIgnoreProperties(ignoreUnknown = false) - @JsonProperty("custom_attributes") - private Map customAttributes = Maps.newHashMap(); - - @JsonProperty("user_agent_data") - private String userAgentData; - - @JsonProperty("location_data") - private LocationData locationData; - - @JsonIgnoreProperties(ignoreUnknown = false) - @JsonProperty("companies") - private CompanyCollection companyCollection = new CompanyCollection(); - - @JsonProperty("social_profiles") - private SocialProfileCollection socialProfileCollection = new SocialProfileCollection(); - - @JsonProperty("segments") - private SegmentCollection segmentCollection = new SegmentCollection(); - - @JsonProperty("tags") - private TagCollection tagCollection = new TagCollection(); - - @JsonProperty("update_last_request_at") - private Boolean updateLastRequestAt; - - @JsonProperty("new_session") - private Boolean newSession; - - private Boolean untag; - - private CompanyCollection removeCompanyCollection = new CompanyCollection(); - - public User() { - } - - public User untag() { - untag = Boolean.TRUE; - return this; - } - - boolean isUntag() { - return untag == null ? false : untag; - } - - @JsonIgnore - public String getReplyType() { - return getType() + "_reply"; - } - - public String getType() { - return type; - } - - public String getId() { - return id; - } - - public User setId(String id) { - this.id = id; - return this; - } - - public String getName() { - return name; - } - - public User setName(String name) { - this.name = name; - return this; - } - - public String getEmail() { - return email; - } - - public User setEmail(String email) { - this.email = email; - return this; - } - - public String getPhone() { - return phone; - } - - public User setPhone(String phone) { - this.phone = phone; - return this; - } - - public String getUserId() { - return userId; - } - - public User setUserId(String userId) { - this.userId = userId; - return this; - } - - public String getPseudonym() { - return pseudonym; - } - - public Avatar getAvatar() { - return avatar; - } - - public User setAvatar(Avatar avatar) { - this.avatar = avatar; - return this; - } - - public long getCreatedAt() { - return createdAt; - } - - public long getUpdatedAt() { - return updatedAt; - } - - public long getRemoteCreatedAt() { - return remoteCreatedAt; - } - - public User setRemoteCreatedAt(long remoteCreatedAt) { - this.remoteCreatedAt = remoteCreatedAt; - return this; - } - - public Boolean getUnsubscribedFromEmails() { - return unsubscribedFromEmails; - } - - public User setUnsubscribedFromEmails(boolean unsubscribedFromEmails) { - this.unsubscribedFromEmails = unsubscribedFromEmails; - return this; - } - - public int getSessionCount() { - return sessionCount; - } - - public long getLastRequestAt() { - return lastRequestAt; - } - - public User setLastRequestAt(long lastRequestAt) { - this.lastRequestAt = lastRequestAt; - return this; - } - - public long getSignedUpAt() { - return signedUpAt; - } - - public User setSignedUpAt(long signedUpAt) { - this.signedUpAt = signedUpAt; - return this; - } - - public String getLastSeenIp() { - return lastSeenIp; - } - - public User setLastSeenIp(String lastSeenIp) { - this.lastSeenIp = lastSeenIp; - return this; - } - - public Map getCustomAttributes() { - return customAttributes; - } - - public User setCustomAttributes(Map customAttributes) { - this.customAttributes = customAttributes; - return this; - } - - public User addCustomAttribute(CustomAttribute customAttribute) { - this.customAttributes.put(customAttribute.getName(), customAttribute); - return this; - } - - public String getUserAgentData() { - return userAgentData; - } - - public User setUserAgentData(String userAgentData) { - this.userAgentData = userAgentData; - return this; - } - - public LocationData getLocationData() { - return locationData; - } - - public CompanyCollection getCompanyCollection() { - return companyCollection; - } - - public User setCompanyCollection(CompanyCollection companyCollection) { - this.companyCollection = companyCollection; - return this; - } - - public User addCompany(Company company) { - // sneak past the immutable list - this.companyCollection.addCompany(company); - return this; - } - - public User removeCompany(Company company) { - this.removeCompanyCollection.addCompany(company); - return this; - } - - public SocialProfileCollection getSocialProfileCollection() { - return socialProfileCollection; - } - - public SegmentCollection getSegmentCollection() { - return segmentCollection; - } - - public TagCollection getTagCollection() { - return tagCollection; - } - - public Boolean isUpdateLastRequestAt() { - return updateLastRequestAt; - } - - public User setUpdateLastRequestAt(boolean updateLastRequestAt) { - this.updateLastRequestAt = updateLastRequestAt; - return this; - } - - public Boolean isNewSession() { - return newSession; - } - - public User setNewSession(boolean newSession) { - this.newSession = newSession; - return this; - } - - CompanyCollection getRemoveCompanyCollection() { - return removeCompanyCollection; - } - - void setRemoveCompanyCollection(CompanyCollection removeCompanyCollection) { - this.removeCompanyCollection = removeCompanyCollection; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - User user = (User) o; - - if (createdAt != user.createdAt) return false; - if (lastRequestAt != user.lastRequestAt) return false; - if (signedUpAt != user.signedUpAt) return false; - if (newSession != user.newSession) return false; - if (remoteCreatedAt != user.remoteCreatedAt) return false; - if (sessionCount != user.sessionCount) return false; - if (unsubscribedFromEmails != user.unsubscribedFromEmails) return false; - if (updateLastRequestAt != user.updateLastRequestAt) return false; - if (updatedAt != user.updatedAt) return false; - if (avatar != null ? !avatar.equals(user.avatar) : user.avatar != null) return false; - if (companyCollection != null ? !companyCollection.equals(user.companyCollection) : user.companyCollection != null) - return false; - if (customAttributes != null ? !customAttributes.equals(user.customAttributes) : user.customAttributes != null) - return false; - if (email != null ? !email.equals(user.email) : user.email != null) return false; - if (phone != null ? !phone.equals(user.phone) : user.phone != null) return false; - if (id != null ? !id.equals(user.id) : user.id != null) return false; - if (lastSeenIp != null ? !lastSeenIp.equals(user.lastSeenIp) : user.lastSeenIp != null) return false; - if (locationData != null ? !locationData.equals(user.locationData) : user.locationData != null) return false; - if (name != null ? !name.equals(user.name) : user.name != null) return false; - if (segmentCollection != null ? !segmentCollection.equals(user.segmentCollection) : user.segmentCollection != null) - return false; - if (socialProfileCollection != null ? !socialProfileCollection.equals(user.socialProfileCollection) : user.socialProfileCollection != null) - return false; - if (tagCollection != null ? !tagCollection.equals(user.tagCollection) : user.tagCollection != null) - return false; - if (!type.equals(user.type)) return false; - if (untag != null ? !untag.equals(user.untag) : user.untag != null) return false; - if (userAgentData != null ? !userAgentData.equals(user.userAgentData) : user.userAgentData != null) - return false; - //noinspection RedundantIfStatement - if (userId != null ? !userId.equals(user.userId) : user.userId != null) return false; - - return true; - } - - - @Override - public int hashCode() { - int result = type != null ? type.hashCode() : 0; - result = 31 * result + (id != null ? id.hashCode() : 0); - result = 31 * result + (name != null ? name.hashCode() : 0); - result = 31 * result + (email != null ? email.hashCode() : 0); - result = 31 * result + (phone != null ? phone.hashCode() : 0); - result = 31 * result + (userId != null ? userId.hashCode() : 0); - result = 31 * result + (pseudonym != null ? pseudonym.hashCode() : 0); - result = 31 * result + (avatar != null ? avatar.hashCode() : 0); - result = 31 * result + (int) (createdAt ^ (createdAt >>> 32)); - result = 31 * result + (int) (updatedAt ^ (updatedAt >>> 32)); - result = 31 * result + (int) (remoteCreatedAt ^ (remoteCreatedAt >>> 32)); - result = 31 * result + (unsubscribedFromEmails != null ? unsubscribedFromEmails.hashCode() : 0); - result = 31 * result + sessionCount; - result = 31 * result + (int) (lastRequestAt ^ (lastRequestAt >>> 32)); - result = 31 * result + (int) (signedUpAt ^ (signedUpAt >>> 32)); - result = 31 * result + (lastSeenIp != null ? lastSeenIp.hashCode() : 0); - result = 31 * result + (customAttributes != null ? customAttributes.hashCode() : 0); - result = 31 * result + (userAgentData != null ? userAgentData.hashCode() : 0); - result = 31 * result + (locationData != null ? locationData.hashCode() : 0); - result = 31 * result + (companyCollection != null ? companyCollection.hashCode() : 0); - result = 31 * result + (socialProfileCollection != null ? socialProfileCollection.hashCode() : 0); - result = 31 * result + (segmentCollection != null ? segmentCollection.hashCode() : 0); - result = 31 * result + (tagCollection != null ? tagCollection.hashCode() : 0); - result = 31 * result + (updateLastRequestAt != null ? updateLastRequestAt.hashCode() : 0); - result = 31 * result + (newSession != null ? newSession.hashCode() : 0); - result = 31 * result + (untag != null ? untag.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "User{" + - "type='" + type + '\'' + - ", id='" + id + '\'' + - ", name='" + name + '\'' + - ", email='" + email + '\'' + - ", phone='" + phone + '\'' + - ", userId='" + userId + '\'' + - ", avatar=" + avatar + - ", createdAt=" + createdAt + - ", updatedAt=" + updatedAt + - ", remoteCreatedAt=" + remoteCreatedAt + - ", unsubscribedFromEmails=" + unsubscribedFromEmails + - ", sessionCount=" + sessionCount + - ", lastRequestAt=" + lastRequestAt + - ", signedUpAt=" + signedUpAt + - ", lastSeenIp='" + lastSeenIp + '\'' + - ", customAttributes=" + customAttributes + - ", userAgentData='" + userAgentData + '\'' + - ", locationData=" + locationData + - ", companyCollection=" + companyCollection + - ", socialProfileCollection=" + socialProfileCollection + - ", segmentCollection=" + segmentCollection + - ", tagCollection=" + tagCollection + - ", updateLastRequestAt=" + updateLastRequestAt + - ", newSession=" + newSession + - ", untag=" + untag + - "} " + super.toString(); - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/UserCollection.java b/intercom-java/src/main/java/io/intercom/api/UserCollection.java deleted file mode 100644 index 78394909..00000000 --- a/intercom-java/src/main/java/io/intercom/api/UserCollection.java +++ /dev/null @@ -1,32 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(ignoreUnknown = true) -public class UserCollection extends TypedDataCollection { - - - public UserCollection() { - } - - public UserCollection(List users) { - this(); - this.page = users; - } - - @SuppressWarnings("EmptyMethod") - @JsonProperty("users") - @Override - public List getPage() { - return super.getPage(); - } - - @Override - public UserCollection nextPage() { - return fetchNextPage(UserCollection.class); - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/UserMessage.java b/intercom-java/src/main/java/io/intercom/api/UserMessage.java deleted file mode 100644 index 244595bf..00000000 --- a/intercom-java/src/main/java/io/intercom/api/UserMessage.java +++ /dev/null @@ -1,28 +0,0 @@ -package io.intercom.api; - - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; - - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(JsonInclude.Include.NON_DEFAULT) -public class UserMessage extends TypedMessage { - - public UserMessage() { - } - - @JsonIgnore - @Deprecated - public UserMessage setUser(User user) { - this.from = user; - return this; - } - - @Override - public String toString() { - return "UserMessage{} " + super.toString(); - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/UserPermanentDeleteRequest.java b/intercom-java/src/main/java/io/intercom/api/UserPermanentDeleteRequest.java deleted file mode 100644 index 2d12d8b0..00000000 --- a/intercom-java/src/main/java/io/intercom/api/UserPermanentDeleteRequest.java +++ /dev/null @@ -1,37 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(JsonInclude.Include.NON_EMPTY) -public class UserPermanentDeleteRequest { - - @JsonProperty("intercom_user_id") - private String intercomUserId; - - public UserPermanentDeleteRequest() { - } - - public UserPermanentDeleteRequest(String intercomUserId) { - this.setIntercomUserId(intercomUserId); - } - - public String getIntercomUserId() { - return intercomUserId; - } - - public UserPermanentDeleteRequest setIntercomUserId(String intercomUserId) { - this.intercomUserId = intercomUserId; - return this; - } - - @Override - public String toString() { - return "UserPermanentlyDeleteResponse{" + - "intercomUserId='" + intercomUserId + '\'' + - "} " + super.toString(); - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/UserPermanentDeleteResponse.java b/intercom-java/src/main/java/io/intercom/api/UserPermanentDeleteResponse.java deleted file mode 100644 index d67fb2bf..00000000 --- a/intercom-java/src/main/java/io/intercom/api/UserPermanentDeleteResponse.java +++ /dev/null @@ -1,33 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(JsonInclude.Include.NON_EMPTY) -public class UserPermanentDeleteResponse { - - @JsonProperty("id") - private String id; - - public UserPermanentDeleteResponse() { - } - - public String getId() { - return id; - } - - public UserPermanentDeleteResponse setId(String id) { - this.id = id; - return this; - } - - @Override - public String toString() { - return "UserPermanentDeleteResponse{" + - "id='" + id + '\'' + - "} " + super.toString(); - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/UserReply.java b/intercom-java/src/main/java/io/intercom/api/UserReply.java deleted file mode 100644 index 33c4828c..00000000 --- a/intercom-java/src/main/java/io/intercom/api/UserReply.java +++ /dev/null @@ -1,69 +0,0 @@ -package io.intercom.api; - - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(JsonInclude.Include.NON_EMPTY) -public class UserReply extends Reply { - - @JsonIgnoreProperties(ignoreUnknown = true) - @JsonInclude(JsonInclude.Include.NON_EMPTY) - static class UserStringReply { - - private UserReply reply; - - public UserStringReply(UserReply reply) { - this.reply = reply; - } - - @JsonProperty("type") - public String getType() { - return reply.getType(); - } - - @SuppressWarnings("SameReturnValue") - @JsonProperty("message_type") - public String getMessageType() { - return "comment"; - } - - @JsonProperty("body") - public String getBody() { - return reply.getBody(); - } - - @JsonProperty("intercom_user_id") - public String getIntercomUserID() { - return reply.getFrom().getId(); - } - - @JsonProperty("user_id") - public String getUserID() { - return reply.getFrom().getUserId(); - } - - @JsonProperty("email") - public String getEmail() { - return reply.getFrom().getEmail(); - } - - @JsonProperty("attachment_urls") - private String[] getAttachmentUrls() { - return reply.getAttachmentUrls(); - } - } - - public UserReply(User user) { - this.from = user; - } - - @Override - public String toString() { - return "UserReply{} " + super.toString(); - } -} diff --git a/intercom-java/src/main/java/io/intercom/api/Visitor.java b/intercom-java/src/main/java/io/intercom/api/Visitor.java deleted file mode 100644 index d7cfc5a6..00000000 --- a/intercom-java/src/main/java/io/intercom/api/Visitor.java +++ /dev/null @@ -1,770 +0,0 @@ -package io.intercom.api; - - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.google.common.annotations.VisibleForTesting; -import com.google.common.collect.Maps; - -import java.net.URI; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -@SuppressWarnings("UnusedDeclaration") -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(JsonInclude.Include.NON_DEFAULT) -public class Visitor extends TypedData { - - private static final Map SENTINEL = Maps.newHashMap(); - - public static Visitor findByID(String id) - throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException { - return new HttpClient(visitorURI(id)).get(Visitor.class); - } - - public static Visitor findByUserID(String userID) - throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException { - final Map params = Maps.newHashMap(); - params.put("user_id", userID); - return DataResource.find(params, "visitors", Visitor.class); - } - - public static Visitor update(Visitor v) - throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException { - return DataResource.updatePut(VisitorUpdate.buildFrom(v), visitorURI(""), Visitor.class); - } - - public static Visitor delete(Visitor v) - throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException { - return DataResource.delete(v.getID(), "visitors", Visitor.class); - } - - public static Visitor delete(String id) - throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException { - return DataResource.delete(id, "visitors", Visitor.class); - } - - public static Contact convertToContact(Visitor v) - throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException { - return DataResource.post(VisitorConvertBuilder.buildConvertToLead(v), convertURI(), Contact.class); - } - - public static User convertToUser(Visitor v, User u) - throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException { - return DataResource.post(VisitorConvertBuilder.buildConvertToUser(v, u), convertURI(), User.class); - } - - private static URI visitorURI(String id) { - return UriBuilder.newBuilder().path("visitors").path(id).build(); - } - - private static URI convertURI() { - return UriBuilder.newBuilder().path("visitors").path("convert").build(); - } - - - static class VisitorConvertBuilder { - - static VisitorConvert buildConvertToLead(Visitor v) throws InvalidException { - return new VisitorConvertBuilder().build(v); - } - - static VisitorConvert buildConvertToUser(Visitor v, User u) throws InvalidException { - return new VisitorConvertBuilder().build(v, u); - } - - VisitorConvert build(Visitor v) throws InvalidException { - return new VisitorConvert(buildConvertVisitor(v)); - } - - VisitorConvert build(Visitor v, User u) throws InvalidException { - return new VisitorConvert(buildConvertVisitor(v), buildConvertUser(u)); - } - - HashMap buildConvertVisitor(Visitor v) { - final HashMap convertVisitor = Maps.newHashMap(); - - if (v.getID() != null) { - convertVisitor.put("id", v.getID()); - } - - if (v.getUserID() != null) { - convertVisitor.put("user_id", v.getUserID()); - } - - checkValidConvertVisitor(convertVisitor); - - return convertVisitor; - } - HashMap buildConvertUser(User u) { - final HashMap convertUser = Maps.newHashMap(); - - if (u.getId() != null) { - convertUser.put("id", u.getId()); - } - - if (u.getUserId() != null) { - convertUser.put("user_id", u.getUserId()); - } - - if (u.getEmail() != null) { - convertUser.put("email", u.getEmail()); - } - - checkValidConvertUser(convertUser); - - return convertUser; - } - - void checkValidConvertVisitor(HashMap convertUser) { - if ((!convertUser.containsKey("id")) && (!convertUser.containsKey("user_id"))) { - throw new InvalidException("a convert visitor must include at least one of, an id or user_id parameter"); - } - } - void checkValidConvertUser(HashMap convertUser) { - if ((!convertUser.containsKey("id")) && (!convertUser.containsKey("user_id")) && (!convertUser.containsKey("email"))) { - throw new InvalidException("a convert user must include at least one of, an id, user_id or email parameter"); - } - } - } - - @SuppressWarnings("UnusedDeclaration") - @JsonIgnoreProperties(ignoreUnknown = true) - @JsonInclude(JsonInclude.Include.NON_DEFAULT) - static class VisitorConvert { - - @JsonProperty("visitor") - private Map visitor; - - @JsonProperty("user") - private Map user; - - @JsonProperty("type") - private String type; - - public VisitorConvert() { - } - - public VisitorConvert(Map visitor) { - this.visitor = visitor; - this.type = "lead"; - } - - public VisitorConvert(Map visitor, Map user) { - this.visitor = visitor; - this.user = user; - this.type = "user"; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public Map getVisitor() { - return visitor; - } - - public void setVisitor(Map visitor) { - this.visitor = visitor; - } - - public Map getUser() { - return user; - } - - public void setUser(Map user) { - this.user = user; - } - } - - @SuppressWarnings("UnusedDeclaration") - @JsonIgnoreProperties(ignoreUnknown = true) - @JsonInclude(JsonInclude.Include.NON_DEFAULT) - static class VisitorUpdate extends TypedData { - - static VisitorUpdate buildFrom(Visitor v) { - final VisitorUpdate visitorUpdate = new VisitorUpdate(); - visitorUpdate.id = v.getID(); // propagated, noset - visitorUpdate.userID = v.getUserID(); // propagated, noset - if(v.getEmail() != null && v.getEmail() != "") visitorUpdate.email = v.getEmail(); - visitorUpdate.phone = v.getPhone(); - visitorUpdate.name = v.getName(); - visitorUpdate.lastSeenIP = v.getLastSeenIP(); - visitorUpdate.customAttributes = v.getCustomAttributes(); - visitorUpdate.avatar = v.getAvatar(); - visitorUpdate.lastRequestAt = v.getLastRequestAt(); - visitorUpdate.lastSeenUserAgent= v.getLastSeenUserAgent(); - visitorUpdate.unsubscribedFromEmails = v.getUnsubscribedFromEmails(); - visitorUpdate.utmCampaign = v.getUtmCampaign(); - visitorUpdate.utmContent = v.getUtmContent(); - visitorUpdate.utmMedium= v.getUtmMedium(); - visitorUpdate.utmSource= v.getUtmSource(); - visitorUpdate.utmTerm= v.getUtmTerm(); - return visitorUpdate; - } - - @JsonProperty("type") - @JsonInclude(JsonInclude.Include.NON_DEFAULT) - private String type; - - @JsonProperty("id") - private String id; - - @JsonProperty("user_id") - private String userID; - - @JsonProperty("email") - @JsonInclude(JsonInclude.Include.NON_EMPTY) - private String email; - - @JsonProperty("phone") - private String phone; - - @JsonProperty("name") - private String name; - - @JsonProperty("utm_campaign") - private String utmCampaign; - - @JsonProperty("utm_content") - private String utmContent; - - @JsonProperty("utm_medium") - private String utmMedium; - - @JsonProperty("utm_source") - private String utmSource; - - @JsonProperty("utm_term") - private String utmTerm; - - @JsonProperty("last_seen_ip") - private String lastSeenIP; - - @JsonProperty("avatar") - private Avatar avatar; - - @JsonIgnoreProperties(ignoreUnknown = false) - @JsonProperty("custom_attributes") - private Map customAttributes = Maps.newHashMap(); - - @JsonProperty("last_seen_user_agent") - private String lastSeenUserAgent; - - @JsonProperty("companies") - private List companyCollection; - - @JsonProperty("last_request_at") - private long lastRequestAt; - - @JsonProperty("signed_up_at") - private String signedUpAt; - - /* - * Making these Booleans allows us to send true or false as set - * values leaving null the ignored field for NON_DEFAULT. A - * primitive would result in false not being sent - */ - - @JsonProperty("unsubscribed_from_emails") - @JsonInclude(JsonInclude.Include.NON_DEFAULT) - private Boolean unsubscribedFromEmails; - - @JsonProperty("update_last_request_at") - @JsonInclude(JsonInclude.Include.NON_DEFAULT) - private Boolean updateLastRequestAt; - - - public VisitorUpdate() { - } - - public String getType() { - return type; - } - - public String getID() { - return id; - } - - public String getUserID() { - return userID; - } - - public String getEmail() { - return email; - } - - public String getPhone() { - return phone; - } - - public String getName() { - return name; - } - - public Avatar getAvatar() { - return avatar; - } - - public String getUtmCampaign() { - return utmCampaign; - } - - public String getUtmContent() { - return utmContent; - } - - public String getUtmMedium() { - return utmMedium; - } - - public String getUtmSource() { - return utmSource; - } - - public String getUtmTerm() { - return utmTerm; - } - - public String getLastSeenIP() { - return lastSeenIP; - } - - public Map getCustomAttributes() { - return customAttributes; - } - - public String getLastSeenUserAgent() { - return lastSeenUserAgent; - } - - public List getCompanyCollection() { - return companyCollection; - } - - public long getLastRequestAt() { - return lastRequestAt; - } - - public Boolean getUnsubscribedFromEmails() { - return unsubscribedFromEmails; - } - - public Boolean isUpdateLastRequestAt() { - return updateLastRequestAt; - } - } - - @JsonProperty("type") - @JsonInclude(JsonInclude.Include.ALWAYS) - private final String type = "visitor"; - - @JsonProperty("id") - private String id; - - @JsonProperty("user_id") - private String userID; - - @JsonProperty("email") - private String email; - - @JsonProperty("phone") - private String phone; - - @JsonProperty("name") - private String name; - - @JsonProperty("pseudonym") - private String pseudonym; - - @JsonProperty("avatar") - private Avatar avatar; - - @JsonProperty("created_at") - private long createdAt; - - @JsonProperty("updated_at") - private long updatedAt; - - @JsonProperty("last_seen_user_agent") - private String lastSeenUserAgent; - - @JsonProperty("referrer") - private String referrer; - - @JsonProperty("utm_campaign") - private String utmCampaign; - - @JsonProperty("utm_content") - private String utmContent; - - @JsonProperty("utm_medium") - private String utmMedium; - - @JsonProperty("utm_source") - private String utmSource; - - @JsonProperty("utm_term") - private String utmTerm; - - @JsonProperty("unsubscribed_from_emails") - private Boolean unsubscribedFromEmails; - - @JsonProperty("session_count") - private int sessionCount; - - @JsonProperty("last_request_at") - private long lastRequestAt; - - @JsonProperty("last_seen_ip") - private String lastSeenIP; - - @JsonIgnoreProperties(ignoreUnknown = false) - @JsonProperty("custom_attributes") - private Map customAttributes = Maps.newHashMap(); - - @JsonProperty("user_agent_data") - private String userAgentData; - - @JsonProperty("location_data") - private LocationData locationData; - - @JsonIgnoreProperties(ignoreUnknown = false) - @JsonProperty("companies") - private CompanyCollection companyCollection = new CompanyCollection(); - - @JsonProperty("social_profiles") - private SocialProfileCollection socialProfileCollection = new SocialProfileCollection(); - - @JsonProperty("segments") - private SegmentCollection segmentCollection = new SegmentCollection(); - - @JsonProperty("tags") - private TagCollection tagCollection = new TagCollection(); - - @JsonProperty("update_last_request_at") - private Boolean updateLastRequestAt; - - public Visitor() { - } - - public String getType() { - return type; - } - - public String getID() { - return id; - } - - public Visitor setID(String id) { - this.id = id; - return this; - } - - public String getName() { - return name; - } - - public Visitor setName(String name) { - this.name = name; - return this; - } - - public String getPseudonym() { - return pseudonym; - } - - public String getEmail() { - return email; - } - - public Visitor setEmail(String email) { - this.email = email; - return this; - } - - public String getPhone() { - return phone; - } - - public Visitor setPhone(String phone) { - this.phone = phone; - return this; - } - - public String getUserID() { - return userID; - } - - public Visitor setUserID(String userID) { - this.userID = userID; - return this; - } - - public Avatar getAvatar() { - return avatar; - } - - public Visitor setAvatar(Avatar avatar) { - this.avatar = avatar; - return this; - } - - public long getCreatedAt() { - return createdAt; - } - - public long getUpdatedAt() { - return updatedAt; - } - - public Boolean getUnsubscribedFromEmails() { - return unsubscribedFromEmails; - } - - public Visitor setUnsubscribedFromEmails(boolean unsubscribedFromEmails) { - this.unsubscribedFromEmails = unsubscribedFromEmails; - return this; - } - - public int getSessionCount() { - return sessionCount; - } - - public long getLastRequestAt() { - return lastRequestAt; - } - - public Visitor setLastRequestAt(long lastRequestAt) { - this.lastRequestAt = lastRequestAt; - return this; - } - - public String getLastSeenIP() { - return lastSeenIP; - } - - public Visitor setLastSeenIP(String lastSeenIP) { - this.lastSeenIP = lastSeenIP; - return this; - } - - public String getLastSeenUserAgent() { - return lastSeenUserAgent; - } - - public Visitor setLastSeenUserAgent(String lastSeenUserAgent) { - this.lastSeenUserAgent = lastSeenUserAgent; - return this; - } - - public Map getCustomAttributes() { - return customAttributes; - } - - public Visitor setCustomAttributes(Map customAttributes) { - this.customAttributes = customAttributes; - return this; - } - - public Visitor addCustomAttribute(CustomAttribute customAttribute) { - this.customAttributes.put(customAttribute.getName(), customAttribute); - return this; - } - - public String getUserAgentData() { - return userAgentData; - } - - public LocationData getLocationData() { - return locationData; - } - - public CompanyCollection getCompanyCollection() { - return companyCollection; - } - - public SocialProfileCollection getSocialProfileCollection() { - return socialProfileCollection; - } - - public SegmentCollection getSegmentCollection() { - return segmentCollection; - } - - public TagCollection getTagCollection() { - return tagCollection; - } - - public Boolean isUpdateLastRequestAt() { - return updateLastRequestAt; - } - - public String getReferrer() { - return referrer; - } - - public String getUtmCampaign() { - return utmCampaign; - } - - public Visitor setUtmCampaign(String utmCampaign) { - this.utmCampaign = utmCampaign; - return this; - } - - public String getUtmContent() { - return utmContent; - } - - public Visitor setUtmContent(String utmContent) { - this.utmContent = utmContent; - return this; - } - - public String getUtmMedium() { - return utmMedium; - } - - public Visitor setUtmMedium(String utmMedium) { - this.utmMedium = utmMedium; - return this; - } - - public String getUtmSource() { - return utmSource; - } - - public Visitor setUtmSource(String utmSource) { - this.utmSource = utmSource; - return this; - } - - public String getUtmTerm() { - return utmTerm; - } - - public Visitor setUtmTerm(String utmTerm) { - this.utmTerm = utmTerm; - return this; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Visitor Visitor = (Visitor) o; - - if (createdAt != Visitor.createdAt) return false; - if (updatedAt != Visitor.updatedAt) return false; - if (sessionCount != Visitor.sessionCount) return false; - if (lastRequestAt != Visitor.lastRequestAt) return false; - if (!type.equals(Visitor.type)) return false; - if (id != null ? !id.equals(Visitor.id) : Visitor.id != null) return false; - if (name != null ? !name.equals(Visitor.name) : Visitor.name != null) return false; - if (email != null ? !email.equals(Visitor.email) : Visitor.email != null) return false; - if (phone != null ? !phone.equals(Visitor.phone) : Visitor.phone != null) return false; - if (userID != null ? !userID.equals(Visitor.userID) : Visitor.userID != null) return false; - if (avatar != null ? !avatar.equals(Visitor.avatar) : Visitor.avatar != null) return false; - if (unsubscribedFromEmails != null ? !unsubscribedFromEmails.equals(Visitor.unsubscribedFromEmails) : Visitor.unsubscribedFromEmails != null) - return false; - if (lastSeenIP != null ? !lastSeenIP.equals(Visitor.lastSeenIP) : Visitor.lastSeenIP != null) return false; - if (customAttributes != null ? !customAttributes.equals(Visitor.customAttributes) : Visitor.customAttributes != null) - return false; - if (userAgentData != null ? !userAgentData.equals(Visitor.userAgentData) : Visitor.userAgentData != null) - return false; - if (locationData != null ? !locationData.equals(Visitor.locationData) : Visitor.locationData != null) - return false; - if (companyCollection != null ? !companyCollection.equals(Visitor.companyCollection) : Visitor.companyCollection != null) - return false; - if (socialProfileCollection != null ? !socialProfileCollection.equals(Visitor.socialProfileCollection) : Visitor.socialProfileCollection != null) - return false; - if (segmentCollection != null ? !segmentCollection.equals(Visitor.segmentCollection) : Visitor.segmentCollection != null) - return false; - if (tagCollection != null ? !tagCollection.equals(Visitor.tagCollection) : Visitor.tagCollection != null) - return false; - if (updateLastRequestAt != null ? !updateLastRequestAt.equals(Visitor.updateLastRequestAt) : Visitor.updateLastRequestAt != null) - return false; - if (referrer != null ? !referrer.equals(Visitor.referrer) : Visitor.referrer != null) return false; - if (utmCampaign != null ? !utmCampaign.equals(Visitor.utmCampaign) : Visitor.utmCampaign != null) return false; - if (utmContent != null ? !utmContent.equals(Visitor.utmContent) : Visitor.utmContent != null) return false; - if (utmMedium != null ? !utmMedium.equals(Visitor.utmMedium) : Visitor.utmMedium != null) return false; - if (utmSource != null ? !utmSource.equals(Visitor.utmSource) : Visitor.utmSource != null) return false; - if (utmTerm != null ? !utmTerm.equals(Visitor.utmTerm) : Visitor.utmTerm != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = type.hashCode(); - result = 31 * result + (id != null ? id.hashCode() : 0); - result = 31 * result + (name != null ? name.hashCode() : 0); - result = 31 * result + (email != null ? email.hashCode() : 0); - result = 31 * result + (phone != null ? phone.hashCode() : 0); - result = 31 * result + (userID != null ? userID.hashCode() : 0); - result = 31 * result + (avatar != null ? avatar.hashCode() : 0); - result = 31 * result + (int) (createdAt ^ (createdAt >>> 32)); - result = 31 * result + (int) (updatedAt ^ (updatedAt >>> 32)); - result = 31 * result + (unsubscribedFromEmails != null ? unsubscribedFromEmails.hashCode() : 0); - result = 31 * result + sessionCount; - result = 31 * result + (int) (lastRequestAt ^ (lastRequestAt >>> 32)); - result = 31 * result + (lastSeenIP != null ? lastSeenIP.hashCode() : 0); - result = 31 * result + (customAttributes != null ? customAttributes.hashCode() : 0); - result = 31 * result + (userAgentData != null ? userAgentData.hashCode() : 0); - result = 31 * result + (locationData != null ? locationData.hashCode() : 0); - result = 31 * result + (companyCollection != null ? companyCollection.hashCode() : 0); - result = 31 * result + (socialProfileCollection != null ? socialProfileCollection.hashCode() : 0); - result = 31 * result + (segmentCollection != null ? segmentCollection.hashCode() : 0); - result = 31 * result + (tagCollection != null ? tagCollection.hashCode() : 0); - result = 31 * result + (updateLastRequestAt != null ? updateLastRequestAt.hashCode() : 0); - result = 31 * result + (referrer != null ? referrer.hashCode() : 0); - result = 31 * result + (utmContent != null ? utmContent.hashCode() : 0); - result = 31 * result + (utmCampaign != null ? utmCampaign.hashCode() : 0); - result = 31 * result + (utmMedium != null ? utmMedium.hashCode() : 0); - result = 31 * result + (utmSource != null ? utmSource.hashCode() : 0); - result = 31 * result + (utmTerm != null ? utmTerm.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "Visitor{" + - "type='" + type + '\'' + - ", id='" + id + '\'' + - ", name='" + name + '\'' + - ", email='" + email + '\'' + - ", phone='" + phone + '\'' + - ", userID='" + userID + '\'' + - ", avatar=" + avatar + - ", createdAt=" + createdAt + - ", updatedAt=" + updatedAt + - ", unsubscribedFromEmails=" + unsubscribedFromEmails + - ", sessionCount=" + sessionCount + - ", lastRequestAt=" + lastRequestAt + - ", lastSeenIP='" + lastSeenIP + '\'' + - ", customAttributes=" + customAttributes + - ", userAgentData='" + userAgentData + '\'' + - ", locationData=" + locationData + - ", companyCollection=" + companyCollection + - ", socialProfileCollection=" + socialProfileCollection + - ", segmentCollection=" + segmentCollection + - ", tagCollection=" + tagCollection + - ", updateLastRequestAt=" + updateLastRequestAt + - ", referrer=" + referrer + - ", utmCampaign='" + utmCampaign + '\'' + - ", utmContent='" + utmContent + '\'' + - ", utmMedium='" + utmMedium + '\'' + - ", utmSource='" + utmSource + '\'' + - ", utmTerm='" + utmTerm + '\'' + - "} " + super.toString(); - } -} diff --git a/intercom-java/src/test/java/io/intercom/api/AdminTest.java b/intercom-java/src/test/java/io/intercom/api/AdminTest.java deleted file mode 100644 index dc0d0f24..00000000 --- a/intercom-java/src/test/java/io/intercom/api/AdminTest.java +++ /dev/null @@ -1,80 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.common.collect.Lists; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.util.List; -import java.util.Map; - -import static io.intercom.api.TestSupport.load; -import static org.junit.Assert.*; - -public class AdminTest { - - private static ObjectMapper mapper; - - @BeforeClass - public static void beforeClass() { - mapper = MapperSupport.objectMapper(); - } - - @Test - public void TestAdminParseJson() throws Exception { - String json = load("admin.json"); - final Admin admin = mapper.readValue(json, Admin.class); - assertEquals("admin", admin.getType()); - assertEquals("123456", admin.getId()); - assertEquals("Admin Name", admin.getName()); - assertEquals("admin@domain.com", admin.getEmail()); - assertTrue(admin.getAwayModeEnabled()); - assertFalse(admin.getAwayModeReassign()); - assertTrue(admin.getHasInboxSeat()); - assertEquals( "https://avatarurl.com/image.jpg", admin.getAvatar().getImageURL().toString()); - assertNotNull(admin.getTeamIds()); - assertEquals(3, admin.getTeamIds().size()); - assertTrue(admin.getTeamIds().contains("123")); - assertTrue(admin.getTeamIds().contains("456")); - assertTrue(admin.getTeamIds().contains("789")); - } - - @Test - public void TestAdminTeamParseJson() throws Exception { - String json = load("admin_team.json"); - final Admin admin = mapper.readValue(json, Admin.class); - assertEquals("team", admin.getType()); - assertEquals("654321", admin.getId()); - assertEquals("A Team", admin.getName()); - assertEquals("team-email@teams.intercom.io", admin.getEmail()); - assertFalse(admin.getAwayModeEnabled()); - assertFalse(admin.getAwayModeReassign()); - assertTrue(admin.getHasInboxSeat()); - assertEquals("https://domain.com/avatar", admin.getAvatar().getImageURL().toString()); - assertNotNull(admin.getAdminIds()); - assertEquals(3, admin.getAdminIds().size()); - assertTrue(admin.getAdminIds().contains("321")); - assertTrue(admin.getAdminIds().contains("654")); - assertTrue(admin.getAdminIds().contains("987")); - } - - - @Test - public void TestAdminParseAdminList() throws Exception { - String json = load("admins.json"); - final AdminCollection adminCollection = mapper.readValue(json, AdminCollection.class); - - assertEquals(6, adminCollection.getPage().size()); - } - - @Test - public void TestAdminSerialiseDeserialise() throws Exception { - String json = load("admin.json"); - final Admin admin = mapper.readValue(json, Admin.class); - final String json1 = mapper.writeValueAsString(admin); - System.out.println(json1); - final Admin admin1 = mapper.readValue(json1, Admin.class); - assertTrue(admin.equals(admin1)); - } - -} diff --git a/intercom-java/src/test/java/io/intercom/api/CompanyTest.java b/intercom-java/src/test/java/io/intercom/api/CompanyTest.java deleted file mode 100644 index 14a2259d..00000000 --- a/intercom-java/src/test/java/io/intercom/api/CompanyTest.java +++ /dev/null @@ -1,223 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.common.collect.Maps; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.util.List; -import java.util.Map; - -import static io.intercom.api.TestSupport.load; -import static org.junit.Assert.*; - -public class CompanyTest { - private static ObjectMapper mapper; - - @BeforeClass - public static void beforeClass() { - mapper = MapperSupport.objectMapper(); - } - - @Test - public void TestCustomAttributes() throws Exception { - final Map customAttributes = Maps.newHashMap(); - final CustomAttribute booleanAttribute = CustomAttribute.newBooleanAttribute("a_boolean", false); - final CustomAttribute doubleAttribute = CustomAttribute.newDoubleAttribute("a_double", 2.34); - final CustomAttribute floatAttribute = CustomAttribute.newFloatAttribute("a_float", 1.2f); - final CustomAttribute integerAttribute = CustomAttribute.newIntegerAttribute("an_integer", 123); - final CustomAttribute longAttribute = CustomAttribute.newLongAttribute("a_long", 1517833441L); - final CustomAttribute stringAttribute = CustomAttribute.newStringAttribute("a_string", "a string"); - customAttributes.put(booleanAttribute.getName(), booleanAttribute); - customAttributes.put(doubleAttribute.getName(), doubleAttribute); - customAttributes.put(floatAttribute.getName(), floatAttribute); - customAttributes.put(integerAttribute.getName(), integerAttribute); - customAttributes.put(longAttribute.getName(), longAttribute); - customAttributes.put(stringAttribute.getName(), stringAttribute); - final Company company = new Company() - .setCustomAttributes(customAttributes); - - final Company companyAddAttributeIndividually = new Company(); - companyAddAttributeIndividually.addCustomAttribute(booleanAttribute); - companyAddAttributeIndividually.addCustomAttribute(doubleAttribute); - companyAddAttributeIndividually.addCustomAttribute(floatAttribute); - companyAddAttributeIndividually.addCustomAttribute(integerAttribute); - companyAddAttributeIndividually.addCustomAttribute(longAttribute); - companyAddAttributeIndividually.addCustomAttribute(stringAttribute); - - assertEquals(company.getCustomAttributes().get("a_boolean"), companyAddAttributeIndividually.getCustomAttributes().get("a_boolean")); - assertEquals(company.getCustomAttributes().get("a_double"), companyAddAttributeIndividually.getCustomAttributes().get("a_double")); - assertEquals(company.getCustomAttributes().get("a_float"), companyAddAttributeIndividually.getCustomAttributes().get("a_float")); - assertEquals(company.getCustomAttributes().get("an_integer"), companyAddAttributeIndividually.getCustomAttributes().get("an_integer")); - assertEquals(company.getCustomAttributes().get("a_long"), companyAddAttributeIndividually.getCustomAttributes().get("a_long")); - assertEquals(company.getCustomAttributes().get("a_string"), companyAddAttributeIndividually.getCustomAttributes().get("a_string")); - } - @Test - public void TestPrepareUpdatableCompany() throws Exception { - final long now = System.currentTimeMillis() / 1000; - final CustomAttribute booleanAttribute = CustomAttribute.newBooleanAttribute("a_boolean", false); - final CustomAttribute doubleAttribute = CustomAttribute.newDoubleAttribute("a_double", 2.34); - final CustomAttribute floatAttribute = CustomAttribute.newFloatAttribute("a_float", 1.2f); - final CustomAttribute integerAttribute = CustomAttribute.newIntegerAttribute("an_integer", 123); - final CustomAttribute longAttribute = CustomAttribute.newLongAttribute("a_long", 1517833441); - final CustomAttribute stringAttribute = CustomAttribute.newStringAttribute("a_string", "a string"); - final Company.Plan plan = new Company.Plan("my plan"); - final Company company = new Company() - .setCompanyID("my_company_id") - .addCustomAttribute(booleanAttribute) - .addCustomAttribute(doubleAttribute) - .addCustomAttribute(floatAttribute) - .addCustomAttribute(integerAttribute) - .addCustomAttribute(longAttribute) - .addCustomAttribute(stringAttribute) - .setId("1") - .setIndustry("the industry") - .setMonthlySpend(123) - .setName("company name") - .setPlan(plan) - .setRemoteCreatedAt(now) - .setSize(432) - .setWebsite("https://intercom.com"); - - - final CompanyCollection companyCollection = new CompanyCollection(); - companyCollection.addCompany(company); - final List companyUpdateList = CompanyUpdateBuilder.buildUserUpdateCompanies(companyCollection, null); - final CompanyWithStringPlan companyUpdate = companyUpdateList.get(0); - assertEquals("my_company_id", companyUpdate.getCompanyID()); - assertEquals(6, companyUpdate.getCustomAttributes().size()); - assertEquals(false, companyUpdate.getCustomAttributes().get("a_boolean").getValue()); - assertEquals(2.34, companyUpdate.getCustomAttributes().get("a_double").getValue()); - assertEquals(1.2f, companyUpdate.getCustomAttributes().get("a_float").getValue()); - assertEquals(123, companyUpdate.getCustomAttributes().get("an_integer").getValue()); - assertEquals(1517833441L, companyUpdate.getCustomAttributes().get("a_long").getValue()); - assertEquals("a string", companyUpdate.getCustomAttributes().get("a_string").getValue()); - assertEquals("1", companyUpdate.getId()); - assertEquals("the industry", companyUpdate.getIndustry()); - assertEquals(123, companyUpdate.getMonthlySpend(), 0f); - assertEquals("company name", companyUpdate.getName()); - assertEquals("my plan", companyUpdate.getPlan()); - assertEquals(now, companyUpdate.getRemoteCreatedAt()); - assertEquals(432, companyUpdate.getSize()); - assertEquals("https://intercom.com", companyUpdate.getWebsite()); - } - - - @Test - public void TestReadJsonResponse() throws Exception { - String json = load("company.json"); - final Company company = mapper.readValue(json, Company.class); - final TagCollection tagCollection = company.getTagCollection(); - final List tags = tagCollection.getPage(); - final SegmentCollection segmentCollection = company.getSegmentCollection(); - final List segments = segmentCollection.getPage(); - final Tag tag = tags.get(0); - final Segment segment1 = segments.get(0); - final Segment segment2= segments.get(1); - final Company.Plan plan = company.getPlan(); - assertEquals("6", company.getCompanyID()); - assertEquals("5694b58371b5025a2a0003e6", company.getId()); - assertEquals("Blue Sun", company.getName()); - assertEquals(1452586372, company.getCreatedAt()); - assertEquals(49, company.getMonthlySpend(), 0f); - assertEquals("plan", plan.getType()); - assertEquals("150154", plan.getId()); - assertEquals("plan1", plan.getName()); - assertEquals(1517835268, company.getUpdatedAt()); - assertEquals(1394531169, company.getRemoteCreatedAt()); - assertEquals(1496292261, company.getLastRequestAt()); - assertEquals(2, company.getSessionCount()); - assertEquals("Manufacturing", company.getIndustry()); - assertEquals("http://www.example.com", company.getWebsite()); - assertEquals(85, company.getSize()); - assertEquals("tag.list", tagCollection.getType()); - assertEquals("tag", tag.getType()); - assertEquals("1072802", tag.getId()); - assertEquals("CompanyTag1", tag.getName()); - assertEquals("segment.list", segmentCollection.getType()); - assertEquals(2, segments.size()); - assertEquals("segment", segment1.getType()); - assertEquals("58b7c061d5cf5649a59f7097", segment1.getId()); - assertEquals("segment", segment2.getType()); - assertEquals("593107f85950a28b168aa9d3", segment2.getId()); - assertEquals(new Integer(1), company.getUserCount()); - - final Map customAttributes = company.getCustomAttributes(); - CustomAttribute customAttribute; - - customAttribute = customAttributes.get("truthy_typed"); - assertEquals(Boolean.class, customAttribute.getValueClass()); - assertEquals(Boolean.TRUE, customAttribute.getValue()); - assertEquals(Boolean.TRUE, customAttribute.booleanValue()); - assertEquals("truthy_typed", customAttribute.getName()); - - customAttribute = customAttributes.get("floatly_typed"); - assertEquals(Double.class, customAttribute.getValueClass()); - assertEquals(155.5d, customAttribute.getValue()); - assertEquals(155.5d, customAttribute.doubleValue(), 0d); - assertEquals("floatly_typed", customAttribute.getName()); - - customAttribute = customAttributes.get("stringly_typed"); - assertEquals(String.class, customAttribute.getValueClass()); - assertEquals("data", customAttribute.getValue()); - assertEquals("data", customAttribute.textValue()); - assertEquals("stringly_typed", customAttribute.getName()); - - customAttribute = customAttributes.get("dately_typed_at"); - assertEquals(Long.class, customAttribute.getValueClass()); - assertEquals(1397574667L, customAttribute.getValue()); - assertEquals(1397574667L, customAttribute.longValue()); - assertEquals("dately_typed_at", customAttribute.getName()); - - customAttribute = customAttributes.get("longly_typed"); - assertEquals(Long.class, customAttribute.getValueClass()); - assertEquals(221397574667L, customAttribute.getValue()); - assertEquals(221397574667L, customAttribute.longValue()); - assertEquals("longly_typed", customAttribute.getName()); - - customAttribute = customAttributes.get("intly_typed"); - assertEquals(Integer.class, customAttribute.getValueClass()); - assertEquals(1, customAttribute.getValue()); - assertEquals(1, customAttribute.integerValue()); - assertEquals("intly_typed", customAttribute.getName()); - - // null values are not ignored - customAttribute = customAttributes.get("nully_typed"); - assertEquals(null, customAttribute); - } - - @Test - public void TestReadJsonResponseNoCompanyData() throws Exception { - String json = load("company_no_data_except_company_id.json"); - final Company company = mapper.readValue(json, Company.class); - final TagCollection tagCollection = company.getTagCollection(); - final List tags = tagCollection.getPage(); - final SegmentCollection segmentCollection = company.getSegmentCollection(); - final List segments = segmentCollection.getPage(); - final Company.Plan plan = company.getPlan(); - assertEquals("6", company.getCompanyID()); - assertEquals("5694b58371b5025a2a0003e6", company.getId()); - assertEquals(null, company.getName()); - assertEquals(1452586372, company.getCreatedAt()); - assertEquals(0, company.getMonthlySpend(), 0f); - assertEquals("plan", plan.getType()); - assertEquals(null, plan.getId()); - assertEquals(null, plan.getName()); - assertEquals(1517835268, company.getUpdatedAt()); - assertEquals(0, company.getRemoteCreatedAt()); - assertEquals(0, company.getLastRequestAt()); - assertEquals(0, company.getSessionCount()); - assertEquals(null, company.getIndustry()); - assertEquals(null, company.getWebsite()); - assertEquals(0, company.getSize()); - assertEquals("tag.list", tagCollection.getType()); - assertEquals(0, tags.size()); - assertEquals("segment.list", segmentCollection.getType()); - assertEquals(0, segments.size()); - assertEquals(new Integer(0), company.getUserCount()); - - final Map customAttributes = company.getCustomAttributes(); - assertEquals(0, customAttributes.size()); - } - -} \ No newline at end of file diff --git a/intercom-java/src/test/java/io/intercom/api/CompanyUpdateBuilderTest.java b/intercom-java/src/test/java/io/intercom/api/CompanyUpdateBuilderTest.java deleted file mode 100644 index d0d08248..00000000 --- a/intercom-java/src/test/java/io/intercom/api/CompanyUpdateBuilderTest.java +++ /dev/null @@ -1,93 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.common.collect.Lists; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.util.List; -import java.util.Map; - -import static org.junit.Assert.*; - -public class CompanyUpdateBuilderTest { - - private static ObjectMapper mapper; - - @BeforeClass - public static void beforeClass() { - mapper = MapperSupport.objectMapper(); - } - - @Test - public void testRemove() throws Exception { - - final Company bacon = new Company().setCompanyID("bacon"); - final Company pancake = new Company().setCompanyID("pancake"); - - final List cos = CompanyUpdateBuilder.buildUserUpdateCompanies( - new CompanyCollection(Lists.newArrayList(bacon, pancake)), - new CompanyCollection(Lists.newArrayList(bacon))); - - Boolean baconIsRemoved = null; - Boolean pancakeIsRemoved = null; - - CompanyWithStringPlan baconCo = null; - CompanyWithStringPlan pancakeCo = null; - - for (CompanyWithStringPlan co : cos) { - if (co.getCompanyID().equals("pancake")) { - pancakeIsRemoved = co.getRemove(); - pancakeCo = co; - } - - if (co.getCompanyID().equals("bacon")) { - baconIsRemoved = co.getRemove(); - baconCo = co; - } - - } - assertNull(pancakeIsRemoved); - assertTrue(baconIsRemoved); - - final String pancakeJson = mapper.writeValueAsString(pancakeCo); - assertFalse(pancakeJson.contains("remove")); - assertFalse(pancakeJson.contains("true")); - - final String baconJson = mapper.writeValueAsString(baconCo); - assertTrue(baconJson.contains("remove")); - assertTrue(baconJson.contains("true")); - - } - - @Test - public void shouldIncludeCustomAttributes() throws Exception { - - final Company withCustomAttributes = new Company().setName("Weyland Corp").setCompanyID("2093"); - - withCustomAttributes.addCustomAttribute(CustomAttribute.newIntegerAttribute("foodstuff-items", 246)); - withCustomAttributes.addCustomAttribute(CustomAttribute.newStringAttribute("bestseller", "fruity oaty bar")); - - final List updatedCompanies = CompanyUpdateBuilder.buildUserUpdateCompanies(new CompanyCollection(Lists.newArrayList(withCustomAttributes)), null); - - CompanyWithStringPlan weylandCorp = null; - - for (CompanyWithStringPlan updatedCompany : updatedCompanies) { - if (updatedCompany.getCompanyID().equals("2093")) { - weylandCorp = updatedCompany; - } - } - - assertNotNull(weylandCorp); - assertNotNull(weylandCorp.getCustomAttributes()); - Map retrievedAttributes = weylandCorp.getCustomAttributes(); - - assertNotNull(retrievedAttributes.get("foodstuff-items")); - assertTrue(retrievedAttributes.get("foodstuff-items").getValue().equals(246)); - assertNotNull(retrievedAttributes.get("bestseller")); - assertTrue(retrievedAttributes.get("bestseller").getValue().equals("fruity oaty bar")); - - - } - -} \ No newline at end of file diff --git a/intercom-java/src/test/java/io/intercom/api/ContactTest.java b/intercom-java/src/test/java/io/intercom/api/ContactTest.java deleted file mode 100644 index 630424f6..00000000 --- a/intercom-java/src/test/java/io/intercom/api/ContactTest.java +++ /dev/null @@ -1,35 +0,0 @@ -package io.intercom.api; - -import org.junit.Test; - -import static org.junit.Assert.*; - -public class ContactTest { - - - @Test - public void testValidateConvertBuilder() { - Contact.ContactConvertBuilder builder = new Contact.ContactConvertBuilder(); - - Contact c = new Contact(); - User u = new User().setEmail("a@b.com"); - - try { - builder.build(c,u); - fail(); - } catch (InvalidException e) { - assertTrue(e.getMessage().contains("convert contact must")); - } - - c = new Contact().setID("1"); - u = new User(); - - try { - builder.build(c,u); - fail(); - } catch (InvalidException e) { - assertTrue(e.getMessage().contains("convert user must")); - } - } - -} \ No newline at end of file diff --git a/intercom-java/src/test/java/io/intercom/api/ConversationTest.java b/intercom-java/src/test/java/io/intercom/api/ConversationTest.java deleted file mode 100644 index d46d0f4d..00000000 --- a/intercom-java/src/test/java/io/intercom/api/ConversationTest.java +++ /dev/null @@ -1,286 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.common.collect.Maps; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mockito; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; - -import java.io.IOException; -import java.util.Map; - -import static io.intercom.api.TestSupport.load; -import static org.junit.Assert.*; -import static org.junit.Assert.assertTrue; - -@RunWith(PowerMockRunner.class) -@PrepareForTest( { Conversation.class }) -public class ConversationTest { - - private static ObjectMapper objectMapper; - - @BeforeClass - public static void beforeClass() { - objectMapper = MapperSupport.objectMapper(); - } - - @Test - public void testIsNullOrBlank() { - assertTrue(Conversation.isNullOrBlank(null)); - assertTrue(Conversation.isNullOrBlank("")); - assertTrue(Conversation.isNullOrBlank(" ")); - assertTrue(Conversation.isNullOrBlank("\n")); - assertTrue(Conversation.isNullOrBlank("\r")); - assertFalse(Conversation.isNullOrBlank("reply")); - } - - @Test - public void testAdminReply() { - - AdminReply adminReply = new AdminReply(null); - adminReply.setAssigneeID("1"); - assertEquals(Conversation.MESSAGE_TYPE_ASSIGNMENT, adminReply.getMessageType()); - - try { - Conversation.validateAdminReplyRequest(adminReply); - } catch (InvalidException e) { - fail(); - } - - adminReply = new AdminReply(null); - adminReply.setMessageType("comment"); - try { - Conversation.validateAdminReplyRequest(adminReply); - fail(); - } catch (InvalidException e) { - assertTrue(e.getMessage() - .contains("a comment or note reply must have a body")); - } - - adminReply.setBody(" "); - try { - Conversation.validateAdminReplyRequest(adminReply); - fail(); - } catch (InvalidException e) { - assertTrue(e.getMessage() - .contains("a comment or note reply must have a body")); - } - - adminReply.setBody("Once, in flight school, I was laconic"); - try { - Conversation.validateAdminReplyRequest(adminReply); - } catch (InvalidException e) { - fail(); - } - - adminReply.setAttachmentUrls(new String[]{"http://www.example.com/attachment.jpg"}); - try { - Conversation.validateAdminReplyRequest(adminReply); - } catch (InvalidException e) { - fail(); - } - } - - @Test - public void testDisplayAs() { - - try { - Conversation.list(buildRequestParameters("pdf")); - fail(); - } catch (InvalidException e) { - assertTrue(e.getMessage() - .contains("A display_as parameter must have one of the values plaintext, html")); - } - - try { - Conversation.validateListRequest(buildRequestParameters("plaintext")); - } catch (InvalidException e) { - fail(); - } - - try { - Conversation.validateListRequest(buildRequestParameters("html")); - } catch (InvalidException e) { - fail(); - } - } - - @Test - public void testGetConversationMessageDetailsFromConversation() throws IOException { - PowerMockito.mockStatic(Conversation.class); - - String json = load("conversation.json"); - final Conversation conversation = objectMapper.readValue(json, Conversation.class); - final ConversationMessage conversationMessage = conversation.getConversationMessage(); - - assertEquals("33954111", conversationMessage.getId()); - assertEquals("

test

", conversationMessage.getBody()); - assertEquals("Email subject", conversationMessage.getSubject()); - assertEquals("https://intercom.com/", conversationMessage.getUrl()); - assertEquals("customer_initiated", conversationMessage.getDeliveredAs()); - - assertEquals("lead", conversationMessage.getAuthor().getType()); - assertEquals("576c1a139d0baad1010011111", conversationMessage.getAuthor().getId()); - - assertEquals(2, conversationMessage.getAttachments().size()); - - final Attachment firstAttachment = conversationMessage.getAttachments().get(0); - final Attachment lastAttachment = conversationMessage.getAttachments().get(1); - assertEquals("upload", firstAttachment.getType()); - assertEquals("123.csv", firstAttachment.getName()); - assertEquals("https://downloads.intercomcdn.com/123.csv", firstAttachment.getUrl()); - assertEquals("text/csv", firstAttachment.getContentType()); - assertEquals(147, firstAttachment.getFilesize()); - assertEquals(0, firstAttachment.getWidth()); - assertEquals(0, firstAttachment.getHeight()); - - assertEquals("upload", lastAttachment.getType()); - assertEquals("abc.txt", lastAttachment.getName()); - assertEquals("https://downloads.intercomcdn.com/txt", lastAttachment.getUrl()); - assertEquals("text/csv", lastAttachment.getContentType()); - assertEquals(100, lastAttachment.getFilesize()); - assertEquals(1, lastAttachment.getWidth()); - assertEquals(2, lastAttachment.getHeight()); - - PowerMockito.verifyStatic(Mockito.never()); - Conversation.find(conversation.getId()); - } - - @Test - public void testGetConversationMessageDetailsFromConversationNoAttachments() throws IOException { - PowerMockito.mockStatic(Conversation.class); - - String json = load("conversation_no_attachments.json"); - final Conversation conversation = objectMapper.readValue(json, Conversation.class); - final ConversationMessage conversationMessage = conversation.getConversationMessage(); - - assertEquals("33954111", conversationMessage.getId()); - assertEquals("

test

", conversationMessage.getBody()); - assertEquals("Email subject", conversationMessage.getSubject()); - assertEquals("https://intercom.com/", conversationMessage.getUrl()); - assertEquals("customer_initiated", conversationMessage.getDeliveredAs()); - - assertEquals("lead", conversationMessage.getAuthor().getType()); - assertEquals("576c1a139d0baad1010011111", conversationMessage.getAuthor().getId()); - - assertEquals(0, conversationMessage.getAttachments().size()); - - PowerMockito.verifyStatic(Mockito.never()); - Conversation.find(conversation.getId()); - } - - @Test - public void testGetConversationsPartFromConversation() throws IOException { - PowerMockito.mockStatic(Conversation.class); - - String json = load("conversation.json"); - final Conversation conversation = objectMapper.readValue(json, Conversation.class); - assertEquals(2, conversation.getConversationPartCollection().getPage().size()); - - PowerMockito.verifyStatic(Mockito.never()); - Conversation.find(conversation.getId()); - } - - @Test - public void testGetConversationsPartFromConversationCollection() throws IOException { - PowerMockito.mockStatic(Conversation.class); - - String conversationsJson = load("conversations.json"); - final ConversationCollection conversationCollection = objectMapper.readValue(conversationsJson, ConversationCollection.class); - final Conversation conversation = conversationCollection.getPage().get(0); - - String conversationJson = load("conversation.json"); - final Conversation conversationWithParts = objectMapper.readValue(conversationJson, Conversation.class); - Mockito.when(Conversation.find(conversation.getId())).thenReturn(conversationWithParts); - assertEquals(2, conversation.getConversationPartCollection().getPage().size()); - - PowerMockito.verifyStatic(Mockito.times(1)); - Conversation.find(conversation.getId()); - } - - @Test - public void testGetEmptyConversationsPartFromConversationCollection() throws IOException { - PowerMockito.mockStatic(Conversation.class); - - String conversationsJson = load("conversations.json"); - final ConversationCollection conversationCollection = objectMapper.readValue(conversationsJson, ConversationCollection.class); - final Conversation conversation = conversationCollection.getPage().get(0); - - String conversationJson = load("conversation_no_parts.json"); - final Conversation conversationWithParts = objectMapper.readValue(conversationJson, Conversation.class); - Mockito.when(Conversation.find(conversation.getId())).thenReturn(conversationWithParts); - assertEquals(0, conversation.getConversationPartCollection().getPage().size()); - - PowerMockito.verifyStatic(Mockito.times(1)); - Conversation.find(conversation.getId()); - } - - @Test - public void testGetTagsFromConversation() throws IOException { - PowerMockito.mockStatic(Conversation.class); - - String json = load("conversation.json"); - final Conversation conversation = objectMapper.readValue(json, Conversation.class); - assertEquals(2, conversation.getTagCollection().getPage().size()); - - PowerMockito.verifyStatic(Mockito.never()); - Conversation.find(conversation.getId()); - } - - @Test - public void testGetTagFromTagCollection() throws IOException { - PowerMockito.mockStatic(Conversation.class); - - String conversationsJson = load("conversations.json"); - final ConversationCollection conversationCollection = objectMapper.readValue(conversationsJson, ConversationCollection.class); - final Conversation conversation = conversationCollection.getPage().get(0); - - String conversationJson = load("conversation.json"); - final Conversation conversationWithTags = objectMapper.readValue(conversationJson, Conversation.class); - Mockito.when(Conversation.find(conversation.getId())).thenReturn(conversationWithTags); - assertEquals(2, conversation.getTagCollection().getPage().size()); - - PowerMockito.verifyStatic(Mockito.times(1)); - Conversation.find(conversation.getId()); - } - - @Test - public void testGetEmptyTagFromTagCollection() throws IOException { - PowerMockito.mockStatic(Conversation.class); - - String conversationsJson = load("conversations.json"); - final ConversationCollection conversationCollection = objectMapper.readValue(conversationsJson, ConversationCollection.class); - final Conversation conversation = conversationCollection.getPage().get(0); - - String conversationJson = load("conversation_no_tags.json"); - final Conversation conversationWithTags= objectMapper.readValue(conversationJson, Conversation.class); - Mockito.when(Conversation.find(conversation.getId())).thenReturn(conversationWithTags); - assertEquals(0, conversation.getConversationPartCollection().getPage().size()); - - PowerMockito.verifyStatic(Mockito.times(1)); - Conversation.find(conversation.getId()); - } - private Map buildRequestParameters(String html) { - Map params2 = Maps.newHashMap(); - params2.put("type", "admin"); - params2.put("admin_id", "1"); - params2.put("display_as", html); - return params2; - } - - @Test - public void testGetConversationCustomerFirstReply() throws IOException { - PowerMockito.mockStatic(Conversation.class); - - String json = load("conversation.json"); - final Conversation conversation = objectMapper.readValue(json, Conversation.class); - assertNotNull(conversation.getCustomerFirstReply()); - assertEquals(1468236397, conversation.getCustomerFirstReply().getCreatedAt()); - assertEquals("conversation", conversation.getCustomerFirstReply().getType()); - assertEquals("https://someurl", conversation.getCustomerFirstReply().getUrl()); - } -} diff --git a/intercom-java/src/test/java/io/intercom/api/ErrorCollectionTest.java b/intercom-java/src/test/java/io/intercom/api/ErrorCollectionTest.java deleted file mode 100644 index a6ae32b3..00000000 --- a/intercom-java/src/test/java/io/intercom/api/ErrorCollectionTest.java +++ /dev/null @@ -1,43 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.common.collect.Lists; -import org.junit.BeforeClass; -import org.junit.Test; - -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -public class ErrorCollectionTest { - - private static ObjectMapper mapper; - - @BeforeClass - public static void beforeClass() { - mapper = TestSupport.objectMapper(); - } - - @Test - public void load() throws Exception { - String json = TestSupport.load("errors.json"); - final ErrorCollection errors = mapper.readValue(json, ErrorCollection.class); - assertTrue(errors.getErrors().size() == 2); - } - - @Test - public void dontload() { - try { - new ErrorCollection(null); - fail(); - } catch (NullPointerException ignored) { - } - - try { - new ErrorCollection(Lists.newArrayList()); - fail(); - } catch (IllegalArgumentException ignored) { - } - - } - -} \ No newline at end of file diff --git a/intercom-java/src/test/java/io/intercom/api/EventTest.java b/intercom-java/src/test/java/io/intercom/api/EventTest.java deleted file mode 100644 index 8969251a..00000000 --- a/intercom-java/src/test/java/io/intercom/api/EventTest.java +++ /dev/null @@ -1,244 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.common.collect.Lists; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.util.List; - -import static io.intercom.api.TestSupport.load; -import static org.junit.Assert.*; - -public class EventTest { - private static ObjectMapper mapper; - - @BeforeClass - public static void beforeClass() { - mapper = MapperSupport.objectMapper(); - } - - @Test - public void testBulkValidation() { - - Event event = new Event(); - event.setEmail(null); - event.setEventName("bought-hat"); - - try { - Event.validateJobItems(Lists.newArrayList(new JobItem("post", event))); - fail("bulk event with no user id or email should be invalid"); - } catch (InvalidException e) { - assertTrue(e.getFirstError() != null); - } - - event = new Event(); - event.setEmail("jayne@serenity.io"); - event.setEventName(null); - try { - Event.validateJobItems(Lists.newArrayList(new JobItem("post", event))); - fail("bulk event with a blank name should be invalid"); - } catch (InvalidException e) { - assertTrue(e.getFirstError() != null); - } - - event = new Event(); - event.setEmail("jayne@serenity.io"); - event.setEventName("bought-hat"); - try { - Event.validateJobItems(Lists.newArrayList(new JobItem("levitate", event))); - fail("bulk event with an unknown method"); - } catch (InvalidException e) { - assertTrue(e.getFirstError() != null); - } - } - - @Test - public void testMissingUser() { - final Event event1 = new Event().setEventName("bought-hat"); - try { - Event.create(event1); - fail("an event with no user id or email should be invalid"); - } catch (InvalidException e) { - assertTrue(e.getFirstError() != null); - } - - final Event event2 = new Event() - .setEventName("bought-hat") - .setUserID("") - .putMetadata("invitee_email", "jayne@serenity.io"); - try { - Event.create(event2); - fail("an event with a blank user id should be invalid"); - } catch (InvalidException e) { - assertTrue(e.getFirstError() != null); - } - - final Event event3 = new Event().setEmail(""); - try { - Event.create(event3); - fail("an event with a blank email should be invalid"); - } catch (InvalidException e) { - assertTrue(e.getFirstError() != null); - } - - } - - @Test - public void testMissingEventName() { - Event event1 = new Event() - .setEmail("jayne@serenity.io"); - try { - Event.create(event1); - fail("an event with a blank name should be invalid"); - } catch (InvalidException e) { - assertTrue(e.getFirstError() != null); - - } - - Event event2 = new Event() - .setEmail("jayne@serenity.io") - .setEventName(""); - try { - Event.create(event2); - fail("an event with a blank name should be invalid"); - } catch (InvalidException e) { - assertTrue(e.getFirstError() != null); - } - } - - @Test - public void testMissingId() { - final Event event1 = new Event().setEventName("test-id"); - try { - Event.create(event1); - fail("an event with no id or email should be invalid"); - } catch (InvalidException e) { - assertTrue(e.getFirstError() != null); - } - - final Event event2 = new Event() - .setEventName("test-id") - .setId("") - .putMetadata("invitee_email", "jayne@serenity.io"); - try { - Event.create(event2); - fail("an event with an empty id should be invalid"); - } catch (InvalidException e) { - assertTrue(e.getFirstError() != null); - } - - final Event event3 = new Event() - .setId("49bf6b081d661db4408a51e1") - .setEmail(""); - try { - Event.create(event3); - fail("an event with an empty email should be invalid"); - } catch (InvalidException e) { - assertTrue(e.getFirstError() != null); - } - - } - - @Test - public void testValid() { - Event event1 = new Event() - .setEmail("jayne@serenity.io") - .setEventName("bought-hat"); - try { - Event.validateCreateEvent(event1); - } catch (InvalidException e) { - fail("an event with an email and a name should be valid"); - } - - Event event2 = new Event() - .setUserID("1") - .setEventName("bought-hat"); - try { - Event.validateCreateEvent(event2); - } catch (InvalidException e) { - fail("an event with a user id and a name should be valid"); - } - - Event event3 = new Event() - .setUserID("1") - .setEmail("jayne@serenity.io") - .setEventName("bought-hat"); - try { - Event.validateCreateEvent(event3); - } catch (InvalidException e) { - fail("an event with a user id, email and a name should be valid"); - } - - Event event4 = new Event() - .setId("49bf6b081d661db4408a51e1") - .setEventName("test-id"); - try { - Event.validateCreateEvent(event4); - } catch (InvalidException e) { - fail("an event with an id and a name should be valid"); - } - - Event event5 = new Event() - .setId("49bf6b081d661db4408a51e1") - .setEmail("jayne@serenity.io") - .setEventName("test-id"); - try { - Event.validateCreateEvent(event5); - } catch (InvalidException e) { - fail("an event with an id, email and a name should be valid"); - } - - } - @Test - public void testListing() throws Exception { - String json = load("events.json"); - final EventCollection eventCollection = mapper.readValue(json, EventCollection.class); - assertEquals(2, eventCollection.getPage().size()); - - final Event eventWithNoMetadata = eventCollection.getPage().get(0); - assertEquals("cc7e2992-e6f1-11e7-9f85-25b0a92374f6", eventWithNoMetadata.getId()); - assertEquals(1513931185, eventWithNoMetadata.getCreatedAt()); - assertEquals("test-event", eventWithNoMetadata.getEventName()); - assertEquals("25", eventWithNoMetadata.getUserID()); - assertEquals("530370b477ad7120001d", eventWithNoMetadata.getIntercomUserID()); - assertEquals(0, eventWithNoMetadata.getMetadata().size()); - - final Event eventWithMetadata = eventCollection.getPage().get(1); - assertEquals("9a096a26-b8c5-11e7-b012-3f043042e6d0", eventWithMetadata.getId()); - assertEquals(1508854449, eventWithMetadata.getCreatedAt()); - assertEquals("invited-friend", eventWithMetadata.getEventName()); - assertEquals("25", eventWithMetadata.getUserID()); - assertEquals("530370b477ad7120001d", eventWithMetadata.getIntercomUserID()); - assertNotEquals(null, eventWithMetadata.getMetadata()); - assertEquals(2, eventWithMetadata.getMetadata().size()); - assertEquals("pi@example.org", eventWithMetadata.getMetadata().get("invitee_email")); - assertEquals("ADDAFRIEND", eventWithMetadata.getMetadata().get("invite_code")); - assertEquals(null, eventWithMetadata.getMetadata().get("non_existing_key")); - } - - @Test - public void testEventSummaryParsing() throws Exception { - String json = load("event_summary.json"); - final EventSummaryCollection eventSummaryCollection = mapper.readValue(json, EventSummaryCollection.class); - assertEquals("event.summary", eventSummaryCollection.getType()); - assertEquals("wash@serenity.io", eventSummaryCollection.getEmail()); - assertEquals("530370b477ad7120001d", eventSummaryCollection.getIntercomUserID()); - assertEquals("25",eventSummaryCollection.getUserID()); - List eventSummaries = eventSummaryCollection.getEventSummaries(); - assertEquals(3, eventSummaries.size()); - - assertEquals("test-event", eventSummaries.get(0).getName()); - assertEquals("2016-12-22T03:54:57.000Z", eventSummaries.get(0).getFirstOccurredAtString()); - assertEquals("2018-10-10T06:51:02.000Z", eventSummaries.get(0).getLastOccurredAtString()); - assertEquals(8, eventSummaries.get(0).getCount()); - assertEquals(null, eventSummaries.get(0).getDescription()); - - assertEquals("clicked-button", eventSummaries.get(1).getName()); - assertEquals("2018-02-20T06:40:16.000Z", eventSummaries.get(1).getFirstOccurredAtString()); - assertEquals("2018-02-20T06:40:16.000Z", eventSummaries.get(1).getLastOccurredAtString()); - assertEquals(1, eventSummaries.get(1).getCount()); - assertEquals("Clicking home page button", eventSummaries.get(1).getDescription()); - } -} - diff --git a/intercom-java/src/test/java/io/intercom/api/IntercomExceptionTest.java b/intercom-java/src/test/java/io/intercom/api/IntercomExceptionTest.java deleted file mode 100644 index 6ed41983..00000000 --- a/intercom-java/src/test/java/io/intercom/api/IntercomExceptionTest.java +++ /dev/null @@ -1,32 +0,0 @@ -package io.intercom.api; - -import com.google.common.collect.Lists; -import org.junit.Test; - -import static org.junit.Assert.*; - -public class IntercomExceptionTest { - - @Test - public void testNullCollection() { - assertEquals("Could not read error message from server", IntercomException.getMessage(null)); - } - - @Test - public void testBlankCollection() { - ErrorCollection ec = new ErrorCollection(); - assertEquals("Could not read error message from server", IntercomException.getMessage(ec)); - } - - @Test - public void testEmptyCollection() { - try { - new ErrorCollection(Lists.newArrayList()); - fail(); - } catch (IllegalArgumentException e) { - } - final ErrorCollection ec = new ErrorCollection(Lists.newArrayList(new Error())); - assertEquals("Could not read error message from server", IntercomException.getMessage(ec)); - } - -} \ No newline at end of file diff --git a/intercom-java/src/test/java/io/intercom/api/IntercomTest.java b/intercom-java/src/test/java/io/intercom/api/IntercomTest.java deleted file mode 100644 index edcade21..00000000 --- a/intercom-java/src/test/java/io/intercom/api/IntercomTest.java +++ /dev/null @@ -1,179 +0,0 @@ -package io.intercom.api; - -import org.junit.After; -import org.junit.Test; - -import java.util.Random; - -import static org.junit.Assert.*; - -public class IntercomTest { - - @After - public void tearDown() { - Intercom.setUseThreadLocal(false); - } - - @Test - public void testUseThreadLocal() { - Intercom.setUseThreadLocal(false); - Intercom.setToken("tx"); - assertFalse(Intercom.usesThreadLocal()); - assertEquals("tx", Intercom.getToken()); - Intercom.setUseThreadLocal(true); - assertTrue(Intercom.usesThreadLocal()); - assertNotEquals("tx", Intercom.getToken()); - Intercom.setUseThreadLocal(false); - assertFalse(Intercom.usesThreadLocal()); - assertEquals("tx", Intercom.getToken()); - } - - @Test - public void testToken() { - Intercom.setToken("t1"); - assertEquals("t1", Intercom.getToken()); - } - - @Test - public void testStaticContext() throws Exception { - Intercom.setToken("t1"); - assertEquals("t1", Intercom.getToken()); - Intercom.setConnectionTimeout(98765); - assertEquals(98765, Intercom.getConnectionTimeout()); - Intercom.setRequestTimeout(12345); - assertEquals(12345, Intercom.getRequestTimeout()); - Intercom.setRequestUsingCaches(true); - assertTrue(Intercom.isRequestUsingCaches()); - - ThreadTester tt1 = new ThreadTester(); - ThreadTester tt2 = new ThreadTester(); - new Thread(tt1).run(); - new Thread(tt2).run(); - tt1.waitUntilComplete(); - tt2.waitUntilComplete(); - - assertEquals(Intercom.getToken(), tt1.token); - assertEquals(Intercom.getConnectionTimeout(), tt1.connectionTimeout); - assertEquals(Intercom.getRequestTimeout(), tt1.requestTimeout); - assertEquals(Intercom.isRequestUsingCaches(), tt1.requestUsingCaches); - - assertEquals(Intercom.getToken(), tt2.token); - assertEquals(Intercom.getConnectionTimeout(), tt2.connectionTimeout); - assertEquals(Intercom.getRequestTimeout(), tt2.requestTimeout); - assertEquals(Intercom.isRequestUsingCaches(), tt2.requestUsingCaches); - } - - @Test - public void testThreadLocalContext() throws Exception { - Intercom.setUseThreadLocal(true); - - ThreadLocalTester1 tt1 = new ThreadLocalTester1(); - ThreadLocalTester2 tt2 = new ThreadLocalTester2(); - new Thread(tt1).run(); - new Thread(tt2).run(); - tt1.waitUntilComplete(); - tt2.waitUntilComplete(); - - assertEquals(tt1.localToken, tt1.token); - assertEquals(tt1.localConnectionTimeout, tt1.connectionTimeout); - assertEquals(tt1.localRequestTimeout, tt1.requestTimeout); - assertEquals(tt1.localRequestUsingCaches, tt1.requestUsingCaches); - - assertEquals(tt2.localToken, tt2.token); - assertEquals(tt2.localConnectionTimeout, tt2.connectionTimeout); - assertEquals(tt2.localRequestTimeout, tt2.requestTimeout); - assertEquals(tt2.localRequestUsingCaches, tt2.requestUsingCaches); - } - - @Test - public void testClearThreadLocalContexts() throws Exception { - Intercom.setUseThreadLocal(true); - - Intercom.setToken("testToken"); - assertEquals("testToken", Intercom.getToken()); - - Intercom.clearThreadLocalContexts(); - assertNull(Intercom.getToken()); - - Intercom.setToken("testToken2"); - assertEquals("testToken2", Intercom.getToken()); - } - - @Test - public void testClearThreadLocalContext() throws Exception { - Intercom.setUseThreadLocal(true); - - Intercom.setToken("testToken"); - assertEquals("testToken", Intercom.getToken()); - - Intercom.clearThreadLocalContext(); - assertNull(Intercom.getToken()); - - Intercom.setToken("testToken2"); - assertEquals("testToken2", Intercom.getToken()); - } - - class ThreadTester implements Runnable { - String token; - int connectionTimeout = -1; - int requestTimeout = -1; - Boolean requestUsingCaches; - boolean completed = false; - - @Override - public void run() { - token = Intercom.getToken(); - connectionTimeout = Intercom.getConnectionTimeout(); - requestTimeout = Intercom.getRequestTimeout(); - requestUsingCaches = Intercom.isRequestUsingCaches(); - completed = true; - synchronized (this) { - notify(); - } - } - - void waitUntilComplete() throws InterruptedException { - synchronized (this) { - while(!completed) { - wait(5000); - } - } - } - } - - class ThreadLocalTester1 extends ThreadTester { - final Random rnd = new Random(); - final String localToken = "tx"; - final int localConnectionTimeout = rnd.nextInt(); - final int localRequestTimeout = rnd.nextInt(); - final boolean localRequestUsingCaches = rnd.nextBoolean(); - - @Override - public void run() { - Intercom.clearThreadLocalContext(); - Intercom.setToken(localToken); - Intercom.setConnectionTimeout(localConnectionTimeout); - Intercom.setRequestTimeout(localRequestTimeout); - Intercom.setRequestUsingCaches(localRequestUsingCaches); - super.run(); - } - } - - class ThreadLocalTester2 extends ThreadTester { - final Random rnd = new Random(); - final String localToken = "t2"; - final int localConnectionTimeout = rnd.nextInt(); - final int localRequestTimeout = rnd.nextInt(); - final boolean localRequestUsingCaches = rnd.nextBoolean(); - - @Override - public void run() { - Intercom.clearThreadLocalContext(); - Intercom.setToken(localToken); - Intercom.setConnectionTimeout(localConnectionTimeout); - Intercom.setRequestTimeout(localRequestTimeout); - Intercom.setRequestUsingCaches(localRequestUsingCaches); - super.run(); - } - } -} \ No newline at end of file diff --git a/intercom-java/src/test/java/io/intercom/api/JobItemTest.java b/intercom-java/src/test/java/io/intercom/api/JobItemTest.java deleted file mode 100644 index c7ca926b..00000000 --- a/intercom-java/src/test/java/io/intercom/api/JobItemTest.java +++ /dev/null @@ -1,27 +0,0 @@ -package io.intercom.api; - -import org.junit.Test; - -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -public class JobItemTest { - - @Test - public void testItemValidation() { - - try { - new JobItem(null, new User()); - fail("item with no method"); - } catch (InvalidException e) { - assertTrue(e.getFirstError() != null); - } - - try { - new JobItem("post", null); - fail("item with no data"); - } catch (InvalidException e) { - assertTrue(e.getFirstError() != null); - } - } -} \ No newline at end of file diff --git a/intercom-java/src/test/java/io/intercom/api/JobSupportTest.java b/intercom-java/src/test/java/io/intercom/api/JobSupportTest.java deleted file mode 100644 index 7ef075ee..00000000 --- a/intercom-java/src/test/java/io/intercom/api/JobSupportTest.java +++ /dev/null @@ -1,22 +0,0 @@ -package io.intercom.api; - -import com.google.common.collect.Lists; -import org.junit.Test; - -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -public class JobSupportTest { - - @Test - public void testItemValidation() { - - final JobSupport jobSupport = new JobSupport(); - try { - jobSupport.validateJobItem(new JobItem("levitate", new User()), Lists.newArrayList("post")); - fail("item with an unknown method"); - } catch (InvalidException e) { - assertTrue(e.getFirstError() != null); - } - } -} \ No newline at end of file diff --git a/intercom-java/src/test/java/io/intercom/api/NoteTest.java b/intercom-java/src/test/java/io/intercom/api/NoteTest.java deleted file mode 100644 index ed055027..00000000 --- a/intercom-java/src/test/java/io/intercom/api/NoteTest.java +++ /dev/null @@ -1,61 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.ByteArrayOutputStream; - -import static io.intercom.api.TestSupport.load; -import static org.junit.Assert.assertEquals; - -public class NoteTest { - - private static ObjectMapper mapper; - - @BeforeClass - public static void beforeClass() { - mapper = TestSupport.objectMapper(); - } - - @Test - public void TestSerdes() throws Exception { - String json = load("note.json"); - final Note note = mapper.readValue(json, Note.class); - assertEquals("16", note.getId()); - assertEquals(1389913941L, note.getCreatedAt()); - assertEquals("

Text for my note

", note.getBody()); - - final Author author = note.getAuthor(); - assertEquals(true, author.isAdmin()); - assertEquals("21", author.getId()); - assertEquals("Jayne Cobb", author.getName()); - assertEquals("jayne@serenity.io", author.getEmail()); - - final User user = note.getUser(); - assertEquals("user", user.getType()); - assertEquals("5310d8e8598c9a0b24000005", user.getId()); - - - final ByteArrayOutputStream baos = new ByteArrayOutputStream(); - mapper.writeValue(baos, note); - - final String json1 = baos.toString(); - final Note note1 = mapper.readValue(json, Note.class); - assertEquals("16", note1.getId()); - assertEquals(1389913941L, note1.getCreatedAt()); - assertEquals("

Text for my note

", note1.getBody()); - - final Author author1 = note1.getAuthor(); - assertEquals(true, author1.isAdmin()); - assertEquals("21", author1.getId()); - assertEquals("Jayne Cobb", author1.getName()); - assertEquals("jayne@serenity.io", author1.getEmail()); - - final User user1 = note1.getUser(); - assertEquals("user", user1.getType()); - assertEquals("5310d8e8598c9a0b24000005", user1.getId()); - - assertEquals(note, note1); - } -} \ No newline at end of file diff --git a/intercom-java/src/test/java/io/intercom/api/NotificationTest.java b/intercom-java/src/test/java/io/intercom/api/NotificationTest.java deleted file mode 100644 index 04ebd09c..00000000 --- a/intercom-java/src/test/java/io/intercom/api/NotificationTest.java +++ /dev/null @@ -1,39 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.util.Map; - -import static io.intercom.api.TestSupport.load; -import static org.junit.Assert.assertEquals; - -public class NotificationTest { - private static ObjectMapper mapper; - - @BeforeClass - public static void beforeClass() { - mapper = TestSupport.objectMapper(); - } - - @Test - public void testPayload() throws Exception { - String json = load("notification.json"); - final Notification notification = mapper.readValue(json, Notification.class); - - assertEquals("notif_d9697680-d363-11e7-9ccb-d3a7f70c358c", notification.getId()); - assertEquals(1511781145L, notification.getCreatedAt()); - assertEquals("a86dr8yl", notification.getAppID()); - assertEquals("pending", notification.getDeliveryStatus()); - assertEquals("user.created", notification.getTopic()); - assertEquals(1, notification.getDeliveryAttempts()); - assertEquals(1511781146L, notification.getFirstSentAt()); - - final NotificationData notificationData = notification.getData(); - final Map notificationDataItem = notificationData.getItem(); - assertEquals("user", notificationDataItem.get("type")); - assertEquals("5a1bf31767893985752b4041", notificationDataItem.get("id")); - assertEquals("test1234", notificationDataItem.get("user_id")); - } -} diff --git a/intercom-java/src/test/java/io/intercom/api/SegmentTest.java b/intercom-java/src/test/java/io/intercom/api/SegmentTest.java deleted file mode 100644 index 29c12cb1..00000000 --- a/intercom-java/src/test/java/io/intercom/api/SegmentTest.java +++ /dev/null @@ -1,45 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.ByteArrayOutputStream; - -import static io.intercom.api.TestSupport.load; -import static org.junit.Assert.assertEquals; - -public class SegmentTest { - - private static ObjectMapper mapper; - - @BeforeClass - public static void beforeClass() { - mapper = TestSupport.objectMapper(); - } - - @Test - public void TestSerdes() throws Exception { - String json = load("segment.json"); - final Segment segment = mapper.readValue(json, Segment.class); - assertEquals(1392734388L, segment.getCreatedAt()); - assertEquals(1392734398L, segment.getUpdatedAt()); - assertEquals("segment-name", segment.getName()); - assertEquals("segment", segment.getType()); - assertEquals("3142", segment.getId()); - - final ByteArrayOutputStream baos = new ByteArrayOutputStream(); - mapper.writeValue(baos, segment); - - final String json1 = baos.toString(); - final Segment segment1 = mapper.readValue(json1, Segment.class); - assertEquals(1392734388L, segment1.getCreatedAt()); - assertEquals(1392734398L, segment1.getUpdatedAt()); - assertEquals("segment-name", segment1.getName()); - assertEquals("segment", segment1.getType()); - assertEquals("3142", segment1.getId()); - - assertEquals(segment, segment1); - } - -} \ No newline at end of file diff --git a/intercom-java/src/test/java/io/intercom/api/SocialProfileTest.java b/intercom-java/src/test/java/io/intercom/api/SocialProfileTest.java deleted file mode 100644 index eb688ac3..00000000 --- a/intercom-java/src/test/java/io/intercom/api/SocialProfileTest.java +++ /dev/null @@ -1,39 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.BeforeClass; -import org.junit.Test; - -import static io.intercom.api.TestSupport.load; -import static org.junit.Assert.assertTrue; - -public class SocialProfileTest { - - - private static ObjectMapper mapper; - - @BeforeClass - public static void beforeClass() { - mapper = MapperSupport.objectMapper(); - } - - @Test - public void testURLMarshalling() throws Exception { - String json = load("social_profile_url_1.json"); - SocialProfile socialProfile = mapper.readValue(json, SocialProfile.class); - assertTrue(socialProfile.getUrl() != null); - - json = load("social_profile_url_2.json"); - socialProfile = mapper.readValue(json, SocialProfile.class); - assertTrue(socialProfile.getUrl() != null); - - json = load("social_profile_url_3.json"); - socialProfile = mapper.readValue(json, SocialProfile.class); - assertTrue(socialProfile.getUrl() == null); - - json = load("social_profile_url_4.json"); - socialProfile = mapper.readValue(json, SocialProfile.class); - assertTrue(socialProfile.getUrl() != null); - } - -} \ No newline at end of file diff --git a/intercom-java/src/test/java/io/intercom/api/TagTest.java b/intercom-java/src/test/java/io/intercom/api/TagTest.java deleted file mode 100644 index 1faeabc5..00000000 --- a/intercom-java/src/test/java/io/intercom/api/TagTest.java +++ /dev/null @@ -1,154 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.common.collect.Lists; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.ByteArrayOutputStream; -import java.util.List; -import java.util.Map; - -import static io.intercom.api.TestSupport.load; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -public class TagTest { - - private static ObjectMapper mapper; - - @BeforeClass - public static void beforeClass() { - mapper = TestSupport.objectMapper(); - } - - @Test - public void testTagUsers() throws Exception { - String json = load("tag.json"); - final Tag tag = mapper.readValue(json, Tag.class); - - final User user1 = new User().setEmail("wash@serenity.io").untag(); - final User user2 = new User().setUserId("22"); - final User user3 = new User().setId("3434"); - final User user4 = new User().setEmail("malcolm@serenity.io"); - final User user5 = new User().setUserId("23"); - final User user6 = new User().setId("3435"); - final UserCollection uc = new UserCollection(Lists.newArrayList(user1, user2, user3, user4, user5, user6)); - final Tag.TaggableCollection taggableCollection = Tag.createTagTypedCollection(tag, uc); - final List> users = taggableCollection.getUsers(); - - int match = 0; - for (Map user : users) { - if (user.containsKey("id") && user.get("id").equals("3434")) { - match += 1; - } - if (user.containsKey("email") && user.get("email").equals("wash@serenity.io")) { - match += 1; - assertTrue(user.containsKey("untag") && user.get("untag") == Boolean.TRUE); - } - if (user.containsKey("user_id") && user.get("user_id").equals("22")) { - match += 1; - } - if (user.containsKey("id") && user.get("id").equals("3435")) { - match += 1; - } - if (user.containsKey("email") && user.get("email").equals("malcolm@serenity.io")) { - match += 1; - } - if (user.containsKey("user_id") && user.get("user_id").equals("23")) { - match += 1; - } - } - assertEquals(6, match); - } - - @Test - public void testTagContacts() throws Exception { - String json = load("tag.json"); - final Tag tag = mapper.readValue(json, Tag.class); - - final Contact contact1 = new Contact().setID("3434"); - final Contact contact2 = new Contact().setID("3435").untag(); - final Contact contact3 = new Contact().setEmail("malcolm@serenity.io"); - final Contact contact4 = new Contact().setEmail("wash@serenity.io").untag(); - final ContactCollection contactCollection = new ContactCollection(Lists.newArrayList(contact1, contact2, contact3, contact4)); - final Tag.TaggableCollection taggableCollection = Tag.createTagTypedCollection(tag, contactCollection); - final List> contacts = taggableCollection.getUsers(); - - int match = 0; - for (Map contact : contacts) { - if (contact.containsKey("id") && contact.get("id").equals("3434")) { - match += 1; - assertTrue(!contact.containsKey("untag")); - } - if (contact.containsKey("id") && contact.get("id").equals("3435")) { - match += 1; - assertTrue(contact.containsKey("untag") && contact.get("untag") == Boolean.TRUE); - } - } - assertEquals(2, match); - } - - @Test - public void testTagCompanies() throws Exception { - String json = load("tag.json"); - final Tag tag = mapper.readValue(json, Tag.class); - - final Company c1 = new Company().setCompanyID("c1").untag(); - final Company c2 = new Company().setName("name1"); - final Company c3 = new Company().setCompanyID("c3"); - final Company c4 = new Company().setName("name4"); - final Company c5 = new Company().setId("1"); - final Company c6 = new Company().setId("2"); - final CompanyCollection uc = new CompanyCollection(Lists.newArrayList(c1, c2, c3, c4, c5, c6)); - final Tag.TaggableCollection taggableCollection = Tag.createTagTypedCollection(tag, uc); - final List> companies = taggableCollection.getCompanies(); - int match = 0; - for (Map company : companies) { - if (company.containsKey("company_id") && company.get("company_id").equals("c1")) { - match += 1; - assertTrue(company.containsKey("untag") && company.get("untag") == Boolean.TRUE); - } - if (company.containsKey("name") && company.get("name").equals("name1")) { - match += 1; - } - if (company.containsKey("company_id") && company.get("company_id").equals("c3")) { - match += 1; - } - if (company.containsKey("name") && company.get("name").equals("name4")) { - match += 1; - } - if (company.containsKey("id") && company.get("id").equals("1")) { - match += 1; - } - if (company.containsKey("id") && company.get("id").equals("2")) { - match += 1; - } - } - assertEquals(6, match); - } - - @Test - public void TestSerdes() throws Exception { - String json = load("tag.json"); - final Tag tag = mapper.readValue(json, Tag.class); - assertEquals(1392734388L, tag.getCreatedAt()); - assertEquals(1392734398L, tag.getUpdatedAt()); - assertEquals("tag-name", tag.getName()); - assertEquals("tag", tag.getType()); - assertEquals("3142", tag.getId()); - - final ByteArrayOutputStream baos = new ByteArrayOutputStream(); - mapper.writeValue(baos, tag); - - final String json1 = baos.toString(); - final Tag tag1 = mapper.readValue(json1, Tag.class); - assertEquals(1392734388L, tag1.getCreatedAt()); - assertEquals(1392734398L, tag1.getUpdatedAt()); - assertEquals("tag-name", tag1.getName()); - assertEquals("tag", tag1.getType()); - assertEquals("3142", tag1.getId()); - - assertEquals(tag, tag1); - } -} diff --git a/intercom-java/src/test/java/io/intercom/api/TestSupport.java b/intercom-java/src/test/java/io/intercom/api/TestSupport.java deleted file mode 100644 index a37e9d16..00000000 --- a/intercom-java/src/test/java/io/intercom/api/TestSupport.java +++ /dev/null @@ -1,19 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.common.base.Charsets; -import com.google.common.io.Resources; - -import java.io.IOException; - -public class TestSupport { - - public static String load(String name) throws IOException { - return Resources.toString(Resources.getResource(name), Charsets.UTF_8); - } - - public static ObjectMapper objectMapper() { - return MapperSupport.objectMapper(); - } - -} diff --git a/intercom-java/src/test/java/io/intercom/api/UriBuilderTest.java b/intercom-java/src/test/java/io/intercom/api/UriBuilderTest.java deleted file mode 100644 index ef2da6be..00000000 --- a/intercom-java/src/test/java/io/intercom/api/UriBuilderTest.java +++ /dev/null @@ -1,45 +0,0 @@ -package io.intercom.api; - -import com.google.common.collect.Maps; -import org.junit.Test; - -import java.net.URI; -import java.util.HashMap; - -import static org.junit.Assert.assertEquals; - -public class UriBuilderTest { - - @Test - public void builder() { - final UriBuilder uriBuilder = UriBuilder.newBuilder("http://example.org"); - final HashMap map = Maps.newHashMap(); - map.put("c", "quux"); - map.put("b", "bar"); - map.put("a", "foo"); - URI uri = uriBuilder.query(map).build(); - assertEquals("http://example.org?a=foo&b=bar&c=quux", uri.toASCIIString()); - } - - @Test - public void buildPath() { - final UriBuilder uriBuilder = UriBuilder.newBuilder("http://example.org"); - final String s = uriBuilder.path("users").path("3142").build().toASCIIString(); - assertEquals("http://example.org/users/3142", s); - } - - - @Test - public void buildPathMix() { - final UriBuilder uriBuilder = UriBuilder.newBuilder("http://example.org"); - final HashMap map = Maps.newHashMap(); - map.put("c", "quu x"); // check we're encoding ws as '%20' and not '+' - map.put("b", "bar"); - map.put("a", "foo"); - // check that adding params before paths works - final String s = uriBuilder.query(map).path("users").path("3142").buildString(); - assertEquals("http://example.org/users/3142?a=foo&b=bar&c=quu%20x", s); - } - - -} \ No newline at end of file diff --git a/intercom-java/src/test/java/io/intercom/api/UserTest.java b/intercom-java/src/test/java/io/intercom/api/UserTest.java deleted file mode 100644 index 5f839ff2..00000000 --- a/intercom-java/src/test/java/io/intercom/api/UserTest.java +++ /dev/null @@ -1,276 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.common.collect.Lists; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.util.List; -import java.util.Map; - -import static io.intercom.api.TestSupport.load; -import static org.junit.Assert.*; - -public class UserTest { - - private static ObjectMapper mapper; - - @BeforeClass - public static void beforeClass() { - mapper = MapperSupport.objectMapper(); - } - - @Test - public void TestUserUpdateEmptyCompanies() throws Exception { - final User user = new User().setEmail("wash@serenity.io"); - final User.UserUpdate userUpdate = User.UserUpdate.buildFrom(user); - assertEquals(null, userUpdate.getCompanyCollection()); - } - - @Test - public void TestUserUpdate() throws Exception { - final Avatar avatar = new Avatar() - .setImageURL("http://example.com/256Wash.jpg"); - - final long now = System.currentTimeMillis() / 1000; - final User user = new User() - .setEmail("wash@serenity.io") - .setPhone("+1234567890") - .setId("54321") - .setUserId("22") - .setRemoteCreatedAt(now) - .setName("Wash") - .setUnsubscribedFromEmails(true) - .setUpdateLastRequestAt(true) - .setNewSession(true) - .setUserAgentData("user-agent") - .setAvatar(avatar); - - final User.UserUpdate userUpdate = User.UserUpdate.buildFrom(user); - - assertEquals("54321", userUpdate.getId()); - assertEquals("wash@serenity.io", userUpdate.getEmail()); - assertEquals("+1234567890", userUpdate.getPhone()); - assertEquals("22", userUpdate.getUserId()); - assertEquals(now, userUpdate.getRemoteCreatedAt()); - assertEquals("Wash", userUpdate.getName()); - assertEquals(true, userUpdate.getUnsubscribedFromEmails()); - assertEquals(true, userUpdate.isUpdateLastRequestAt()); - assertEquals(true, userUpdate.isNewSession()); - assertEquals("user-agent", userUpdate.getLastSeenUserAgent()); - assertEquals(null, userUpdate.getType()); - assertEquals("http://example.com/256Wash.jpg", userUpdate.getAvatar().getImageURL().toString()); - } - - @Test - public void testUserUpdateDefaultSerdes() throws Exception { - final User user = new User(); - final User.UserUpdate userUpdate = User.UserUpdate.buildFrom(user); - - /* - check we didn't set unsubscribed_from_emails, update_last_request_at, or - new_session by default - */ - assertEquals(null, userUpdate.getUnsubscribedFromEmails()); - assertEquals(null, userUpdate.isNewSession()); - assertEquals(null, userUpdate.isUpdateLastRequestAt()); - - /* - https://github.com/intercom/intercom-java/issues/45 - Workaround for server limitation (not accepting - the type field on create/update) - */ - assertEquals(null, userUpdate.getType()); - final String json = mapper.writeValueAsString(userUpdate); - - assertFalse(json.contains("type")); - assertFalse(json.contains("unsubscribed_from_emails")); - assertFalse(json.contains("update_last_request_at")); - assertFalse(json.contains("new_session")); - - final Map map = mapper.readValue(json, Map.class); - assertFalse(map.containsKey("type")); - assertFalse(map.containsKey("unsubscribed_from_emails")); - assertFalse(map.containsKey("update_last_request_at")); - assertFalse(map.containsKey("new_session")); - } - - @Test - public void testUserUpdateDefaultModifiedSerdes() throws Exception { - final User user = new User(); - - user.setNewSession(true); - user.setUnsubscribedFromEmails(true); - user.setUpdateLastRequestAt(true); - - final User.UserUpdate userUpdate = User.UserUpdate.buildFrom(user); - - assertEquals(true, userUpdate.getUnsubscribedFromEmails()); - assertEquals(true, userUpdate.isNewSession()); - assertEquals(true, userUpdate.isUpdateLastRequestAt()); - - final String json = mapper.writeValueAsString(userUpdate); - - assertTrue(json.contains("unsubscribed_from_emails")); - assertTrue(json.contains("update_last_request_at")); - assertTrue(json.contains("new_session")); - - final Map map = mapper.readValue(json, Map.class); - assertTrue(map.containsKey("unsubscribed_from_emails")); - assertTrue(map.containsKey("update_last_request_at")); - assertTrue(map.containsKey("new_session")); - } - - @Test - public void TestUserIncludesId() throws Exception { - final User user = new User(); - user.setEmail("a@b.com"); - user.setUserId("1"); - user.setId("5432"); - final String json = mapper.writeValueAsString(user); - final Map map = mapper.readValue(json, Map.class); - assertTrue(map.size() == 4); - assertTrue(map.containsKey("email")); - assertTrue(map.containsKey("user_id")); - assertTrue(map.containsKey("id")); - assertTrue(map.containsKey("type")); - } - - @Test - public void TestUserSerdesNullAndNotEmpty() throws Exception { - final User user = new User(); - user.setEmail("a@b.com"); - user.setUserId("1"); - final String json = mapper.writeValueAsString(user); - final Map map = mapper.readValue(json, Map.class); - assertTrue(map.size() == 3); - assertTrue(map.containsKey("email")); - assertTrue(map.containsKey("user_id")); - assertTrue(map.containsKey("type")); - } - - @Test - public void TestUserSerdesTrip() throws Exception { - String json = load("user.json"); - final User user = mapper.readValue(json, User.class); - final String json1 = mapper.writeValueAsString(user); - final User user1 = mapper.readValue(json1, User.class); - assertTrue(user.equals(user1)); - } - - @Test - public void TestCustomAttributeSerdesTrip() throws Exception { - String json = load("user.json"); - final User user = mapper.readValue(json, User.class); - final String json1 = mapper.writeValueAsString(user); - final User user1 = mapper.readValue(json1, User.class); - assertEquals(user.getCustomAttributes(), user1.getCustomAttributes()); - } - - @Test - public void TestSerdes() throws Exception { - String json = load("user.json"); - final User user = mapper.readValue(json, User.class); - assertEquals("user", user.getType()); - assertEquals("530370b477ad7120001d", user.getId()); - assertEquals("25", user.getUserId()); - assertEquals("wash@serenity.io", user.getEmail()); - assertEquals("+1234567890", user.getPhone()); - assertEquals("Hoban Washburne", user.getName()); - assertEquals(0, user.getSessionCount()); - assertEquals("1.2.3.4", user.getLastSeenIp()); - assertEquals(Boolean.FALSE, user.getUnsubscribedFromEmails()); - assertEquals("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9", user.getUserAgentData()); - assertEquals(1397574667L, user.getLastRequestAt()); - assertEquals(1392731331L, user.getRemoteCreatedAt()); - assertEquals(1392731331L, user.getSignedUpAt()); - assertEquals(1392734388L, user.getCreatedAt()); - assertEquals(1392734388L, user.getUpdatedAt()); - - final Avatar avatar = user.getAvatar(); - assertEquals("avatar", avatar.getType()); - assertEquals("http://example.org/128Wash.jpg", avatar.getImageURL().toString()); - - final SegmentCollection segmentCollection = user.getSegmentCollection(); - assertEquals("segment.list", segmentCollection.getType()); - final List items = segmentCollection.getPage(); - final Segment segment = items.get(0); - assertEquals("segment", segment.getType()); - assertEquals("5310d8e7598c9a0b24000002", segment.getId()); - - - @SuppressWarnings("UnusedDeclaration") - final CompanyCollection companyCollection = user.getCompanyCollection(); - - final Map customAttributes = user.getCustomAttributes(); - CustomAttribute customAttribute; - - customAttribute = customAttributes.get("truthy_typed"); - assertEquals(Boolean.class, customAttribute.getValueClass()); - assertEquals(Boolean.TRUE, customAttribute.getValue()); - assertEquals(Boolean.TRUE, customAttribute.booleanValue()); - assertEquals("truthy_typed", customAttribute.getName()); - - customAttribute = customAttributes.get("floatly_typed"); - assertEquals(Double.class, customAttribute.getValueClass()); - assertEquals(155.5d, customAttribute.getValue()); - assertEquals(155.5d, customAttribute.doubleValue(), 0d); - assertEquals("floatly_typed", customAttribute.getName()); - - customAttribute = customAttributes.get("stringly_typed"); - assertEquals(String.class, customAttribute.getValueClass()); - assertEquals("data", customAttribute.getValue()); - assertEquals("data", customAttribute.textValue()); - assertEquals("stringly_typed", customAttribute.getName()); - - customAttribute = customAttributes.get("dately_typed_at"); - assertEquals(Long.class, customAttribute.getValueClass()); - assertEquals(1397574667L, customAttribute.getValue()); - assertEquals(1397574667L, customAttribute.longValue()); - assertEquals("dately_typed_at", customAttribute.getName()); - - customAttribute = customAttributes.get("longly_typed"); - assertEquals(Long.class, customAttribute.getValueClass()); - assertEquals(221397574667L, customAttribute.getValue()); - assertEquals(221397574667L, customAttribute.longValue()); - assertEquals("longly_typed", customAttribute.getName()); - - customAttribute = customAttributes.get("intly_typed"); - assertEquals(Integer.class, customAttribute.getValueClass()); - assertEquals(1, customAttribute.getValue()); - assertEquals(1, customAttribute.integerValue()); - assertEquals("intly_typed", customAttribute.getName()); - - // null values are not ignored - customAttribute = customAttributes.get("nully_typed"); - assertEquals(null, customAttribute); - } - - @Test - public void TestSerdesNoAvatar() throws Exception { - String json = load("user_no_avatar.json"); - final User user = mapper.readValue(json, User.class); - assertEquals(null, user.getAvatar().getImageURL()); - } - - @Test - public void testBulkValidation() { - - final User user = new User(); - user.setEmail("a@b.com"); - user.setUserId("1"); - try { - User.UserUpdate.validateAndConvertJobItems(Lists.newArrayList(new JobItem("levitate", user))); - fail("bulk user with an unknown method"); - } catch (InvalidException e) { - assertTrue(e.getFirstError() != null); - } - } - - @Test - public void TestPermanentDelete() throws Exception{ - String json = load("permanent_delete_response.json"); - final UserPermanentDeleteResponse userPermanentDeleteResponse= mapper.readValue(json, UserPermanentDeleteResponse.class); - assertEquals("123456", userPermanentDeleteResponse.getId()); - } -} diff --git a/intercom-java/src/test/java/io/intercom/api/VisitorTest.java b/intercom-java/src/test/java/io/intercom/api/VisitorTest.java deleted file mode 100644 index 5d49e740..00000000 --- a/intercom-java/src/test/java/io/intercom/api/VisitorTest.java +++ /dev/null @@ -1,109 +0,0 @@ -package io.intercom.api; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.common.collect.Lists; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.util.List; -import java.util.Map; - -import static io.intercom.api.TestSupport.load; -import static org.junit.Assert.*; - -public class VisitorTest { - - private static ObjectMapper mapper; - - @BeforeClass - public static void beforeClass() { - mapper = MapperSupport.objectMapper(); - } - - @Test - public void TestVisitorUpdate() throws Exception { - final Avatar avatar = new Avatar() - .setImageURL("http://example.com/256Wash.jpg"); - - final long now = System.currentTimeMillis() / 1000; - final Visitor visitor = new Visitor() - .setEmail("wash@serenity.io") - .setPhone("+1234567890") - .setID("54321") - .setUserID("22") - .setName("Wash") - .setUnsubscribedFromEmails(true) - .setLastSeenUserAgent("user-agent") - .setLastSeenIP("1.2.3.4") - .setUtmCampaign("utm campaign") - .setUtmContent("utm content") - .setUtmMedium("utm medium") - .setUtmSource("utm source") - .setUtmTerm("utm term") - .addCustomAttribute(CustomAttribute.newStringAttribute("test_string", "visitor string")) - .addCustomAttribute(CustomAttribute.newIntegerAttribute("test_integer", 123)) - .setAvatar(avatar); - - final Visitor.VisitorUpdate visitorUpdate = Visitor.VisitorUpdate.buildFrom(visitor); - - assertEquals("wash@serenity.io", visitorUpdate.getEmail()); - assertEquals("+1234567890", visitorUpdate.getPhone()); - assertEquals("54321", visitorUpdate.getID()); - assertEquals("22", visitorUpdate.getUserID()); - assertEquals("Wash", visitorUpdate.getName()); - assertEquals(true, visitorUpdate.getUnsubscribedFromEmails()); - assertEquals("user-agent", visitorUpdate.getLastSeenUserAgent()); - assertEquals("1.2.3.4", visitorUpdate.getLastSeenIP()); - assertEquals("utm campaign", visitorUpdate.getUtmCampaign()); - assertEquals("utm content", visitorUpdate.getUtmContent()); - assertEquals("utm medium", visitorUpdate.getUtmMedium()); - assertEquals("utm source", visitorUpdate.getUtmSource()); - assertEquals("utm term", visitorUpdate.getUtmTerm()); - assertEquals("http://example.com/256Wash.jpg", visitorUpdate.getAvatar().getImageURL().toString()); - Map attributes = visitorUpdate.getCustomAttributes(); - assertEquals(2, attributes.size()); - assertEquals("visitor string", attributes.get("test_string").getValue()); - assertEquals(123, attributes.get("test_integer").getValue()); - - } - - @Test - public void TestVisitorParseJson() throws Exception { - String json = load("visitor.json"); - final Visitor visitor = mapper.readValue(json, Visitor.class); - assertEquals("visitor", visitor.getType()); - assertEquals("5b69565fa737210d1c2127f1", visitor.getID()); - assertEquals("6a347bc9-0b96-4925-bbbc-1f8b11f94c50", visitor.getUserID()); - assertEquals("visitor@example.com", visitor.getEmail()); - assertEquals("123456789", visitor.getPhone()); - assertEquals("Violet Star from Singapore", visitor.getPseudonym()); - assertEquals("A Visitor", visitor.getName()); - - assertEquals("https://static.intercomassets.com/app/pseudonym_avatars_2018/violet-star.png", visitor.getAvatar().getImageURL().toString()); - - Map attributes = visitor.getCustomAttributes(); - assertEquals(2, attributes.size()); - assertEquals("visitor string", attributes.get("test_string").getValue()); - assertEquals(123, attributes.get("test_integer").getValue()); - assertEquals("61.6.236.243", visitor.getLastSeenIP()); - assertEquals("Bandar Seri Begawan",visitor.getLocationData().getCity_Name()); - assertEquals("BRN",visitor.getLocationData().getCountryCode()); - assertEquals("Brunei Darussalam",visitor.getLocationData().getCountryName()); - assertEquals("AS",visitor.getLocationData().getContinentCode()); - assertEquals("1234",visitor.getLocationData().getPostalCode()); - assertEquals("a region",visitor.getLocationData().getRegionName()); - assertEquals("Asia/Brunei",visitor.getLocationData().getTimezone()); - assertEquals("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.84 Safari/537.36",visitor.getUserAgentData()); - assertEquals(1533636256,visitor.getLastRequestAt()); - assertEquals(1533630047,visitor.getCreatedAt()); - assertEquals(1533636257,visitor.getUpdatedAt()); - - assertEquals("utm campaign", visitor.getUtmCampaign()); - assertEquals("utm content", visitor.getUtmContent()); - assertEquals("utm medium", visitor.getUtmMedium()); - assertEquals("utm source", visitor.getUtmSource()); - assertEquals("utm term", visitor.getUtmTerm()); - assertEquals("the referrer", visitor.getReferrer()); - } - -} diff --git a/intercom-java/src/test/resources/admin.json b/intercom-java/src/test/resources/admin.json deleted file mode 100644 index 25da0239..00000000 --- a/intercom-java/src/test/resources/admin.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "type": "admin", - "id": "123456", - "name": "Admin Name", - "email": "admin@domain.com", - "away_mode_enabled": true, - "away_mode_reassign": false, - "has_inbox_seat": true, - "avatar": { - "image_url": "https://avatarurl.com/image.jpg" - }, - "team_ids": [ - 123, - 456, - 789 - ] -} \ No newline at end of file diff --git a/intercom-java/src/test/resources/admin_team.json b/intercom-java/src/test/resources/admin_team.json deleted file mode 100644 index 070fe936..00000000 --- a/intercom-java/src/test/resources/admin_team.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "type": "team", - "id": "654321", - "name": "A Team", - "email": "team-email@teams.intercom.io", - "away_mode_enabled": false, - "away_mode_reassign": false, - "has_inbox_seat": true, - "avatar": { - "image_url": "https://domain.com/avatar" - }, - "admin_ids": [ - 987, - 654, - 321 - ] -} \ No newline at end of file diff --git a/intercom-java/src/test/resources/admins.json b/intercom-java/src/test/resources/admins.json deleted file mode 100644 index 944b6935..00000000 --- a/intercom-java/src/test/resources/admins.json +++ /dev/null @@ -1,91 +0,0 @@ -{ - "type": "admin.list", - "admins": [ - { - "type": "admin", - "id": "123456", - "name": "Admin Name", - "email": "admin@domain.com", - "away_mode_enabled": true, - "away_mode_reassign": false, - "has_inbox_seat": true, - "avatar": { - "image_url": "https://avatarurl.com/image.jpg" - }, - "team_ids": [ - 123, - 456, - 789 - ] - }, - { - "type": "admin", - "id": "234567", - "name": "Admin2 Name", - "email": "admin2@domain.com", - "away_mode_enabled": false, - "away_mode_reassign": false, - "has_inbox_seat": false, - "avatar": { - "image_url": "https://avatarurl.com/image2.jpg" - }, - "team_ids": [ - 456, - 789 - ] - }, - { - "type": "team", - "id": "123", - "name": "A Team", - "email": "team-email@teams.intercom.io", - "away_mode_enabled": false, - "away_mode_reassign": false, - "has_inbox_seat": true, - "avatar": { - "image_url": "https://domain.com/avatar" - }, - "admin_ids": [ - 123456, - 234567 - ] - }, - { - "type": "team", - "id": "456", - "name": "B Team", - "email": "team-email2@teams.intercom.io", - "away_mode_enabled": false, - "away_mode_reassign": false, - "has_inbox_seat": true, - "avatar": { - "image_url": "https://domain.com/avatar2" - }, - "admin_ids": [ - 123456 - ] - }, - { - "type": "team", - "id": "789", - "name": "C Team", - "email": "team-email3@teams.intercom.io", - "away_mode_enabled": false, - "away_mode_reassign": false, - "has_inbox_seat": false, - "avatar": { - "image_url": "https://domain.com/avatar3" - }, - "admin_ids": [ - ] - }, - { - "type": "admin", - "email": "bot-123123123@bots.intercom.io", - "id": "807", - "name": "A bot", - "away_mode_enabled": false, - "away_mode_reassign": false - } - ] -} \ No newline at end of file diff --git a/intercom-java/src/test/resources/company.json b/intercom-java/src/test/resources/company.json deleted file mode 100644 index c6e276b1..00000000 --- a/intercom-java/src/test/resources/company.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "type": "company", - "company_id": "6", - "id": "5694b58371b5025a2a0003e6", - "app_id": "qji82zks", - "name": "Blue Sun", - "remote_created_at": 1394531169, - "created_at": 1452586372, - "updated_at": 1517835268, - "last_request_at": 1496292261, - "monthly_spend": 49, - "session_count": 2, - "user_count": 1, - "size": 85, - "website": "http://www.example.com", - "industry": "Manufacturing", - "tags": { - "type": "tag.list", - "tags": [ - { - "type": "tag", - "id": "1072802", - "name": "CompanyTag1" - } - ] - }, - "segments": { - "type": "segment.list", - "segments": [ - { - "type": "segment", - "id": "58b7c061d5cf5649a59f7097" - }, - { - "type": "segment", - "id": "593107f85950a28b168aa9d3" - } - ] - }, - "plan": { - "type": "plan", - "id": "150154", - "name": "plan1" - }, - "custom_attributes": { - "truthy_typed": true, - "floatly_typed": 155.5, - "stringly_typed": "data", - "dately_typed_at": 1397574667, - "longly_typed": 221397574667, - "intly_typed": 1, - "nully_typed": null - } -} diff --git a/intercom-java/src/test/resources/company_no_data_except_company_id.json b/intercom-java/src/test/resources/company_no_data_except_company_id.json deleted file mode 100644 index 10ab052b..00000000 --- a/intercom-java/src/test/resources/company_no_data_except_company_id.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "type": "company", - "company_id": "6", - "id": "5694b58371b5025a2a0003e6", - "created_at": 1452586372, - "updated_at": 1517835268, - "monthly_spend": 0, - "session_count": 0, - "user_count": 0, - "tags": { - "type": "tag.list", - "tags": [] - }, - "segments": { - "type": "segment.list", - "segments": [] - }, - "plan": {}, - "custom_attributes": { - } -} diff --git a/intercom-java/src/test/resources/conversation.json b/intercom-java/src/test/resources/conversation.json deleted file mode 100644 index 1326841a..00000000 --- a/intercom-java/src/test/resources/conversation.json +++ /dev/null @@ -1,104 +0,0 @@ -{ - "type": "conversation", - "id": "5143511111", - "created_at": 1466703132, - "updated_at": 1468236397, - "waiting_since": 1468236397, - "conversation_message": { - "type": "conversation_message", - "id": "33954111", - "subject": "Email subject", - "body": "

test

", - "delivered_as": "customer_initiated", - "author": { - "type": "lead", - "id": "576c1a139d0baad1010011111" - }, - "attachments": [{ - "type": "upload", - "name": "123.csv", - "url": "https://downloads.intercomcdn.com/123.csv", - "content_type": "text/csv", - "filesize": 147, - "width": null, - "height": null - },{ - "type": "upload", - "name": "abc.txt", - "url": "https://downloads.intercomcdn.com/txt", - "content_type": "text/csv", - "filesize": 100, - "width": 1, - "height": 2 - }], - "url": "https://intercom.com/" - }, - "user": { - "type": "user", - "id": "576c1a139d0baad1010001111" - }, - "assignee": { - "type": "admin", - "id": "358111" - }, - "customer_first_reply": { - "created_at": 1468236397, - "type": "conversation", - "url": "https://someurl" - }, - "conversation_parts": { - "type": "conversation_part.list", - "conversation_parts": [ - { - "type": "conversation_part", - "id": "142533411", - "part_type": "comment", - "body": "

dm-9187dba8-fb3b-cb99-da05-37a932d3d678

", - "created_at": 1468031160, - "updated_at": 1468031160, - "notified_at": 1468031160, - "assigned_to": null, - "author": { - "type": "user", - "id": "576c1a139d0baad1010001111" - }, - "attachments": [], - "external_id": null - }, - { - "type": "conversation_part", - "id": "142533511", - "part_type": "comment", - "body": "

im-99a3a78f-5105-449d-a114-a7b5eb7e5b80

", - "created_at": 1468031171, - "updated_at": 1468031171, - "notified_at": 1468031171, - "assigned_to": null, - "author": { - "type": "admin", - "id": "358111" - }, - "attachments": [], - "external_id": null - } - ], - "total_count": 2 - }, - "open": true, - "read": false, - "tags": { - "type": "tag.list", - "tags": [ - { - "type": "tag", - "id": "123", - "name": "Tag 1" - }, - { - "type": "tag", - "id": "456", - "name": "Tag 2" - } - ] - } -} diff --git a/intercom-java/src/test/resources/conversation_no_attachments.json b/intercom-java/src/test/resources/conversation_no_attachments.json deleted file mode 100644 index 0f395873..00000000 --- a/intercom-java/src/test/resources/conversation_no_attachments.json +++ /dev/null @@ -1,83 +0,0 @@ -{ - "type": "conversation", - "id": "5143511111", - "created_at": 1466703132, - "updated_at": 1468236397, - "waiting_since": 1468236397, - "conversation_message": { - "type": "conversation_message", - "id": "33954111", - "subject": "Email subject", - "body": "

test

", - "delivered_as": "customer_initiated", - "author": { - "type": "lead", - "id": "576c1a139d0baad1010011111" - }, - "attachments": [], - "url": "https://intercom.com/" - }, - "user": { - "type": "user", - "id": "576c1a139d0baad1010001111" - }, - "assignee": { - "type": "admin", - "id": "358111" - }, - "conversation_parts": { - "type": "conversation_part.list", - "conversation_parts": [ - { - "type": "conversation_part", - "id": "142533411", - "part_type": "comment", - "body": "

dm-9187dba8-fb3b-cb99-da05-37a932d3d678

", - "created_at": 1468031160, - "updated_at": 1468031160, - "notified_at": 1468031160, - "assigned_to": null, - "author": { - "type": "user", - "id": "576c1a139d0baad1010001111" - }, - "attachments": [], - "external_id": null - }, - { - "type": "conversation_part", - "id": "142533511", - "part_type": "comment", - "body": "

im-99a3a78f-5105-449d-a114-a7b5eb7e5b80

", - "created_at": 1468031171, - "updated_at": 1468031171, - "notified_at": 1468031171, - "assigned_to": null, - "author": { - "type": "admin", - "id": "358111" - }, - "attachments": [], - "external_id": null - } - ], - "total_count": 2 - }, - "open": true, - "read": false, - "tags": { - "type": "tag.list", - "tags": [ - { - "type": "tag", - "id": "123", - "name": "Tag 1" - }, - { - "type": "tag", - "id": "456", - "name": "Tag 2" - } - ] - } -} diff --git a/intercom-java/src/test/resources/conversation_no_parts.json b/intercom-java/src/test/resources/conversation_no_parts.json deleted file mode 100644 index baa29d79..00000000 --- a/intercom-java/src/test/resources/conversation_no_parts.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "type": "conversation", - "id": "5143511111", - "created_at": 1466703132, - "updated_at": 1468236397, - "waiting_since": 1468236397, - "conversation_message": { - "type": "conversation_message", - "id": "33954111", - "subject": "", - "body": "

test

", - "author": { - "type": "lead", - "id": "576c1a139d0baad1010011111" - }, - "attachments": [], - "url": null - }, - "user": { - "type": "user", - "id": "576c1a139d0baad1010001111" - }, - "assignee": { - "type": "admin", - "id": "358111" - }, - "conversation_parts": { - "type": "conversation_part.list", - "conversation_parts": [], - "total_count": 0 - }, - "open": true, - "read": false, - "tags": { - "type": "tag.list", - "tags": [] - } -} diff --git a/intercom-java/src/test/resources/conversation_no_tags.json b/intercom-java/src/test/resources/conversation_no_tags.json deleted file mode 100644 index baa29d79..00000000 --- a/intercom-java/src/test/resources/conversation_no_tags.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "type": "conversation", - "id": "5143511111", - "created_at": 1466703132, - "updated_at": 1468236397, - "waiting_since": 1468236397, - "conversation_message": { - "type": "conversation_message", - "id": "33954111", - "subject": "", - "body": "

test

", - "author": { - "type": "lead", - "id": "576c1a139d0baad1010011111" - }, - "attachments": [], - "url": null - }, - "user": { - "type": "user", - "id": "576c1a139d0baad1010001111" - }, - "assignee": { - "type": "admin", - "id": "358111" - }, - "conversation_parts": { - "type": "conversation_part.list", - "conversation_parts": [], - "total_count": 0 - }, - "open": true, - "read": false, - "tags": { - "type": "tag.list", - "tags": [] - } -} diff --git a/intercom-java/src/test/resources/conversations.json b/intercom-java/src/test/resources/conversations.json deleted file mode 100644 index e1909803..00000000 --- a/intercom-java/src/test/resources/conversations.json +++ /dev/null @@ -1,102 +0,0 @@ -{ - "type": "conversation.list", - "pages": { - "type": "pages", - "next": null, - "page": 1, - "per_page": 20, - "total_pages": 1 - }, - "conversations": [ - { - "type": "conversation", - "id": "5680931777", - "created_at": 1471438637, - "updated_at": 1471438637, - "waiting_since": 1468236397, - "user": { - "type": "user", - "id": "57b45f16d1aad7e69e011111" - }, - "assignee": { - "type": "nobody_admin", - "id": null - }, - "conversation_message": { - "type": "conversation_message", - "id": "41111111", - "subject": "", - "body": "

Hey2

", - "delivered_as": "customer_initiated", - "author": { - "type": "user", - "id": "57b45f16d1aad7e69e011111" - }, - "attachments": [], - "url": null - }, - "open": true, - "read": true - }, - { - "type": "conversation", - "id": "5680912811", - "created_at": 1471438151, - "updated_at": 1471438151, - "waiting_since": 1468236397, - "user": { - "type": "user", - "id": "57b45bfef436c8d78611111" - }, - "assignee": { - "type": "nobody_admin", - "id": null - }, - "conversation_message": { - "type": "conversation_message", - "id": "41141111", - "subject": "", - "body": "

Hey

", - "delivered_as": "customer_initiated", - "author": { - "type": "user", - "id": "57b45bfef436c8d786000111" - }, - "attachments": [], - "url": null - }, - "open": true, - "read": true - }, - { - "type": "conversation", - "id": "5143511111", - "created_at": 1466703132, - "updated_at": 1468236397, - "waiting_since": 1468236397, - "user": { - "type": "lead", - "id": "576c1a139d0baad101001111" - }, - "assignee": { - "type": "admin", - "id": "358111" - }, - "conversation_message": { - "type": "conversation_message", - "id": "33954838", - "subject": "", - "body": "

test

", - "delivered_as": "customer_initiated", - "author": { - "type": "lead", - "id": "576c1a139d0baad101001111" - }, - "attachments": [], - "url": null - }, - "open": true, - "read": false - } - ] -} diff --git a/intercom-java/src/test/resources/errors.json b/intercom-java/src/test/resources/errors.json deleted file mode 100644 index 2bea5c5b..00000000 --- a/intercom-java/src/test/resources/errors.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "type": "error.list", - "errors": [ - { - "code": "not_found", - "message": "No such user_id[314159]" - }, - { - "code": "not_found", - "message": "No such email[pi@example.org]" - } - ] -} \ No newline at end of file diff --git a/intercom-java/src/test/resources/event_summary.json b/intercom-java/src/test/resources/event_summary.json deleted file mode 100644 index c5c0da73..00000000 --- a/intercom-java/src/test/resources/event_summary.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "type": "event.summary", - "email": "wash@serenity.io", - "intercom_user_id": "530370b477ad7120001d", - "user_id": "25", - "events": [ - { - "name": "test-event", - "first": "2016-12-22T03:54:57.000Z", - "last": "2018-10-10T06:51:02.000Z", - "count": 8, - "description": null - }, - { - "name": "clicked-button", - "first": "2018-02-20T06:40:16.000Z", - "last": "2018-02-20T06:40:16.000Z", - "count": 1, - "description": "Clicking home page button" - }, - { - "name": "completed purchase", - "first": "2018-03-13T02:52:53.000Z", - "last": "2018-03-13T02:58:31.000Z", - "count": 4, - "description": null - } - ] -} diff --git a/intercom-java/src/test/resources/events.json b/intercom-java/src/test/resources/events.json deleted file mode 100644 index 5ba3e594..00000000 --- a/intercom-java/src/test/resources/events.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "type": "event.list", - "events": [ - { - "type": "event", - "id": "cc7e2992-e6f1-11e7-9f85-25b0a92374f6", - "created_at": 1513931185, - "event_name": "test-event", - "user_id": "25", - "email": "wash@serenity.io", - "intercom_user_id": "530370b477ad7120001d", - "metadata": {} - }, - { - "type": "event", - "id": "9a096a26-b8c5-11e7-b012-3f043042e6d0", - "created_at": 1508854449, - "event_name": "invited-friend", - "user_id": "25", - "email": "wash@serenity.io", - "intercom_user_id": "530370b477ad7120001d", - "metadata": { - "invitee_email": "pi@example.org", - "invite_code": "ADDAFRIEND" - } - } - ], - "pages": { - "since": "https://api.intercom.io/events?intercom_user_id=530370b477ad7120001d&type=user&since=1513931185041" - } -} - diff --git a/intercom-java/src/test/resources/note.json b/intercom-java/src/test/resources/note.json deleted file mode 100644 index 0d0dcbe7..00000000 --- a/intercom-java/src/test/resources/note.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "type": "note", - "id": "16", - "created_at": 1389913941, - "body": "

Text for my note

", - "author": { - "type": "admin", - "id": "21", - "name": "Jayne Cobb", - "email": "jayne@serenity.io", - "companies": [] - }, - "user": { - "type": "user", - "id": "5310d8e8598c9a0b24000005" - } -} \ No newline at end of file diff --git a/intercom-java/src/test/resources/notification.json b/intercom-java/src/test/resources/notification.json deleted file mode 100644 index 8b68991c..00000000 --- a/intercom-java/src/test/resources/notification.json +++ /dev/null @@ -1,72 +0,0 @@ -{ - "type" : "notification_event", - "app_id" : "a86dr8yl", - "data" : { - "type" : "notification_event_data", - "item" : { - "type" : "user", - "id" : "5a1bf31767893985752b4041", - "user_id" : "test1234", - "anonymous" : false, - "email" : "wash@serenity.io", - "phone" : "1234567890", - "name" : "name1", - "pseudonym" : null, - "avatar" : { - "type" : "avatar", - "image_url" : "http://example.org/128Wash.jpg" - }, - "app_id" : "a86dr8yl", - "companies" : { - "type" : "company.list", - "companies" : [ ] - }, - "location_data": { - "type": "location_data", - "city_name": "Dublin", - "continent_code": "EU", - "country_code": "IRL", - "country_name": "Ireland", - "latitude": 53.159233, - "longitude": -6.723, - "postal_code": null, - "region_name": "Dublin", - "timezone": "Europe/Dublin" - }, - "last_request_at" : "2017-10-17T12:38:46.000Z", - "last_seen_ip" : "1.2.3.4", - "created_at" : "2017-11-27T11:12:24.000Z", - "remote_created_at" : "2017-10-17T12:38:47.000Z", - "signed_up_at" : "2017-10-17T12:38:47.000Z", - "updated_at" : "2017-11-27T11:12:24.713Z", - "session_count" : 0, - "social_profiles" : { - "type" : "social_profile.list", - "social_profiles" : [ ] - }, - "unsubscribed_from_emails" : false, - "marked_email_as_spam" : false, - "has_hard_bounced" : false, - "user_agent_data" : "abc", - "tags" : { - "type" : "tag.list", - "tags" : [ ] - }, - "segments" : { - "type" : "segment.list", - "segments" : [ ] - }, - "custom_attributes" : { } - } - }, - "links" : { }, - "id" : "notif_d9697680-d363-11e7-9ccb-d3a7f70c358c", - "topic" : "user.created", - "delivery_status" : "pending", - "delivery_attempts" : 1, - "delivered_at" : 0, - "first_sent_at" : 1511781146, - "created_at" : 1511781145, - "self" : null, - "test_unknown_property" : "1234" -} \ No newline at end of file diff --git a/intercom-java/src/test/resources/permanent_delete_response.json b/intercom-java/src/test/resources/permanent_delete_response.json deleted file mode 100644 index 025c2e40..00000000 --- a/intercom-java/src/test/resources/permanent_delete_response.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "id": 123456 -} diff --git a/intercom-java/src/test/resources/segment.json b/intercom-java/src/test/resources/segment.json deleted file mode 100644 index ba530a85..00000000 --- a/intercom-java/src/test/resources/segment.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "type": "segment", - "id": "3142", - "name": "segment-name", - "created_at": 1392734388, - "updated_at": 1392734398 -} diff --git a/intercom-java/src/test/resources/social_profile_url_1.json b/intercom-java/src/test/resources/social_profile_url_1.json deleted file mode 100644 index 4a20e662..00000000 --- a/intercom-java/src/test/resources/social_profile_url_1.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "Social", - "id": "1235d3213", - "username": "th1sland", - "url": "th1sland.example.com" -} \ No newline at end of file diff --git a/intercom-java/src/test/resources/social_profile_url_2.json b/intercom-java/src/test/resources/social_profile_url_2.json deleted file mode 100644 index fa9e2cbc..00000000 --- a/intercom-java/src/test/resources/social_profile_url_2.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "Social", - "id": "1235d3213", - "username": "th1sland", - "url": "./relative.html" -} \ No newline at end of file diff --git a/intercom-java/src/test/resources/social_profile_url_3.json b/intercom-java/src/test/resources/social_profile_url_3.json deleted file mode 100644 index 205497aa..00000000 --- a/intercom-java/src/test/resources/social_profile_url_3.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "Social", - "id": "1235d3213", - "username": "th1sland", - "url": "./relative troll" -} \ No newline at end of file diff --git a/intercom-java/src/test/resources/social_profile_url_4.json b/intercom-java/src/test/resources/social_profile_url_4.json deleted file mode 100644 index 1ab0f1b9..00000000 --- a/intercom-java/src/test/resources/social_profile_url_4.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "Social", - "id": "1235d3213", - "username": "th1sland", - "url": "http://example.net/absolute troll" -} \ No newline at end of file diff --git a/intercom-java/src/test/resources/tag.json b/intercom-java/src/test/resources/tag.json deleted file mode 100644 index d4672f09..00000000 --- a/intercom-java/src/test/resources/tag.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "type": "tag", - "id": "3142", - "name": "tag-name", - "created_at": 1392734388, - "updated_at": 1392734398 -} diff --git a/intercom-java/src/test/resources/user.json b/intercom-java/src/test/resources/user.json deleted file mode 100644 index cef8a269..00000000 --- a/intercom-java/src/test/resources/user.json +++ /dev/null @@ -1,77 +0,0 @@ -{ - "type": "user", - "id": "530370b477ad7120001d", - "user_id": "25", - "email": "wash@serenity.io", - "phone": "+1234567890", - "name": "Hoban Washburne", - "remote_created_at": 1392731331, - "signed_up_at": 1392731331, - "updated_at": 1392734388, - "session_count": 0, - "last_seen_ip": "1.2.3.4", - "unsubscribed_from_emails": false, - "last_request_at": 1397574667, - "created_at": 1392734388, - "user_agent_data": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9", - "custom_attributes": { - "truthy_typed": true, - "floatly_typed": 155.5, - "stringly_typed": "data", - "dately_typed_at": 1397574667, - "longly_typed": 221397574667, - "intly_typed": 1, - "nully_typed": null - }, - "avatar": { - "type": "avatar", - "image_url": "http://example.org/128Wash.jpg" - }, - "location_data": { - "type": "location_data", - "city_name": "Dublin", - "continent_code": "EU", - "country_code": "IRL", - "country_name": "Ireland", - "latitude": 53.159233, - "longitude": -6.723, - "postal_code": null, - "region_name": "Dublin", - "timezone": "Europe/Dublin" - }, - "social_profiles": { - "type": "social_profile.list", - "social_profiles": [ - { - "name": "Twitter", - "id": "1235d3213", - "username": "th1sland", - "url": "http://twitter.com/th1sland" - } - ] - }, - "companies": { - "type": "company.list", - "companies": [ - { - "id": "530370b477ad7120001e" - } - ] - }, - "segments": { - "type": "segment.list", - "segments": [ - { - "id": "5310d8e7598c9a0b24000002" - } - ] - }, - "tags": { - "type": "tag.list", - "tags": [ - { - "id": "202" - } - ] - } -} diff --git a/intercom-java/src/test/resources/user_no_avatar.json b/intercom-java/src/test/resources/user_no_avatar.json deleted file mode 100644 index 5c9c2bd1..00000000 --- a/intercom-java/src/test/resources/user_no_avatar.json +++ /dev/null @@ -1,77 +0,0 @@ -{ - "type": "user", - "id": "530370b477ad7120001d", - "user_id": "25", - "email": "wash@serenity.io", - "phone": "+1234567890", - "name": "Hoban Washburne", - "remote_created_at": 1392731331, - "signed_up_at": 1392731331, - "updated_at": 1392734388, - "session_count": 0, - "last_seen_ip": "1.2.3.4", - "unsubscribed_from_emails": false, - "last_request_at": 1397574667, - "created_at": 1392734388, - "user_agent_data": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9", - "custom_attributes": { - "truthy_typed": true, - "floatly_typed": 155.5, - "stringly_typed": "data", - "dately_typed_at": 1397574667, - "longly_typed": 221397574667, - "intly_typed": 1, - "nully_typed": null - }, - "avatar": { - "type": "avatar", - "image_url": null - }, - "location_data": { - "type": "location_data", - "city_name": "Dublin", - "continent_code": "EU", - "country_code": "IRL", - "country_name": "Ireland", - "latitude": 53.159233, - "longitude": -6.723, - "postal_code": null, - "region_name": "Dublin", - "timezone": "Europe/Dublin" - }, - "social_profiles": { - "type": "social_profile.list", - "social_profiles": [ - { - "name": "Twitter", - "id": "1235d3213", - "username": "th1sland", - "url": "http://twitter.com/th1sland" - } - ] - }, - "companies": { - "type": "company.list", - "companies": [ - { - "id": "530370b477ad7120001e" - } - ] - }, - "segments": { - "type": "segment.list", - "segments": [ - { - "id": "5310d8e7598c9a0b24000002" - } - ] - }, - "tags": { - "type": "tag.list", - "tags": [ - { - "id": "202" - } - ] - } -} diff --git a/intercom-java/src/test/resources/visitor.json b/intercom-java/src/test/resources/visitor.json deleted file mode 100644 index 94c0b001..00000000 --- a/intercom-java/src/test/resources/visitor.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "type": "visitor", - "id": "5b69565fa737210d1c2127f1", - "user_id": "6a347bc9-0b96-4925-bbbc-1f8b11f94c50", - "anonymous": true, - "email": "visitor@example.com", - "phone": "123456789", - "name": "A Visitor", - "pseudonym": "Violet Star from Singapore", - "avatar": { - "type": "avatar", - "image_url": "https://static.intercomassets.com/app/pseudonym_avatars_2018/violet-star.png" - }, - "app_id": "qji82zks", - "companies": { - "type": "company.list", - "companies": [] - }, - "location_data": { - "type": "location_data", - "city_name": "Bandar Seri Begawan", - "continent_code": "AS", - "country_name": "Brunei Darussalam", - "latitude": 4.88, - "longitude": 114.93, - "postal_code": "1234", - "region_name": "a region", - "timezone": "Asia/Brunei", - "country_code": "BRN" - }, - "last_request_at": 1533636256, - "last_seen_ip": "61.6.236.243", - "created_at": 1533630047, - "remote_created_at": null, - "signed_up_at": null, - "updated_at": 1533636257, - "session_count": 0, - "social_profiles": { - "type": "social_profile.list", - "social_profiles": [] - }, - "unsubscribed_from_emails": false, - "marked_email_as_spam": false, - "has_hard_bounced": false, - "user_agent_data": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.84 Safari/537.36", - "tags": { - "type": "tag.list", - "tags": [] - }, - "segments": { - "type": "segment.list", - "segments": [] - }, - "custom_attributes": {"test_string": "visitor string", "test_integer": 123}, - "referrer": "the referrer", - "utm_campaign": "utm campaign", - "utm_content": "utm content", - "utm_medium": "utm medium", - "utm_source": "utm source", - "utm_term": "utm term" -} \ No newline at end of file diff --git a/sample-app/build.gradle b/sample-app/build.gradle new file mode 100644 index 00000000..4ee8f227 --- /dev/null +++ b/sample-app/build.gradle @@ -0,0 +1,19 @@ +plugins { + id 'java-library' +} + +repositories { + mavenCentral() + maven { + url 'https://s01.oss.sonatype.org/content/repositories/releases/' + } +} + +dependencies { + implementation rootProject +} + + +sourceCompatibility = 1.8 +targetCompatibility = 1.8 + diff --git a/sample-app/src/main/java/sample/App.java b/sample-app/src/main/java/sample/App.java new file mode 100644 index 00000000..52575f19 --- /dev/null +++ b/sample-app/src/main/java/sample/App.java @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package sample; + +import java.lang.String; + +public final class App { + public static void main(String[] args) { + // import com.intercom.api.AsyncIntercom + } +} diff --git a/settings.gradle b/settings.gradle index 4c086d76..aed36fec 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1 @@ -modules.split(',').each { include it } \ No newline at end of file +include 'sample-app' \ No newline at end of file diff --git a/src/main/java/com/intercom/api/AsyncIntercom.java b/src/main/java/com/intercom/api/AsyncIntercom.java new file mode 100644 index 00000000..9e707292 --- /dev/null +++ b/src/main/java/com/intercom/api/AsyncIntercom.java @@ -0,0 +1,180 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.Suppliers; +import com.intercom.api.resources.admins.AsyncAdminsClient; +import com.intercom.api.resources.articles.AsyncArticlesClient; +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.dataattributes.AsyncDataAttributesClient; +import com.intercom.api.resources.dataexport.AsyncDataExportClient; +import com.intercom.api.resources.events.AsyncEventsClient; +import com.intercom.api.resources.helpcenters.AsyncHelpCentersClient; +import com.intercom.api.resources.messages.AsyncMessagesClient; +import com.intercom.api.resources.news.AsyncNewsClient; +import com.intercom.api.resources.notes.AsyncNotesClient; +import com.intercom.api.resources.phonecallredirects.AsyncPhoneCallRedirectsClient; +import com.intercom.api.resources.segments.AsyncSegmentsClient; +import com.intercom.api.resources.subscriptiontypes.AsyncSubscriptionTypesClient; +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.tickettypes.AsyncTicketTypesClient; +import com.intercom.api.resources.visitors.AsyncVisitorsClient; +import java.util.function.Supplier; + +public class AsyncIntercom { + protected final ClientOptions clientOptions; + + protected final Supplier adminsClient; + + protected final Supplier articlesClient; + + protected final Supplier helpCentersClient; + + protected final Supplier companiesClient; + + protected final Supplier contactsClient; + + protected final Supplier notesClient; + + protected final Supplier tagsClient; + + protected final Supplier conversationsClient; + + protected final Supplier dataAttributesClient; + + protected final Supplier eventsClient; + + protected final Supplier dataExportClient; + + protected final Supplier messagesClient; + + protected final Supplier segmentsClient; + + protected final Supplier subscriptionTypesClient; + + protected final Supplier phoneCallRedirectsClient; + + protected final Supplier teamsClient; + + protected final Supplier ticketTypesClient; + + protected final Supplier ticketsClient; + + protected final Supplier visitorsClient; + + protected final Supplier newsClient; + + public AsyncIntercom(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.adminsClient = Suppliers.memoize(() -> new AsyncAdminsClient(clientOptions)); + this.articlesClient = Suppliers.memoize(() -> new AsyncArticlesClient(clientOptions)); + this.helpCentersClient = Suppliers.memoize(() -> new AsyncHelpCentersClient(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.dataAttributesClient = Suppliers.memoize(() -> new AsyncDataAttributesClient(clientOptions)); + this.eventsClient = Suppliers.memoize(() -> new AsyncEventsClient(clientOptions)); + this.dataExportClient = Suppliers.memoize(() -> new AsyncDataExportClient(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.teamsClient = Suppliers.memoize(() -> new AsyncTeamsClient(clientOptions)); + this.ticketTypesClient = Suppliers.memoize(() -> new AsyncTicketTypesClient(clientOptions)); + this.ticketsClient = Suppliers.memoize(() -> new AsyncTicketsClient(clientOptions)); + this.visitorsClient = Suppliers.memoize(() -> new AsyncVisitorsClient(clientOptions)); + this.newsClient = Suppliers.memoize(() -> new AsyncNewsClient(clientOptions)); + } + + public AsyncAdminsClient admins() { + return this.adminsClient.get(); + } + + public AsyncArticlesClient articles() { + return this.articlesClient.get(); + } + + public AsyncHelpCentersClient helpCenters() { + return this.helpCentersClient.get(); + } + + public AsyncCompaniesClient companies() { + return this.companiesClient.get(); + } + + public AsyncContactsClient contacts() { + return this.contactsClient.get(); + } + + public AsyncNotesClient notes() { + return this.notesClient.get(); + } + + public AsyncTagsClient tags() { + return this.tagsClient.get(); + } + + public AsyncConversationsClient conversations() { + return this.conversationsClient.get(); + } + + public AsyncDataAttributesClient dataAttributes() { + return this.dataAttributesClient.get(); + } + + public AsyncEventsClient events() { + return this.eventsClient.get(); + } + + public AsyncDataExportClient dataExport() { + return this.dataExportClient.get(); + } + + public AsyncMessagesClient messages() { + return this.messagesClient.get(); + } + + public AsyncSegmentsClient segments() { + return this.segmentsClient.get(); + } + + public AsyncSubscriptionTypesClient subscriptionTypes() { + return this.subscriptionTypesClient.get(); + } + + public AsyncPhoneCallRedirectsClient phoneCallRedirects() { + return this.phoneCallRedirectsClient.get(); + } + + public AsyncTeamsClient teams() { + return this.teamsClient.get(); + } + + public AsyncTicketTypesClient ticketTypes() { + return this.ticketTypesClient.get(); + } + + public AsyncTicketsClient tickets() { + return this.ticketsClient.get(); + } + + public AsyncVisitorsClient visitors() { + return this.visitorsClient.get(); + } + + public AsyncNewsClient news() { + return this.newsClient.get(); + } + + public static AsyncIntercomBuilder builder() { + return new AsyncIntercomBuilder(); + } +} diff --git a/src/main/java/com/intercom/api/AsyncIntercomBuilder.java b/src/main/java/com/intercom/api/AsyncIntercomBuilder.java new file mode 100644 index 00000000..15737447 --- /dev/null +++ b/src/main/java/com/intercom/api/AsyncIntercomBuilder.java @@ -0,0 +1,60 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.Environment; +import okhttp3.OkHttpClient; + +public final class AsyncIntercomBuilder { + private ClientOptions.Builder clientOptionsBuilder = ClientOptions.builder(); + + private String token = System.getenv("INTERCOM_API_KEY"); + + private Environment environment = Environment.US_PRODUCTION; + + /** + * Sets token. + * Defaults to the INTERCOM_API_KEY environment variable. + */ + public AsyncIntercomBuilder token(String token) { + this.token = token; + return this; + } + + public AsyncIntercomBuilder environment(Environment environment) { + this.environment = environment; + return this; + } + + public AsyncIntercomBuilder url(String url) { + this.environment = Environment.custom(url); + return this; + } + + /** + * Sets the timeout (in seconds) for the client + */ + public AsyncIntercomBuilder timeout(int timeout) { + this.clientOptionsBuilder.timeout(timeout); + return this; + } + + /** + * Sets the underlying OkHttp client + */ + public AsyncIntercomBuilder httpClient(OkHttpClient httpClient) { + this.clientOptionsBuilder.httpClient(httpClient); + return this; + } + + public AsyncIntercom build() { + if (token == null) { + throw new RuntimeException("Please provide token or set the INTERCOM_API_KEY environment variable."); + } + this.clientOptionsBuilder.addHeader("Authorization", "Bearer " + this.token); + clientOptionsBuilder.environment(this.environment); + return new AsyncIntercom(clientOptionsBuilder.build()); + } +} diff --git a/src/main/java/com/intercom/api/Intercom.java b/src/main/java/com/intercom/api/Intercom.java new file mode 100644 index 00000000..0bc61258 --- /dev/null +++ b/src/main/java/com/intercom/api/Intercom.java @@ -0,0 +1,180 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.Suppliers; +import com.intercom.api.resources.admins.AdminsClient; +import com.intercom.api.resources.articles.ArticlesClient; +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.dataattributes.DataAttributesClient; +import com.intercom.api.resources.dataexport.DataExportClient; +import com.intercom.api.resources.events.EventsClient; +import com.intercom.api.resources.helpcenters.HelpCentersClient; +import com.intercom.api.resources.messages.MessagesClient; +import com.intercom.api.resources.news.NewsClient; +import com.intercom.api.resources.notes.NotesClient; +import com.intercom.api.resources.phonecallredirects.PhoneCallRedirectsClient; +import com.intercom.api.resources.segments.SegmentsClient; +import com.intercom.api.resources.subscriptiontypes.SubscriptionTypesClient; +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.tickettypes.TicketTypesClient; +import com.intercom.api.resources.visitors.VisitorsClient; +import java.util.function.Supplier; + +public class Intercom { + protected final ClientOptions clientOptions; + + protected final Supplier adminsClient; + + protected final Supplier articlesClient; + + protected final Supplier helpCentersClient; + + protected final Supplier companiesClient; + + protected final Supplier contactsClient; + + protected final Supplier notesClient; + + protected final Supplier tagsClient; + + protected final Supplier conversationsClient; + + protected final Supplier dataAttributesClient; + + protected final Supplier eventsClient; + + protected final Supplier dataExportClient; + + protected final Supplier messagesClient; + + protected final Supplier segmentsClient; + + protected final Supplier subscriptionTypesClient; + + protected final Supplier phoneCallRedirectsClient; + + protected final Supplier teamsClient; + + protected final Supplier ticketTypesClient; + + protected final Supplier ticketsClient; + + protected final Supplier visitorsClient; + + protected final Supplier newsClient; + + public Intercom(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.adminsClient = Suppliers.memoize(() -> new AdminsClient(clientOptions)); + this.articlesClient = Suppliers.memoize(() -> new ArticlesClient(clientOptions)); + this.helpCentersClient = Suppliers.memoize(() -> new HelpCentersClient(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.dataAttributesClient = Suppliers.memoize(() -> new DataAttributesClient(clientOptions)); + this.eventsClient = Suppliers.memoize(() -> new EventsClient(clientOptions)); + this.dataExportClient = Suppliers.memoize(() -> new DataExportClient(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.teamsClient = Suppliers.memoize(() -> new TeamsClient(clientOptions)); + this.ticketTypesClient = Suppliers.memoize(() -> new TicketTypesClient(clientOptions)); + this.ticketsClient = Suppliers.memoize(() -> new TicketsClient(clientOptions)); + this.visitorsClient = Suppliers.memoize(() -> new VisitorsClient(clientOptions)); + this.newsClient = Suppliers.memoize(() -> new NewsClient(clientOptions)); + } + + public AdminsClient admins() { + return this.adminsClient.get(); + } + + public ArticlesClient articles() { + return this.articlesClient.get(); + } + + public HelpCentersClient helpCenters() { + return this.helpCentersClient.get(); + } + + public CompaniesClient companies() { + return this.companiesClient.get(); + } + + public ContactsClient contacts() { + return this.contactsClient.get(); + } + + public NotesClient notes() { + return this.notesClient.get(); + } + + public TagsClient tags() { + return this.tagsClient.get(); + } + + public ConversationsClient conversations() { + return this.conversationsClient.get(); + } + + public DataAttributesClient dataAttributes() { + return this.dataAttributesClient.get(); + } + + public EventsClient events() { + return this.eventsClient.get(); + } + + public DataExportClient dataExport() { + return this.dataExportClient.get(); + } + + public MessagesClient messages() { + return this.messagesClient.get(); + } + + public SegmentsClient segments() { + return this.segmentsClient.get(); + } + + public SubscriptionTypesClient subscriptionTypes() { + return this.subscriptionTypesClient.get(); + } + + public PhoneCallRedirectsClient phoneCallRedirects() { + return this.phoneCallRedirectsClient.get(); + } + + public TeamsClient teams() { + return this.teamsClient.get(); + } + + public TicketTypesClient ticketTypes() { + return this.ticketTypesClient.get(); + } + + public TicketsClient tickets() { + return this.ticketsClient.get(); + } + + public VisitorsClient visitors() { + return this.visitorsClient.get(); + } + + public NewsClient news() { + return this.newsClient.get(); + } + + public static IntercomBuilder builder() { + return new IntercomBuilder(); + } +} diff --git a/src/main/java/com/intercom/api/IntercomBuilder.java b/src/main/java/com/intercom/api/IntercomBuilder.java new file mode 100644 index 00000000..02ad0487 --- /dev/null +++ b/src/main/java/com/intercom/api/IntercomBuilder.java @@ -0,0 +1,60 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.Environment; +import okhttp3.OkHttpClient; + +public final class IntercomBuilder { + private ClientOptions.Builder clientOptionsBuilder = ClientOptions.builder(); + + private String token = System.getenv("INTERCOM_API_KEY"); + + private Environment environment = Environment.US_PRODUCTION; + + /** + * Sets token. + * Defaults to the INTERCOM_API_KEY environment variable. + */ + public IntercomBuilder token(String token) { + this.token = token; + return this; + } + + public IntercomBuilder environment(Environment environment) { + this.environment = environment; + return this; + } + + public IntercomBuilder url(String url) { + this.environment = Environment.custom(url); + return this; + } + + /** + * Sets the timeout (in seconds) for the client + */ + public IntercomBuilder timeout(int timeout) { + this.clientOptionsBuilder.timeout(timeout); + return this; + } + + /** + * Sets the underlying OkHttp client + */ + public IntercomBuilder httpClient(OkHttpClient httpClient) { + this.clientOptionsBuilder.httpClient(httpClient); + return this; + } + + public Intercom build() { + if (token == null) { + throw new RuntimeException("Please provide token or set the INTERCOM_API_KEY environment variable."); + } + this.clientOptionsBuilder.addHeader("Authorization", "Bearer " + this.token); + clientOptionsBuilder.environment(this.environment); + return new Intercom(clientOptionsBuilder.build()); + } +} diff --git a/src/main/java/com/intercom/api/core/ApiVersion.java b/src/main/java/com/intercom/api/core/ApiVersion.java new file mode 100644 index 00000000..6bb49f37 --- /dev/null +++ b/src/main/java/com/intercom/api/core/ApiVersion.java @@ -0,0 +1,252 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.core; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class ApiVersion { + public static final ApiVersion _2_1 = new ApiVersion(Value._2_1, "2.1"); + + public static final ApiVersion CURRENT = new ApiVersion(Value.CURRENT, "2.11"); + + 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"); + + public static final ApiVersion _2_3 = new ApiVersion(Value._2_3, "2.3"); + + public static final ApiVersion _1_1 = new ApiVersion(Value._1_1, "1.1"); + + public static final ApiVersion _2_4 = new ApiVersion(Value._2_4, "2.4"); + + public static final ApiVersion _1_2 = new ApiVersion(Value._1_2, "1.2"); + + public static final ApiVersion _2_5 = new ApiVersion(Value._2_5, "2.5"); + + public static final ApiVersion _1_3 = new ApiVersion(Value._1_3, "1.3"); + + public static final ApiVersion _2_6 = new ApiVersion(Value._2_6, "2.6"); + + public static final ApiVersion _1_4 = new ApiVersion(Value._1_4, "1.4"); + + public static final ApiVersion _2_7 = new ApiVersion(Value._2_7, "2.7"); + + public static final ApiVersion _2_8 = new ApiVersion(Value._2_8, "2.8"); + + public static final ApiVersion _2_10 = new ApiVersion(Value._2_10, "2.10"); + + public static final ApiVersion _2_9 = new ApiVersion(Value._2_9, "2.9"); + + public static final ApiVersion _2_11 = new ApiVersion(Value._2_11, "2.11"); + + public static final ApiVersion UNSTABLE = new ApiVersion(Value.UNSTABLE, "Unstable"); + + public static final ApiVersion _2_0 = new ApiVersion(Value._2_0, "2.0"); + + private final Value value; + + private final String string; + + ApiVersion(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 ApiVersion && this.string.equals(((ApiVersion) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case _2_1: + return visitor.visit_21(); + case CURRENT: + return visitor.visitCurrent(); + case _2_2: + return visitor.visit_22(); + case _1_0: + return visitor.visit_10(); + case _2_3: + return visitor.visit_23(); + case _1_1: + return visitor.visit_11(); + case _2_4: + return visitor.visit_24(); + case _1_2: + return visitor.visit_12(); + case _2_5: + return visitor.visit_25(); + case _1_3: + return visitor.visit_13(); + case _2_6: + return visitor.visit_26(); + case _1_4: + return visitor.visit_14(); + case _2_7: + return visitor.visit_27(); + case _2_8: + return visitor.visit_28(); + case _2_10: + return visitor.visit_210(); + case _2_9: + return visitor.visit_29(); + case _2_11: + return visitor.visit_211(); + case UNSTABLE: + return visitor.visitUnstable(); + case _2_0: + return visitor.visit_20(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static ApiVersion valueOf(String value) { + switch (value) { + case "2.1": + return _2_1; + case "2.11": + return CURRENT; + case "2.2": + return _2_2; + case "1.0": + return _1_0; + case "2.3": + return _2_3; + case "1.1": + return _1_1; + case "2.4": + return _2_4; + case "1.2": + return _1_2; + case "2.5": + return _2_5; + case "1.3": + return _1_3; + case "2.6": + return _2_6; + case "1.4": + return _1_4; + case "2.7": + return _2_7; + case "2.8": + return _2_8; + case "2.10": + return _2_10; + case "2.9": + return _2_9; + case "2.11": + return _2_11; + case "Unstable": + return UNSTABLE; + case "2.0": + return _2_0; + default: + return new ApiVersion(Value.UNKNOWN, value); + } + } + + public enum Value { + _1_0, + + _1_1, + + _1_2, + + _1_3, + + _1_4, + + _2_0, + + _2_1, + + _2_2, + + _2_3, + + _2_4, + + _2_5, + + _2_6, + + _2_7, + + _2_8, + + _2_9, + + _2_10, + + _2_11, + + UNSTABLE, + + CURRENT, + + UNKNOWN + } + + public interface Visitor { + T visit_10(); + + T visit_11(); + + T visit_12(); + + T visit_13(); + + T visit_14(); + + T visit_20(); + + T visit_21(); + + T visit_22(); + + T visit_23(); + + T visit_24(); + + T visit_25(); + + T visit_26(); + + T visit_27(); + + T visit_28(); + + T visit_29(); + + T visit_210(); + + T visit_211(); + + T visitUnstable(); + + T visitCurrent(); + + 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 new file mode 100644 index 00000000..b91f4852 --- /dev/null +++ b/src/main/java/com/intercom/api/core/ClientOptions.java @@ -0,0 +1,185 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.core; + +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import java.util.concurrent.TimeUnit; +import java.util.function.Supplier; +import okhttp3.OkHttpClient; + +public final class ClientOptions { + private final Environment environment; + + private final Map headers; + + private final Map> headerSuppliers; + + private final OkHttpClient httpClient; + + private final int timeout; + + /** + * version.toString() is sent as the "Intercom-Version" header. + */ + private final ApiVersion version; + + /** + * @param version Defaults to "{\n" + * + " \"name\" : {\n" + * + " \"wireValue\" : \"2.11\",\n" + * + " \"name\" : {\n" + * + " \"originalName\" : \"2.11\",\n" + * + " \"camelCase\" : {\n" + * + " \"unsafeName\" : \"211\",\n" + * + " \"safeName\" : \"_211\"\n" + * + " },\n" + * + " \"pascalCase\" : {\n" + * + " \"unsafeName\" : \"211\",\n" + * + " \"safeName\" : \"_211\"\n" + * + " },\n" + * + " \"snakeCase\" : {\n" + * + " \"unsafeName\" : \"2_11\",\n" + * + " \"safeName\" : \"_2_11\"\n" + * + " },\n" + * + " \"screamingSnakeCase\" : {\n" + * + " \"unsafeName\" : \"2_11\",\n" + * + " \"safeName\" : \"_2_11\"\n" + * + " }\n" + * + " }\n" + * + " }\n" + * + "}" if empty + */ + private ClientOptions( + Environment environment, + Map headers, + Map> headerSuppliers, + OkHttpClient httpClient, + int timeout, + Optional version) { + this.environment = environment; + this.headers = new HashMap<>(); + this.headers.putAll(headers); + this.headers.putAll(new HashMap() { + { + put("X-Fern-Language", "JAVA"); + put("X-Fern-SDK-Name", "com.intercom.fern:api-sdk"); + put("X-Fern-SDK-Version", "0.0.153"); + } + }); + this.headerSuppliers = headerSuppliers; + this.httpClient = httpClient; + this.timeout = timeout; + this.version = version.orElse(ApiVersion.CURRENT); + this.headers.put("Intercom-Version", this.version.toString()); + } + + public Environment environment() { + return this.environment; + } + + public Map headers(RequestOptions requestOptions) { + Map values = new HashMap<>(this.headers); + headerSuppliers.forEach((key, supplier) -> { + values.put(key, supplier.get()); + }); + if (requestOptions != null) { + values.putAll(requestOptions.getHeaders()); + } + return values; + } + + /** + * version.toString() is sent as the "Intercom-Version" header. + */ + public ApiVersion version() { + return this.version; + } + + public int timeout(RequestOptions requestOptions) { + if (requestOptions == null) { + return this.timeout; + } + return requestOptions.getTimeout().orElse(this.timeout); + } + + public OkHttpClient httpClient() { + return this.httpClient; + } + + public OkHttpClient httpClientWithTimeout(RequestOptions requestOptions) { + if (requestOptions == null) { + return this.httpClient; + } + return this.httpClient + .newBuilder() + .callTimeout(requestOptions.getTimeout().get(), requestOptions.getTimeoutTimeUnit()) + .connectTimeout(0, TimeUnit.SECONDS) + .writeTimeout(0, TimeUnit.SECONDS) + .readTimeout(0, TimeUnit.SECONDS) + .build(); + } + + public static Builder builder() { + return new Builder(); + } + + public static final class Builder { + private Environment environment; + + private final Map headers = new HashMap<>(); + + private final Map> headerSuppliers = new HashMap<>(); + + private int timeout = 60; + + private OkHttpClient httpClient = new OkHttpClient.Builder() + .addInterceptor(new RetryInterceptor(3)) + .callTimeout(this.timeout, TimeUnit.SECONDS) + .build(); + + private Optional version = Optional.empty(); + + public Builder environment(Environment environment) { + this.environment = environment; + return this; + } + + public Builder addHeader(String key, String value) { + this.headers.put(key, value); + return this; + } + + public Builder addHeader(String key, Supplier value) { + this.headerSuppliers.put(key, value); + return this; + } + + /** + * Override the timeout in seconds. Defaults to 60 seconds. + */ + public Builder timeout(int timeout) { + this.timeout = timeout; + return this; + } + + public Builder httpClient(OkHttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /** + * version.toString() is sent as the "Intercom-Version" header. + */ + public Builder version(ApiVersion version) { + this.version = Optional.of(version); + return this; + } + + public ClientOptions build() { + return new ClientOptions(environment, headers, headerSuppliers, httpClient, this.timeout, version); + } + } +} diff --git a/src/main/java/com/intercom/api/core/DateTimeDeserializer.java b/src/main/java/com/intercom/api/core/DateTimeDeserializer.java new file mode 100644 index 00000000..a704433c --- /dev/null +++ b/src/main/java/com/intercom/api/core/DateTimeDeserializer.java @@ -0,0 +1,55 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.core; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.databind.module.SimpleModule; +import java.io.IOException; +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.OffsetDateTime; +import java.time.ZoneOffset; +import java.time.format.DateTimeFormatter; +import java.time.temporal.TemporalAccessor; +import java.time.temporal.TemporalQueries; + +/** + * Custom deserializer that handles converting ISO8601 dates into {@link OffsetDateTime} objects. + */ +class DateTimeDeserializer extends JsonDeserializer { + private static final SimpleModule MODULE; + + static { + MODULE = new SimpleModule().addDeserializer(OffsetDateTime.class, new DateTimeDeserializer()); + } + + /** + * Gets a module wrapping this deserializer as an adapter for the Jackson ObjectMapper. + * + * @return A {@link SimpleModule} to be plugged onto Jackson ObjectMapper. + */ + public static SimpleModule getModule() { + return MODULE; + } + + @Override + public OffsetDateTime deserialize(JsonParser parser, DeserializationContext context) throws IOException { + JsonToken token = parser.currentToken(); + if (token == JsonToken.VALUE_NUMBER_INT) { + return OffsetDateTime.ofInstant(Instant.ofEpochSecond(parser.getValueAsLong()), ZoneOffset.UTC); + } else { + TemporalAccessor temporal = DateTimeFormatter.ISO_DATE_TIME.parseBest( + parser.getValueAsString(), OffsetDateTime::from, LocalDateTime::from); + + if (temporal.query(TemporalQueries.offset()) == null) { + return LocalDateTime.from(temporal).atOffset(ZoneOffset.UTC); + } else { + return OffsetDateTime.from(temporal); + } + } + } +} diff --git a/src/main/java/com/intercom/api/core/Environment.java b/src/main/java/com/intercom/api/core/Environment.java new file mode 100644 index 00000000..47a8b0f8 --- /dev/null +++ b/src/main/java/com/intercom/api/core/Environment.java @@ -0,0 +1,26 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.core; + +public final class Environment { + public static final Environment US_PRODUCTION = new Environment("https://api.intercom.io"); + + public static final Environment EU_PRODUCTION = new Environment("https://api.eu.intercom.io"); + + public static final Environment AU_PRODUCTION = new Environment("https://api.au.intercom.io"); + + private final String url; + + private Environment(String url) { + this.url = url; + } + + public String getUrl() { + return this.url; + } + + public static Environment custom(String url) { + return new Environment(url); + } +} diff --git a/src/main/java/com/intercom/api/core/FileStream.java b/src/main/java/com/intercom/api/core/FileStream.java new file mode 100644 index 00000000..42365187 --- /dev/null +++ b/src/main/java/com/intercom/api/core/FileStream.java @@ -0,0 +1,60 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.core; + +import java.io.InputStream; +import java.util.Objects; +import okhttp3.MediaType; +import okhttp3.RequestBody; +import org.jetbrains.annotations.Nullable; + +/** + * Represents a file stream with associated metadata for file uploads. + */ +public class FileStream { + private final InputStream inputStream; + private final String fileName; + private final MediaType contentType; + + /** + * Constructs a FileStream with the given input stream and optional metadata. + * + * @param inputStream The input stream of the file content. Must not be null. + * @param fileName The name of the file, or null if unknown. + * @param contentType The MIME type of the file content, or null if unknown. + * @throws NullPointerException if inputStream is null + */ + public FileStream(InputStream inputStream, @Nullable String fileName, @Nullable MediaType contentType) { + this.inputStream = Objects.requireNonNull(inputStream, "Input stream cannot be null"); + this.fileName = fileName; + this.contentType = contentType; + } + + public FileStream(InputStream inputStream) { + this(inputStream, null, null); + } + + public InputStream getInputStream() { + return inputStream; + } + + @Nullable + public String getFileName() { + return fileName; + } + + @Nullable + public MediaType getContentType() { + return contentType; + } + + /** + * Creates a RequestBody suitable for use with OkHttp client. + * + * @return A RequestBody instance representing this file stream. + */ + public RequestBody toRequestBody() { + return new InputStreamRequestBody(contentType, inputStream); + } +} diff --git a/src/main/java/com/intercom/api/core/InputStreamRequestBody.java b/src/main/java/com/intercom/api/core/InputStreamRequestBody.java new file mode 100644 index 00000000..58c63eec --- /dev/null +++ b/src/main/java/com/intercom/api/core/InputStreamRequestBody.java @@ -0,0 +1,79 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.core; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Objects; +import okhttp3.MediaType; +import okhttp3.RequestBody; +import okhttp3.internal.Util; +import okio.BufferedSink; +import okio.Okio; +import okio.Source; +import org.jetbrains.annotations.Nullable; + +/** + * A custom implementation of OkHttp's RequestBody that wraps an InputStream. + * This class allows streaming of data from an InputStream directly to an HTTP request body, + * which is useful for file uploads or sending large amounts of data without loading it all into memory. + */ +public class InputStreamRequestBody extends RequestBody { + private final InputStream inputStream; + private final MediaType contentType; + + /** + * Constructs an InputStreamRequestBody with the specified content type and input stream. + * + * @param contentType the MediaType of the content, or null if not known + * @param inputStream the InputStream containing the data to be sent + * @throws NullPointerException if inputStream is null + */ + public InputStreamRequestBody(@Nullable MediaType contentType, InputStream inputStream) { + this.contentType = contentType; + this.inputStream = Objects.requireNonNull(inputStream, "inputStream == null"); + } + + /** + * Returns the content type of this request body. + * + * @return the MediaType of the content, or null if not specified + */ + @Nullable + @Override + public MediaType contentType() { + return contentType; + } + + /** + * Returns the content length of this request body, if known. + * This method attempts to determine the length using the InputStream's available() method, + * which may not always accurately reflect the total length of the stream. + * + * @return the content length, or -1 if the length is unknown + * @throws IOException if an I/O error occurs + */ + @Override + public long contentLength() throws IOException { + return inputStream.available() == 0 ? -1 : inputStream.available(); + } + + /** + * Writes the content of the InputStream to the given BufferedSink. + * This method is responsible for transferring the data from the InputStream to the network request. + * + * @param sink the BufferedSink to write the content to + * @throws IOException if an I/O error occurs during writing + */ + @Override + public void writeTo(BufferedSink sink) throws IOException { + Source source = null; + try { + source = Okio.source(inputStream); + sink.writeAll(source); + } finally { + Util.closeQuietly(Objects.requireNonNull(source)); + } + } +} diff --git a/src/main/java/com/intercom/api/core/IntercomApiException.java b/src/main/java/com/intercom/api/core/IntercomApiException.java new file mode 100644 index 00000000..0dc06214 --- /dev/null +++ b/src/main/java/com/intercom/api/core/IntercomApiException.java @@ -0,0 +1,45 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.core; + +/** + * This exception type will be thrown for any non-2XX API responses. + */ +public class IntercomApiException extends IntercomException { + /** + * The error code of the response that triggered the exception. + */ + private final int statusCode; + + /** + * The body of the response that triggered the exception. + */ + private final Object body; + + public IntercomApiException(String message, int statusCode, Object body) { + super(message); + this.statusCode = statusCode; + this.body = body; + } + + /** + * @return the statusCode + */ + public int statusCode() { + return this.statusCode; + } + + /** + * @return the body + */ + public Object body() { + return this.body; + } + + @java.lang.Override + public String toString() { + return "IntercomApiException{" + "message: " + getMessage() + ", statusCode: " + statusCode + ", body: " + body + + "}"; + } +} diff --git a/src/main/java/com/intercom/api/core/IntercomException.java b/src/main/java/com/intercom/api/core/IntercomException.java new file mode 100644 index 00000000..eb7fdc69 --- /dev/null +++ b/src/main/java/com/intercom/api/core/IntercomException.java @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.core; + +/** + * This class serves as the base exception for all errors in the SDK. + */ +public class IntercomException extends RuntimeException { + public IntercomException(String message) { + super(message); + } + + public IntercomException(String message, Exception e) { + super(message, e); + } +} diff --git a/src/main/java/com/intercom/api/core/MediaTypes.java b/src/main/java/com/intercom/api/core/MediaTypes.java new file mode 100644 index 00000000..32505033 --- /dev/null +++ b/src/main/java/com/intercom/api/core/MediaTypes.java @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.core; + +import okhttp3.MediaType; + +public final class MediaTypes { + + public static final MediaType APPLICATION_JSON = MediaType.parse("application/json"); + + private MediaTypes() {} +} diff --git a/src/main/java/com/intercom/api/core/Nullable.java b/src/main/java/com/intercom/api/core/Nullable.java new file mode 100644 index 00000000..e788d1fb --- /dev/null +++ b/src/main/java/com/intercom/api/core/Nullable.java @@ -0,0 +1,140 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.core; + +import java.util.Optional; +import java.util.function.Function; + +public final class Nullable { + + private final Either, Null> value; + + private Nullable() { + this.value = Either.left(Optional.empty()); + } + + private Nullable(T value) { + if (value == null) { + this.value = Either.right(Null.INSTANCE); + } else { + this.value = Either.left(Optional.of(value)); + } + } + + public static Nullable ofNull() { + return new Nullable<>(null); + } + + public static Nullable of(T value) { + return new Nullable<>(value); + } + + public static Nullable empty() { + return new Nullable<>(); + } + + public static Nullable ofOptional(Optional value) { + if (value.isPresent()) { + return of(value.get()); + } else { + return empty(); + } + } + + public boolean isNull() { + return this.value.isRight(); + } + + public boolean isEmpty() { + return this.value.isLeft() && !this.value.getLeft().isPresent(); + } + + public T get() { + if (this.isNull()) { + return null; + } + + return this.value.getLeft().get(); + } + + public Nullable map(Function mapper) { + if (this.isNull()) { + return Nullable.ofNull(); + } + + return Nullable.ofOptional(this.value.getLeft().map(mapper)); + } + + @Override + public boolean equals(Object other) { + if (!(other instanceof Nullable)) { + return false; + } + + if (((Nullable) other).isNull() && this.isNull()) { + return true; + } + + return this.value.getLeft().equals(((Nullable) other).value.getLeft()); + } + + private static final class Either { + private L left = null; + private R right = null; + + private Either(L left, R right) { + if (left != null && right != null) { + throw new IllegalArgumentException("Left and right argument cannot both be non-null."); + } + + if (left == null && right == null) { + throw new IllegalArgumentException("Left and right argument cannot both be null."); + } + + if (left != null) { + this.left = left; + } + + if (right != null) { + this.right = right; + } + } + + public static Either left(L left) { + return new Either<>(left, null); + } + + public static Either right(R right) { + return new Either<>(null, right); + } + + public boolean isLeft() { + return this.left != null; + } + + public boolean isRight() { + return this.right != null; + } + + public L getLeft() { + if (!this.isLeft()) { + throw new IllegalArgumentException("Cannot get left from right Either."); + } + return this.left; + } + + public R getRight() { + if (!this.isRight()) { + throw new IllegalArgumentException("Cannot get right from left Either."); + } + return this.right; + } + } + + private static final class Null { + private static final Null INSTANCE = new Null(); + + private Null() {} + } +} diff --git a/src/main/java/com/intercom/api/core/NullableNonemptyFilter.java b/src/main/java/com/intercom/api/core/NullableNonemptyFilter.java new file mode 100644 index 00000000..bb17a343 --- /dev/null +++ b/src/main/java/com/intercom/api/core/NullableNonemptyFilter.java @@ -0,0 +1,19 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.core; + +import java.util.Optional; + +public final class NullableNonemptyFilter { + @Override + public boolean equals(Object o) { + boolean isOptionalEmpty = isOptionalEmpty(o); + + return isOptionalEmpty; + } + + private boolean isOptionalEmpty(Object o) { + return o instanceof Optional && !((Optional) o).isPresent(); + } +} diff --git a/src/main/java/com/intercom/api/core/ObjectMappers.java b/src/main/java/com/intercom/api/core/ObjectMappers.java new file mode 100644 index 00000000..52d73aab --- /dev/null +++ b/src/main/java/com/intercom/api/core/ObjectMappers.java @@ -0,0 +1,36 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.core; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.databind.json.JsonMapper; +import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import java.io.IOException; + +public final class ObjectMappers { + public static final ObjectMapper JSON_MAPPER = JsonMapper.builder() + .addModule(new Jdk8Module()) + .addModule(new JavaTimeModule()) + .addModule(DateTimeDeserializer.getModule()) + .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) + .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) + .build(); + + private ObjectMappers() {} + + public static String stringify(Object o) { + try { + return JSON_MAPPER + .setSerializationInclusion(JsonInclude.Include.ALWAYS) + .writerWithDefaultPrettyPrinter() + .writeValueAsString(o); + } catch (IOException e) { + return o.getClass().getName() + "@" + Integer.toHexString(o.hashCode()); + } + } +} diff --git a/src/main/java/com/intercom/api/core/QueryStringMapper.java b/src/main/java/com/intercom/api/core/QueryStringMapper.java new file mode 100644 index 00000000..e4e32bbe --- /dev/null +++ b/src/main/java/com/intercom/api/core/QueryStringMapper.java @@ -0,0 +1,142 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.core; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.ObjectNode; +import java.util.AbstractMap; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import okhttp3.HttpUrl; +import okhttp3.MultipartBody; + +public class QueryStringMapper { + + private static final ObjectMapper MAPPER = ObjectMappers.JSON_MAPPER; + + public static void addQueryParameter(HttpUrl.Builder httpUrl, String key, Object value, boolean arraysAsRepeats) { + JsonNode valueNode = MAPPER.valueToTree(value); + + List> flat; + if (valueNode.isObject()) { + flat = flattenObject((ObjectNode) valueNode, arraysAsRepeats); + } else if (valueNode.isArray()) { + flat = flattenArray((ArrayNode) valueNode, "", arraysAsRepeats); + } else { + if (valueNode.isTextual()) { + httpUrl.addQueryParameter(key, valueNode.textValue()); + } else { + httpUrl.addQueryParameter(key, valueNode.toString()); + } + return; + } + + for (Map.Entry field : flat) { + if (field.getValue().isTextual()) { + httpUrl.addQueryParameter(key + field.getKey(), field.getValue().textValue()); + } else { + httpUrl.addQueryParameter(key + field.getKey(), field.getValue().toString()); + } + } + } + + public static void addFormDataPart( + MultipartBody.Builder multipartBody, String key, Object value, boolean arraysAsRepeats) { + JsonNode valueNode = MAPPER.valueToTree(value); + + List> flat; + if (valueNode.isObject()) { + flat = flattenObject((ObjectNode) valueNode, arraysAsRepeats); + } else if (valueNode.isArray()) { + flat = flattenArray((ArrayNode) valueNode, "", arraysAsRepeats); + } else { + if (valueNode.isTextual()) { + multipartBody.addFormDataPart(key, valueNode.textValue()); + } else { + multipartBody.addFormDataPart(key, valueNode.toString()); + } + return; + } + + for (Map.Entry field : flat) { + if (field.getValue().isTextual()) { + multipartBody.addFormDataPart( + key + field.getKey(), field.getValue().textValue()); + } else { + multipartBody.addFormDataPart( + key + field.getKey(), field.getValue().toString()); + } + } + } + + public static List> flattenObject(ObjectNode object, boolean arraysAsRepeats) { + List> flat = new ArrayList<>(); + + Iterator> fields = object.fields(); + while (fields.hasNext()) { + Map.Entry field = fields.next(); + + String key = "[" + field.getKey() + "]"; + + if (field.getValue().isObject()) { + List> flatField = + flattenObject((ObjectNode) field.getValue(), arraysAsRepeats); + addAll(flat, flatField, key); + } else if (field.getValue().isArray()) { + List> flatField = + flattenArray((ArrayNode) field.getValue(), key, arraysAsRepeats); + addAll(flat, flatField, ""); + } else { + flat.add(new AbstractMap.SimpleEntry<>(key, field.getValue())); + } + } + + return flat; + } + + private static List> flattenArray( + ArrayNode array, String key, boolean arraysAsRepeats) { + List> flat = new ArrayList<>(); + + Iterator elements = array.elements(); + + int index = 0; + while (elements.hasNext()) { + JsonNode element = elements.next(); + + String indexKey = key + "[" + index + "]"; + + if (arraysAsRepeats) { + indexKey = key; + } + + if (element.isObject()) { + List> flatField = flattenObject((ObjectNode) element, arraysAsRepeats); + addAll(flat, flatField, indexKey); + } else if (element.isArray()) { + List> flatField = flattenArray((ArrayNode) element, "", arraysAsRepeats); + addAll(flat, flatField, indexKey); + } else { + flat.add(new AbstractMap.SimpleEntry<>(indexKey, element)); + } + + index++; + } + + return flat; + } + + private static void addAll( + List> target, List> source, String prefix) { + for (Map.Entry entry : source) { + Map.Entry entryToAdd = + new AbstractMap.SimpleEntry<>(prefix + entry.getKey(), entry.getValue()); + target.add(entryToAdd); + } + } +} diff --git a/src/main/java/com/intercom/api/core/RequestOptions.java b/src/main/java/com/intercom/api/core/RequestOptions.java new file mode 100644 index 00000000..b264d6b7 --- /dev/null +++ b/src/main/java/com/intercom/api/core/RequestOptions.java @@ -0,0 +1,128 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.core; + +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import java.util.concurrent.TimeUnit; +import java.util.function.Supplier; + +public final class RequestOptions { + private final String token; + + private final Optional timeout; + + private final TimeUnit timeoutTimeUnit; + + /** + * version.get().toString() is sent as the "Intercom-Version" header, overriding client options if present. + */ + private final Optional version; + + private final Map headers; + + private final Map> headerSuppliers; + + private RequestOptions( + String token, + Optional timeout, + TimeUnit timeoutTimeUnit, + Optional version, + Map headers, + Map> headerSuppliers) { + this.token = token; + this.timeout = timeout; + this.timeoutTimeUnit = timeoutTimeUnit; + this.version = version; + this.headers = headers; + this.headerSuppliers = headerSuppliers; + } + + public Optional getTimeout() { + return timeout; + } + + public TimeUnit getTimeoutTimeUnit() { + return timeoutTimeUnit; + } + + /** + * version.get().toString() is sent as the "Intercom-Version" header, overriding client options if present. + */ + public Optional getVersion() { + return version; + } + + public Map getHeaders() { + Map headers = new HashMap<>(); + if (this.version.isPresent()) { + headers.put("Intercom-Version", this.version.get().toString()); + } + if (this.token != null) { + headers.put("Authorization", "Bearer " + this.token); + } + headers.putAll(this.headers); + this.headerSuppliers.forEach((key, supplier) -> { + headers.put(key, supplier.get()); + }); + return headers; + } + + public static Builder builder() { + return new Builder(); + } + + public static final class Builder { + private String token = null; + + private Optional timeout = Optional.empty(); + + private TimeUnit timeoutTimeUnit = TimeUnit.SECONDS; + + private Optional version = Optional.empty(); + + private final Map headers = new HashMap<>(); + + private final Map> headerSuppliers = new HashMap<>(); + + public Builder token(String token) { + this.token = token; + return this; + } + + /** + * version.get().toString() is sent as the "Intercom-Version" header, overriding client options if present. + */ + public Builder version(ApiVersion version) { + this.version = Optional.of(version); + return this; + } + + public Builder timeout(Integer timeout) { + this.timeout = Optional.of(timeout); + return this; + } + + public Builder timeout(Integer timeout, TimeUnit timeoutTimeUnit) { + this.timeout = Optional.of(timeout); + this.timeoutTimeUnit = timeoutTimeUnit; + return this; + } + + public Builder addHeader(String key, String value) { + this.headers.put(key, value); + return this; + } + + public Builder addHeader(String key, Supplier value) { + this.headerSuppliers.put(key, value); + return this; + } + + public RequestOptions build() { + return new RequestOptions(token, timeout, timeoutTimeUnit, version, headers, headerSuppliers); + } + } +} diff --git a/src/main/java/com/intercom/api/core/ResponseBodyInputStream.java b/src/main/java/com/intercom/api/core/ResponseBodyInputStream.java new file mode 100644 index 00000000..e72f831d --- /dev/null +++ b/src/main/java/com/intercom/api/core/ResponseBodyInputStream.java @@ -0,0 +1,45 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.core; + +import java.io.FilterInputStream; +import java.io.IOException; +import okhttp3.Response; + +/** + * A custom InputStream that wraps the InputStream from the OkHttp Response and ensures that the + * OkHttp Response object is properly closed when the stream is closed. + * + * This class extends FilterInputStream and takes an OkHttp Response object as a parameter. + * It retrieves the InputStream from the Response and overrides the close method to close + * both the InputStream and the Response object, ensuring proper resource management and preventing + * premature closure of the underlying HTTP connection. + */ +public class ResponseBodyInputStream extends FilterInputStream { + private final Response response; + + /** + * Constructs a ResponseBodyInputStream that wraps the InputStream from the given OkHttp + * Response object. + * + * @param response the OkHttp Response object from which the InputStream is retrieved + * @throws IOException if an I/O error occurs while retrieving the InputStream + */ + public ResponseBodyInputStream(Response response) throws IOException { + super(response.body().byteStream()); + this.response = response; + } + + /** + * Closes the InputStream and the associated OkHttp Response object. This ensures that the + * underlying HTTP connection is properly closed after the stream is no longer needed. + * + * @throws IOException if an I/O error occurs + */ + @Override + public void close() throws IOException { + super.close(); + response.close(); // Ensure the response is closed when the stream is closed + } +} diff --git a/src/main/java/com/intercom/api/core/ResponseBodyReader.java b/src/main/java/com/intercom/api/core/ResponseBodyReader.java new file mode 100644 index 00000000..512c64d8 --- /dev/null +++ b/src/main/java/com/intercom/api/core/ResponseBodyReader.java @@ -0,0 +1,44 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.core; + +import java.io.FilterReader; +import java.io.IOException; +import okhttp3.Response; + +/** + * A custom Reader that wraps the Reader from the OkHttp Response and ensures that the + * OkHttp Response object is properly closed when the reader is closed. + * + * This class extends FilterReader and takes an OkHttp Response object as a parameter. + * It retrieves the Reader from the Response and overrides the close method to close + * both the Reader and the Response object, ensuring proper resource management and preventing + * premature closure of the underlying HTTP connection. + */ +public class ResponseBodyReader extends FilterReader { + private final Response response; + + /** + * Constructs a ResponseBodyReader that wraps the Reader from the given OkHttp Response object. + * + * @param response the OkHttp Response object from which the Reader is retrieved + * @throws IOException if an I/O error occurs while retrieving the Reader + */ + public ResponseBodyReader(Response response) throws IOException { + super(response.body().charStream()); + this.response = response; + } + + /** + * Closes the Reader and the associated OkHttp Response object. This ensures that the + * underlying HTTP connection is properly closed after the reader is no longer needed. + * + * @throws IOException if an I/O error occurs + */ + @Override + public void close() throws IOException { + super.close(); + response.close(); // Ensure the response is closed when the reader is closed + } +} diff --git a/src/main/java/com/intercom/api/core/RetryInterceptor.java b/src/main/java/com/intercom/api/core/RetryInterceptor.java new file mode 100644 index 00000000..1f61a2c7 --- /dev/null +++ b/src/main/java/com/intercom/api/core/RetryInterceptor.java @@ -0,0 +1,78 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.core; + +import java.io.IOException; +import java.time.Duration; +import java.util.Optional; +import java.util.Random; +import okhttp3.Interceptor; +import okhttp3.Response; + +public class RetryInterceptor implements Interceptor { + + private static final Duration ONE_SECOND = Duration.ofSeconds(1); + private final ExponentialBackoff backoff; + private final Random random = new Random(); + + public RetryInterceptor(int maxRetries) { + this.backoff = new ExponentialBackoff(maxRetries); + } + + @Override + public Response intercept(Chain chain) throws IOException { + Response response = chain.proceed(chain.request()); + + if (shouldRetry(response.code())) { + return retryChain(response, chain); + } + + return response; + } + + private Response retryChain(Response response, Chain chain) throws IOException { + Optional nextBackoff = this.backoff.nextBackoff(); + while (nextBackoff.isPresent()) { + try { + Thread.sleep(nextBackoff.get().toMillis()); + } catch (InterruptedException e) { + throw new IOException("Interrupted while trying request", e); + } + response.close(); + response = chain.proceed(chain.request()); + if (shouldRetry(response.code())) { + nextBackoff = this.backoff.nextBackoff(); + } else { + return response; + } + } + + return response; + } + + private static boolean shouldRetry(int statusCode) { + return statusCode == 408 || statusCode == 409 || statusCode == 429 || statusCode >= 500; + } + + private final class ExponentialBackoff { + + private final int maxNumRetries; + + private int retryNumber = 0; + + ExponentialBackoff(int maxNumRetries) { + this.maxNumRetries = maxNumRetries; + } + + public Optional nextBackoff() { + retryNumber += 1; + if (retryNumber > maxNumRetries) { + return Optional.empty(); + } + + int upperBound = (int) Math.pow(2, retryNumber); + return Optional.of(ONE_SECOND.multipliedBy(random.nextInt(upperBound))); + } + } +} diff --git a/src/main/java/com/intercom/api/core/Stream.java b/src/main/java/com/intercom/api/core/Stream.java new file mode 100644 index 00000000..9c6b3ef9 --- /dev/null +++ b/src/main/java/com/intercom/api/core/Stream.java @@ -0,0 +1,97 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.core; + +import java.io.Reader; +import java.util.Iterator; +import java.util.NoSuchElementException; +import java.util.Scanner; + +/** + * The {@code Stream} class implements {@link Iterable} to provide a simple mechanism for reading and parsing + * objects of a given type from data streamed via a {@link Reader} using a specified delimiter. + *

+ * {@code Stream} assumes that data is being pushed to the provided {@link Reader} asynchronously and utilizes a + * {@code Scanner} to block during iteration if the next object is not available. + * + * @param The type of objects in the stream. + */ +public final class Stream implements Iterable { + /** + * The {@link Class} of the objects in the stream. + */ + private final Class valueType; + /** + * The {@link Scanner} used for reading from the input stream and blocking when needed during iteration. + */ + private final Scanner scanner; + + /** + * Constructs a new {@code Stream} with the specified value type, reader, and delimiter. + * + * @param valueType The class of the objects in the stream. + * @param reader The reader that provides the streamed data. + * @param delimiter The delimiter used to separate elements in the stream. + */ + public Stream(Class valueType, Reader reader, String delimiter) { + this.scanner = new Scanner(reader).useDelimiter(delimiter); + this.valueType = valueType; + } + + /** + * Returns an iterator over the elements in this stream that blocks during iteration when the next object is + * not yet available. + * + * @return An iterator that can be used to traverse the elements in the stream. + */ + @Override + public Iterator iterator() { + return new Iterator() { + /** + * Returns {@code true} if there are more elements in the stream. + *

+ * Will block and wait for input if the stream has not ended and the next object is not yet available. + * + * @return {@code true} if there are more elements, {@code false} otherwise. + */ + @Override + public boolean hasNext() { + return scanner.hasNext(); + } + + /** + * Returns the next element in the stream. + *

+ * Will block and wait for input if the stream has not ended and the next object is not yet available. + * + * @return The next element in the stream. + * @throws NoSuchElementException If there are no more elements in the stream. + */ + @Override + public T next() { + if (!scanner.hasNext()) { + throw new NoSuchElementException(); + } else { + try { + T parsedResponse = ObjectMappers.JSON_MAPPER.readValue( + scanner.next().trim(), valueType); + return parsedResponse; + } catch (Exception e) { + throw new RuntimeException(e); + } + } + } + + /** + * Removing elements from {@code Stream} is not supported. + * + * @throws UnsupportedOperationException Always, as removal is not supported. + */ + @Override + public void remove() { + throw new UnsupportedOperationException(); + } + }; + } +} diff --git a/src/main/java/com/intercom/api/core/Suppliers.java b/src/main/java/com/intercom/api/core/Suppliers.java new file mode 100644 index 00000000..f7998519 --- /dev/null +++ b/src/main/java/com/intercom/api/core/Suppliers.java @@ -0,0 +1,23 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.core; + +import java.util.Objects; +import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Supplier; + +public final class Suppliers { + private Suppliers() {} + + public static Supplier memoize(Supplier delegate) { + AtomicReference value = new AtomicReference<>(); + return () -> { + T val = value.get(); + if (val == null) { + val = value.updateAndGet(cur -> cur == null ? Objects.requireNonNull(delegate.get()) : cur); + } + return val; + }; + } +} diff --git a/src/main/java/com/intercom/api/core/pagination/BasePage.java b/src/main/java/com/intercom/api/core/pagination/BasePage.java new file mode 100644 index 00000000..cbc2098d --- /dev/null +++ b/src/main/java/com/intercom/api/core/pagination/BasePage.java @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.core.pagination; + +import java.util.List; + +public abstract class BasePage { + private final boolean hasNext; + private final List items; + + public BasePage(boolean hasNext, List items) { + this.hasNext = hasNext; + this.items = items; + } + + public boolean hasNext() { + return !items.isEmpty() && hasNext; + } + + public List getItems() { + return items; + } +} diff --git a/src/main/java/com/intercom/api/core/pagination/SyncPage.java b/src/main/java/com/intercom/api/core/pagination/SyncPage.java new file mode 100644 index 00000000..59c8bf74 --- /dev/null +++ b/src/main/java/com/intercom/api/core/pagination/SyncPage.java @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.core.pagination; + +import java.util.List; +import java.util.NoSuchElementException; +import java.util.function.Supplier; + +public class SyncPage extends BasePage { + protected final Supplier> nextSupplier; + + public SyncPage(boolean hasNext, List items, Supplier> nextSupplier) { + super(hasNext, items); + this.nextSupplier = nextSupplier; + } + + public SyncPage nextPage() { + if (!hasNext()) { + throw new NoSuchElementException(); + } + return nextSupplier.get(); + } +} diff --git a/src/main/java/com/intercom/api/core/pagination/SyncPagingIterable.java b/src/main/java/com/intercom/api/core/pagination/SyncPagingIterable.java new file mode 100644 index 00000000..cf05eeb4 --- /dev/null +++ b/src/main/java/com/intercom/api/core/pagination/SyncPagingIterable.java @@ -0,0 +1,61 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.core.pagination; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.NoSuchElementException; +import java.util.Optional; +import java.util.function.Supplier; +import java.util.stream.Stream; +import java.util.stream.StreamSupport; + +public class SyncPagingIterable extends SyncPage implements Iterable { + + public SyncPagingIterable(boolean hasNext, List items, Supplier> getNext) { + super(hasNext, items, getNext); + } + + public SyncPagingIterable(boolean hasNext, Optional> items, Supplier> getNext) { + super(hasNext, items.orElse(new ArrayList<>()), getNext); + } + + public Stream streamItems() { + return StreamSupport.stream(this.spliterator(), false); + } + + @Override + public Iterator iterator() { + return new Iterator() { + private Iterator itemsIterator = getItems().iterator(); + private SyncPage currentPage = SyncPagingIterable.this; + + @Override + public boolean hasNext() { + if (itemsIterator.hasNext()) { + return true; + } + if (currentPage.hasNext()) { + advancePage(); + return itemsIterator.hasNext(); + } + return false; + } + + @Override + public T next() { + if (!hasNext()) { + throw new NoSuchElementException(); + } + return itemsIterator.next(); + } + + private void advancePage() { + currentPage = currentPage.nextPage(); + itemsIterator = currentPage.getItems().iterator(); + } + }; + } +} diff --git a/src/main/java/com/intercom/api/errors/BadRequestError.java b/src/main/java/com/intercom/api/errors/BadRequestError.java new file mode 100644 index 00000000..b20358b2 --- /dev/null +++ b/src/main/java/com/intercom/api/errors/BadRequestError.java @@ -0,0 +1,26 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.errors; + +import com.intercom.api.core.IntercomApiException; + +public final class BadRequestError extends IntercomApiException { + /** + * The body of the response that triggered the exception. + */ + private final Object body; + + public BadRequestError(Object body) { + super("BadRequestError", 400, body); + this.body = body; + } + + /** + * @return the body + */ + @java.lang.Override + public Object body() { + return this.body; + } +} diff --git a/src/main/java/com/intercom/api/errors/ForbiddenError.java b/src/main/java/com/intercom/api/errors/ForbiddenError.java new file mode 100644 index 00000000..bddad94f --- /dev/null +++ b/src/main/java/com/intercom/api/errors/ForbiddenError.java @@ -0,0 +1,27 @@ +/** + * 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; + +public final class ForbiddenError extends IntercomApiException { + /** + * The body of the response that triggered the exception. + */ + private final Error body; + + public ForbiddenError(Error body) { + super("ForbiddenError", 403, body); + this.body = body; + } + + /** + * @return the body + */ + @java.lang.Override + public Error body() { + return this.body; + } +} diff --git a/src/main/java/com/intercom/api/errors/NotFoundError.java b/src/main/java/com/intercom/api/errors/NotFoundError.java new file mode 100644 index 00000000..730f46b0 --- /dev/null +++ b/src/main/java/com/intercom/api/errors/NotFoundError.java @@ -0,0 +1,26 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.errors; + +import com.intercom.api.core.IntercomApiException; + +public final class NotFoundError extends IntercomApiException { + /** + * The body of the response that triggered the exception. + */ + private final Object body; + + public NotFoundError(Object body) { + super("NotFoundError", 404, body); + this.body = body; + } + + /** + * @return the body + */ + @java.lang.Override + public Object body() { + return this.body; + } +} diff --git a/src/main/java/com/intercom/api/errors/UnauthorizedError.java b/src/main/java/com/intercom/api/errors/UnauthorizedError.java new file mode 100644 index 00000000..5d07b742 --- /dev/null +++ b/src/main/java/com/intercom/api/errors/UnauthorizedError.java @@ -0,0 +1,27 @@ +/** + * 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; + +public final class UnauthorizedError extends IntercomApiException { + /** + * The body of the response that triggered the exception. + */ + private final Error body; + + public UnauthorizedError(Error body) { + super("UnauthorizedError", 401, body); + this.body = body; + } + + /** + * @return the body + */ + @java.lang.Override + public Error body() { + return this.body; + } +} diff --git a/src/main/java/com/intercom/api/errors/UnprocessableEntityError.java b/src/main/java/com/intercom/api/errors/UnprocessableEntityError.java new file mode 100644 index 00000000..11256244 --- /dev/null +++ b/src/main/java/com/intercom/api/errors/UnprocessableEntityError.java @@ -0,0 +1,26 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.errors; + +import com.intercom.api.core.IntercomApiException; + +public final class UnprocessableEntityError extends IntercomApiException { + /** + * The body of the response that triggered the exception. + */ + private final Object body; + + public UnprocessableEntityError(Object body) { + super("UnprocessableEntityError", 422, body); + this.body = body; + } + + /** + * @return the body + */ + @java.lang.Override + public Object 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 new file mode 100644 index 00000000..ca154a41 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/admins/AdminsClient.java @@ -0,0 +1,302 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.admins; + +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.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.admins.requests.ConfigureAwayAdminRequest; +import com.intercom.api.resources.admins.requests.FindAdminRequest; +import com.intercom.api.resources.admins.requests.ListAllActivityLogsRequest; +import com.intercom.api.resources.admins.types.Admin; +import com.intercom.api.types.ActivityLogList; +import com.intercom.api.types.AdminList; +import com.intercom.api.types.AdminWithApp; +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 AdminsClient { + protected final ClientOptions clientOptions; + + public AdminsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can view the currently authorised admin along with the embedded app object (a "workspace" in legacy terminology). + *

+ *

🚧 Single Sign On

+ *

If you are building a custom "Log in with Intercom" flow for your site, and you call the /me endpoint to identify the logged-in user, you should not accept any sign-ins from users with unverified email addresses as it poses a potential impersonation security risk.

+ *
+ */ + public AdminWithApp identify() { + return identify(null); + } + + /** + * You can view the currently authorised admin along with the embedded app object (a "workspace" in legacy terminology). + *
+ *

🚧 Single Sign On

+ *

If you are building a custom "Log in with Intercom" flow for your site, and you call the /me endpoint to identify the logged-in user, you should not accept any sign-ins from users with unverified email addresses as it poses a potential impersonation security risk.

+ *
+ */ + public AdminWithApp identify(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("me") + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AdminWithApp.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can set an Admin as away for the Inbox. + */ + public Admin away(ConfigureAwayAdminRequest request) { + return away(request, null); + } + + /** + * You can set an Admin as away for the Inbox. + */ + public Admin away(ConfigureAwayAdminRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("admins") + .addPathSegment(request.getAdminId()) + .addPathSegments("away") + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Admin.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can get a log of activities by all admins in an app. + */ + public ActivityLogList listAllActivityLogs(ListAllActivityLogsRequest request) { + return listAllActivityLogs(request, null); + } + + /** + * You can get a log of activities by all admins in an app. + */ + public ActivityLogList listAllActivityLogs(ListAllActivityLogsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("admins/activity_logs"); + QueryStringMapper.addQueryParameter(httpUrl, "created_at_after", request.getCreatedAtAfter(), false); + if (request.getCreatedAtBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_at_before", request.getCreatedAtBefore().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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ActivityLogList.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can fetch a list of admins for a given workspace. + */ + public AdminList list() { + return list(null); + } + + /** + * You can fetch a list of admins for a given workspace. + */ + public AdminList list(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("admins") + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AdminList.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can retrieve the details of a single admin. + */ + public Admin find(FindAdminRequest request) { + return find(request, null); + } + + /** + * You can retrieve the details of a single admin. + */ + public Admin find(FindAdminRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("admins") + .addPathSegment(request.getAdminId()) + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Admin.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/admins/AsyncAdminsClient.java b/src/main/java/com/intercom/api/resources/admins/AsyncAdminsClient.java new file mode 100644 index 00000000..28a8409f --- /dev/null +++ b/src/main/java/com/intercom/api/resources/admins/AsyncAdminsClient.java @@ -0,0 +1,383 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.admins; + +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.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.admins.requests.ConfigureAwayAdminRequest; +import com.intercom.api.resources.admins.requests.FindAdminRequest; +import com.intercom.api.resources.admins.requests.ListAllActivityLogsRequest; +import com.intercom.api.resources.admins.types.Admin; +import com.intercom.api.types.ActivityLogList; +import com.intercom.api.types.AdminList; +import com.intercom.api.types.AdminWithApp; +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 AsyncAdminsClient { + protected final ClientOptions clientOptions; + + public AsyncAdminsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can view the currently authorised admin along with the embedded app object (a "workspace" in legacy terminology). + *
+ *

🚧 Single Sign On

+ *

If you are building a custom "Log in with Intercom" flow for your site, and you call the /me endpoint to identify the logged-in user, you should not accept any sign-ins from users with unverified email addresses as it poses a potential impersonation security risk.

+ *
+ */ + public CompletableFuture identify() { + return identify(null); + } + + /** + * You can view the currently authorised admin along with the embedded app object (a "workspace" in legacy terminology). + *
+ *

🚧 Single Sign On

+ *

If you are building a custom "Log in with Intercom" flow for your site, and you call the /me endpoint to identify the logged-in user, you should not accept any sign-ins from users with unverified email addresses as it poses a potential impersonation security risk.

+ *
+ */ + public CompletableFuture identify(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("me") + .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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AdminWithApp.class)); + 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))); + 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 set an Admin as away for the Inbox. + */ + public CompletableFuture away(ConfigureAwayAdminRequest request) { + return away(request, null); + } + + /** + * You can set an Admin as away for the Inbox. + */ + public CompletableFuture away(ConfigureAwayAdminRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("admins") + .addPathSegment(request.getAdminId()) + .addPathSegments("away") + .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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Admin.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + 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))); + 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 get a log of activities by all admins in an app. + */ + public CompletableFuture listAllActivityLogs(ListAllActivityLogsRequest request) { + return listAllActivityLogs(request, null); + } + + /** + * You can get a log of activities by all admins in an app. + */ + public CompletableFuture listAllActivityLogs( + ListAllActivityLogsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("admins/activity_logs"); + QueryStringMapper.addQueryParameter(httpUrl, "created_at_after", request.getCreatedAtAfter(), false); + if (request.getCreatedAtBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_at_before", request.getCreatedAtBefore().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( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ActivityLogList.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + 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))); + 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 a list of admins for a given workspace. + */ + public CompletableFuture list() { + return list(null); + } + + /** + * You can fetch a list of admins for a given workspace. + */ + public CompletableFuture list(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("admins") + .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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AdminList.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + 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))); + 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 the details of a single admin. + */ + public CompletableFuture find(FindAdminRequest request) { + return find(request, null); + } + + /** + * You can retrieve the details of a single admin. + */ + public CompletableFuture find(FindAdminRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("admins") + .addPathSegment(request.getAdminId()) + .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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Admin.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + 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))); + 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/admins/requests/ConfigureAwayAdminRequest.java b/src/main/java/com/intercom/api/resources/admins/requests/ConfigureAwayAdminRequest.java new file mode 100644 index 00000000..d3ec9b95 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/admins/requests/ConfigureAwayAdminRequest.java @@ -0,0 +1,174 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.admins.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 = ConfigureAwayAdminRequest.Builder.class) +public final class ConfigureAwayAdminRequest { + private final String adminId; + + private final boolean awayModeEnabled; + + private final boolean awayModeReassign; + + private final Map additionalProperties; + + private ConfigureAwayAdminRequest( + String adminId, + boolean awayModeEnabled, + boolean awayModeReassign, + Map additionalProperties) { + this.adminId = adminId; + this.awayModeEnabled = awayModeEnabled; + this.awayModeReassign = awayModeReassign; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier of a given admin + */ + @JsonProperty("admin_id") + public String getAdminId() { + return adminId; + } + + /** + * @return Set to "true" to change the status of the admin to away. + */ + @JsonProperty("away_mode_enabled") + public boolean getAwayModeEnabled() { + return awayModeEnabled; + } + + /** + * @return Set to "true" to assign any new conversation replies to your default inbox. + */ + @JsonProperty("away_mode_reassign") + public boolean getAwayModeReassign() { + return awayModeReassign; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ConfigureAwayAdminRequest && equalTo((ConfigureAwayAdminRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ConfigureAwayAdminRequest other) { + return adminId.equals(other.adminId) + && awayModeEnabled == other.awayModeEnabled + && awayModeReassign == other.awayModeReassign; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.adminId, this.awayModeEnabled, this.awayModeReassign); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static AdminIdStage builder() { + return new Builder(); + } + + public interface AdminIdStage { + AwayModeEnabledStage adminId(@NotNull String adminId); + + Builder from(ConfigureAwayAdminRequest other); + } + + public interface AwayModeEnabledStage { + AwayModeReassignStage awayModeEnabled(boolean awayModeEnabled); + } + + public interface AwayModeReassignStage { + _FinalStage awayModeReassign(boolean awayModeReassign); + } + + public interface _FinalStage { + ConfigureAwayAdminRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements AdminIdStage, AwayModeEnabledStage, AwayModeReassignStage, _FinalStage { + private String adminId; + + private boolean awayModeEnabled; + + private boolean awayModeReassign; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ConfigureAwayAdminRequest other) { + adminId(other.getAdminId()); + awayModeEnabled(other.getAwayModeEnabled()); + awayModeReassign(other.getAwayModeReassign()); + return this; + } + + /** + *

The unique identifier of a given admin

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

Set to "true" to change the status of the admin to away.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("away_mode_enabled") + public AwayModeReassignStage awayModeEnabled(boolean awayModeEnabled) { + this.awayModeEnabled = awayModeEnabled; + return this; + } + + /** + *

Set to "true" to assign any new conversation replies to your default inbox.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("away_mode_reassign") + public _FinalStage awayModeReassign(boolean awayModeReassign) { + this.awayModeReassign = awayModeReassign; + return this; + } + + @java.lang.Override + public ConfigureAwayAdminRequest build() { + return new ConfigureAwayAdminRequest(adminId, awayModeEnabled, awayModeReassign, 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 new file mode 100644 index 00000000..3b169f7b --- /dev/null +++ b/src/main/java/com/intercom/api/resources/admins/requests/FindAdminRequest.java @@ -0,0 +1,109 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.admins.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 = FindAdminRequest.Builder.class) +public final class FindAdminRequest { + private final String adminId; + + private final Map additionalProperties; + + private FindAdminRequest(String adminId, Map additionalProperties) { + this.adminId = adminId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier of a given admin + */ + @JsonProperty("admin_id") + public String getAdminId() { + return adminId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof FindAdminRequest && equalTo((FindAdminRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(FindAdminRequest other) { + return adminId.equals(other.adminId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.adminId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static AdminIdStage builder() { + return new Builder(); + } + + public interface AdminIdStage { + _FinalStage adminId(@NotNull String adminId); + + Builder from(FindAdminRequest other); + } + + public interface _FinalStage { + FindAdminRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements AdminIdStage, _FinalStage { + private String adminId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(FindAdminRequest other) { + adminId(other.getAdminId()); + return this; + } + + /** + *

The unique identifier of a given admin

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("admin_id") + public _FinalStage adminId(@NotNull String adminId) { + this.adminId = Objects.requireNonNull(adminId, "adminId must not be null"); + return this; + } + + @java.lang.Override + public FindAdminRequest build() { + return new FindAdminRequest(adminId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/admins/requests/ListAllActivityLogsRequest.java b/src/main/java/com/intercom/api/resources/admins/requests/ListAllActivityLogsRequest.java new file mode 100644 index 00000000..f2362c98 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/admins/requests/ListAllActivityLogsRequest.java @@ -0,0 +1,147 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.admins.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 = ListAllActivityLogsRequest.Builder.class) +public final class ListAllActivityLogsRequest { + private final String createdAtAfter; + + private final Optional createdAtBefore; + + private final Map additionalProperties; + + private ListAllActivityLogsRequest( + String createdAtAfter, Optional createdAtBefore, Map additionalProperties) { + this.createdAtAfter = createdAtAfter; + this.createdAtBefore = createdAtBefore; + this.additionalProperties = additionalProperties; + } + + /** + * @return The start date that you request data for. It must be formatted as a UNIX timestamp. + */ + @JsonProperty("created_at_after") + public String getCreatedAtAfter() { + return createdAtAfter; + } + + /** + * @return The end date that you request data for. It must be formatted as a UNIX timestamp. + */ + @JsonProperty("created_at_before") + public Optional getCreatedAtBefore() { + return createdAtBefore; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListAllActivityLogsRequest && equalTo((ListAllActivityLogsRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListAllActivityLogsRequest other) { + return createdAtAfter.equals(other.createdAtAfter) && createdAtBefore.equals(other.createdAtBefore); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.createdAtAfter, this.createdAtBefore); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static CreatedAtAfterStage builder() { + return new Builder(); + } + + public interface CreatedAtAfterStage { + _FinalStage createdAtAfter(@NotNull String createdAtAfter); + + Builder from(ListAllActivityLogsRequest other); + } + + public interface _FinalStage { + ListAllActivityLogsRequest build(); + + _FinalStage createdAtBefore(Optional createdAtBefore); + + _FinalStage createdAtBefore(String createdAtBefore); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements CreatedAtAfterStage, _FinalStage { + private String createdAtAfter; + + private Optional createdAtBefore = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ListAllActivityLogsRequest other) { + createdAtAfter(other.getCreatedAtAfter()); + createdAtBefore(other.getCreatedAtBefore()); + return this; + } + + /** + *

The start date that you request data for. It must be formatted as a UNIX timestamp.

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

The end date that you request data for. It must be formatted as a UNIX timestamp.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage createdAtBefore(String createdAtBefore) { + this.createdAtBefore = Optional.ofNullable(createdAtBefore); + return this; + } + + @java.lang.Override + @JsonSetter(value = "created_at_before", nulls = Nulls.SKIP) + public _FinalStage createdAtBefore(Optional createdAtBefore) { + this.createdAtBefore = createdAtBefore; + return this; + } + + @java.lang.Override + public ListAllActivityLogsRequest build() { + return new ListAllActivityLogsRequest(createdAtAfter, createdAtBefore, additionalProperties); + } + } +} 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 new file mode 100644 index 00000000..556bcae6 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/admins/types/Admin.java @@ -0,0 +1,579 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.admins.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.TeamPriorityLevel; +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 = Admin.Builder.class) +public final class Admin { + private final Optional type; + + private final String id; + + private final String name; + + private final String email; + + private final String jobTitle; + + private final boolean awayModeEnabled; + + private final boolean awayModeReassign; + + private final boolean hasInboxSeat; + + private final List teamIds; + + private final Optional avatar; + + private final Optional teamPriorityLevel; + + private final Map additionalProperties; + + private Admin( + Optional type, + String id, + String name, + String email, + String jobTitle, + boolean awayModeEnabled, + boolean awayModeReassign, + boolean hasInboxSeat, + List teamIds, + Optional avatar, + Optional teamPriorityLevel, + Map additionalProperties) { + this.type = type; + this.id = id; + this.name = name; + this.email = email; + this.jobTitle = jobTitle; + this.awayModeEnabled = awayModeEnabled; + this.awayModeReassign = awayModeReassign; + this.hasInboxSeat = hasInboxSeat; + this.teamIds = teamIds; + this.avatar = avatar; + this.teamPriorityLevel = teamPriorityLevel; + this.additionalProperties = additionalProperties; + } + + /** + * @return String representing the object's type. Always has the value admin. + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return The id representing the admin. + */ + @JsonProperty("id") + public String getId() { + return id; + } + + /** + * @return The name of the admin. + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * @return The email of the admin. + */ + @JsonProperty("email") + public String getEmail() { + return email; + } + + /** + * @return The job title of the admin. + */ + @JsonProperty("job_title") + public String getJobTitle() { + return jobTitle; + } + + /** + * @return Identifies if this admin is currently set in away mode. + */ + @JsonProperty("away_mode_enabled") + public boolean getAwayModeEnabled() { + return awayModeEnabled; + } + + /** + * @return Identifies if this admin is set to automatically reassign new conversations to the apps default inbox. + */ + @JsonProperty("away_mode_reassign") + public boolean getAwayModeReassign() { + return awayModeReassign; + } + + /** + * @return Identifies if this admin has a paid inbox seat to restrict/allow features that require them. + */ + @JsonProperty("has_inbox_seat") + public boolean getHasInboxSeat() { + return hasInboxSeat; + } + + /** + * @return This object represents the avatar associated with the admin. + */ + @JsonProperty("team_ids") + public List getTeamIds() { + return teamIds; + } + + /** + * @return The avatar object associated with the admin + */ + @JsonProperty("avatar") + public Optional getAvatar() { + return avatar; + } + + @JsonProperty("team_priority_level") + public Optional getTeamPriorityLevel() { + return teamPriorityLevel; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Admin && equalTo((Admin) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Admin other) { + return type.equals(other.type) + && id.equals(other.id) + && name.equals(other.name) + && email.equals(other.email) + && jobTitle.equals(other.jobTitle) + && awayModeEnabled == other.awayModeEnabled + && awayModeReassign == other.awayModeReassign + && hasInboxSeat == other.hasInboxSeat + && teamIds.equals(other.teamIds) + && avatar.equals(other.avatar) + && teamPriorityLevel.equals(other.teamPriorityLevel); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.type, + this.id, + this.name, + this.email, + this.jobTitle, + this.awayModeEnabled, + this.awayModeReassign, + this.hasInboxSeat, + this.teamIds, + this.avatar, + this.teamPriorityLevel); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + NameStage id(@NotNull String id); + + Builder from(Admin other); + } + + public interface NameStage { + EmailStage name(@NotNull String name); + } + + public interface EmailStage { + JobTitleStage email(@NotNull String email); + } + + public interface JobTitleStage { + AwayModeEnabledStage jobTitle(@NotNull String jobTitle); + } + + public interface AwayModeEnabledStage { + AwayModeReassignStage awayModeEnabled(boolean awayModeEnabled); + } + + public interface AwayModeReassignStage { + HasInboxSeatStage awayModeReassign(boolean awayModeReassign); + } + + public interface HasInboxSeatStage { + _FinalStage hasInboxSeat(boolean hasInboxSeat); + } + + public interface _FinalStage { + Admin build(); + + _FinalStage type(Optional type); + + _FinalStage type(String type); + + _FinalStage teamIds(List teamIds); + + _FinalStage addTeamIds(Integer teamIds); + + _FinalStage addAllTeamIds(List teamIds); + + _FinalStage avatar(Optional avatar); + + _FinalStage avatar(Avatar avatar); + + _FinalStage teamPriorityLevel(Optional teamPriorityLevel); + + _FinalStage teamPriorityLevel(TeamPriorityLevel teamPriorityLevel); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements IdStage, + NameStage, + EmailStage, + JobTitleStage, + AwayModeEnabledStage, + AwayModeReassignStage, + HasInboxSeatStage, + _FinalStage { + private String id; + + private String name; + + private String email; + + private String jobTitle; + + private boolean awayModeEnabled; + + private boolean awayModeReassign; + + private boolean hasInboxSeat; + + private Optional teamPriorityLevel = Optional.empty(); + + private Optional avatar = Optional.empty(); + + private List teamIds = new ArrayList<>(); + + private Optional type = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(Admin other) { + type(other.getType()); + id(other.getId()); + name(other.getName()); + email(other.getEmail()); + jobTitle(other.getJobTitle()); + awayModeEnabled(other.getAwayModeEnabled()); + awayModeReassign(other.getAwayModeReassign()); + hasInboxSeat(other.getHasInboxSeat()); + teamIds(other.getTeamIds()); + avatar(other.getAvatar()); + teamPriorityLevel(other.getTeamPriorityLevel()); + return this; + } + + /** + *

The id representing the admin.

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

The name of the admin.

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

The email of the admin.

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

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.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("away_mode_enabled") + public AwayModeReassignStage awayModeEnabled(boolean awayModeEnabled) { + this.awayModeEnabled = awayModeEnabled; + return this; + } + + /** + *

Identifies if this admin is set to automatically reassign new conversations to the apps default inbox.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("away_mode_reassign") + public HasInboxSeatStage awayModeReassign(boolean awayModeReassign) { + this.awayModeReassign = awayModeReassign; + return this; + } + + /** + *

Identifies if this admin has a paid inbox seat to restrict/allow features that require them.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("has_inbox_seat") + public _FinalStage hasInboxSeat(boolean hasInboxSeat) { + this.hasInboxSeat = hasInboxSeat; + return this; + } + + @java.lang.Override + public _FinalStage teamPriorityLevel(TeamPriorityLevel teamPriorityLevel) { + this.teamPriorityLevel = Optional.ofNullable(teamPriorityLevel); + return this; + } + + @java.lang.Override + @JsonSetter(value = "team_priority_level", nulls = Nulls.SKIP) + public _FinalStage teamPriorityLevel(Optional teamPriorityLevel) { + this.teamPriorityLevel = teamPriorityLevel; + return this; + } + + /** + *

The avatar object associated with the admin

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage avatar(Avatar avatar) { + this.avatar = Optional.ofNullable(avatar); + return this; + } + + @java.lang.Override + @JsonSetter(value = "avatar", nulls = Nulls.SKIP) + public _FinalStage avatar(Optional avatar) { + this.avatar = avatar; + return this; + } + + /** + *

This object represents the avatar associated with the admin.

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

This object represents the avatar associated with the admin.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage addTeamIds(Integer teamIds) { + this.teamIds.add(teamIds); + return this; + } + + @java.lang.Override + @JsonSetter(value = "team_ids", nulls = Nulls.SKIP) + public _FinalStage teamIds(List teamIds) { + this.teamIds.clear(); + this.teamIds.addAll(teamIds); + 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. + */ + @java.lang.Override + public _FinalStage type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + @java.lang.Override + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public _FinalStage type(Optional type) { + this.type = type; + return this; + } + + @java.lang.Override + public Admin build() { + return new Admin( + type, + id, + name, + email, + jobTitle, + awayModeEnabled, + awayModeReassign, + hasInboxSeat, + teamIds, + avatar, + teamPriorityLevel, + 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 { + _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

+ * @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 new file mode 100644 index 00000000..ad2abbfc --- /dev/null +++ b/src/main/java/com/intercom/api/resources/aiagent/types/AiAgent.java @@ -0,0 +1,452 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.aiagent.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 com.intercom.api.types.ContentSourcesList; +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 = AiAgent.Builder.class) +public final class AiAgent { + private final SourceType sourceType; + + private final Optional sourceTitle; + + private final Optional lastAnswerType; + + private final Optional resolutionState; + + private final Optional rating; + + private final Optional ratingRemark; + + private final Optional contentSources; + + private final Map additionalProperties; + + private AiAgent( + SourceType sourceType, + Optional sourceTitle, + Optional lastAnswerType, + Optional resolutionState, + Optional rating, + Optional ratingRemark, + Optional contentSources, + Map additionalProperties) { + this.sourceType = sourceType; + this.sourceTitle = sourceTitle; + this.lastAnswerType = lastAnswerType; + this.resolutionState = resolutionState; + this.rating = rating; + this.ratingRemark = ratingRemark; + this.contentSources = contentSources; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of the source that triggered AI Agent involvement in the conversation. + */ + @JsonProperty("source_type") + public SourceType getSourceType() { + return sourceType; + } + + /** + * @return The title of the source that triggered AI Agent involvement in the conversation. If this is essentials_plan_setup then it will return null. + */ + @JsonProperty("source_title") + public Optional getSourceTitle() { + return sourceTitle; + } + + /** + * @return The type of the last answer delivered by AI Agent. If no answer was delivered then this will return null + */ + @JsonProperty("last_answer_type") + public Optional getLastAnswerType() { + return lastAnswerType; + } + + /** + * @return The resolution state of AI Agent. If no AI or custom answer has been delivered then this will return null. + */ + @JsonProperty("resolution_state") + public Optional getResolutionState() { + return resolutionState; + } + + /** + * @return The customer satisfaction rating given to AI Agent, from 1-5. + */ + @JsonProperty("rating") + public Optional getRating() { + return rating; + } + + /** + * @return The customer satisfaction rating remark given to AI Agent. + */ + @JsonProperty("rating_remark") + public Optional getRatingRemark() { + return ratingRemark; + } + + @JsonProperty("content_sources") + public Optional getContentSources() { + return contentSources; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AiAgent && equalTo((AiAgent) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(AiAgent other) { + return sourceType.equals(other.sourceType) + && sourceTitle.equals(other.sourceTitle) + && lastAnswerType.equals(other.lastAnswerType) + && resolutionState.equals(other.resolutionState) + && rating.equals(other.rating) + && ratingRemark.equals(other.ratingRemark) + && contentSources.equals(other.contentSources); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.sourceType, + this.sourceTitle, + this.lastAnswerType, + this.resolutionState, + this.rating, + this.ratingRemark, + this.contentSources); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static SourceTypeStage builder() { + return new Builder(); + } + + public interface SourceTypeStage { + _FinalStage sourceType(@NotNull SourceType sourceType); + + Builder from(AiAgent other); + } + + public interface _FinalStage { + AiAgent build(); + + _FinalStage sourceTitle(Optional sourceTitle); + + _FinalStage sourceTitle(String sourceTitle); + + _FinalStage lastAnswerType(Optional lastAnswerType); + + _FinalStage lastAnswerType(String lastAnswerType); + + _FinalStage resolutionState(Optional resolutionState); + + _FinalStage resolutionState(String resolutionState); + + _FinalStage rating(Optional rating); + + _FinalStage rating(Integer rating); + + _FinalStage ratingRemark(Optional ratingRemark); + + _FinalStage ratingRemark(String ratingRemark); + + _FinalStage contentSources(Optional contentSources); + + _FinalStage contentSources(ContentSourcesList contentSources); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements SourceTypeStage, _FinalStage { + private SourceType sourceType; + + private Optional contentSources = Optional.empty(); + + private Optional ratingRemark = Optional.empty(); + + private Optional rating = Optional.empty(); + + private Optional resolutionState = Optional.empty(); + + private Optional lastAnswerType = Optional.empty(); + + private Optional sourceTitle = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(AiAgent other) { + sourceType(other.getSourceType()); + sourceTitle(other.getSourceTitle()); + lastAnswerType(other.getLastAnswerType()); + resolutionState(other.getResolutionState()); + rating(other.getRating()); + ratingRemark(other.getRatingRemark()); + contentSources(other.getContentSources()); + return this; + } + + /** + *

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. + */ + @java.lang.Override + @JsonSetter("source_type") + public _FinalStage sourceType(@NotNull SourceType sourceType) { + this.sourceType = Objects.requireNonNull(sourceType, "sourceType must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage contentSources(ContentSourcesList contentSources) { + this.contentSources = Optional.ofNullable(contentSources); + return this; + } + + @java.lang.Override + @JsonSetter(value = "content_sources", nulls = Nulls.SKIP) + public _FinalStage contentSources(Optional contentSources) { + this.contentSources = contentSources; + 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "rating_remark", nulls = Nulls.SKIP) + public _FinalStage ratingRemark(Optional ratingRemark) { + this.ratingRemark = ratingRemark; + 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. + */ + @java.lang.Override + public _FinalStage rating(Integer rating) { + this.rating = Optional.ofNullable(rating); + return this; + } + + @java.lang.Override + @JsonSetter(value = "rating", nulls = Nulls.SKIP) + public _FinalStage 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "resolution_state", nulls = Nulls.SKIP) + public _FinalStage resolutionState(Optional resolutionState) { + this.resolutionState = resolutionState; + 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "last_answer_type", nulls = Nulls.SKIP) + public _FinalStage lastAnswerType(Optional lastAnswerType) { + this.lastAnswerType = lastAnswerType; + 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "source_title", nulls = Nulls.SKIP) + public _FinalStage sourceTitle(Optional sourceTitle) { + this.sourceTitle = sourceTitle; + return this; + } + + @java.lang.Override + public AiAgent build() { + return new AiAgent( + sourceType, + sourceTitle, + lastAnswerType, + resolutionState, + rating, + ratingRemark, + contentSources, + additionalProperties); + } + } + + public final class SourceType { + public static final SourceType WORKFLOW = new SourceType(Value.WORKFLOW, "workflow"); + + public static final SourceType WORKFLOW_PREVIEW = new SourceType(Value.WORKFLOW_PREVIEW, "workflow_preview"); + + public static final SourceType FIN_PREVIEW = new SourceType(Value.FIN_PREVIEW, "fin_preview"); + + public static final SourceType ESSENTIALS_PLAN_SETUP = + new SourceType(Value.ESSENTIALS_PLAN_SETUP, "essentials_plan_setup"); + + public static final SourceType PROFILE = new SourceType(Value.PROFILE, "profile"); + + private final Value value; + + private final String string; + + SourceType(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 SourceType && this.string.equals(((SourceType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case WORKFLOW: + return visitor.visitWorkflow(); + case WORKFLOW_PREVIEW: + return visitor.visitWorkflowPreview(); + case FIN_PREVIEW: + return visitor.visitFinPreview(); + case ESSENTIALS_PLAN_SETUP: + return visitor.visitEssentialsPlanSetup(); + case PROFILE: + return visitor.visitProfile(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static SourceType valueOf(String value) { + switch (value) { + case "workflow": + return WORKFLOW; + case "workflow_preview": + return WORKFLOW_PREVIEW; + case "fin_preview": + return FIN_PREVIEW; + case "essentials_plan_setup": + return ESSENTIALS_PLAN_SETUP; + case "profile": + return PROFILE; + default: + return new SourceType(Value.UNKNOWN, value); + } + } + + public enum Value { + ESSENTIALS_PLAN_SETUP, + + PROFILE, + + WORKFLOW, + + WORKFLOW_PREVIEW, + + FIN_PREVIEW, + + UNKNOWN + } + + public interface Visitor { + T visitEssentialsPlanSetup(); + + T visitProfile(); + + T visitWorkflow(); + + T visitWorkflowPreview(); + + T visitFinPreview(); + + T visitUnknown(String unknownType); + } + } +} 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 new file mode 100644 index 00000000..510a294a --- /dev/null +++ b/src/main/java/com/intercom/api/resources/aicontentsource/types/ContentSource.java @@ -0,0 +1,175 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.aicontentsource.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.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 = ContentSource.Builder.class) +public final class ContentSource { + private final String url; + + private final String title; + + private final String locale; + + private final Map additionalProperties; + + private ContentSource(String url, String title, String locale, Map additionalProperties) { + this.url = url; + this.title = title; + this.locale = locale; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of the content source. + */ + @JsonProperty("content_type") + public String getContentType() { + return "custom_answer"; + } + + /** + * @return The internal URL linking to the content source for teammates. + */ + @JsonProperty("url") + public String getUrl() { + return url; + } + + /** + * @return The title of the content source. + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * @return The ISO 639 language code of the content source. + */ + @JsonProperty("locale") + public String getLocale() { + return locale; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ContentSource && equalTo((ContentSource) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ContentSource other) { + return 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); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static UrlStage builder() { + return new Builder(); + } + + public interface UrlStage { + TitleStage url(@NotNull String url); + + Builder from(ContentSource other); + } + + public interface TitleStage { + LocaleStage title(@NotNull String title); + } + + public interface LocaleStage { + _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; + + private String title; + + private String locale; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ContentSource other) { + url(other.getUrl()); + title(other.getTitle()); + locale(other.getLocale()); + return this; + } + + /** + *

The internal URL linking to the content source for teammates.

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

The title of the content source.

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

The ISO 639 language code of the content source.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("locale") + public _FinalStage locale(@NotNull String locale) { + this.locale = Objects.requireNonNull(locale, "locale must not be null"); + return this; + } + + @java.lang.Override + public ContentSource build() { + return new ContentSource(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 new file mode 100644 index 00000000..8c35cba9 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/articles/ArticlesClient.java @@ -0,0 +1,424 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.articles; + +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.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.QueryStringMapper; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.core.pagination.SyncPagingIterable; +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; +import com.intercom.api.resources.articles.requests.SearchArticlesRequest; +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.types.ArticleList; +import com.intercom.api.types.DeletedArticleObject; +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.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class ArticlesClient { + protected final ClientOptions clientOptions; + + public ArticlesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can fetch a list of all articles by making a GET request to https://api.intercom.io/articles. + *
+ *

📘 How are the articles sorted and ordered?

+ *

Articles will be returned in descending order on the updated_at attribute. This means if you need to iterate through results then we'll show the most recently updated articles first.

+ *
+ */ + public SyncPagingIterable list() { + return list(ListArticlesRequest.builder().build()); + } + + /** + * You can fetch a list of all articles by making a GET request to https://api.intercom.io/articles. + *
+ *

📘 How are the articles sorted and ordered?

+ *

Articles will be returned in descending order on the updated_at attribute. This means if you need to iterate through results then we'll show the most recently updated articles first.

+ *
+ */ + public SyncPagingIterable list(ListArticlesRequest request) { + return list(request, null); + } + + /** + * You can fetch a list of all articles by making a GET request to https://api.intercom.io/articles. + *
+ *

📘 How are the articles sorted and ordered?

+ *

Articles will be returned in descending order on the updated_at attribute. This means if you need to iterate through results then we'll show the most recently updated articles first.

+ *
+ */ + public SyncPagingIterable list(ListArticlesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("articles"); + 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()) { + ArticleList parsedResponse = + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ArticleList.class); + int newPageNumber = request.getPage().map(page -> page + 1).orElse(1); + ListArticlesRequest nextRequest = ListArticlesRequest.builder() + .from(request) + .page(newPageNumber) + .build(); + List result = parsedResponse.getData(); + return new SyncPagingIterable(true, result, () -> list(nextRequest, requestOptions)); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can create a new article by making a POST request to https://api.intercom.io/articles. + */ + public Article create(CreateArticleRequest request) { + return create(request, null); + } + + /** + * You can create a new article by making a POST request to https://api.intercom.io/articles. + */ + public Article create(CreateArticleRequest 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); + } 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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Article.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can fetch the details of a single article by making a GET request to https://api.intercom.io/articles/<id>. + */ + public Article find(FindArticleRequest request) { + return find(request, null); + } + + /** + * You can fetch the details of a single article by making a GET request to https://api.intercom.io/articles/<id>. + */ + public Article find(FindArticleRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("articles") + .addPathSegment(request.getArticleId()) + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Article.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can update the details of a single article by making a PUT request to https://api.intercom.io/articles/<id>. + */ + public Article update(UpdateArticleRequest request) { + return update(request, null); + } + + /** + * You can update the details of a single article by making a PUT request to https://api.intercom.io/articles/<id>. + */ + public Article update(UpdateArticleRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("articles") + .addPathSegment(request.getArticleId()) + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Article.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can delete a single article by making a DELETE request to https://api.intercom.io/articles/<id>. + */ + public DeletedArticleObject delete(DeleteArticleRequest request) { + return delete(request, null); + } + + /** + * You can delete a single article by making a DELETE request to https://api.intercom.io/articles/<id>. + */ + public DeletedArticleObject delete(DeleteArticleRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("articles") + .addPathSegment(request.getArticleId()) + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeletedArticleObject.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can search for articles by making a GET request to https://api.intercom.io/articles/search. + */ + public SearchArticlesResponse search() { + return search(SearchArticlesRequest.builder().build()); + } + + /** + * You can search for articles by making a GET request to https://api.intercom.io/articles/search. + */ + public SearchArticlesResponse 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 SearchArticlesResponse search(SearchArticlesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("articles/search"); + if (request.getPhrase().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "phrase", request.getPhrase().get(), false); + } + if (request.getState().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "state", request.getState().get(), false); + } + if (request.getHelpCenterId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "help_center_id", request.getHelpCenterId().get().toString(), false); + } + if (request.getHighlight().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "highlight", request.getHighlight().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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SearchArticlesResponse.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/articles/AsyncArticlesClient.java b/src/main/java/com/intercom/api/resources/articles/AsyncArticlesClient.java new file mode 100644 index 00000000..8e523dd6 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/articles/AsyncArticlesClient.java @@ -0,0 +1,533 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.articles; + +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.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.QueryStringMapper; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.core.pagination.SyncPagingIterable; +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; +import com.intercom.api.resources.articles.requests.SearchArticlesRequest; +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.types.ArticleList; +import com.intercom.api.types.DeletedArticleObject; +import com.intercom.api.types.Error; +import java.io.IOException; +import java.util.List; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; +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 AsyncArticlesClient { + protected final ClientOptions clientOptions; + + public AsyncArticlesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can fetch a list of all articles by making a GET request to https://api.intercom.io/articles. + *
+ *

📘 How are the articles sorted and ordered?

+ *

Articles will be returned in descending order on the updated_at attribute. This means if you need to iterate through results then we'll show the most recently updated articles first.

+ *
+ */ + public CompletableFuture> list() { + return list(ListArticlesRequest.builder().build()); + } + + /** + * You can fetch a list of all articles by making a GET request to https://api.intercom.io/articles. + *
+ *

📘 How are the articles sorted and ordered?

+ *

Articles will be returned in descending order on the updated_at attribute. This means if you need to iterate through results then we'll show the most recently updated articles first.

+ *
+ */ + public CompletableFuture> list(ListArticlesRequest request) { + return list(request, null); + } + + /** + * You can fetch a list of all articles by making a GET request to https://api.intercom.io/articles. + *
+ *

📘 How are the articles sorted and ordered?

+ *

Articles will be returned in descending order on the updated_at attribute. This means if you need to iterate through results then we'll show the most recently updated articles first.

+ *
+ */ + public CompletableFuture> list( + ListArticlesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("articles"); + 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()) { + ArticleList parsedResponse = + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ArticleList.class); + int newPageNumber = + request.getPage().map(page -> page + 1).orElse(1); + ListArticlesRequest nextRequest = ListArticlesRequest.builder() + .from(request) + .page(newPageNumber) + .build(); + List result = parsedResponse.getData(); + future.complete(new SyncPagingIterable(true, result, () -> { + try { + return list(nextRequest, requestOptions).get(); + } catch (InterruptedException | ExecutionException e) { + throw new RuntimeException(e); + } + })); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + 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))); + 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 article by making a POST request to https://api.intercom.io/articles. + */ + public CompletableFuture
create(CreateArticleRequest request) { + return create(request, null); + } + + /** + * You can create a new article by making a POST request to https://api.intercom.io/articles. + */ + public CompletableFuture
create(CreateArticleRequest 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); + } 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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Article.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + 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))); + 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 article by making a GET request to https://api.intercom.io/articles/<id>. + */ + public CompletableFuture
find(FindArticleRequest request) { + return find(request, null); + } + + /** + * You can fetch the details of a single article by making a GET request to https://api.intercom.io/articles/<id>. + */ + public CompletableFuture
find(FindArticleRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("articles") + .addPathSegment(request.getArticleId()) + .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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Article.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + 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))); + 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 article by making a PUT request to https://api.intercom.io/articles/<id>. + */ + public CompletableFuture
update(UpdateArticleRequest request) { + return update(request, null); + } + + /** + * You can update the details of a single article by making a PUT request to https://api.intercom.io/articles/<id>. + */ + public CompletableFuture
update(UpdateArticleRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("articles") + .addPathSegment(request.getArticleId()) + .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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Article.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + 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))); + 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 article by making a DELETE request to https://api.intercom.io/articles/<id>. + */ + public CompletableFuture delete(DeleteArticleRequest request) { + return delete(request, null); + } + + /** + * You can delete a single article by making a DELETE request to https://api.intercom.io/articles/<id>. + */ + public CompletableFuture delete(DeleteArticleRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("articles") + .addPathSegment(request.getArticleId()) + .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( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeletedArticleObject.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + 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))); + 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 articles by making a GET request to https://api.intercom.io/articles/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) { + return search(request, null); + } + + /** + * You can search for articles by making a GET request to https://api.intercom.io/articles/search. + */ + public CompletableFuture search( + SearchArticlesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("articles/search"); + if (request.getPhrase().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "phrase", request.getPhrase().get(), false); + } + if (request.getState().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "state", request.getState().get(), false); + } + if (request.getHelpCenterId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "help_center_id", request.getHelpCenterId().get().toString(), false); + } + if (request.getHighlight().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "highlight", request.getHighlight().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(ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), SearchArticlesResponse.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + 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))); + 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/articles/requests/CreateArticleRequest.java b/src/main/java/com/intercom/api/resources/articles/requests/CreateArticleRequest.java new file mode 100644 index 00000000..58b7d825 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/articles/requests/CreateArticleRequest.java @@ -0,0 +1,529 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.articles.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 com.intercom.api.types.ArticleTranslatedContent; +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 = CreateArticleRequest.Builder.class) +public final class CreateArticleRequest { + private final String title; + + private final Optional description; + + private final Optional body; + + private final int authorId; + + private final Optional state; + + private final Optional parentId; + + private final Optional parentType; + + private final Optional translatedContent; + + private final Map additionalProperties; + + private CreateArticleRequest( + String title, + Optional description, + Optional body, + int authorId, + Optional state, + Optional parentId, + Optional parentType, + Optional translatedContent, + Map additionalProperties) { + this.title = title; + this.description = description; + this.body = body; + this.authorId = authorId; + this.state = state; + this.parentId = parentId; + this.parentType = parentType; + this.translatedContent = translatedContent; + this.additionalProperties = additionalProperties; + } + + /** + * @return The title of the article.For multilingual articles, this will be the title of the default language's content. + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * @return The description of the article. For multilingual articles, this will be the description of the default language's content. + */ + @JsonProperty("description") + public Optional getDescription() { + return description; + } + + /** + * @return The content of the article. For multilingual articles, this will be the body of the default language's content. + */ + @JsonProperty("body") + public Optional getBody() { + return body; + } + + /** + * @return The id of the author of the article. For multilingual articles, this will be the id of the author of the default language's content. Must be a teammate on the help center's workspace. + */ + @JsonProperty("author_id") + public int getAuthorId() { + return authorId; + } + + /** + * @return Whether the article will be published or will be a draft. Defaults to draft. For multilingual articles, this will be the state of the default language's content. + */ + @JsonProperty("state") + public Optional getState() { + return state; + } + + /** + * @return The id of the article's parent collection or section. An article without this field stands alone. + */ + @JsonProperty("parent_id") + public Optional getParentId() { + return parentId; + } + + /** + * @return The type of parent, which can either be a collection or section. + */ + @JsonProperty("parent_type") + public Optional getParentType() { + return parentType; + } + + @JsonProperty("translated_content") + public Optional getTranslatedContent() { + return translatedContent; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreateArticleRequest && equalTo((CreateArticleRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreateArticleRequest other) { + return title.equals(other.title) + && description.equals(other.description) + && body.equals(other.body) + && authorId == other.authorId + && state.equals(other.state) + && parentId.equals(other.parentId) + && parentType.equals(other.parentType) + && translatedContent.equals(other.translatedContent); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.title, + this.description, + this.body, + this.authorId, + this.state, + this.parentId, + this.parentType, + this.translatedContent); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TitleStage builder() { + return new Builder(); + } + + public interface TitleStage { + AuthorIdStage title(@NotNull String title); + + Builder from(CreateArticleRequest other); + } + + public interface AuthorIdStage { + _FinalStage authorId(int authorId); + } + + public interface _FinalStage { + CreateArticleRequest build(); + + _FinalStage description(Optional description); + + _FinalStage description(String description); + + _FinalStage body(Optional body); + + _FinalStage body(String body); + + _FinalStage state(Optional state); + + _FinalStage state(State state); + + _FinalStage parentId(Optional parentId); + + _FinalStage parentId(Integer parentId); + + _FinalStage parentType(Optional parentType); + + _FinalStage parentType(ParentType parentType); + + _FinalStage translatedContent(Optional translatedContent); + + _FinalStage translatedContent(ArticleTranslatedContent translatedContent); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements TitleStage, AuthorIdStage, _FinalStage { + private String title; + + private int authorId; + + private Optional translatedContent = Optional.empty(); + + private Optional parentType = Optional.empty(); + + private Optional parentId = Optional.empty(); + + private Optional state = Optional.empty(); + + private Optional body = Optional.empty(); + + private Optional description = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CreateArticleRequest other) { + title(other.getTitle()); + description(other.getDescription()); + body(other.getBody()); + authorId(other.getAuthorId()); + state(other.getState()); + parentId(other.getParentId()); + parentType(other.getParentType()); + translatedContent(other.getTranslatedContent()); + return this; + } + + /** + *

The title of the article.For multilingual articles, this will be the title of the default language's content.

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

The id of the author of the article. For multilingual articles, this will be the id of the author of the default language's content. Must be a teammate on the help center's workspace.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("author_id") + public _FinalStage authorId(int authorId) { + this.authorId = authorId; + 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 type of parent, which can either be a collection or section.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage parentType(ParentType parentType) { + this.parentType = Optional.ofNullable(parentType); + return this; + } + + @java.lang.Override + @JsonSetter(value = "parent_type", nulls = Nulls.SKIP) + public _FinalStage parentType(Optional parentType) { + this.parentType = parentType; + return this; + } + + /** + *

The id of the article's parent collection or section. An article without this field stands alone.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage parentId(Integer parentId) { + this.parentId = Optional.ofNullable(parentId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "parent_id", nulls = Nulls.SKIP) + public _FinalStage parentId(Optional parentId) { + this.parentId = parentId; + return this; + } + + /** + *

Whether the article will be published or will be a draft. Defaults to draft. For multilingual articles, this will be the state of the default language's content.

+ * @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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "state", nulls = Nulls.SKIP) + public _FinalStage state(Optional state) { + this.state = state; + return this; + } + + /** + *

The content of the article. For multilingual articles, this will be the body of the default language's content.

+ * @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; + } + + @java.lang.Override + @JsonSetter(value = "body", nulls = Nulls.SKIP) + public _FinalStage body(Optional body) { + this.body = body; + return this; + } + + /** + *

The description of the article. For multilingual articles, this will be the description of the default language's content.

+ * @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; + } + + @java.lang.Override + @JsonSetter(value = "description", nulls = Nulls.SKIP) + public _FinalStage description(Optional description) { + this.description = description; + return this; + } + + @java.lang.Override + public CreateArticleRequest build() { + return new CreateArticleRequest( + title, + description, + body, + authorId, + state, + parentId, + parentType, + translatedContent, + additionalProperties); + } + } + + public final class State { + public static final State PUBLISHED = new State(Value.PUBLISHED, "published"); + + public static final State DRAFT = new State(Value.DRAFT, "draft"); + + 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 PUBLISHED: + return visitor.visitPublished(); + case DRAFT: + return visitor.visitDraft(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static State valueOf(String value) { + switch (value) { + case "published": + return PUBLISHED; + case "draft": + return DRAFT; + default: + return new State(Value.UNKNOWN, value); + } + } + + public enum Value { + PUBLISHED, + + DRAFT, + + UNKNOWN + } + + public interface Visitor { + T visitPublished(); + + T visitDraft(); + + T visitUnknown(String unknownType); + } + } + + public 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); + } + } +} 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 new file mode 100644 index 00000000..3c574dc1 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/articles/requests/DeleteArticleRequest.java @@ -0,0 +1,109 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.articles.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 = DeleteArticleRequest.Builder.class) +public final class DeleteArticleRequest { + private final String articleId; + + private final Map additionalProperties; + + private DeleteArticleRequest(String articleId, Map additionalProperties) { + this.articleId = articleId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the article which is given by Intercom. + */ + @JsonProperty("article_id") + public String getArticleId() { + return articleId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeleteArticleRequest && equalTo((DeleteArticleRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeleteArticleRequest other) { + return articleId.equals(other.articleId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.articleId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ArticleIdStage builder() { + return new Builder(); + } + + public interface ArticleIdStage { + _FinalStage articleId(@NotNull String articleId); + + Builder from(DeleteArticleRequest other); + } + + public interface _FinalStage { + DeleteArticleRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ArticleIdStage, _FinalStage { + private String articleId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DeleteArticleRequest other) { + articleId(other.getArticleId()); + return this; + } + + /** + *

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("article_id") + public _FinalStage articleId(@NotNull String articleId) { + this.articleId = Objects.requireNonNull(articleId, "articleId must not be null"); + return this; + } + + @java.lang.Override + public DeleteArticleRequest build() { + return new DeleteArticleRequest(articleId, additionalProperties); + } + } +} 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 new file mode 100644 index 00000000..6141b653 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/articles/requests/FindArticleRequest.java @@ -0,0 +1,109 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.articles.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 = FindArticleRequest.Builder.class) +public final class FindArticleRequest { + private final String articleId; + + private final Map additionalProperties; + + private FindArticleRequest(String articleId, Map additionalProperties) { + this.articleId = articleId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the article which is given by Intercom. + */ + @JsonProperty("article_id") + public String getArticleId() { + return articleId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof FindArticleRequest && equalTo((FindArticleRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(FindArticleRequest other) { + return articleId.equals(other.articleId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.articleId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ArticleIdStage builder() { + return new Builder(); + } + + public interface ArticleIdStage { + _FinalStage articleId(@NotNull String articleId); + + Builder from(FindArticleRequest other); + } + + public interface _FinalStage { + FindArticleRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ArticleIdStage, _FinalStage { + private String articleId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(FindArticleRequest other) { + articleId(other.getArticleId()); + return this; + } + + /** + *

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("article_id") + public _FinalStage articleId(@NotNull String articleId) { + this.articleId = Objects.requireNonNull(articleId, "articleId must not be null"); + return this; + } + + @java.lang.Override + public FindArticleRequest build() { + return new FindArticleRequest(articleId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/articles/requests/ListArticlesRequest.java b/src/main/java/com/intercom/api/resources/articles/requests/ListArticlesRequest.java new file mode 100644 index 00000000..26ab01ce --- /dev/null +++ b/src/main/java/com/intercom/api/resources/articles/requests/ListArticlesRequest.java @@ -0,0 +1,124 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.articles.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 = ListArticlesRequest.Builder.class) +public final class ListArticlesRequest { + private final Optional page; + + private final Optional perPage; + + private final Map additionalProperties; + + private ListArticlesRequest( + 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 15 + */ + @JsonProperty("per_page") + public Optional getPerPage() { + return perPage; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListArticlesRequest && equalTo((ListArticlesRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListArticlesRequest 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(ListArticlesRequest other) { + page(other.getPage()); + perPage(other.getPerPage()); + return this; + } + + @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; + } + + @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 ListArticlesRequest build() { + return new ListArticlesRequest(page, perPage, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/articles/requests/SearchArticlesRequest.java b/src/main/java/com/intercom/api/resources/articles/requests/SearchArticlesRequest.java new file mode 100644 index 00000000..bd651818 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/articles/requests/SearchArticlesRequest.java @@ -0,0 +1,181 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.articles.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 = SearchArticlesRequest.Builder.class) +public final class SearchArticlesRequest { + private final Optional phrase; + + private final Optional state; + + private final Optional helpCenterId; + + private final Optional highlight; + + private final Map additionalProperties; + + private SearchArticlesRequest( + Optional phrase, + Optional state, + Optional helpCenterId, + Optional highlight, + Map additionalProperties) { + this.phrase = phrase; + this.state = state; + this.helpCenterId = helpCenterId; + this.highlight = highlight; + this.additionalProperties = additionalProperties; + } + + /** + * @return The phrase within your articles to search for. + */ + @JsonProperty("phrase") + public Optional getPhrase() { + return phrase; + } + + /** + * @return The state of the Articles returned. One of published, draft or all. + */ + @JsonProperty("state") + public Optional getState() { + return state; + } + + /** + * @return The ID of the Help Center to search in. + */ + @JsonProperty("help_center_id") + public Optional getHelpCenterId() { + return helpCenterId; + } + + /** + * @return Return a highlighted version of the matching content within your articles. Refer to the response schema for more details. + */ + @JsonProperty("highlight") + public Optional getHighlight() { + return highlight; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof SearchArticlesRequest && equalTo((SearchArticlesRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(SearchArticlesRequest other) { + return phrase.equals(other.phrase) + && state.equals(other.state) + && helpCenterId.equals(other.helpCenterId) + && highlight.equals(other.highlight); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.phrase, this.state, this.helpCenterId, this.highlight); + } + + @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 phrase = Optional.empty(); + + private Optional state = Optional.empty(); + + private Optional helpCenterId = Optional.empty(); + + private Optional highlight = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(SearchArticlesRequest other) { + phrase(other.getPhrase()); + state(other.getState()); + helpCenterId(other.getHelpCenterId()); + highlight(other.getHighlight()); + return this; + } + + @JsonSetter(value = "phrase", nulls = Nulls.SKIP) + public Builder phrase(Optional phrase) { + this.phrase = phrase; + return this; + } + + public Builder phrase(String phrase) { + this.phrase = Optional.ofNullable(phrase); + return this; + } + + @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 = "help_center_id", nulls = Nulls.SKIP) + public Builder helpCenterId(Optional helpCenterId) { + this.helpCenterId = helpCenterId; + return this; + } + + public Builder helpCenterId(Integer helpCenterId) { + this.helpCenterId = Optional.ofNullable(helpCenterId); + return this; + } + + @JsonSetter(value = "highlight", nulls = Nulls.SKIP) + public Builder highlight(Optional highlight) { + this.highlight = highlight; + return this; + } + + public Builder highlight(Boolean highlight) { + this.highlight = Optional.ofNullable(highlight); + return this; + } + + public SearchArticlesRequest build() { + return new SearchArticlesRequest(phrase, state, helpCenterId, highlight, additionalProperties); + } + } +} 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 new file mode 100644 index 00000000..cc2c3fa2 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/articles/requests/UpdateArticleRequest.java @@ -0,0 +1,574 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.articles.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 com.intercom.api.types.ArticleTranslatedContent; +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 = UpdateArticleRequest.Builder.class) +public final class UpdateArticleRequest { + private final String articleId; + + private final Optional title; + + private final Optional description; + + private final Optional body; + + private final Optional authorId; + + private final Optional state; + + private final Optional parentId; + + private final Optional parentType; + + private final Optional translatedContent; + + private final Map additionalProperties; + + private UpdateArticleRequest( + String articleId, + Optional title, + Optional description, + Optional body, + Optional authorId, + Optional state, + Optional parentId, + Optional parentType, + Optional translatedContent, + Map additionalProperties) { + this.articleId = articleId; + this.title = title; + this.description = description; + this.body = body; + this.authorId = authorId; + this.state = state; + this.parentId = parentId; + this.parentType = parentType; + this.translatedContent = translatedContent; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the article which is given by Intercom. + */ + @JsonProperty("article_id") + public String getArticleId() { + return articleId; + } + + /** + * @return The title of the article.For multilingual articles, this will be the title of the default language's content. + */ + @JsonProperty("title") + public Optional getTitle() { + return title; + } + + /** + * @return The description of the article. For multilingual articles, this will be the description of the default language's content. + */ + @JsonProperty("description") + public Optional getDescription() { + return description; + } + + /** + * @return The content of the article. For multilingual articles, this will be the body of the default language's content. + */ + @JsonProperty("body") + public Optional getBody() { + return body; + } + + /** + * @return The id of the author of the article. For multilingual articles, this will be the id of the author of the default language's content. Must be a teammate on the help center's workspace. + */ + @JsonProperty("author_id") + public Optional getAuthorId() { + return authorId; + } + + /** + * @return Whether the article will be published or will be a draft. Defaults to draft. For multilingual articles, this will be the state of the default language's content. + */ + @JsonProperty("state") + public Optional getState() { + return state; + } + + /** + * @return The id of the article's parent collection or section. An article without this field stands alone. + */ + @JsonProperty("parent_id") + public Optional getParentId() { + return parentId; + } + + /** + * @return The type of parent, which can either be a collection or section. + */ + @JsonProperty("parent_type") + public Optional getParentType() { + return parentType; + } + + @JsonProperty("translated_content") + public Optional getTranslatedContent() { + return translatedContent; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UpdateArticleRequest && equalTo((UpdateArticleRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UpdateArticleRequest other) { + return articleId.equals(other.articleId) + && title.equals(other.title) + && description.equals(other.description) + && body.equals(other.body) + && authorId.equals(other.authorId) + && state.equals(other.state) + && parentId.equals(other.parentId) + && parentType.equals(other.parentType) + && translatedContent.equals(other.translatedContent); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.articleId, + this.title, + this.description, + this.body, + this.authorId, + this.state, + this.parentId, + this.parentType, + this.translatedContent); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ArticleIdStage builder() { + return new Builder(); + } + + public interface ArticleIdStage { + _FinalStage articleId(@NotNull String articleId); + + Builder from(UpdateArticleRequest other); + } + + public interface _FinalStage { + UpdateArticleRequest build(); + + _FinalStage title(Optional title); + + _FinalStage title(String title); + + _FinalStage description(Optional description); + + _FinalStage description(String description); + + _FinalStage body(Optional body); + + _FinalStage body(String body); + + _FinalStage authorId(Optional authorId); + + _FinalStage authorId(Integer authorId); + + _FinalStage state(Optional state); + + _FinalStage state(State state); + + _FinalStage parentId(Optional parentId); + + _FinalStage parentId(String parentId); + + _FinalStage parentType(Optional parentType); + + _FinalStage parentType(ParentType parentType); + + _FinalStage translatedContent(Optional translatedContent); + + _FinalStage translatedContent(ArticleTranslatedContent translatedContent); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ArticleIdStage, _FinalStage { + private String articleId; + + private Optional translatedContent = Optional.empty(); + + private Optional parentType = Optional.empty(); + + private Optional parentId = Optional.empty(); + + private Optional state = Optional.empty(); + + private Optional authorId = Optional.empty(); + + private Optional body = Optional.empty(); + + private Optional description = Optional.empty(); + + private Optional title = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(UpdateArticleRequest other) { + articleId(other.getArticleId()); + title(other.getTitle()); + description(other.getDescription()); + body(other.getBody()); + authorId(other.getAuthorId()); + state(other.getState()); + parentId(other.getParentId()); + parentType(other.getParentType()); + translatedContent(other.getTranslatedContent()); + return this; + } + + /** + *

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("article_id") + public _FinalStage articleId(@NotNull String articleId) { + this.articleId = Objects.requireNonNull(articleId, "articleId must not be null"); + 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 type of parent, which can either be a collection or section.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage parentType(ParentType parentType) { + this.parentType = Optional.ofNullable(parentType); + return this; + } + + @java.lang.Override + @JsonSetter(value = "parent_type", nulls = Nulls.SKIP) + public _FinalStage parentType(Optional parentType) { + this.parentType = parentType; + return this; + } + + /** + *

The id of the article's parent collection or section. An article without this field stands alone.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage parentId(String parentId) { + this.parentId = Optional.ofNullable(parentId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "parent_id", nulls = Nulls.SKIP) + public _FinalStage parentId(Optional parentId) { + this.parentId = parentId; + return this; + } + + /** + *

Whether the article will be published or will be a draft. Defaults to draft. For multilingual articles, this will be the state of the default language's content.

+ * @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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "state", nulls = Nulls.SKIP) + public _FinalStage state(Optional state) { + this.state = state; + return this; + } + + /** + *

The id of the author of the article. For multilingual articles, this will be the id of the author of the default language's content. Must be a teammate on the help center's workspace.

+ * @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; + } + + @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. For multilingual articles, this will be the body of the default language's content.

+ * @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; + } + + @java.lang.Override + @JsonSetter(value = "body", nulls = Nulls.SKIP) + public _FinalStage body(Optional body) { + this.body = body; + return this; + } + + /** + *

The description of the article. For multilingual articles, this will be the description of the default language's content.

+ * @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; + } + + @java.lang.Override + @JsonSetter(value = "description", nulls = Nulls.SKIP) + public _FinalStage description(Optional description) { + this.description = description; + return this; + } + + /** + *

The title of the article.For multilingual articles, this will be the title of the default language's content.

+ * @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; + } + + @java.lang.Override + @JsonSetter(value = "title", nulls = Nulls.SKIP) + public _FinalStage title(Optional title) { + this.title = title; + return this; + } + + @java.lang.Override + public UpdateArticleRequest build() { + return new UpdateArticleRequest( + articleId, + title, + description, + body, + authorId, + state, + parentId, + parentType, + translatedContent, + additionalProperties); + } + } + + public 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 final class State { + public static final State PUBLISHED = new State(Value.PUBLISHED, "published"); + + public static final State DRAFT = new State(Value.DRAFT, "draft"); + + 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 PUBLISHED: + return visitor.visitPublished(); + case DRAFT: + return visitor.visitDraft(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static State valueOf(String value) { + switch (value) { + case "published": + return PUBLISHED; + case "draft": + return DRAFT; + default: + return new State(Value.UNKNOWN, value); + } + } + + public enum Value { + PUBLISHED, + + DRAFT, + + UNKNOWN + } + + public interface Visitor { + T visitPublished(); + + T visitDraft(); + + T visitUnknown(String unknownType); + } + } +} 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 new file mode 100644 index 00000000..68633299 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/articles/types/Article.java @@ -0,0 +1,768 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.articles.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 com.intercom.api.types.ArticleStatistics; +import com.intercom.api.types.ArticleTranslatedContent; +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 = Article.Builder.class) +public final class Article implements IArticleListItem { + private final Optional type; + + private final String id; + + private final String workspaceId; + + private final String title; + + private final Optional description; + + private final Optional body; + + private final int authorId; + + private final State state; + + private final int createdAt; + + private final int updatedAt; + + private final Optional url; + + private final Optional parentId; + + private final Optional> parentIds; + + private final Optional parentType; + + private final String defaultLocale; + + private final ArticleTranslatedContent translatedContent; + + private final Optional statistics; + + private final Map additionalProperties; + + private Article( + Optional type, + String id, + String workspaceId, + String title, + Optional description, + Optional body, + int authorId, + State state, + int createdAt, + int updatedAt, + Optional url, + Optional parentId, + Optional> parentIds, + Optional parentType, + String defaultLocale, + ArticleTranslatedContent translatedContent, + Optional statistics, + Map additionalProperties) { + this.type = type; + this.id = id; + this.workspaceId = workspaceId; + this.title = title; + this.description = description; + this.body = body; + this.authorId = authorId; + this.state = state; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.url = url; + this.parentId = parentId; + this.parentIds = parentIds; + this.parentType = parentType; + this.defaultLocale = defaultLocale; + this.translatedContent = translatedContent; + this.statistics = statistics; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of object - article. + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return The unique identifier for the article which is given by Intercom. + */ + @JsonProperty("id") + public String getId() { + return id; + } + + /** + * @return The id of the workspace which the article belongs to. + */ + @JsonProperty("workspace_id") + public String getWorkspaceId() { + return workspaceId; + } + + /** + * @return The title of the article. For multilingual articles, this will be the title of the default language's content. + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * @return The description of the article. For multilingual articles, this will be the description of the default language's content. + */ + @JsonProperty("description") + public Optional getDescription() { + return description; + } + + /** + * @return The body of the article in HTML. For multilingual articles, this will be the body of the default language's content. + */ + @JsonProperty("body") + public Optional getBody() { + return body; + } + + /** + * @return The id of the author of the article. For multilingual articles, this will be the id of the author of the default language's content. Must be a teammate on the help center's workspace. + */ + @JsonProperty("author_id") + public int getAuthorId() { + return authorId; + } + + /** + * @return Whether the article is published or is a draft. For multilingual articles, this will be the state of the default language's content. + */ + @JsonProperty("state") + public State getState() { + return state; + } + + /** + * @return The time when the article was created. For multilingual articles, this will be the timestamp of creation of the default language's content in seconds. + */ + @JsonProperty("created_at") + public int getCreatedAt() { + return createdAt; + } + + /** + * @return 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. + */ + @JsonProperty("updated_at") + public int getUpdatedAt() { + return updatedAt; + } + + /** + * @return The URL of the article. For multilingual articles, this will be the URL of the default language's content. + */ + @JsonProperty("url") + public Optional getUrl() { + return url; + } + + /** + * @return The id of the article's parent collection or section. An article without this field stands alone. + */ + @JsonProperty("parent_id") + public Optional getParentId() { + return parentId; + } + + /** + * @return The ids of the article's parent collections or sections. An article without this field stands alone. + */ + @JsonProperty("parent_ids") + public Optional> getParentIds() { + return parentIds; + } + + /** + * @return The type of parent, which can either be a collection or section. + */ + @JsonProperty("parent_type") + public Optional getParentType() { + return parentType; + } + + /** + * @return The default locale of the help center. This field is only returned for multilingual help centers. + */ + @JsonProperty("default_locale") + public String getDefaultLocale() { + return defaultLocale; + } + + @JsonProperty("translated_content") + public ArticleTranslatedContent getTranslatedContent() { + return translatedContent; + } + + @JsonProperty("statistics") + public Optional getStatistics() { + return statistics; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Article && equalTo((Article) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Article other) { + return type.equals(other.type) + && id.equals(other.id) + && workspaceId.equals(other.workspaceId) + && title.equals(other.title) + && description.equals(other.description) + && body.equals(other.body) + && authorId == other.authorId + && state.equals(other.state) + && createdAt == other.createdAt + && updatedAt == other.updatedAt + && url.equals(other.url) + && parentId.equals(other.parentId) + && parentIds.equals(other.parentIds) + && parentType.equals(other.parentType) + && defaultLocale.equals(other.defaultLocale) + && translatedContent.equals(other.translatedContent) + && statistics.equals(other.statistics); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.type, + this.id, + this.workspaceId, + this.title, + this.description, + this.body, + this.authorId, + this.state, + this.createdAt, + this.updatedAt, + this.url, + this.parentId, + this.parentIds, + this.parentType, + this.defaultLocale, + this.translatedContent, + this.statistics); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + WorkspaceIdStage id(@NotNull String id); + + Builder from(Article other); + } + + public interface WorkspaceIdStage { + TitleStage workspaceId(@NotNull String workspaceId); + } + + public interface TitleStage { + AuthorIdStage title(@NotNull String title); + } + + public interface AuthorIdStage { + StateStage authorId(int authorId); + } + + public interface StateStage { + CreatedAtStage state(@NotNull State state); + } + + public interface CreatedAtStage { + UpdatedAtStage createdAt(int createdAt); + } + + public interface UpdatedAtStage { + DefaultLocaleStage updatedAt(int updatedAt); + } + + public interface DefaultLocaleStage { + TranslatedContentStage defaultLocale(@NotNull String defaultLocale); + } + + public interface TranslatedContentStage { + _FinalStage translatedContent(@NotNull ArticleTranslatedContent translatedContent); + } + + public interface _FinalStage { + Article build(); + + _FinalStage type(Optional type); + + _FinalStage type(String type); + + _FinalStage description(Optional description); + + _FinalStage description(String description); + + _FinalStage body(Optional body); + + _FinalStage body(String body); + + _FinalStage url(Optional url); + + _FinalStage url(String url); + + _FinalStage parentId(Optional parentId); + + _FinalStage parentId(Integer parentId); + + _FinalStage parentIds(Optional> parentIds); + + _FinalStage parentIds(List parentIds); + + _FinalStage parentType(Optional parentType); + + _FinalStage parentType(String parentType); + + _FinalStage statistics(Optional statistics); + + _FinalStage statistics(ArticleStatistics statistics); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements IdStage, + WorkspaceIdStage, + TitleStage, + AuthorIdStage, + StateStage, + CreatedAtStage, + UpdatedAtStage, + DefaultLocaleStage, + TranslatedContentStage, + _FinalStage { + private String id; + + private String workspaceId; + + private String title; + + private int authorId; + + private State state; + + private int createdAt; + + private int updatedAt; + + private String defaultLocale; + + private ArticleTranslatedContent translatedContent; + + private Optional statistics = Optional.empty(); + + private Optional parentType = Optional.empty(); + + private Optional> parentIds = Optional.empty(); + + private Optional parentId = Optional.empty(); + + private Optional url = Optional.empty(); + + private Optional body = Optional.empty(); + + private Optional description = Optional.empty(); + + private Optional type = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(Article other) { + type(other.getType()); + id(other.getId()); + workspaceId(other.getWorkspaceId()); + title(other.getTitle()); + description(other.getDescription()); + body(other.getBody()); + authorId(other.getAuthorId()); + state(other.getState()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + url(other.getUrl()); + parentId(other.getParentId()); + parentIds(other.getParentIds()); + parentType(other.getParentType()); + defaultLocale(other.getDefaultLocale()); + translatedContent(other.getTranslatedContent()); + statistics(other.getStatistics()); + return this; + } + + /** + *

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("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 article belongs to.

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

The title of the article. For multilingual articles, this will be the title of the default language's content.

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

The id of the author of the article. For multilingual articles, this will be the id of the author of the default language's content. Must be a teammate on the help center's workspace.

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

Whether the article is published or is a draft. For multilingual articles, this will be the state of the default language's content.

+ * @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"); + return this; + } + + /** + *

The time when the article was created. For multilingual articles, this will be the timestamp of creation of the default language's content in seconds.

+ * @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 article was last updated. For multilingual articles, this will be the timestamp of last update of the default language's content in seconds.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("updated_at") + public DefaultLocaleStage updatedAt(int updatedAt) { + this.updatedAt = updatedAt; + 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 + @JsonSetter("default_locale") + public TranslatedContentStage defaultLocale(@NotNull String defaultLocale) { + this.defaultLocale = Objects.requireNonNull(defaultLocale, "defaultLocale must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("translated_content") + public _FinalStage translatedContent(@NotNull ArticleTranslatedContent translatedContent) { + this.translatedContent = Objects.requireNonNull(translatedContent, "translatedContent must not be null"); + return this; + } + + @java.lang.Override + 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; + } + + /** + *

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

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage parentType(String parentType) { + this.parentType = Optional.ofNullable(parentType); + return this; + } + + @java.lang.Override + @JsonSetter(value = "parent_type", nulls = Nulls.SKIP) + public _FinalStage parentType(Optional parentType) { + this.parentType = parentType; + return this; + } + + /** + *

The ids of the article's parent collections or sections. An article without this field stands alone.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage parentIds(List parentIds) { + this.parentIds = Optional.ofNullable(parentIds); + return this; + } + + @java.lang.Override + @JsonSetter(value = "parent_ids", nulls = Nulls.SKIP) + public _FinalStage parentIds(Optional> parentIds) { + this.parentIds = parentIds; + return this; + } + + /** + *

The id of the article's parent collection or section. An article without this field stands alone.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage parentId(Integer parentId) { + this.parentId = Optional.ofNullable(parentId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "parent_id", nulls = Nulls.SKIP) + public _FinalStage parentId(Optional parentId) { + this.parentId = parentId; + return this; + } + + /** + *

The URL of the article. For multilingual articles, this will be the URL of the default language's content.

+ * @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; + } + + @java.lang.Override + @JsonSetter(value = "url", nulls = Nulls.SKIP) + public _FinalStage url(Optional url) { + this.url = url; + return this; + } + + /** + *

The body of the article in HTML. For multilingual articles, this will be the body of the default language's content.

+ * @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; + } + + @java.lang.Override + @JsonSetter(value = "body", nulls = Nulls.SKIP) + public _FinalStage body(Optional body) { + this.body = body; + return this; + } + + /** + *

The description of the article. For multilingual articles, this will be the description of the default language's content.

+ * @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; + } + + @java.lang.Override + @JsonSetter(value = "description", nulls = Nulls.SKIP) + public _FinalStage description(Optional description) { + this.description = description; + return this; + } + + /** + *

The type of object - article.

+ * @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; + } + + @java.lang.Override + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public _FinalStage type(Optional type) { + this.type = type; + return this; + } + + @java.lang.Override + public Article build() { + return new Article( + type, + id, + workspaceId, + title, + description, + body, + authorId, + state, + createdAt, + updatedAt, + url, + parentId, + parentIds, + parentType, + defaultLocale, + translatedContent, + statistics, + additionalProperties); + } + } + + public final class State { + public static final State PUBLISHED = new State(Value.PUBLISHED, "published"); + + public static final State DRAFT = new State(Value.DRAFT, "draft"); + + 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 PUBLISHED: + return visitor.visitPublished(); + case DRAFT: + return visitor.visitDraft(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static State valueOf(String value) { + switch (value) { + case "published": + return PUBLISHED; + case "draft": + return DRAFT; + default: + return new State(Value.UNKNOWN, value); + } + } + + public enum Value { + PUBLISHED, + + DRAFT, + + UNKNOWN + } + + public interface Visitor { + T visitPublished(); + + T visitDraft(); + + T visitUnknown(String unknownType); + } + } +} 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 new file mode 100644 index 00000000..aec70195 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/articles/types/ArticleListItem.java @@ -0,0 +1,735 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.articles.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 com.intercom.api.types.ArticleTranslatedContent; +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 = ArticleListItem.Builder.class) +public final class ArticleListItem implements IArticleListItem { + private final Optional type; + + private final String id; + + private final String workspaceId; + + private final String title; + + private final Optional description; + + private final Optional body; + + private final int authorId; + + private final State state; + + private final int createdAt; + + private final int updatedAt; + + private final Optional url; + + private final Optional parentId; + + private final Optional> parentIds; + + private final Optional parentType; + + private final String defaultLocale; + + private final ArticleTranslatedContent translatedContent; + + private final Map additionalProperties; + + private ArticleListItem( + Optional type, + String id, + String workspaceId, + String title, + Optional description, + Optional body, + int authorId, + State state, + int createdAt, + int updatedAt, + Optional url, + Optional parentId, + Optional> parentIds, + Optional parentType, + String defaultLocale, + ArticleTranslatedContent translatedContent, + Map additionalProperties) { + this.type = type; + this.id = id; + this.workspaceId = workspaceId; + this.title = title; + this.description = description; + this.body = body; + this.authorId = authorId; + this.state = state; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.url = url; + this.parentId = parentId; + this.parentIds = parentIds; + this.parentType = parentType; + this.defaultLocale = defaultLocale; + this.translatedContent = translatedContent; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of object - article. + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return The unique identifier for the article which is given by Intercom. + */ + @JsonProperty("id") + public String getId() { + return id; + } + + /** + * @return The id of the workspace which the article belongs to. + */ + @JsonProperty("workspace_id") + public String getWorkspaceId() { + return workspaceId; + } + + /** + * @return The title of the article. For multilingual articles, this will be the title of the default language's content. + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * @return The description of the article. For multilingual articles, this will be the description of the default language's content. + */ + @JsonProperty("description") + public Optional getDescription() { + return description; + } + + /** + * @return The body of the article in HTML. For multilingual articles, this will be the body of the default language's content. + */ + @JsonProperty("body") + public Optional getBody() { + return body; + } + + /** + * @return The id of the author of the article. For multilingual articles, this will be the id of the author of the default language's content. Must be a teammate on the help center's workspace. + */ + @JsonProperty("author_id") + public int getAuthorId() { + return authorId; + } + + /** + * @return Whether the article is published or is a draft. For multilingual articles, this will be the state of the default language's content. + */ + @JsonProperty("state") + public State getState() { + return state; + } + + /** + * @return The time when the article was created. For multilingual articles, this will be the timestamp of creation of the default language's content in seconds. + */ + @JsonProperty("created_at") + public int getCreatedAt() { + return createdAt; + } + + /** + * @return 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. + */ + @JsonProperty("updated_at") + public int getUpdatedAt() { + return updatedAt; + } + + /** + * @return The URL of the article. For multilingual articles, this will be the URL of the default language's content. + */ + @JsonProperty("url") + public Optional getUrl() { + return url; + } + + /** + * @return The id of the article's parent collection or section. An article without this field stands alone. + */ + @JsonProperty("parent_id") + public Optional getParentId() { + return parentId; + } + + /** + * @return The ids of the article's parent collections or sections. An article without this field stands alone. + */ + @JsonProperty("parent_ids") + public Optional> getParentIds() { + return parentIds; + } + + /** + * @return The type of parent, which can either be a collection or section. + */ + @JsonProperty("parent_type") + public Optional getParentType() { + return parentType; + } + + /** + * @return The default locale of the help center. This field is only returned for multilingual help centers. + */ + @JsonProperty("default_locale") + public String getDefaultLocale() { + return defaultLocale; + } + + @JsonProperty("translated_content") + public ArticleTranslatedContent getTranslatedContent() { + return translatedContent; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ArticleListItem && equalTo((ArticleListItem) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ArticleListItem other) { + return type.equals(other.type) + && id.equals(other.id) + && workspaceId.equals(other.workspaceId) + && title.equals(other.title) + && description.equals(other.description) + && body.equals(other.body) + && authorId == other.authorId + && state.equals(other.state) + && createdAt == other.createdAt + && updatedAt == other.updatedAt + && url.equals(other.url) + && parentId.equals(other.parentId) + && parentIds.equals(other.parentIds) + && parentType.equals(other.parentType) + && defaultLocale.equals(other.defaultLocale) + && translatedContent.equals(other.translatedContent); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.type, + this.id, + this.workspaceId, + this.title, + this.description, + this.body, + this.authorId, + this.state, + this.createdAt, + this.updatedAt, + this.url, + this.parentId, + this.parentIds, + this.parentType, + this.defaultLocale, + this.translatedContent); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + WorkspaceIdStage id(@NotNull String id); + + Builder from(ArticleListItem other); + } + + public interface WorkspaceIdStage { + TitleStage workspaceId(@NotNull String workspaceId); + } + + public interface TitleStage { + AuthorIdStage title(@NotNull String title); + } + + public interface AuthorIdStage { + StateStage authorId(int authorId); + } + + public interface StateStage { + CreatedAtStage state(@NotNull State state); + } + + public interface CreatedAtStage { + UpdatedAtStage createdAt(int createdAt); + } + + public interface UpdatedAtStage { + DefaultLocaleStage updatedAt(int updatedAt); + } + + public interface DefaultLocaleStage { + TranslatedContentStage defaultLocale(@NotNull String defaultLocale); + } + + public interface TranslatedContentStage { + _FinalStage translatedContent(@NotNull ArticleTranslatedContent translatedContent); + } + + public interface _FinalStage { + ArticleListItem build(); + + _FinalStage type(Optional type); + + _FinalStage type(String type); + + _FinalStage description(Optional description); + + _FinalStage description(String description); + + _FinalStage body(Optional body); + + _FinalStage body(String body); + + _FinalStage url(Optional url); + + _FinalStage url(String url); + + _FinalStage parentId(Optional parentId); + + _FinalStage parentId(Integer parentId); + + _FinalStage parentIds(Optional> parentIds); + + _FinalStage parentIds(List parentIds); + + _FinalStage parentType(Optional parentType); + + _FinalStage parentType(String parentType); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements IdStage, + WorkspaceIdStage, + TitleStage, + AuthorIdStage, + StateStage, + CreatedAtStage, + UpdatedAtStage, + DefaultLocaleStage, + TranslatedContentStage, + _FinalStage { + private String id; + + private String workspaceId; + + private String title; + + private int authorId; + + private State state; + + private int createdAt; + + private int updatedAt; + + private String defaultLocale; + + private ArticleTranslatedContent translatedContent; + + private Optional parentType = Optional.empty(); + + private Optional> parentIds = Optional.empty(); + + private Optional parentId = Optional.empty(); + + private Optional url = Optional.empty(); + + private Optional body = Optional.empty(); + + private Optional description = Optional.empty(); + + private Optional type = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ArticleListItem other) { + type(other.getType()); + id(other.getId()); + workspaceId(other.getWorkspaceId()); + title(other.getTitle()); + description(other.getDescription()); + body(other.getBody()); + authorId(other.getAuthorId()); + state(other.getState()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + url(other.getUrl()); + parentId(other.getParentId()); + parentIds(other.getParentIds()); + parentType(other.getParentType()); + defaultLocale(other.getDefaultLocale()); + translatedContent(other.getTranslatedContent()); + return this; + } + + /** + *

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("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 article belongs to.

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

The title of the article. For multilingual articles, this will be the title of the default language's content.

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

The id of the author of the article. For multilingual articles, this will be the id of the author of the default language's content. Must be a teammate on the help center's workspace.

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

Whether the article is published or is a draft. For multilingual articles, this will be the state of the default language's content.

+ * @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"); + return this; + } + + /** + *

The time when the article was created. For multilingual articles, this will be the timestamp of creation of the default language's content in seconds.

+ * @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 article was last updated. For multilingual articles, this will be the timestamp of last update of the default language's content in seconds.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("updated_at") + public DefaultLocaleStage updatedAt(int updatedAt) { + this.updatedAt = updatedAt; + 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 + @JsonSetter("default_locale") + public TranslatedContentStage defaultLocale(@NotNull String defaultLocale) { + this.defaultLocale = Objects.requireNonNull(defaultLocale, "defaultLocale must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("translated_content") + public _FinalStage translatedContent(@NotNull ArticleTranslatedContent translatedContent) { + this.translatedContent = Objects.requireNonNull(translatedContent, "translatedContent must not be null"); + return this; + } + + /** + *

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

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage parentType(String parentType) { + this.parentType = Optional.ofNullable(parentType); + return this; + } + + @java.lang.Override + @JsonSetter(value = "parent_type", nulls = Nulls.SKIP) + public _FinalStage parentType(Optional parentType) { + this.parentType = parentType; + return this; + } + + /** + *

The ids of the article's parent collections or sections. An article without this field stands alone.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage parentIds(List parentIds) { + this.parentIds = Optional.ofNullable(parentIds); + return this; + } + + @java.lang.Override + @JsonSetter(value = "parent_ids", nulls = Nulls.SKIP) + public _FinalStage parentIds(Optional> parentIds) { + this.parentIds = parentIds; + return this; + } + + /** + *

The id of the article's parent collection or section. An article without this field stands alone.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage parentId(Integer parentId) { + this.parentId = Optional.ofNullable(parentId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "parent_id", nulls = Nulls.SKIP) + public _FinalStage parentId(Optional parentId) { + this.parentId = parentId; + return this; + } + + /** + *

The URL of the article. For multilingual articles, this will be the URL of the default language's content.

+ * @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; + } + + @java.lang.Override + @JsonSetter(value = "url", nulls = Nulls.SKIP) + public _FinalStage url(Optional url) { + this.url = url; + return this; + } + + /** + *

The body of the article in HTML. For multilingual articles, this will be the body of the default language's content.

+ * @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; + } + + @java.lang.Override + @JsonSetter(value = "body", nulls = Nulls.SKIP) + public _FinalStage body(Optional body) { + this.body = body; + return this; + } + + /** + *

The description of the article. For multilingual articles, this will be the description of the default language's content.

+ * @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; + } + + @java.lang.Override + @JsonSetter(value = "description", nulls = Nulls.SKIP) + public _FinalStage description(Optional description) { + this.description = description; + return this; + } + + /** + *

The type of object - article.

+ * @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; + } + + @java.lang.Override + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public _FinalStage type(Optional type) { + this.type = type; + return this; + } + + @java.lang.Override + public ArticleListItem build() { + return new ArticleListItem( + type, + id, + workspaceId, + title, + description, + body, + authorId, + state, + createdAt, + updatedAt, + url, + parentId, + parentIds, + parentType, + defaultLocale, + translatedContent, + additionalProperties); + } + } + + public final class State { + public static final State PUBLISHED = new State(Value.PUBLISHED, "published"); + + public static final State DRAFT = new State(Value.DRAFT, "draft"); + + 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 PUBLISHED: + return visitor.visitPublished(); + case DRAFT: + return visitor.visitDraft(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static State valueOf(String value) { + switch (value) { + case "published": + return PUBLISHED; + case "draft": + return DRAFT; + default: + return new State(Value.UNKNOWN, value); + } + } + + public enum Value { + PUBLISHED, + + DRAFT, + + UNKNOWN + } + + public interface Visitor { + T visitPublished(); + + T visitDraft(); + + T visitUnknown(String unknownType); + } + } +} 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 new file mode 100644 index 00000000..33bc392d --- /dev/null +++ b/src/main/java/com/intercom/api/resources/articles/types/ArticleSearchHighlights.java @@ -0,0 +1,579 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.articles.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.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 List highlightedTitle; + + private final List> highlightedSummary; + + private final Map additionalProperties; + + private ArticleSearchHighlights( + String articleId, + List highlightedTitle, + List> highlightedSummary, + Map additionalProperties) { + this.articleId = articleId; + this.highlightedTitle = highlightedTitle; + this.highlightedSummary = highlightedSummary; + this.additionalProperties = additionalProperties; + } + + /** + * @return The ID of the corresponding article. + */ + @JsonProperty("article_id") + public String getArticleId() { + return articleId; + } + + /** + * @return An Article title highlighted. + */ + @JsonProperty("highlighted_title") + public List getHighlightedTitle() { + return highlightedTitle; + } + + /** + * @return An Article description and body text highlighted. + */ + @JsonProperty("highlighted_summary") + public List> getHighlightedSummary() { + return highlightedSummary; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ArticleSearchHighlights && equalTo((ArticleSearchHighlights) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ArticleSearchHighlights other) { + return articleId.equals(other.articleId) + && highlightedTitle.equals(other.highlightedTitle) + && highlightedSummary.equals(other.highlightedSummary); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.articleId, this.highlightedTitle, this.highlightedSummary); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ArticleIdStage builder() { + return new Builder(); + } + + public interface ArticleIdStage { + _FinalStage articleId(@NotNull String articleId); + + Builder from(ArticleSearchHighlights other); + } + + public interface _FinalStage { + ArticleSearchHighlights build(); + + _FinalStage highlightedTitle(List highlightedTitle); + + _FinalStage addHighlightedTitle(HighlightedTitleItem highlightedTitle); + + _FinalStage addAllHighlightedTitle(List highlightedTitle); + + _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; + + private List> highlightedSummary = new ArrayList<>(); + + private List highlightedTitle = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ArticleSearchHighlights other) { + articleId(other.getArticleId()); + highlightedTitle(other.getHighlightedTitle()); + highlightedSummary(other.getHighlightedSummary()); + return this; + } + + /** + *

The ID of the corresponding article.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("article_id") + public _FinalStage articleId(@NotNull String articleId) { + this.articleId = Objects.requireNonNull(articleId, "articleId must not be null"); + 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); + 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 addHighlightedSummary(List highlightedSummary) { + this.highlightedSummary.add(highlightedSummary); + return this; + } + + @java.lang.Override + @JsonSetter(value = "highlighted_summary", nulls = Nulls.SKIP) + public _FinalStage highlightedSummary(List> highlightedSummary) { + this.highlightedSummary.clear(); + this.highlightedSummary.addAll(highlightedSummary); + 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. + */ + @java.lang.Override + public _FinalStage addHighlightedTitle(HighlightedTitleItem highlightedTitle) { + this.highlightedTitle.add(highlightedTitle); + return this; + } + + @java.lang.Override + @JsonSetter(value = "highlighted_title", nulls = Nulls.SKIP) + public _FinalStage highlightedTitle(List highlightedTitle) { + this.highlightedTitle.clear(); + this.highlightedTitle.addAll(highlightedTitle); + return this; + } + + @java.lang.Override + public ArticleSearchHighlights build() { + return new ArticleSearchHighlights(articleId, highlightedTitle, highlightedSummary, additionalProperties); + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = HighlightedTitleItem.Builder.class) + public static final class HighlightedTitleItem { + private final Optional type; + + private final Optional text; + + private final Map additionalProperties; + + private HighlightedTitleItem( + Optional type, Optional text, Map additionalProperties) { + this.type = type; + this.text = text; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of text - highlight or plain. + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return The text of the title. + */ + @JsonProperty("text") + public Optional getText() { + return text; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof HighlightedTitleItem && equalTo((HighlightedTitleItem) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(HighlightedTitleItem other) { + return type.equals(other.type) && text.equals(other.text); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.text); + } + + @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 text = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(HighlightedTitleItem other) { + type(other.getType()); + text(other.getText()); + return this; + } + + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(Type type) { + this.type = Optional.ofNullable(type); + return this; + } + + @JsonSetter(value = "text", nulls = Nulls.SKIP) + public Builder text(Optional text) { + this.text = text; + return this; + } + + public Builder text(String text) { + this.text = Optional.ofNullable(text); + return this; + } + + public HighlightedTitleItem build() { + return new HighlightedTitleItem(type, text, additionalProperties); + } + } + + public final class Type { + public static final Type PLAIN = new Type(Value.PLAIN, "plain"); + + public static final Type HIGHLIGHT = new Type(Value.HIGHLIGHT, "highlight"); + + private final Value value; + + private final String string; + + Type(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 Type && this.string.equals(((Type) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case PLAIN: + return visitor.visitPlain(); + case HIGHLIGHT: + return visitor.visitHighlight(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static Type valueOf(String value) { + switch (value) { + case "plain": + return PLAIN; + case "highlight": + return HIGHLIGHT; + default: + return new Type(Value.UNKNOWN, value); + } + } + + public enum Value { + HIGHLIGHT, + + PLAIN, + + UNKNOWN + } + + public interface Visitor { + T visitHighlight(); + + T visitPlain(); + + T visitUnknown(String unknownType); + } + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = HighlightedSummaryItemItem.Builder.class) + public static final class HighlightedSummaryItemItem { + private final Optional type; + + private final Optional text; + + private final Map additionalProperties; + + private HighlightedSummaryItemItem( + Optional type, Optional text, Map additionalProperties) { + this.type = type; + this.text = text; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of text - highlight or plain. + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return The text of the title. + */ + @JsonProperty("text") + public Optional getText() { + return text; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof HighlightedSummaryItemItem && equalTo((HighlightedSummaryItemItem) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(HighlightedSummaryItemItem other) { + return type.equals(other.type) && text.equals(other.text); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.text); + } + + @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 text = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(HighlightedSummaryItemItem other) { + type(other.getType()); + text(other.getText()); + return this; + } + + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(Type type) { + this.type = Optional.ofNullable(type); + return this; + } + + @JsonSetter(value = "text", nulls = Nulls.SKIP) + public Builder text(Optional text) { + this.text = text; + return this; + } + + public Builder text(String text) { + this.text = Optional.ofNullable(text); + return this; + } + + public HighlightedSummaryItemItem build() { + return new HighlightedSummaryItemItem(type, text, additionalProperties); + } + } + + public final class Type { + public static final Type PLAIN = new Type(Value.PLAIN, "plain"); + + public static final Type HIGHLIGHT = new Type(Value.HIGHLIGHT, "highlight"); + + private final Value value; + + private final String string; + + Type(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 Type && this.string.equals(((Type) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case PLAIN: + return visitor.visitPlain(); + case HIGHLIGHT: + return visitor.visitHighlight(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static Type valueOf(String value) { + switch (value) { + case "plain": + return PLAIN; + case "highlight": + return HIGHLIGHT; + default: + return new Type(Value.UNKNOWN, value); + } + } + + public enum Value { + HIGHLIGHT, + + PLAIN, + + UNKNOWN + } + + public interface Visitor { + T visitHighlight(); + + T visitPlain(); + + T visitUnknown(String unknownType); + } + } + } +} 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 new file mode 100644 index 00000000..8d53ce18 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/articles/types/IArticleListItem.java @@ -0,0 +1,40 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.articles.types; + +import com.intercom.api.types.ArticleTranslatedContent; +import java.util.List; +import java.util.Optional; + +public interface IArticleListItem { + Optional getType(); + + String getId(); + + String getWorkspaceId(); + + String getTitle(); + + Optional getDescription(); + + Optional getBody(); + + int getAuthorId(); + + int getCreatedAt(); + + int getUpdatedAt(); + + Optional getUrl(); + + Optional getParentId(); + + Optional> getParentIds(); + + Optional getParentType(); + + String getDefaultLocale(); + + ArticleTranslatedContent getTranslatedContent(); +} diff --git a/src/main/java/com/intercom/api/resources/articles/types/SearchArticlesResponse.java b/src/main/java/com/intercom/api/resources/articles/types/SearchArticlesResponse.java new file mode 100644 index 00000000..ee32f02c --- /dev/null +++ b/src/main/java/com/intercom/api/resources/articles/types/SearchArticlesResponse.java @@ -0,0 +1,287 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.articles.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; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = SearchArticlesResponse.Builder.class) +public final class SearchArticlesResponse { + private final int totalCount; + + private final Data data; + + private final Optional pages; + + private final Map additionalProperties; + + private SearchArticlesResponse( + int totalCount, Data data, Optional pages, Map additionalProperties) { + this.totalCount = totalCount; + this.data = data; + this.pages = pages; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of the object - list. + */ + @JsonProperty("type") + public String getType() { + return "list"; + } + + /** + * @return The total number of Articles matching the search query + */ + @JsonProperty("total_count") + public int getTotalCount() { + return totalCount; + } + + /** + * @return An object containing the results of the search. + */ + @JsonProperty("data") + public Data 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 SearchArticlesResponse && equalTo((SearchArticlesResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(SearchArticlesResponse other) { + return totalCount == 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); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TotalCountStage builder() { + return new Builder(); + } + + public interface TotalCountStage { + DataStage totalCount(int totalCount); + + Builder from(SearchArticlesResponse other); + } + + public interface DataStage { + _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; + + private Data data; + + private Optional pages = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(SearchArticlesResponse other) { + totalCount(other.getTotalCount()); + data(other.getData()); + pages(other.getPages()); + return this; + } + + /** + *

The total number of Articles matching the search query

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

An object containing the results of the search.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("data") + public _FinalStage data(@NotNull Data data) { + this.data = Objects.requireNonNull(data, "data must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage pages(CursorPages pages) { + this.pages = Optional.ofNullable(pages); + return this; + } + + @java.lang.Override + @JsonSetter(value = "pages", nulls = Nulls.SKIP) + public _FinalStage pages(Optional pages) { + this.pages = pages; + return this; + } + + @java.lang.Override + public SearchArticlesResponse build() { + return new SearchArticlesResponse(totalCount, data, pages, additionalProperties); + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = Data.Builder.class) + public static final class Data { + private final Optional> articles; + + private final Optional> highlights; + + private final Map additionalProperties; + + private Data( + Optional> articles, + Optional> highlights, + Map additionalProperties) { + this.articles = articles; + this.highlights = highlights; + this.additionalProperties = additionalProperties; + } + + /** + * @return An array of Article objects + */ + @JsonProperty("articles") + public Optional> getArticles() { + return articles; + } + + /** + * @return A corresponding array of highlighted Article content + */ + @JsonProperty("highlights") + public Optional> getHighlights() { + return highlights; + } + + @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 articles.equals(other.articles) && highlights.equals(other.highlights); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.articles, this.highlights); + } + + @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> articles = Optional.empty(); + + private Optional> highlights = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(Data other) { + articles(other.getArticles()); + highlights(other.getHighlights()); + return this; + } + + @JsonSetter(value = "articles", nulls = Nulls.SKIP) + public Builder articles(Optional> articles) { + this.articles = articles; + return this; + } + + public Builder articles(List
articles) { + this.articles = Optional.ofNullable(articles); + return this; + } + + @JsonSetter(value = "highlights", nulls = Nulls.SKIP) + public Builder highlights(Optional> highlights) { + this.highlights = highlights; + return this; + } + + public Builder highlights(List highlights) { + this.highlights = Optional.ofNullable(highlights); + return this; + } + + public Data build() { + return new Data(articles, highlights, 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 new file mode 100644 index 00000000..01689582 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/companies/AsyncCompaniesClient.java @@ -0,0 +1,1034 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.companies; + +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.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.QueryStringMapper; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.core.pagination.SyncPagingIterable; +import com.intercom.api.errors.BadRequestError; +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; +import com.intercom.api.resources.companies.requests.ListAttachedContactsRequest; +import com.intercom.api.resources.companies.requests.ListCompaniesRequest; +import com.intercom.api.resources.companies.requests.ListSegmentsAttachedToCompanyRequest; +import com.intercom.api.resources.companies.requests.RetrieveCompanyRequest; +import com.intercom.api.resources.companies.requests.ScrollCompaniesRequest; +import com.intercom.api.resources.companies.requests.UpdateCompanyRequest; +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.CompanyList; +import com.intercom.api.types.CompanyScroll; +import com.intercom.api.types.DeletedCompanyObject; +import com.intercom.api.types.Error; +import java.io.IOException; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; +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 AsyncCompaniesClient { + protected final ClientOptions clientOptions; + + public AsyncCompaniesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can fetch a single company by passing in company_id or name. + *

https://api.intercom.io/companies?name={name}

+ *

https://api.intercom.io/companies?company_id={company_id}

+ *

You can fetch all companies and filter by segment_id or tag_id as a query parameter.

+ *

https://api.intercom.io/companies?tag_id={tag_id}

+ *

https://api.intercom.io/companies?segment_id={segment_id}

+ */ + public CompletableFuture retrieve() { + return retrieve(RetrieveCompanyRequest.builder().build()); + } + + /** + * You can fetch a single company by passing in company_id or name. + *

https://api.intercom.io/companies?name={name}

+ *

https://api.intercom.io/companies?company_id={company_id}

+ *

You can fetch all companies and filter by segment_id or tag_id as a query parameter.

+ *

https://api.intercom.io/companies?tag_id={tag_id}

+ *

https://api.intercom.io/companies?segment_id={segment_id}

+ */ + public CompletableFuture retrieve(RetrieveCompanyRequest request) { + return retrieve(request, null); + } + + /** + * You can fetch a single company by passing in company_id or name. + *

https://api.intercom.io/companies?name={name}

+ *

https://api.intercom.io/companies?company_id={company_id}

+ *

You can fetch all companies and filter by segment_id or tag_id as a query parameter.

+ *

https://api.intercom.io/companies?tag_id={tag_id}

+ *

https://api.intercom.io/companies?segment_id={segment_id}

+ */ + public CompletableFuture retrieve(RetrieveCompanyRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("companies"); + if (request.getName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "name", request.getName().get(), false); + } + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getTagId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "tag_id", request.getTagId().get(), false); + } + if (request.getSegmentId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "segment_id", request.getSegmentId().get(), false); + } + 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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CompanyList.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + 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))); + 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 or update a company. + *

Companies will be only visible in Intercom when there is at least one associated user.

+ *

Companies are looked up via company_id in a POST request, if not found via company_id, the new company will be created, if found, that company will be updated.

+ *

{% admonition type="warning" name="Using company_id" %} + * You can set a unique company_id value when creating a company. However, it is not possible to update company_id. Be sure to set a unique value once upon creation of the company. + * {% /admonition %}

+ */ + public CompletableFuture createOrUpdate() { + return createOrUpdate(CreateOrUpdateCompanyRequest.builder().build()); + } + + /** + * You can create or update a company. + *

Companies will be only visible in Intercom when there is at least one associated user.

+ *

Companies are looked up via company_id in a POST request, if not found via company_id, the new company will be created, if found, that company will be updated.

+ *

{% admonition type="warning" name="Using company_id" %} + * You can set a unique company_id value when creating a company. However, it is not possible to update company_id. Be sure to set a unique value once upon creation of the company. + * {% /admonition %}

+ */ + public CompletableFuture createOrUpdate(CreateOrUpdateCompanyRequest request) { + return createOrUpdate(request, null); + } + + /** + * You can create or update a company. + *

Companies will be only visible in Intercom when there is at least one associated user.

+ *

Companies are looked up via company_id in a POST request, if not found via company_id, the new company will be created, if found, that company will be updated.

+ *

{% admonition type="warning" name="Using company_id" %} + * You can set a unique company_id value when creating a company. However, it is not possible to update company_id. Be sure to set a unique value once upon creation of the company. + * {% /admonition %}

+ */ + public CompletableFuture createOrUpdate( + CreateOrUpdateCompanyRequest 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); + } 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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Company.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + 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))); + 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 a single company. + */ + public CompletableFuture find(FindCompanyRequest request) { + return find(request, null); + } + + /** + * You can fetch a single company. + */ + public CompletableFuture find(FindCompanyRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("companies") + .addPathSegment(request.getCompanyId()) + .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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Company.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + 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))); + 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 a single company using the Intercom provisioned id. + *

{% admonition type="warning" name="Using company_id" %} + * When updating a company it is not possible to update company_id. This can only be set once upon creation of the company. + * {% /admonition %}

+ */ + public CompletableFuture update(UpdateCompanyRequest request) { + return update(request, null); + } + + /** + * You can update a single company using the Intercom provisioned id. + *

{% admonition type="warning" name="Using company_id" %} + * When updating a company it is not possible to update company_id. This can only be set once upon creation of the company. + * {% /admonition %}

+ */ + public CompletableFuture update(UpdateCompanyRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("companies") + .addPathSegment(request.getCompanyId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("PUT", 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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Company.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + 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))); + 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 company. + */ + public CompletableFuture delete(DeleteCompanyRequest request) { + return delete(request, null); + } + + /** + * You can delete a single company. + */ + public CompletableFuture delete(DeleteCompanyRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("companies") + .addPathSegment(request.getCompanyId()) + .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( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeletedCompanyObject.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + 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))); + 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 a list of all contacts that belong to a company. + */ + public CompletableFuture listAttachedContacts(ListAttachedContactsRequest request) { + return listAttachedContacts(request, null); + } + + /** + * You can fetch a list of all contacts that belong to a company. + */ + public CompletableFuture listAttachedContacts( + ListAttachedContactsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder 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); + } + 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(ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CompanyAttachedContacts.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + 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))); + 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 a list of all segments that belong to a company. + */ + public CompletableFuture listAttachedSegments( + ListSegmentsAttachedToCompanyRequest request) { + return listAttachedSegments(request, null); + } + + /** + * You can fetch a list of all segments that belong to a company. + */ + public CompletableFuture listAttachedSegments( + ListSegmentsAttachedToCompanyRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("companies") + .addPathSegment(request.getCompanyId()) + .addPathSegments("segments") + .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(ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CompanyAttachedSegments.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + 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))); + 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 list companies. The company list is sorted by the last_request_at field and by default is ordered descending, most recently requested first. + *

Note that the API does not include companies who have no associated users in list responses.

+ *

When using the Companies endpoint and the pages object to iterate through the returned companies, there is a limit of 10,000 Companies that can be returned. If you need to list or iterate on more than 10,000 Companies, please use the Scroll API. + * {% admonition type="warning" name="Pagination" %} + * You can use pagination to limit the number of results returned. The default is 20 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ */ + public CompletableFuture> list() { + return list(ListCompaniesRequest.builder().build()); + } + + /** + * You can list companies. The company list is sorted by the last_request_at field and by default is ordered descending, most recently requested first. + *

Note that the API does not include companies who have no associated users in list responses.

+ *

When using the Companies endpoint and the pages object to iterate through the returned companies, there is a limit of 10,000 Companies that can be returned. If you need to list or iterate on more than 10,000 Companies, please use the Scroll API. + * {% admonition type="warning" name="Pagination" %} + * You can use pagination to limit the number of results returned. The default is 20 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ */ + public CompletableFuture> list(ListCompaniesRequest request) { + return list(request, null); + } + + /** + * You can list companies. The company list is sorted by the last_request_at field and by default is ordered descending, most recently requested first. + *

Note that the API does not include companies who have no associated users in list responses.

+ *

When using the Companies endpoint and the pages object to iterate through the returned companies, there is a limit of 10,000 Companies that can be returned. If you need to list or iterate on more than 10,000 Companies, please use the Scroll API. + * {% admonition type="warning" name="Pagination" %} + * You can use pagination to limit the number of results returned. The default is 20 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ */ + public CompletableFuture> list( + ListCompaniesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("companies/list"); + 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); + } + if (request.getOrder().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "order", request.getOrder().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .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()) { + CompanyList parsedResponse = + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CompanyList.class); + int newPageNumber = + request.getPage().map(page -> page + 1).orElse(1); + ListCompaniesRequest nextRequest = ListCompaniesRequest.builder() + .from(request) + .page(newPageNumber) + .build(); + List result = parsedResponse.getData(); + future.complete(new SyncPagingIterable(true, result, () -> { + try { + return list(nextRequest, requestOptions).get(); + } catch (InterruptedException | ExecutionException e) { + throw new RuntimeException(e); + } + })); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + 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))); + 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; + } + + /** + * The list all companies functionality does not work well for huge datasets, and can result in errors and performance problems when paging deeply. The Scroll API provides an efficient mechanism for iterating over all companies in a dataset. + *
    + *
  • Each app can only have 1 scroll open at a time. You'll get an error message if you try to have more than one open per app.
  • + *
  • If the scroll isn't used for 1 minute, it expires and calls with that scroll param will fail
  • + *
  • If the end of the scroll is reached, "companies" will be empty and the scroll parameter will expire
  • + *
+ *

{% admonition type="info" name="Scroll Parameter" %} + * You can get the first page of companies by simply sending a GET request to the scroll endpoint. + * For subsequent requests you will need to use the scroll parameter from the response. + * {% /admonition %} + * {% admonition type="danger" name="Scroll network timeouts" %} + * Since scroll is often used on large datasets network errors such as timeouts can be encountered. When this occurs you will see a HTTP 500 error with the following message: + * "Request failed due to an internal network error. Please restart the scroll operation." + * If this happens, you will need to restart your scroll query: It is not possible to continue from a specific point when using scroll. + * {% /admonition %}

+ */ + public CompletableFuture> scroll() { + return scroll(ScrollCompaniesRequest.builder().build()); + } + + /** + * The list all companies functionality does not work well for huge datasets, and can result in errors and performance problems when paging deeply. The Scroll API provides an efficient mechanism for iterating over all companies in a dataset. + *
    + *
  • Each app can only have 1 scroll open at a time. You'll get an error message if you try to have more than one open per app.
  • + *
  • If the scroll isn't used for 1 minute, it expires and calls with that scroll param will fail
  • + *
  • If the end of the scroll is reached, "companies" will be empty and the scroll parameter will expire
  • + *
+ *

{% admonition type="info" name="Scroll Parameter" %} + * You can get the first page of companies by simply sending a GET request to the scroll endpoint. + * For subsequent requests you will need to use the scroll parameter from the response. + * {% /admonition %} + * {% admonition type="danger" name="Scroll network timeouts" %} + * Since scroll is often used on large datasets network errors such as timeouts can be encountered. When this occurs you will see a HTTP 500 error with the following message: + * "Request failed due to an internal network error. Please restart the scroll operation." + * If this happens, you will need to restart your scroll query: It is not possible to continue from a specific point when using scroll. + * {% /admonition %}

+ */ + public CompletableFuture> scroll(ScrollCompaniesRequest request) { + return scroll(request, null); + } + + /** + * The list all companies functionality does not work well for huge datasets, and can result in errors and performance problems when paging deeply. The Scroll API provides an efficient mechanism for iterating over all companies in a dataset. + *
    + *
  • Each app can only have 1 scroll open at a time. You'll get an error message if you try to have more than one open per app.
  • + *
  • If the scroll isn't used for 1 minute, it expires and calls with that scroll param will fail
  • + *
  • If the end of the scroll is reached, "companies" will be empty and the scroll parameter will expire
  • + *
+ *

{% admonition type="info" name="Scroll Parameter" %} + * You can get the first page of companies by simply sending a GET request to the scroll endpoint. + * For subsequent requests you will need to use the scroll parameter from the response. + * {% /admonition %} + * {% admonition type="danger" name="Scroll network timeouts" %} + * Since scroll is often used on large datasets network errors such as timeouts can be encountered. When this occurs you will see a HTTP 500 error with the following message: + * "Request failed due to an internal network error. Please restart the scroll operation." + * If this happens, you will need to restart your scroll query: It is not possible to continue from a specific point when using scroll. + * {% /admonition %}

+ */ + public CompletableFuture> scroll( + ScrollCompaniesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("companies/scroll"); + if (request.getScrollParam().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "scroll_param", request.getScrollParam().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()) { + CompanyScroll parsedResponse = + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CompanyScroll.class); + Optional startingAfter = parsedResponse.getScrollParam(); + ScrollCompaniesRequest nextRequest = ScrollCompaniesRequest.builder() + .from(request) + .scrollParam(startingAfter) + .build(); + List result = parsedResponse.getData(); + future.complete(new SyncPagingIterable(startingAfter.isPresent(), result, () -> { + try { + return scroll(nextRequest, requestOptions).get(); + } catch (InterruptedException | ExecutionException e) { + throw new RuntimeException(e); + } + })); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + 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))); + 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 attach a company to a single contact. + */ + public CompletableFuture attachContact(AttachContactToCompanyRequest request) { + return attachContact(request, null); + } + + /** + * You can attach a company to a single contact. + */ + public CompletableFuture attachContact( + AttachContactToCompanyRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getContactId()) + .addPathSegments("companies") + .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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Company.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + 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))); + 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 detach a company from a single contact. + */ + public CompletableFuture detachContact(DetachContactFromCompanyRequest request) { + return detachContact(request, null); + } + + /** + * You can detach a company from a single contact. + */ + public CompletableFuture detachContact( + DetachContactFromCompanyRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getContactId()) + .addPathSegments("companies") + .addPathSegment(request.getCompanyId()) + .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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Company.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + 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))); + 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/companies/CompaniesClient.java b/src/main/java/com/intercom/api/resources/companies/CompaniesClient.java new file mode 100644 index 00000000..4811c451 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/companies/CompaniesClient.java @@ -0,0 +1,834 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.companies; + +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.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.QueryStringMapper; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.core.pagination.SyncPagingIterable; +import com.intercom.api.errors.BadRequestError; +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; +import com.intercom.api.resources.companies.requests.ListAttachedContactsRequest; +import com.intercom.api.resources.companies.requests.ListCompaniesRequest; +import com.intercom.api.resources.companies.requests.ListSegmentsAttachedToCompanyRequest; +import com.intercom.api.resources.companies.requests.RetrieveCompanyRequest; +import com.intercom.api.resources.companies.requests.ScrollCompaniesRequest; +import com.intercom.api.resources.companies.requests.UpdateCompanyRequest; +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.CompanyList; +import com.intercom.api.types.CompanyScroll; +import com.intercom.api.types.DeletedCompanyObject; +import com.intercom.api.types.Error; +import java.io.IOException; +import java.util.List; +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 CompaniesClient { + protected final ClientOptions clientOptions; + + public CompaniesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can fetch a single company by passing in company_id or name. + *

https://api.intercom.io/companies?name={name}

+ *

https://api.intercom.io/companies?company_id={company_id}

+ *

You can fetch all companies and filter by segment_id or tag_id as a query parameter.

+ *

https://api.intercom.io/companies?tag_id={tag_id}

+ *

https://api.intercom.io/companies?segment_id={segment_id}

+ */ + public CompanyList retrieve() { + return retrieve(RetrieveCompanyRequest.builder().build()); + } + + /** + * You can fetch a single company by passing in company_id or name. + *

https://api.intercom.io/companies?name={name}

+ *

https://api.intercom.io/companies?company_id={company_id}

+ *

You can fetch all companies and filter by segment_id or tag_id as a query parameter.

+ *

https://api.intercom.io/companies?tag_id={tag_id}

+ *

https://api.intercom.io/companies?segment_id={segment_id}

+ */ + public CompanyList retrieve(RetrieveCompanyRequest request) { + return retrieve(request, null); + } + + /** + * You can fetch a single company by passing in company_id or name. + *

https://api.intercom.io/companies?name={name}

+ *

https://api.intercom.io/companies?company_id={company_id}

+ *

You can fetch all companies and filter by segment_id or tag_id as a query parameter.

+ *

https://api.intercom.io/companies?tag_id={tag_id}

+ *

https://api.intercom.io/companies?segment_id={segment_id}

+ */ + public CompanyList retrieve(RetrieveCompanyRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("companies"); + if (request.getName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "name", request.getName().get(), false); + } + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getTagId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "tag_id", request.getTagId().get(), false); + } + if (request.getSegmentId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "segment_id", request.getSegmentId().get(), false); + } + 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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CompanyList.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can create or update a company. + *

Companies will be only visible in Intercom when there is at least one associated user.

+ *

Companies are looked up via company_id in a POST request, if not found via company_id, the new company will be created, if found, that company will be updated.

+ *

{% admonition type="warning" name="Using company_id" %} + * You can set a unique company_id value when creating a company. However, it is not possible to update company_id. Be sure to set a unique value once upon creation of the company. + * {% /admonition %}

+ */ + public Company createOrUpdate() { + return createOrUpdate(CreateOrUpdateCompanyRequest.builder().build()); + } + + /** + * You can create or update a company. + *

Companies will be only visible in Intercom when there is at least one associated user.

+ *

Companies are looked up via company_id in a POST request, if not found via company_id, the new company will be created, if found, that company will be updated.

+ *

{% admonition type="warning" name="Using company_id" %} + * You can set a unique company_id value when creating a company. However, it is not possible to update company_id. Be sure to set a unique value once upon creation of the company. + * {% /admonition %}

+ */ + public Company createOrUpdate(CreateOrUpdateCompanyRequest request) { + return createOrUpdate(request, null); + } + + /** + * You can create or update a company. + *

Companies will be only visible in Intercom when there is at least one associated user.

+ *

Companies are looked up via company_id in a POST request, if not found via company_id, the new company will be created, if found, that company will be updated.

+ *

{% admonition type="warning" name="Using company_id" %} + * You can set a unique company_id value when creating a company. However, it is not possible to update company_id. Be sure to set a unique value once upon creation of the company. + * {% /admonition %}

+ */ + public Company createOrUpdate(CreateOrUpdateCompanyRequest 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); + } 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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Company.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can fetch a single company. + */ + public Company find(FindCompanyRequest request) { + return find(request, null); + } + + /** + * You can fetch a single company. + */ + public Company find(FindCompanyRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("companies") + .addPathSegment(request.getCompanyId()) + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Company.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can update a single company using the Intercom provisioned id. + *

{% admonition type="warning" name="Using company_id" %} + * When updating a company it is not possible to update company_id. This can only be set once upon creation of the company. + * {% /admonition %}

+ */ + public Company update(UpdateCompanyRequest request) { + return update(request, null); + } + + /** + * You can update a single company using the Intercom provisioned id. + *

{% admonition type="warning" name="Using company_id" %} + * When updating a company it is not possible to update company_id. This can only be set once upon creation of the company. + * {% /admonition %}

+ */ + public Company update(UpdateCompanyRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("companies") + .addPathSegment(request.getCompanyId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("PUT", 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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Company.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can delete a single company. + */ + public DeletedCompanyObject delete(DeleteCompanyRequest request) { + return delete(request, null); + } + + /** + * You can delete a single company. + */ + public DeletedCompanyObject delete(DeleteCompanyRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("companies") + .addPathSegment(request.getCompanyId()) + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeletedCompanyObject.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can fetch a list of all contacts that belong to a company. + */ + public CompanyAttachedContacts listAttachedContacts(ListAttachedContactsRequest request) { + return listAttachedContacts(request, null); + } + + /** + * You can fetch a list of all contacts that belong to a company. + */ + public CompanyAttachedContacts listAttachedContacts( + ListAttachedContactsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder 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); + } + 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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CompanyAttachedContacts.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can fetch a list of all segments that belong to a company. + */ + public CompanyAttachedSegments listAttachedSegments(ListSegmentsAttachedToCompanyRequest request) { + return listAttachedSegments(request, null); + } + + /** + * You can fetch a list of all segments that belong to a company. + */ + public CompanyAttachedSegments listAttachedSegments( + ListSegmentsAttachedToCompanyRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("companies") + .addPathSegment(request.getCompanyId()) + .addPathSegments("segments") + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CompanyAttachedSegments.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can list companies. The company list is sorted by the last_request_at field and by default is ordered descending, most recently requested first. + *

Note that the API does not include companies who have no associated users in list responses.

+ *

When using the Companies endpoint and the pages object to iterate through the returned companies, there is a limit of 10,000 Companies that can be returned. If you need to list or iterate on more than 10,000 Companies, please use the Scroll API. + * {% admonition type="warning" name="Pagination" %} + * You can use pagination to limit the number of results returned. The default is 20 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ */ + public SyncPagingIterable list() { + return list(ListCompaniesRequest.builder().build()); + } + + /** + * You can list companies. The company list is sorted by the last_request_at field and by default is ordered descending, most recently requested first. + *

Note that the API does not include companies who have no associated users in list responses.

+ *

When using the Companies endpoint and the pages object to iterate through the returned companies, there is a limit of 10,000 Companies that can be returned. If you need to list or iterate on more than 10,000 Companies, please use the Scroll API. + * {% admonition type="warning" name="Pagination" %} + * You can use pagination to limit the number of results returned. The default is 20 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ */ + public SyncPagingIterable list(ListCompaniesRequest request) { + return list(request, null); + } + + /** + * You can list companies. The company list is sorted by the last_request_at field and by default is ordered descending, most recently requested first. + *

Note that the API does not include companies who have no associated users in list responses.

+ *

When using the Companies endpoint and the pages object to iterate through the returned companies, there is a limit of 10,000 Companies that can be returned. If you need to list or iterate on more than 10,000 Companies, please use the Scroll API. + * {% admonition type="warning" name="Pagination" %} + * You can use pagination to limit the number of results returned. The default is 20 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ */ + public SyncPagingIterable list(ListCompaniesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("companies/list"); + 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); + } + if (request.getOrder().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "order", request.getOrder().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .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()) { + CompanyList parsedResponse = + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CompanyList.class); + int newPageNumber = request.getPage().map(page -> page + 1).orElse(1); + ListCompaniesRequest nextRequest = ListCompaniesRequest.builder() + .from(request) + .page(newPageNumber) + .build(); + List result = parsedResponse.getData(); + return new SyncPagingIterable(true, result, () -> list(nextRequest, requestOptions)); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * The list all companies functionality does not work well for huge datasets, and can result in errors and performance problems when paging deeply. The Scroll API provides an efficient mechanism for iterating over all companies in a dataset. + *
    + *
  • Each app can only have 1 scroll open at a time. You'll get an error message if you try to have more than one open per app.
  • + *
  • If the scroll isn't used for 1 minute, it expires and calls with that scroll param will fail
  • + *
  • If the end of the scroll is reached, "companies" will be empty and the scroll parameter will expire
  • + *
+ *

{% admonition type="info" name="Scroll Parameter" %} + * You can get the first page of companies by simply sending a GET request to the scroll endpoint. + * For subsequent requests you will need to use the scroll parameter from the response. + * {% /admonition %} + * {% admonition type="danger" name="Scroll network timeouts" %} + * Since scroll is often used on large datasets network errors such as timeouts can be encountered. When this occurs you will see a HTTP 500 error with the following message: + * "Request failed due to an internal network error. Please restart the scroll operation." + * If this happens, you will need to restart your scroll query: It is not possible to continue from a specific point when using scroll. + * {% /admonition %}

+ */ + public SyncPagingIterable scroll() { + return scroll(ScrollCompaniesRequest.builder().build()); + } + + /** + * The list all companies functionality does not work well for huge datasets, and can result in errors and performance problems when paging deeply. The Scroll API provides an efficient mechanism for iterating over all companies in a dataset. + *
    + *
  • Each app can only have 1 scroll open at a time. You'll get an error message if you try to have more than one open per app.
  • + *
  • If the scroll isn't used for 1 minute, it expires and calls with that scroll param will fail
  • + *
  • If the end of the scroll is reached, "companies" will be empty and the scroll parameter will expire
  • + *
+ *

{% admonition type="info" name="Scroll Parameter" %} + * You can get the first page of companies by simply sending a GET request to the scroll endpoint. + * For subsequent requests you will need to use the scroll parameter from the response. + * {% /admonition %} + * {% admonition type="danger" name="Scroll network timeouts" %} + * Since scroll is often used on large datasets network errors such as timeouts can be encountered. When this occurs you will see a HTTP 500 error with the following message: + * "Request failed due to an internal network error. Please restart the scroll operation." + * If this happens, you will need to restart your scroll query: It is not possible to continue from a specific point when using scroll. + * {% /admonition %}

+ */ + public SyncPagingIterable scroll(ScrollCompaniesRequest request) { + return scroll(request, null); + } + + /** + * The list all companies functionality does not work well for huge datasets, and can result in errors and performance problems when paging deeply. The Scroll API provides an efficient mechanism for iterating over all companies in a dataset. + *
    + *
  • Each app can only have 1 scroll open at a time. You'll get an error message if you try to have more than one open per app.
  • + *
  • If the scroll isn't used for 1 minute, it expires and calls with that scroll param will fail
  • + *
  • If the end of the scroll is reached, "companies" will be empty and the scroll parameter will expire
  • + *
+ *

{% admonition type="info" name="Scroll Parameter" %} + * You can get the first page of companies by simply sending a GET request to the scroll endpoint. + * For subsequent requests you will need to use the scroll parameter from the response. + * {% /admonition %} + * {% admonition type="danger" name="Scroll network timeouts" %} + * Since scroll is often used on large datasets network errors such as timeouts can be encountered. When this occurs you will see a HTTP 500 error with the following message: + * "Request failed due to an internal network error. Please restart the scroll operation." + * If this happens, you will need to restart your scroll query: It is not possible to continue from a specific point when using scroll. + * {% /admonition %}

+ */ + public SyncPagingIterable scroll(ScrollCompaniesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("companies/scroll"); + if (request.getScrollParam().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "scroll_param", request.getScrollParam().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()) { + CompanyScroll parsedResponse = + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CompanyScroll.class); + Optional startingAfter = parsedResponse.getScrollParam(); + ScrollCompaniesRequest nextRequest = ScrollCompaniesRequest.builder() + .from(request) + .scrollParam(startingAfter) + .build(); + List result = parsedResponse.getData(); + return new SyncPagingIterable( + startingAfter.isPresent(), result, () -> scroll(nextRequest, requestOptions)); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can attach a company to a single contact. + */ + public Company attachContact(AttachContactToCompanyRequest request) { + return attachContact(request, null); + } + + /** + * You can attach a company to a single contact. + */ + public Company attachContact(AttachContactToCompanyRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getContactId()) + .addPathSegments("companies") + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Company.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can detach a company from a single contact. + */ + public Company detachContact(DetachContactFromCompanyRequest request) { + return detachContact(request, null); + } + + /** + * You can detach a company from a single contact. + */ + public Company detachContact(DetachContactFromCompanyRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getContactId()) + .addPathSegments("companies") + .addPathSegment(request.getCompanyId()) + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Company.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} 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 new file mode 100644 index 00000000..796a9532 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/companies/requests/AttachContactToCompanyRequest.java @@ -0,0 +1,139 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.companies.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 = AttachContactToCompanyRequest.Builder.class) +public final class AttachContactToCompanyRequest { + private final String contactId; + + private final String companyId; + + private final Map additionalProperties; + + private AttachContactToCompanyRequest( + String contactId, String companyId, Map additionalProperties) { + this.contactId = contactId; + this.companyId = companyId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the contact which is given by Intercom + */ + @JsonProperty("contact_id") + public String getContactId() { + return contactId; + } + + /** + * @return The unique identifier for the company which is given by Intercom + */ + @JsonProperty("id") + public String getCompanyId() { + return companyId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AttachContactToCompanyRequest && equalTo((AttachContactToCompanyRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(AttachContactToCompanyRequest other) { + return contactId.equals(other.contactId) && companyId.equals(other.companyId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.contactId, this.companyId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ContactIdStage builder() { + return new Builder(); + } + + public interface ContactIdStage { + CompanyIdStage contactId(@NotNull String contactId); + + Builder from(AttachContactToCompanyRequest other); + } + + public interface CompanyIdStage { + _FinalStage companyId(@NotNull String companyId); + } + + public interface _FinalStage { + AttachContactToCompanyRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ContactIdStage, CompanyIdStage, _FinalStage { + private String contactId; + + private String companyId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(AttachContactToCompanyRequest other) { + contactId(other.getContactId()); + companyId(other.getCompanyId()); + return this; + } + + /** + *

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("contact_id") + public CompanyIdStage contactId(@NotNull String contactId) { + this.contactId = Objects.requireNonNull(contactId, "contactId must not be null"); + return this; + } + + /** + *

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 + @JsonSetter("id") + public _FinalStage companyId(@NotNull String companyId) { + this.companyId = Objects.requireNonNull(companyId, "companyId must not be null"); + return this; + } + + @java.lang.Override + public AttachContactToCompanyRequest build() { + return new AttachContactToCompanyRequest(contactId, companyId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/companies/requests/CreateOrUpdateCompanyRequest.java b/src/main/java/com/intercom/api/resources/companies/requests/CreateOrUpdateCompanyRequest.java new file mode 100644 index 00000000..41868002 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/companies/requests/CreateOrUpdateCompanyRequest.java @@ -0,0 +1,335 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.companies.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 = CreateOrUpdateCompanyRequest.Builder.class) +public final class CreateOrUpdateCompanyRequest { + private final Optional name; + + private final Optional companyId; + + private final Optional plan; + + private final Optional size; + + private final Optional website; + + private final Optional industry; + + private final Optional> customAttributes; + + private final Optional remoteCreatedAt; + + private final Optional monthlySpend; + + private final Map additionalProperties; + + private CreateOrUpdateCompanyRequest( + Optional name, + Optional companyId, + Optional plan, + Optional size, + Optional website, + Optional industry, + Optional> customAttributes, + Optional remoteCreatedAt, + Optional monthlySpend, + Map additionalProperties) { + this.name = name; + this.companyId = companyId; + this.plan = plan; + this.size = size; + this.website = website; + this.industry = industry; + this.customAttributes = customAttributes; + this.remoteCreatedAt = remoteCreatedAt; + this.monthlySpend = monthlySpend; + this.additionalProperties = additionalProperties; + } + + /** + * @return The name of the Company + */ + @JsonProperty("name") + public Optional getName() { + return name; + } + + /** + * @return The company id you have defined for the company. Can't be updated + */ + @JsonProperty("company_id") + public Optional getCompanyId() { + return companyId; + } + + /** + * @return The name of the plan you have associated with the company. + */ + @JsonProperty("plan") + public Optional getPlan() { + return plan; + } + + /** + * @return The number of employees in this company. + */ + @JsonProperty("size") + public Optional getSize() { + return size; + } + + /** + * @return The URL for this company's website. Please note that the value specified here is not validated. Accepts any string. + */ + @JsonProperty("website") + public Optional getWebsite() { + return website; + } + + /** + * @return The industry that this company operates in. + */ + @JsonProperty("industry") + public Optional getIndustry() { + return industry; + } + + /** + * @return A hash of key/value pairs containing any other data about the company you want Intercom to store. + */ + @JsonProperty("custom_attributes") + public Optional> getCustomAttributes() { + return customAttributes; + } + + /** + * @return The time the company was created by you. + */ + @JsonProperty("remote_created_at") + public Optional getRemoteCreatedAt() { + return remoteCreatedAt; + } + + /** + * @return How much revenue the company generates for your business. Note that this will truncate floats. i.e. it only allow for whole integers, 155.98 will be truncated to 155. Note that this has an upper limit of 2**31-1 or 2147483647.. + */ + @JsonProperty("monthly_spend") + public Optional getMonthlySpend() { + return monthlySpend; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreateOrUpdateCompanyRequest && equalTo((CreateOrUpdateCompanyRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreateOrUpdateCompanyRequest other) { + return name.equals(other.name) + && companyId.equals(other.companyId) + && plan.equals(other.plan) + && size.equals(other.size) + && website.equals(other.website) + && industry.equals(other.industry) + && customAttributes.equals(other.customAttributes) + && remoteCreatedAt.equals(other.remoteCreatedAt) + && monthlySpend.equals(other.monthlySpend); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.name, + this.companyId, + this.plan, + this.size, + this.website, + this.industry, + this.customAttributes, + this.remoteCreatedAt, + this.monthlySpend); + } + + @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 name = Optional.empty(); + + private Optional companyId = Optional.empty(); + + private Optional plan = Optional.empty(); + + private Optional size = Optional.empty(); + + private Optional website = Optional.empty(); + + private Optional industry = Optional.empty(); + + private Optional> customAttributes = Optional.empty(); + + private Optional remoteCreatedAt = Optional.empty(); + + private Optional monthlySpend = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(CreateOrUpdateCompanyRequest other) { + name(other.getName()); + companyId(other.getCompanyId()); + plan(other.getPlan()); + size(other.getSize()); + website(other.getWebsite()); + industry(other.getIndustry()); + customAttributes(other.getCustomAttributes()); + remoteCreatedAt(other.getRemoteCreatedAt()); + monthlySpend(other.getMonthlySpend()); + 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 = "company_id", nulls = Nulls.SKIP) + public Builder companyId(Optional companyId) { + this.companyId = companyId; + return this; + } + + public Builder companyId(String companyId) { + this.companyId = Optional.ofNullable(companyId); + return this; + } + + @JsonSetter(value = "plan", nulls = Nulls.SKIP) + public Builder plan(Optional plan) { + this.plan = plan; + return this; + } + + public Builder plan(String plan) { + this.plan = Optional.ofNullable(plan); + return this; + } + + @JsonSetter(value = "size", nulls = Nulls.SKIP) + public Builder size(Optional size) { + this.size = size; + return this; + } + + public Builder size(Integer size) { + this.size = Optional.ofNullable(size); + return this; + } + + @JsonSetter(value = "website", nulls = Nulls.SKIP) + public Builder website(Optional website) { + this.website = website; + return this; + } + + public Builder website(String website) { + this.website = Optional.ofNullable(website); + return this; + } + + @JsonSetter(value = "industry", nulls = Nulls.SKIP) + public Builder industry(Optional industry) { + this.industry = industry; + return this; + } + + public Builder industry(String industry) { + this.industry = Optional.ofNullable(industry); + return this; + } + + @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; + } + + @JsonSetter(value = "remote_created_at", nulls = Nulls.SKIP) + public Builder remoteCreatedAt(Optional remoteCreatedAt) { + this.remoteCreatedAt = remoteCreatedAt; + return this; + } + + public Builder remoteCreatedAt(Integer remoteCreatedAt) { + this.remoteCreatedAt = Optional.ofNullable(remoteCreatedAt); + return this; + } + + @JsonSetter(value = "monthly_spend", nulls = Nulls.SKIP) + public Builder monthlySpend(Optional monthlySpend) { + this.monthlySpend = monthlySpend; + return this; + } + + public Builder monthlySpend(Integer monthlySpend) { + this.monthlySpend = Optional.ofNullable(monthlySpend); + return this; + } + + public CreateOrUpdateCompanyRequest build() { + return new CreateOrUpdateCompanyRequest( + name, + companyId, + plan, + size, + website, + industry, + customAttributes, + remoteCreatedAt, + monthlySpend, + additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/companies/requests/DeleteCompanyRequest.java b/src/main/java/com/intercom/api/resources/companies/requests/DeleteCompanyRequest.java new file mode 100644 index 00000000..b0f262fe --- /dev/null +++ b/src/main/java/com/intercom/api/resources/companies/requests/DeleteCompanyRequest.java @@ -0,0 +1,109 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.companies.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 = DeleteCompanyRequest.Builder.class) +public final class DeleteCompanyRequest { + private final String companyId; + + private final Map additionalProperties; + + private DeleteCompanyRequest(String companyId, Map additionalProperties) { + this.companyId = companyId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the company which is given by Intercom + */ + @JsonProperty("company_id") + public String getCompanyId() { + return companyId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeleteCompanyRequest && equalTo((DeleteCompanyRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeleteCompanyRequest other) { + return companyId.equals(other.companyId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.companyId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static CompanyIdStage builder() { + return new Builder(); + } + + public interface CompanyIdStage { + _FinalStage companyId(@NotNull String companyId); + + Builder from(DeleteCompanyRequest other); + } + + public interface _FinalStage { + DeleteCompanyRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements CompanyIdStage, _FinalStage { + private String companyId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DeleteCompanyRequest other) { + companyId(other.getCompanyId()); + return this; + } + + /** + *

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 + @JsonSetter("company_id") + public _FinalStage companyId(@NotNull String companyId) { + this.companyId = Objects.requireNonNull(companyId, "companyId must not be null"); + return this; + } + + @java.lang.Override + public DeleteCompanyRequest build() { + return new DeleteCompanyRequest(companyId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/companies/requests/DetachContactFromCompanyRequest.java b/src/main/java/com/intercom/api/resources/companies/requests/DetachContactFromCompanyRequest.java new file mode 100644 index 00000000..516819eb --- /dev/null +++ b/src/main/java/com/intercom/api/resources/companies/requests/DetachContactFromCompanyRequest.java @@ -0,0 +1,139 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.companies.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 = DetachContactFromCompanyRequest.Builder.class) +public final class DetachContactFromCompanyRequest { + private final String contactId; + + private final String companyId; + + private final Map additionalProperties; + + private DetachContactFromCompanyRequest( + String contactId, String companyId, Map additionalProperties) { + this.contactId = contactId; + this.companyId = companyId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the contact which is given by Intercom + */ + @JsonProperty("contact_id") + public String getContactId() { + return contactId; + } + + /** + * @return The unique identifier for the company which is given by Intercom + */ + @JsonProperty("company_id") + public String getCompanyId() { + return companyId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DetachContactFromCompanyRequest && equalTo((DetachContactFromCompanyRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DetachContactFromCompanyRequest other) { + return contactId.equals(other.contactId) && companyId.equals(other.companyId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.contactId, this.companyId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ContactIdStage builder() { + return new Builder(); + } + + public interface ContactIdStage { + CompanyIdStage contactId(@NotNull String contactId); + + Builder from(DetachContactFromCompanyRequest other); + } + + public interface CompanyIdStage { + _FinalStage companyId(@NotNull String companyId); + } + + public interface _FinalStage { + DetachContactFromCompanyRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ContactIdStage, CompanyIdStage, _FinalStage { + private String contactId; + + private String companyId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DetachContactFromCompanyRequest other) { + contactId(other.getContactId()); + companyId(other.getCompanyId()); + return this; + } + + /** + *

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("contact_id") + public CompanyIdStage contactId(@NotNull String contactId) { + this.contactId = Objects.requireNonNull(contactId, "contactId must not be null"); + return this; + } + + /** + *

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 + @JsonSetter("company_id") + public _FinalStage companyId(@NotNull String companyId) { + this.companyId = Objects.requireNonNull(companyId, "companyId must not be null"); + return this; + } + + @java.lang.Override + public DetachContactFromCompanyRequest build() { + return new DetachContactFromCompanyRequest(contactId, companyId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/companies/requests/FindCompanyRequest.java b/src/main/java/com/intercom/api/resources/companies/requests/FindCompanyRequest.java new file mode 100644 index 00000000..0c03143e --- /dev/null +++ b/src/main/java/com/intercom/api/resources/companies/requests/FindCompanyRequest.java @@ -0,0 +1,109 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.companies.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 = FindCompanyRequest.Builder.class) +public final class FindCompanyRequest { + private final String companyId; + + private final Map additionalProperties; + + private FindCompanyRequest(String companyId, Map additionalProperties) { + this.companyId = companyId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the company which is given by Intercom + */ + @JsonProperty("company_id") + public String getCompanyId() { + return companyId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof FindCompanyRequest && equalTo((FindCompanyRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(FindCompanyRequest other) { + return companyId.equals(other.companyId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.companyId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static CompanyIdStage builder() { + return new Builder(); + } + + public interface CompanyIdStage { + _FinalStage companyId(@NotNull String companyId); + + Builder from(FindCompanyRequest other); + } + + public interface _FinalStage { + FindCompanyRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements CompanyIdStage, _FinalStage { + private String companyId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(FindCompanyRequest other) { + companyId(other.getCompanyId()); + return this; + } + + /** + *

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 + @JsonSetter("company_id") + public _FinalStage companyId(@NotNull String companyId) { + this.companyId = Objects.requireNonNull(companyId, "companyId must not be null"); + return this; + } + + @java.lang.Override + public FindCompanyRequest build() { + return new FindCompanyRequest(companyId, additionalProperties); + } + } +} 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 new file mode 100644 index 00000000..628530c6 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/companies/requests/ListAttachedContactsRequest.java @@ -0,0 +1,185 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.companies.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 = ListAttachedContactsRequest.Builder.class) +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) { + this.companyId = companyId; + this.page = page; + this.perPage = perPage; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the company which is given by Intercom + */ + @JsonProperty("company_id") + 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; + return other instanceof ListAttachedContactsRequest && equalTo((ListAttachedContactsRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListAttachedContactsRequest other) { + return companyId.equals(other.companyId) && page.equals(other.page) && perPage.equals(other.perPage); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.companyId, this.page, this.perPage); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static CompanyIdStage builder() { + return new Builder(); + } + + public interface CompanyIdStage { + _FinalStage companyId(@NotNull String companyId); + + Builder from(ListAttachedContactsRequest other); + } + + public interface _FinalStage { + ListAttachedContactsRequest build(); + + _FinalStage page(Optional page); + + _FinalStage page(Integer page); + + _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<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ListAttachedContactsRequest other) { + companyId(other.getCompanyId()); + page(other.getPage()); + perPage(other.getPerPage()); + return this; + } + + /** + *

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 + @JsonSetter("company_id") + public _FinalStage companyId(@NotNull String companyId) { + this.companyId = Objects.requireNonNull(companyId, "companyId must not be null"); + 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; + } + + @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; + } + + @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); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/companies/requests/ListCompaniesRequest.java b/src/main/java/com/intercom/api/resources/companies/requests/ListCompaniesRequest.java new file mode 100644 index 00000000..32440264 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/companies/requests/ListCompaniesRequest.java @@ -0,0 +1,152 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.companies.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 = ListCompaniesRequest.Builder.class) +public final class ListCompaniesRequest { + private final Optional page; + + private final Optional perPage; + + private final Optional order; + + private final Map additionalProperties; + + private ListCompaniesRequest( + Optional page, + Optional perPage, + Optional order, + Map additionalProperties) { + this.page = page; + this.perPage = perPage; + this.order = order; + 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 return per page. Defaults to 15 + */ + @JsonProperty("per_page") + public Optional getPerPage() { + return perPage; + } + + /** + * @return asc or desc. Return the companies in ascending or descending order. Defaults to desc + */ + @JsonProperty("order") + public Optional getOrder() { + return order; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListCompaniesRequest && equalTo((ListCompaniesRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListCompaniesRequest other) { + return page.equals(other.page) && perPage.equals(other.perPage) && order.equals(other.order); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.page, this.perPage, this.order); + } + + @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(); + + private Optional order = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ListCompaniesRequest other) { + page(other.getPage()); + perPage(other.getPerPage()); + order(other.getOrder()); + return this; + } + + @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; + } + + @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; + } + + @JsonSetter(value = "order", nulls = Nulls.SKIP) + public Builder order(Optional order) { + this.order = order; + return this; + } + + public Builder order(String order) { + this.order = Optional.ofNullable(order); + return this; + } + + public ListCompaniesRequest build() { + return new ListCompaniesRequest(page, perPage, order, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/companies/requests/ListSegmentsAttachedToCompanyRequest.java b/src/main/java/com/intercom/api/resources/companies/requests/ListSegmentsAttachedToCompanyRequest.java new file mode 100644 index 00000000..491e06d9 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/companies/requests/ListSegmentsAttachedToCompanyRequest.java @@ -0,0 +1,110 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.companies.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 = ListSegmentsAttachedToCompanyRequest.Builder.class) +public final class ListSegmentsAttachedToCompanyRequest { + private final String companyId; + + private final Map additionalProperties; + + private ListSegmentsAttachedToCompanyRequest(String companyId, Map additionalProperties) { + this.companyId = companyId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the company which is given by Intercom + */ + @JsonProperty("company_id") + public String getCompanyId() { + return companyId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListSegmentsAttachedToCompanyRequest + && equalTo((ListSegmentsAttachedToCompanyRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListSegmentsAttachedToCompanyRequest other) { + return companyId.equals(other.companyId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.companyId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static CompanyIdStage builder() { + return new Builder(); + } + + public interface CompanyIdStage { + _FinalStage companyId(@NotNull String companyId); + + Builder from(ListSegmentsAttachedToCompanyRequest other); + } + + public interface _FinalStage { + ListSegmentsAttachedToCompanyRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements CompanyIdStage, _FinalStage { + private String companyId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ListSegmentsAttachedToCompanyRequest other) { + companyId(other.getCompanyId()); + return this; + } + + /** + *

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 + @JsonSetter("company_id") + public _FinalStage companyId(@NotNull String companyId) { + this.companyId = Objects.requireNonNull(companyId, "companyId must not be null"); + return this; + } + + @java.lang.Override + public ListSegmentsAttachedToCompanyRequest build() { + return new ListSegmentsAttachedToCompanyRequest(companyId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/companies/requests/RetrieveCompanyRequest.java b/src/main/java/com/intercom/api/resources/companies/requests/RetrieveCompanyRequest.java new file mode 100644 index 00000000..a4305b43 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/companies/requests/RetrieveCompanyRequest.java @@ -0,0 +1,235 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.companies.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 = RetrieveCompanyRequest.Builder.class) +public final class RetrieveCompanyRequest { + private final Optional name; + + private final Optional companyId; + + private final Optional tagId; + + private final Optional segmentId; + + private final Optional page; + + private final Optional perPage; + + private final Map additionalProperties; + + private RetrieveCompanyRequest( + Optional name, + Optional companyId, + Optional tagId, + Optional segmentId, + Optional page, + Optional perPage, + Map additionalProperties) { + this.name = name; + this.companyId = companyId; + this.tagId = tagId; + this.segmentId = segmentId; + this.page = page; + this.perPage = perPage; + this.additionalProperties = additionalProperties; + } + + /** + * @return The name of the company to filter by. + */ + @JsonProperty("name") + public Optional getName() { + return name; + } + + /** + * @return The company_id of the company to filter by. + */ + @JsonProperty("company_id") + public Optional getCompanyId() { + return companyId; + } + + /** + * @return The tag_id of the company to filter by. + */ + @JsonProperty("tag_id") + public Optional getTagId() { + return tagId; + } + + /** + * @return The segment_id of the company to filter by. + */ + @JsonProperty("segment_id") + public Optional getSegmentId() { + return segmentId; + } + + /** + * @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 15 + */ + @JsonProperty("per_page") + public Optional getPerPage() { + return perPage; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof RetrieveCompanyRequest && equalTo((RetrieveCompanyRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(RetrieveCompanyRequest other) { + return name.equals(other.name) + && companyId.equals(other.companyId) + && tagId.equals(other.tagId) + && segmentId.equals(other.segmentId) + && page.equals(other.page) + && perPage.equals(other.perPage); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.name, this.companyId, this.tagId, this.segmentId, 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 name = Optional.empty(); + + private Optional companyId = Optional.empty(); + + private Optional tagId = Optional.empty(); + + private Optional segmentId = Optional.empty(); + + private Optional page = Optional.empty(); + + private Optional perPage = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(RetrieveCompanyRequest other) { + name(other.getName()); + companyId(other.getCompanyId()); + tagId(other.getTagId()); + segmentId(other.getSegmentId()); + page(other.getPage()); + perPage(other.getPerPage()); + 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 = "company_id", nulls = Nulls.SKIP) + public Builder companyId(Optional companyId) { + this.companyId = companyId; + return this; + } + + public Builder companyId(String companyId) { + this.companyId = Optional.ofNullable(companyId); + return this; + } + + @JsonSetter(value = "tag_id", nulls = Nulls.SKIP) + public Builder tagId(Optional tagId) { + this.tagId = tagId; + return this; + } + + public Builder tagId(String tagId) { + this.tagId = Optional.ofNullable(tagId); + return this; + } + + @JsonSetter(value = "segment_id", nulls = Nulls.SKIP) + public Builder segmentId(Optional segmentId) { + this.segmentId = segmentId; + return this; + } + + public Builder segmentId(String segmentId) { + this.segmentId = Optional.ofNullable(segmentId); + return this; + } + + @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; + } + + @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 RetrieveCompanyRequest build() { + return new RetrieveCompanyRequest(name, companyId, tagId, segmentId, page, perPage, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/companies/requests/ScrollCompaniesRequest.java b/src/main/java/com/intercom/api/resources/companies/requests/ScrollCompaniesRequest.java new file mode 100644 index 00000000..3a5af942 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/companies/requests/ScrollCompaniesRequest.java @@ -0,0 +1,98 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.companies.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 = ScrollCompaniesRequest.Builder.class) +public final class ScrollCompaniesRequest { + private final Optional scrollParam; + + private final Map additionalProperties; + + private ScrollCompaniesRequest(Optional scrollParam, Map additionalProperties) { + this.scrollParam = scrollParam; + this.additionalProperties = additionalProperties; + } + + /** + * @return + */ + @JsonProperty("scroll_param") + public Optional getScrollParam() { + return scrollParam; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ScrollCompaniesRequest && equalTo((ScrollCompaniesRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ScrollCompaniesRequest other) { + return scrollParam.equals(other.scrollParam); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.scrollParam); + } + + @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 scrollParam = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ScrollCompaniesRequest other) { + scrollParam(other.getScrollParam()); + return this; + } + + @JsonSetter(value = "scroll_param", nulls = Nulls.SKIP) + public Builder scrollParam(Optional scrollParam) { + this.scrollParam = scrollParam; + return this; + } + + public Builder scrollParam(String scrollParam) { + this.scrollParam = Optional.ofNullable(scrollParam); + return this; + } + + public ScrollCompaniesRequest build() { + return new ScrollCompaniesRequest(scrollParam, 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 new file mode 100644 index 00000000..5df445f5 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/companies/requests/UpdateCompanyRequest.java @@ -0,0 +1,109 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.companies.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 = UpdateCompanyRequest.Builder.class) +public final class UpdateCompanyRequest { + private final String companyId; + + private final Map additionalProperties; + + private UpdateCompanyRequest(String companyId, Map additionalProperties) { + this.companyId = companyId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the company which is given by Intercom + */ + @JsonProperty("company_id") + public String getCompanyId() { + return companyId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UpdateCompanyRequest && equalTo((UpdateCompanyRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UpdateCompanyRequest other) { + return companyId.equals(other.companyId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.companyId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static CompanyIdStage builder() { + return new Builder(); + } + + public interface CompanyIdStage { + _FinalStage companyId(@NotNull String companyId); + + Builder from(UpdateCompanyRequest other); + } + + public interface _FinalStage { + UpdateCompanyRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements CompanyIdStage, _FinalStage { + private String companyId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(UpdateCompanyRequest other) { + companyId(other.getCompanyId()); + return this; + } + + /** + *

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 + @JsonSetter("company_id") + public _FinalStage companyId(@NotNull String companyId) { + this.companyId = Objects.requireNonNull(companyId, "companyId must not be null"); + return this; + } + + @java.lang.Override + public UpdateCompanyRequest build() { + return new UpdateCompanyRequest(companyId, 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 new file mode 100644 index 00000000..9fc0bde6 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/companies/types/Company.java @@ -0,0 +1,1089 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.companies.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.resources.segments.types.Segment; +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 = Company.Builder.class) +public final class Company { + private final Optional type; + + private final String id; + + private final String name; + + private final String appId; + + private final Optional plan; + + private final String companyId; + + private final int remoteCreatedAt; + + private final int createdAt; + + private final int updatedAt; + + private final int lastRequestAt; + + private final int size; + + private final String website; + + private final String industry; + + private final int monthlySpend; + + private final int sessionCount; + + private final int userCount; + + private final Optional> customAttributes; + + private final Optional tags; + + private final Optional segments; + + private final Map additionalProperties; + + private Company( + Optional type, + String id, + String name, + String appId, + Optional plan, + String companyId, + int remoteCreatedAt, + int createdAt, + int updatedAt, + int lastRequestAt, + int size, + String website, + String industry, + int monthlySpend, + int sessionCount, + int userCount, + Optional> customAttributes, + Optional tags, + Optional segments, + Map additionalProperties) { + this.type = type; + this.id = id; + this.name = name; + this.appId = appId; + this.plan = plan; + this.companyId = companyId; + this.remoteCreatedAt = remoteCreatedAt; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.lastRequestAt = lastRequestAt; + this.size = size; + this.website = website; + this.industry = industry; + this.monthlySpend = monthlySpend; + this.sessionCount = sessionCount; + this.userCount = userCount; + this.customAttributes = customAttributes; + this.tags = tags; + this.segments = segments; + this.additionalProperties = additionalProperties; + } + + /** + * @return Value is company + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return The Intercom defined id representing the company. + */ + @JsonProperty("id") + public String getId() { + return id; + } + + /** + * @return The name of the company. + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * @return The Intercom defined code of the workspace the company is associated to. + */ + @JsonProperty("app_id") + public String getAppId() { + return appId; + } + + @JsonProperty("plan") + public Optional getPlan() { + return plan; + } + + /** + * @return The company id you have defined for the company. + */ + @JsonProperty("company_id") + public String getCompanyId() { + return companyId; + } + + /** + * @return The time the company was created by you. + */ + @JsonProperty("remote_created_at") + public int getRemoteCreatedAt() { + return remoteCreatedAt; + } + + /** + * @return The time the company was added in Intercom. + */ + @JsonProperty("created_at") + public int getCreatedAt() { + return createdAt; + } + + /** + * @return The last time the company was updated. + */ + @JsonProperty("updated_at") + public int getUpdatedAt() { + return updatedAt; + } + + /** + * @return The time the company last recorded making a request. + */ + @JsonProperty("last_request_at") + public int getLastRequestAt() { + return lastRequestAt; + } + + /** + * @return The number of employees in the company. + */ + @JsonProperty("size") + public int getSize() { + return size; + } + + /** + * @return The URL for the company website. + */ + @JsonProperty("website") + public String getWebsite() { + return website; + } + + /** + * @return The industry that the company operates in. + */ + @JsonProperty("industry") + public String getIndustry() { + return industry; + } + + /** + * @return How much revenue the company generates for your business. + */ + @JsonProperty("monthly_spend") + public int getMonthlySpend() { + return monthlySpend; + } + + /** + * @return How many sessions the company has recorded. + */ + @JsonProperty("session_count") + public int getSessionCount() { + return sessionCount; + } + + /** + * @return The number of users in the company. + */ + @JsonProperty("user_count") + public int getUserCount() { + return userCount; + } + + /** + * @return The custom attributes you have set on the company. + */ + @JsonProperty("custom_attributes") + public Optional> getCustomAttributes() { + return customAttributes; + } + + /** + * @return The list of tags associated with the company + */ + @JsonProperty("tags") + public Optional getTags() { + return tags; + } + + /** + * @return The list of segments associated with the company + */ + @JsonProperty("segments") + public Optional getSegments() { + return segments; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Company && equalTo((Company) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Company other) { + return type.equals(other.type) + && id.equals(other.id) + && name.equals(other.name) + && appId.equals(other.appId) + && plan.equals(other.plan) + && companyId.equals(other.companyId) + && remoteCreatedAt == other.remoteCreatedAt + && createdAt == other.createdAt + && updatedAt == other.updatedAt + && lastRequestAt == other.lastRequestAt + && size == other.size + && website.equals(other.website) + && industry.equals(other.industry) + && monthlySpend == other.monthlySpend + && sessionCount == other.sessionCount + && userCount == other.userCount + && customAttributes.equals(other.customAttributes) + && tags.equals(other.tags) + && segments.equals(other.segments); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.type, + this.id, + this.name, + this.appId, + this.plan, + this.companyId, + this.remoteCreatedAt, + this.createdAt, + this.updatedAt, + this.lastRequestAt, + this.size, + this.website, + this.industry, + this.monthlySpend, + this.sessionCount, + this.userCount, + this.customAttributes, + this.tags, + this.segments); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + NameStage id(@NotNull String id); + + Builder from(Company other); + } + + public interface NameStage { + AppIdStage name(@NotNull String name); + } + + public interface AppIdStage { + CompanyIdStage appId(@NotNull String appId); + } + + public interface CompanyIdStage { + RemoteCreatedAtStage companyId(@NotNull String companyId); + } + + public interface RemoteCreatedAtStage { + CreatedAtStage remoteCreatedAt(int remoteCreatedAt); + } + + public interface CreatedAtStage { + UpdatedAtStage createdAt(int createdAt); + } + + public interface UpdatedAtStage { + LastRequestAtStage updatedAt(int updatedAt); + } + + public interface LastRequestAtStage { + SizeStage lastRequestAt(int lastRequestAt); + } + + public interface SizeStage { + WebsiteStage size(int size); + } + + public interface WebsiteStage { + IndustryStage website(@NotNull String website); + } + + public interface IndustryStage { + MonthlySpendStage industry(@NotNull String industry); + } + + public interface MonthlySpendStage { + SessionCountStage monthlySpend(int monthlySpend); + } + + public interface SessionCountStage { + UserCountStage sessionCount(int sessionCount); + } + + public interface UserCountStage { + _FinalStage userCount(int userCount); + } + + public interface _FinalStage { + Company build(); + + _FinalStage type(Optional type); + + _FinalStage type(String type); + + _FinalStage plan(Optional plan); + + _FinalStage plan(Plan plan); + + _FinalStage customAttributes(Optional> customAttributes); + + _FinalStage customAttributes(Map customAttributes); + + _FinalStage tags(Optional tags); + + _FinalStage tags(Tags tags); + + _FinalStage segments(Optional segments); + + _FinalStage segments(Segments segments); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements IdStage, + NameStage, + AppIdStage, + CompanyIdStage, + RemoteCreatedAtStage, + CreatedAtStage, + UpdatedAtStage, + LastRequestAtStage, + SizeStage, + WebsiteStage, + IndustryStage, + MonthlySpendStage, + SessionCountStage, + UserCountStage, + _FinalStage { + private String id; + + private String name; + + private String appId; + + 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; + + private int userCount; + + private Optional segments = Optional.empty(); + + private Optional tags = Optional.empty(); + + private Optional> customAttributes = Optional.empty(); + + private Optional plan = Optional.empty(); + + private Optional type = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(Company other) { + type(other.getType()); + id(other.getId()); + name(other.getName()); + appId(other.getAppId()); + plan(other.getPlan()); + companyId(other.getCompanyId()); + remoteCreatedAt(other.getRemoteCreatedAt()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + lastRequestAt(other.getLastRequestAt()); + size(other.getSize()); + website(other.getWebsite()); + industry(other.getIndustry()); + monthlySpend(other.getMonthlySpend()); + sessionCount(other.getSessionCount()); + userCount(other.getUserCount()); + customAttributes(other.getCustomAttributes()); + tags(other.getTags()); + segments(other.getSegments()); + return this; + } + + /** + *

The Intercom defined id representing the company.

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

The name of the company.

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

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 CompanyIdStage appId(@NotNull String appId) { + this.appId = Objects.requireNonNull(appId, "appId must not be null"); + return this; + } + + /** + *

The company id you have defined for the company.

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

The time the company was added in Intercom.

+ * @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 last time the company was updated.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("updated_at") + public LastRequestAtStage updatedAt(int updatedAt) { + this.updatedAt = updatedAt; + 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 + @JsonSetter("last_request_at") + public SizeStage lastRequestAt(int lastRequestAt) { + this.lastRequestAt = lastRequestAt; + 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 + @JsonSetter("size") + public WebsiteStage size(int size) { + this.size = size; + return this; + } + + /** + *

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.

+ * @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.

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

How many sessions the company has recorded.

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

The number of users in the company.

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

The list of segments associated with the company

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage segments(Segments segments) { + this.segments = Optional.ofNullable(segments); + return this; + } + + @java.lang.Override + @JsonSetter(value = "segments", nulls = Nulls.SKIP) + public _FinalStage segments(Optional segments) { + this.segments = segments; + return this; + } + + /** + *

The list of tags associated with the company

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage tags(Tags 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; + return this; + } + + /** + *

The custom attributes you have set on the company.

+ * @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; + } + + @java.lang.Override + @JsonSetter(value = "custom_attributes", nulls = Nulls.SKIP) + public _FinalStage customAttributes(Optional> customAttributes) { + this.customAttributes = customAttributes; + return this; + } + + @java.lang.Override + public _FinalStage plan(Plan plan) { + this.plan = Optional.ofNullable(plan); + return this; + } + + @java.lang.Override + @JsonSetter(value = "plan", nulls = Nulls.SKIP) + public _FinalStage plan(Optional plan) { + this.plan = plan; + return this; + } + + /** + *

Value is company

+ * @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; + } + + @java.lang.Override + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public _FinalStage type(Optional type) { + this.type = type; + return this; + } + + @java.lang.Override + public Company build() { + return new Company( + type, + id, + name, + appId, + plan, + companyId, + remoteCreatedAt, + createdAt, + updatedAt, + lastRequestAt, + size, + website, + industry, + monthlySpend, + sessionCount, + userCount, + customAttributes, + tags, + segments, + additionalProperties); + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = Tags.Builder.class) + public static final class Tags { + private final Optional type; + + private final Optional> tags; + + private final Map additionalProperties; + + private Tags(Optional type, Optional> tags, Map additionalProperties) { + this.type = type; + this.tags = tags; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of the object + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + @JsonProperty("tags") + public Optional> getTags() { + return tags; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Tags && equalTo((Tags) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Tags other) { + return type.equals(other.type) && tags.equals(other.tags); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.tags); + } + + @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> tags = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(Tags other) { + type(other.getType()); + tags(other.getTags()); + 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 = "tags", nulls = Nulls.SKIP) + public Builder tags(Optional> tags) { + this.tags = tags; + return this; + } + + public Builder tags(List tags) { + this.tags = Optional.ofNullable(tags); + return this; + } + + public Tags build() { + return new Tags(type, tags, additionalProperties); + } + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = Segments.Builder.class) + public static final class Segments { + private final Optional type; + + private final Optional> segments; + + private final Map additionalProperties; + + private Segments( + Optional type, Optional> segments, Map additionalProperties) { + this.type = type; + this.segments = segments; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of the object + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + @JsonProperty("segments") + public Optional> getSegments() { + return segments; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Segments && equalTo((Segments) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Segments other) { + return type.equals(other.type) && segments.equals(other.segments); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.segments); + } + + @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> segments = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(Segments other) { + type(other.getType()); + segments(other.getSegments()); + 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 = "segments", nulls = Nulls.SKIP) + public Builder segments(Optional> segments) { + this.segments = segments; + return this; + } + + public Builder segments(List segments) { + this.segments = Optional.ofNullable(segments); + return this; + } + + public Segments build() { + return new Segments(type, segments, additionalProperties); + } + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = Plan.Builder.class) + public static final class Plan { + private final Optional type; + + private final Optional id; + + private final Optional name; + + private final Map additionalProperties; + + private Plan( + Optional type, + Optional id, + Optional name, + Map additionalProperties) { + this.type = type; + this.id = id; + this.name = name; + this.additionalProperties = additionalProperties; + } + + /** + * @return Value is always "plan" + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return The id of the plan + */ + @JsonProperty("id") + public Optional getId() { + return id; + } + + /** + * @return The name of the plan + */ + @JsonProperty("name") + public Optional getName() { + return name; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Plan && equalTo((Plan) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Plan other) { + return type.equals(other.type) && id.equals(other.id) && name.equals(other.name); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, 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 type = Optional.empty(); + + private Optional id = Optional.empty(); + + private Optional name = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(Plan other) { + type(other.getType()); + id(other.getId()); + name(other.getName()); + 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 = "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 Plan build() { + return new Plan(type, id, name, additionalProperties); + } + } + } +} diff --git a/src/main/java/com/intercom/api/resources/contacts/AsyncContactsClient.java b/src/main/java/com/intercom/api/resources/contacts/AsyncContactsClient.java new file mode 100644 index 00000000..9d09d5f3 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/contacts/AsyncContactsClient.java @@ -0,0 +1,1371 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.contacts; + +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.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.QueryStringMapper; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.core.pagination.SyncPagingIterable; +import com.intercom.api.errors.NotFoundError; +import com.intercom.api.errors.UnauthorizedError; +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.DeleteContactRequest; +import com.intercom.api.resources.contacts.requests.DetachSubscriptionFromContactRequest; +import com.intercom.api.resources.contacts.requests.FindContactRequest; +import com.intercom.api.resources.contacts.requests.ListAttachedCompaniesRequest; +import com.intercom.api.resources.contacts.requests.ListAttachedSubscriptionsRequest; +import com.intercom.api.resources.contacts.requests.ListContactsRequest; +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.UnarchiveContactRequest; +import com.intercom.api.resources.contacts.requests.UpdateContactRequest; +import com.intercom.api.resources.contacts.types.Contact; +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.ContactDeleted; +import com.intercom.api.types.ContactList; +import com.intercom.api.types.ContactSegments; +import com.intercom.api.types.ContactUnarchived; +import com.intercom.api.types.CreateContactRequest; +import com.intercom.api.types.CursorPages; +import com.intercom.api.types.Error; +import com.intercom.api.types.SearchRequest; +import com.intercom.api.types.StartingAfterPaging; +import com.intercom.api.types.SubscriptionTypeList; +import com.intercom.api.types.TagList; +import java.io.IOException; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; +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 AsyncContactsClient { + protected final ClientOptions clientOptions; + + public AsyncContactsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can fetch a list of companies that are associated to a contact. + */ + public CompletableFuture> listAttachedCompanies(ListAttachedCompaniesRequest request) { + return listAttachedCompanies(request, null); + } + + /** + * You can fetch a list of companies that are associated to a contact. + */ + public CompletableFuture> listAttachedCompanies( + ListAttachedCompaniesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getContactId()) + .addPathSegments("companies"); + 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()) { + ContactAttachedCompanies parsedResponse = ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ContactAttachedCompanies.class); + int newPageNumber = + request.getPage().map(page -> page + 1).orElse(1); + ListAttachedCompaniesRequest nextRequest = ListAttachedCompaniesRequest.builder() + .from(request) + .page(newPageNumber) + .build(); + List result = parsedResponse.getCompanies(); + future.complete(new SyncPagingIterable(true, result, () -> { + try { + return listAttachedCompanies(nextRequest, requestOptions) + .get(); + } catch (InterruptedException | ExecutionException e) { + throw new RuntimeException(e); + } + })); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + 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))); + 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 a list of segments that are associated to a contact. + */ + public CompletableFuture listAttachedSegments(ListSegmentsAttachedToContactRequest request) { + return listAttachedSegments(request, null); + } + + /** + * You can fetch a list of segments that are associated to a contact. + */ + public CompletableFuture listAttachedSegments( + ListSegmentsAttachedToContactRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getContactId()) + .addPathSegments("segments") + .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( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ContactSegments.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + 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))); + 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 a list of subscription types that are attached to a contact. These can be subscriptions that a user has 'opted-in' to or has 'opted-out' from, depending on the subscription type. + * This will return a list of Subscription Type objects that the contact is associated with. + *

The data property will show a combined list of:

+ *

1.Opt-out subscription types that the user has opted-out from. + * 2.Opt-in subscription types that the user has opted-in to receiving.

+ */ + public CompletableFuture listAttachedSubscriptions(ListAttachedSubscriptionsRequest request) { + return listAttachedSubscriptions(request, null); + } + + /** + * You can fetch a list of subscription types that are attached to a contact. These can be subscriptions that a user has 'opted-in' to or has 'opted-out' from, depending on the subscription type. + * This will return a list of Subscription Type objects that the contact is associated with. + *

The data property will show a combined list of:

+ *

1.Opt-out subscription types that the user has opted-out from. + * 2.Opt-in subscription types that the user has opted-in to receiving.

+ */ + public CompletableFuture listAttachedSubscriptions( + ListAttachedSubscriptionsRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getContactId()) + .addPathSegments("subscriptions") + .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( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SubscriptionTypeList.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + 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))); + 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 a specific subscription to a contact. In Intercom, we have two different subscription types based on user consent - opt-out and opt-in: + *

1.Attaching a contact to an opt-out subscription type will opt that user out from receiving messages related to that subscription type.

+ *

2.Attaching a contact to an opt-in subscription type will opt that user in to receiving messages related to that subscription type.

+ *

This will return a subscription type model for the subscription type that was added to the contact.

+ */ + public CompletableFuture attachSubscription(AttachSubscriptionToContactRequest request) { + return attachSubscription(request, null); + } + + /** + * You can add a specific subscription to a contact. In Intercom, we have two different subscription types based on user consent - opt-out and opt-in: + *

1.Attaching a contact to an opt-out subscription type will opt that user out from receiving messages related to that subscription type.

+ *

2.Attaching a contact to an opt-in subscription type will opt that user in to receiving messages related to that subscription type.

+ *

This will return a subscription type model for the subscription type that was added to the contact.

+ */ + public CompletableFuture attachSubscription( + AttachSubscriptionToContactRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getContactId()) + .addPathSegments("subscriptions") + .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( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SubscriptionType.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + 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))); + 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 remove a specific subscription from a contact. This will return a subscription type model for the subscription type that was removed from the contact. + */ + public CompletableFuture detachSubscription(DetachSubscriptionFromContactRequest request) { + return detachSubscription(request, null); + } + + /** + * You can remove a specific subscription from a contact. This will return a subscription type model for the subscription type that was removed from the contact. + */ + public CompletableFuture detachSubscription( + DetachSubscriptionFromContactRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getContactId()) + .addPathSegments("subscriptions") + .addPathSegment(request.getSubscriptionId()) + .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( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SubscriptionType.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + 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))); + 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 a list of all tags that are attached to a specific contact. + */ + public CompletableFuture listAttachedTags(ListTagsAttachedToContactRequest request) { + return listAttachedTags(request, null); + } + + /** + * You can fetch a list of all tags that are attached to a specific contact. + */ + public CompletableFuture listAttachedTags( + ListTagsAttachedToContactRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getContactId()) + .addPathSegments("tags") + .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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TagList.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + 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))); + 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. + */ + public CompletableFuture find(FindContactRequest request) { + return find(request, null); + } + + /** + * You can fetch the details of a single contact. + */ + public CompletableFuture find(FindContactRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getContactId()) + .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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Contact.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + 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))); + 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 contact (ie. user or lead). + */ + public CompletableFuture update(UpdateContactRequest request) { + return update(request, null); + } + + /** + * You can update an existing contact (ie. user or lead). + */ + public CompletableFuture update(UpdateContactRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getContactId()) + .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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Contact.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + 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))); + 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 contact. + */ + public CompletableFuture delete(DeleteContactRequest request) { + return delete(request, null); + } + + /** + * You can delete a single contact. + */ + public CompletableFuture delete(DeleteContactRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getContactId()) + .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( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ContactDeleted.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + 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))); + 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 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(MergeContactsRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts/merge") + .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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Contact.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + 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))); + 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 contacts by the value of their attributes in order to fetch exactly who you want. + *

To search for contacts, you need to send a POST request to https://api.intercom.io/contacts/search.

+ *

This will accept a query object in the body which will define your filters in order to search for contacts.

+ *

{% admonition type="warning" name="Optimizing search queries" %} + * Search queries can be complex, so optimizing them can help the performance of your search. + * Use the AND and OR operators to combine multiple filters to get the exact results you need and utilize + * pagination to limit the number of results returned. The default is 50 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ *

Contact Creation Delay

+ *

If a contact has recently been created, there is a possibility that it will not yet be available when searching. This means that it may not appear in the response. This delay can take a few minutes. If you need to be instantly notified it is recommended to use webhooks and iterate to see if they match your search filters.

+ *

Nesting & Limitations

+ *

You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). + * There are some limitations to the amount of multiple's there can be:

+ *
    + *
  • There's a limit of max 2 nested filters
  • + *
  • There's a limit of max 15 filters for each AND or OR group
  • + *
+ *

Searching for Timestamp Fields

+ *

All timestamp fields (created_at, updated_at etc.) are indexed as Dates for Contact Search queries; Datetime queries are not currently supported. This means you can only query for timestamp fields by day - not hour, minute or second. + * For example, if you search for all Contacts with a created_at value greater (>) than 1577869200 (the UNIX timestamp for January 1st, 2020 9:00 AM), that will be interpreted as 1577836800 (January 1st, 2020 12:00 AM). The search results will then include Contacts created from January 2nd, 2020 12:00 AM onwards. + * If you'd like to get contacts created on January 1st, 2020 you should search with a created_at value equal (=) to 1577836800 (January 1st, 2020 12:00 AM). + * This behaviour applies only to timestamps used in search queries. The search results will still contain the full UNIX timestamp and be sorted accordingly.

+ *

Accepted Fields

+ *

Most key listed as part of the Contacts Model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as created_at accepts a date, the value cannot be a string such as "foorbar").

+ *

| Field | Type | + * | ---------------------------------- | ------------------------------ | + * | id | String | + * | role | String<br>Accepts user or lead | + * | name | String | + * | avatar | String | + * | owner_id | Integer | + * | email | String | + * | email_domain | String | + * | phone | String | + * | external_id | String | + * | created_at | Date (UNIX Timestamp) | + * | signed_up_at | Date (UNIX Timestamp) | + * | updated_at | Date (UNIX Timestamp) | + * | last_seen_at | Date (UNIX Timestamp) | + * | last_contacted_at | Date (UNIX Timestamp) | + * | last_replied_at | Date (UNIX Timestamp) | + * | last_email_opened_at | Date (UNIX Timestamp) | + * | last_email_clicked_at | Date (UNIX Timestamp) | + * | language_override | String | + * | browser | String | + * | browser_language | String | + * | os | String | + * | location.country | String | + * | location.region | String | + * | location.city | String | + * | unsubscribed_from_emails | Boolean | + * | marked_email_as_spam | Boolean | + * | has_hard_bounced | Boolean | + * | ios_last_seen_at | Date (UNIX Timestamp) | + * | ios_app_version | String | + * | ios_device | String | + * | ios_app_device | String | + * | ios_os_version | String | + * | ios_app_name | String | + * | ios_sdk_version | String | + * | android_last_seen_at | Date (UNIX Timestamp) | + * | android_app_version | String | + * | android_device | String | + * | android_app_name | String | + * | andoid_sdk_version | String | + * | segment_id | String | + * | tag_id | String | + * | custom_attributes.{attribute_name} | String |

+ *

Accepted Operators

+ *

{% admonition type="warning" name="Searching based on created_at" %} + * You cannot use the <= or >= operators to search by created_at. + * {% /admonition %}

+ *

The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string ("="). The operator has to be compatible with the field's type (eg. you cannot search with > for a given string value as it's only compatible for integer's and dates).

+ *

| Operator | Valid Types | Description | + * | :------- | :------------------------------- | :--------------------------------------------------------------- | + * | = | All | Equals | + * | != | All | Doesn't Equal | + * | IN | All | In<br>Shortcut for OR queries<br>Values must be in Array | + * | NIN | All | Not In<br>Shortcut for OR ! queries<br>Values must be in Array | + * | > | Integer<br>Date (UNIX Timestamp) | Greater than | + * | < | Integer<br>Date (UNIX Timestamp) | Lower than | + * | ~ | String | Contains | + * | !~ | String | Doesn't Contain | + * | ^ | String | Starts With | + * | $ | String | Ends With |

+ */ + public CompletableFuture> search(SearchRequest request) { + return search(request, null); + } + + /** + * You can search for multiple contacts by the value of their attributes in order to fetch exactly who you want. + *

To search for contacts, you need to send a POST request to https://api.intercom.io/contacts/search.

+ *

This will accept a query object in the body which will define your filters in order to search for contacts.

+ *

{% admonition type="warning" name="Optimizing search queries" %} + * Search queries can be complex, so optimizing them can help the performance of your search. + * Use the AND and OR operators to combine multiple filters to get the exact results you need and utilize + * pagination to limit the number of results returned. The default is 50 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ *

Contact Creation Delay

+ *

If a contact has recently been created, there is a possibility that it will not yet be available when searching. This means that it may not appear in the response. This delay can take a few minutes. If you need to be instantly notified it is recommended to use webhooks and iterate to see if they match your search filters.

+ *

Nesting & Limitations

+ *

You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). + * There are some limitations to the amount of multiple's there can be:

+ *
    + *
  • There's a limit of max 2 nested filters
  • + *
  • There's a limit of max 15 filters for each AND or OR group
  • + *
+ *

Searching for Timestamp Fields

+ *

All timestamp fields (created_at, updated_at etc.) are indexed as Dates for Contact Search queries; Datetime queries are not currently supported. This means you can only query for timestamp fields by day - not hour, minute or second. + * For example, if you search for all Contacts with a created_at value greater (>) than 1577869200 (the UNIX timestamp for January 1st, 2020 9:00 AM), that will be interpreted as 1577836800 (January 1st, 2020 12:00 AM). The search results will then include Contacts created from January 2nd, 2020 12:00 AM onwards. + * If you'd like to get contacts created on January 1st, 2020 you should search with a created_at value equal (=) to 1577836800 (January 1st, 2020 12:00 AM). + * This behaviour applies only to timestamps used in search queries. The search results will still contain the full UNIX timestamp and be sorted accordingly.

+ *

Accepted Fields

+ *

Most key listed as part of the Contacts Model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as created_at accepts a date, the value cannot be a string such as "foorbar").

+ *

| Field | Type | + * | ---------------------------------- | ------------------------------ | + * | id | String | + * | role | String<br>Accepts user or lead | + * | name | String | + * | avatar | String | + * | owner_id | Integer | + * | email | String | + * | email_domain | String | + * | phone | String | + * | external_id | String | + * | created_at | Date (UNIX Timestamp) | + * | signed_up_at | Date (UNIX Timestamp) | + * | updated_at | Date (UNIX Timestamp) | + * | last_seen_at | Date (UNIX Timestamp) | + * | last_contacted_at | Date (UNIX Timestamp) | + * | last_replied_at | Date (UNIX Timestamp) | + * | last_email_opened_at | Date (UNIX Timestamp) | + * | last_email_clicked_at | Date (UNIX Timestamp) | + * | language_override | String | + * | browser | String | + * | browser_language | String | + * | os | String | + * | location.country | String | + * | location.region | String | + * | location.city | String | + * | unsubscribed_from_emails | Boolean | + * | marked_email_as_spam | Boolean | + * | has_hard_bounced | Boolean | + * | ios_last_seen_at | Date (UNIX Timestamp) | + * | ios_app_version | String | + * | ios_device | String | + * | ios_app_device | String | + * | ios_os_version | String | + * | ios_app_name | String | + * | ios_sdk_version | String | + * | android_last_seen_at | Date (UNIX Timestamp) | + * | android_app_version | String | + * | android_device | String | + * | android_app_name | String | + * | andoid_sdk_version | String | + * | segment_id | String | + * | tag_id | String | + * | custom_attributes.{attribute_name} | String |

+ *

Accepted Operators

+ *

{% admonition type="warning" name="Searching based on created_at" %} + * You cannot use the <= or >= operators to search by created_at. + * {% /admonition %}

+ *

The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string ("="). The operator has to be compatible with the field's type (eg. you cannot search with > for a given string value as it's only compatible for integer's and dates).

+ *

| Operator | Valid Types | Description | + * | :------- | :------------------------------- | :--------------------------------------------------------------- | + * | = | All | Equals | + * | != | All | Doesn't Equal | + * | IN | All | In<br>Shortcut for OR queries<br>Values must be in Array | + * | NIN | All | Not In<br>Shortcut for OR ! queries<br>Values must be in Array | + * | > | Integer<br>Date (UNIX Timestamp) | Greater than | + * | < | Integer<br>Date (UNIX Timestamp) | Lower than | + * | ~ | String | Contains | + * | !~ | String | Doesn't Contain | + * | ^ | String | Starts With | + * | $ | String | Ends With |

+ */ + public CompletableFuture> search(SearchRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts/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()) { + ContactList parsedResponse = + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ContactList.class); + Optional startingAfter = parsedResponse + .getPages() + .flatMap(CursorPages::getNext) + .flatMap(StartingAfterPaging::getStartingAfter); + Optional pagination = request.getPagination() + .map(pagination_ -> StartingAfterPaging.builder() + .from(pagination_) + .startingAfter(startingAfter) + .build()); + SearchRequest nextRequest = SearchRequest.builder() + .from(request) + .pagination(pagination) + .build(); + List result = parsedResponse.getData(); + future.complete(new SyncPagingIterable(startingAfter.isPresent(), result, () -> { + try { + return search(nextRequest, requestOptions).get(); + } catch (InterruptedException | ExecutionException e) { + throw new RuntimeException(e); + } + })); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + 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))); + 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 a list of all contacts (ie. users or leads) in your workspace. + * {% admonition type="warning" name="Pagination" %} + * You can use pagination to limit the number of results returned. The default is 50 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %} + */ + public CompletableFuture> list() { + return list(ListContactsRequest.builder().build()); + } + + /** + * You can fetch a list of all contacts (ie. users or leads) in your workspace. + * {% admonition type="warning" name="Pagination" %} + * You can use pagination to limit the number of results returned. The default is 50 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %} + */ + public CompletableFuture> list(ListContactsRequest request) { + return list(request, null); + } + + /** + * You can fetch a list of all contacts (ie. users or leads) in your workspace. + * {% admonition type="warning" name="Pagination" %} + * You can use pagination to limit the number of results returned. The default is 50 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %} + */ + public CompletableFuture> list( + ListContactsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .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); + } + if (request.getStartingAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "starting_after", request.getStartingAfter().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()) { + ContactList parsedResponse = + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ContactList.class); + Optional startingAfter = parsedResponse + .getPages() + .flatMap(CursorPages::getNext) + .flatMap(StartingAfterPaging::getStartingAfter); + ListContactsRequest nextRequest = ListContactsRequest.builder() + .from(request) + .startingAfter(startingAfter) + .build(); + List result = parsedResponse.getData(); + future.complete(new SyncPagingIterable(startingAfter.isPresent(), result, () -> { + try { + return list(nextRequest, requestOptions).get(); + } catch (InterruptedException | ExecutionException e) { + throw new RuntimeException(e); + } + })); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + 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))); + 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 contact (ie. user or lead). + */ + public CompletableFuture create(CreateContactRequest request) { + return create(request, null); + } + + /** + * You can create a new contact (ie. user or lead). + */ + public CompletableFuture create(CreateContactRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Contact.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + 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))); + 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 archive a single contact. + */ + public CompletableFuture archive(ArchiveContactRequest request) { + return archive(request, null); + } + + /** + * You can archive a single contact. + */ + public CompletableFuture archive(ArchiveContactRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getContactId()) + .addPathSegments("archive") + .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( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ContactArchived.class)); + 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))); + 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 unarchive a single contact. + */ + public CompletableFuture unarchive(UnarchiveContactRequest request) { + return unarchive(request, null); + } + + /** + * You can unarchive a single contact. + */ + public CompletableFuture unarchive( + UnarchiveContactRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getContactId()) + .addPathSegments("unarchive") + .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( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ContactUnarchived.class)); + 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))); + 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 new file mode 100644 index 00000000..dcf93cf4 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/contacts/ContactsClient.java @@ -0,0 +1,1112 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.contacts; + +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.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.QueryStringMapper; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.core.pagination.SyncPagingIterable; +import com.intercom.api.errors.NotFoundError; +import com.intercom.api.errors.UnauthorizedError; +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.DeleteContactRequest; +import com.intercom.api.resources.contacts.requests.DetachSubscriptionFromContactRequest; +import com.intercom.api.resources.contacts.requests.FindContactRequest; +import com.intercom.api.resources.contacts.requests.ListAttachedCompaniesRequest; +import com.intercom.api.resources.contacts.requests.ListAttachedSubscriptionsRequest; +import com.intercom.api.resources.contacts.requests.ListContactsRequest; +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.UnarchiveContactRequest; +import com.intercom.api.resources.contacts.requests.UpdateContactRequest; +import com.intercom.api.resources.contacts.types.Contact; +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.ContactDeleted; +import com.intercom.api.types.ContactList; +import com.intercom.api.types.ContactSegments; +import com.intercom.api.types.ContactUnarchived; +import com.intercom.api.types.CreateContactRequest; +import com.intercom.api.types.CursorPages; +import com.intercom.api.types.Error; +import com.intercom.api.types.SearchRequest; +import com.intercom.api.types.StartingAfterPaging; +import com.intercom.api.types.SubscriptionTypeList; +import com.intercom.api.types.TagList; +import java.io.IOException; +import java.util.List; +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 ContactsClient { + protected final ClientOptions clientOptions; + + public ContactsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can fetch a list of companies that are associated to a contact. + */ + public SyncPagingIterable listAttachedCompanies(ListAttachedCompaniesRequest request) { + return listAttachedCompanies(request, null); + } + + /** + * You can fetch a list of companies that are associated to a contact. + */ + public SyncPagingIterable listAttachedCompanies( + ListAttachedCompaniesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getContactId()) + .addPathSegments("companies"); + 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()) { + ContactAttachedCompanies parsedResponse = + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ContactAttachedCompanies.class); + int newPageNumber = request.getPage().map(page -> page + 1).orElse(1); + ListAttachedCompaniesRequest nextRequest = ListAttachedCompaniesRequest.builder() + .from(request) + .page(newPageNumber) + .build(); + List result = parsedResponse.getCompanies(); + return new SyncPagingIterable( + true, result, () -> listAttachedCompanies(nextRequest, requestOptions)); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can fetch a list of segments that are associated to a contact. + */ + public ContactSegments listAttachedSegments(ListSegmentsAttachedToContactRequest request) { + return listAttachedSegments(request, null); + } + + /** + * You can fetch a list of segments that are associated to a contact. + */ + public ContactSegments listAttachedSegments( + ListSegmentsAttachedToContactRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getContactId()) + .addPathSegments("segments") + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ContactSegments.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can fetch a list of subscription types that are attached to a contact. These can be subscriptions that a user has 'opted-in' to or has 'opted-out' from, depending on the subscription type. + * This will return a list of Subscription Type objects that the contact is associated with. + *

The data property will show a combined list of:

+ *

1.Opt-out subscription types that the user has opted-out from. + * 2.Opt-in subscription types that the user has opted-in to receiving.

+ */ + public SubscriptionTypeList listAttachedSubscriptions(ListAttachedSubscriptionsRequest request) { + return listAttachedSubscriptions(request, null); + } + + /** + * You can fetch a list of subscription types that are attached to a contact. These can be subscriptions that a user has 'opted-in' to or has 'opted-out' from, depending on the subscription type. + * This will return a list of Subscription Type objects that the contact is associated with. + *

The data property will show a combined list of:

+ *

1.Opt-out subscription types that the user has opted-out from. + * 2.Opt-in subscription types that the user has opted-in to receiving.

+ */ + public SubscriptionTypeList listAttachedSubscriptions( + ListAttachedSubscriptionsRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getContactId()) + .addPathSegments("subscriptions") + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SubscriptionTypeList.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can add a specific subscription to a contact. In Intercom, we have two different subscription types based on user consent - opt-out and opt-in: + *

1.Attaching a contact to an opt-out subscription type will opt that user out from receiving messages related to that subscription type.

+ *

2.Attaching a contact to an opt-in subscription type will opt that user in to receiving messages related to that subscription type.

+ *

This will return a subscription type model for the subscription type that was added to the contact.

+ */ + public SubscriptionType attachSubscription(AttachSubscriptionToContactRequest request) { + return attachSubscription(request, null); + } + + /** + * You can add a specific subscription to a contact. In Intercom, we have two different subscription types based on user consent - opt-out and opt-in: + *

1.Attaching a contact to an opt-out subscription type will opt that user out from receiving messages related to that subscription type.

+ *

2.Attaching a contact to an opt-in subscription type will opt that user in to receiving messages related to that subscription type.

+ *

This will return a subscription type model for the subscription type that was added to the contact.

+ */ + public SubscriptionType attachSubscription( + AttachSubscriptionToContactRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getContactId()) + .addPathSegments("subscriptions") + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SubscriptionType.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can remove a specific subscription from a contact. This will return a subscription type model for the subscription type that was removed from the contact. + */ + public SubscriptionType detachSubscription(DetachSubscriptionFromContactRequest request) { + return detachSubscription(request, null); + } + + /** + * You can remove a specific subscription from a contact. This will return a subscription type model for the subscription type that was removed from the contact. + */ + public SubscriptionType detachSubscription( + DetachSubscriptionFromContactRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getContactId()) + .addPathSegments("subscriptions") + .addPathSegment(request.getSubscriptionId()) + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SubscriptionType.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can fetch a list of all tags that are attached to a specific contact. + */ + public TagList listAttachedTags(ListTagsAttachedToContactRequest request) { + return listAttachedTags(request, null); + } + + /** + * You can fetch a list of all tags that are attached to a specific contact. + */ + public TagList listAttachedTags(ListTagsAttachedToContactRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getContactId()) + .addPathSegments("tags") + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TagList.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can fetch the details of a single contact. + */ + public Contact find(FindContactRequest request) { + return find(request, null); + } + + /** + * You can fetch the details of a single contact. + */ + public Contact find(FindContactRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getContactId()) + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Contact.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can update an existing contact (ie. user or lead). + */ + public Contact update(UpdateContactRequest request) { + return update(request, null); + } + + /** + * You can update an existing contact (ie. user or lead). + */ + public Contact update(UpdateContactRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getContactId()) + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Contact.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can delete a single contact. + */ + public ContactDeleted delete(DeleteContactRequest request) { + return delete(request, null); + } + + /** + * You can delete a single contact. + */ + public ContactDeleted delete(DeleteContactRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getContactId()) + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ContactDeleted.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can merge a contact with a role of lead into a contact with a role of user. + */ + public Contact 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 Contact mergeLeadInUser(MergeContactsRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts/merge") + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Contact.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can search for multiple contacts by the value of their attributes in order to fetch exactly who you want. + *

To search for contacts, you need to send a POST request to https://api.intercom.io/contacts/search.

+ *

This will accept a query object in the body which will define your filters in order to search for contacts.

+ *

{% admonition type="warning" name="Optimizing search queries" %} + * Search queries can be complex, so optimizing them can help the performance of your search. + * Use the AND and OR operators to combine multiple filters to get the exact results you need and utilize + * pagination to limit the number of results returned. The default is 50 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ *

Contact Creation Delay

+ *

If a contact has recently been created, there is a possibility that it will not yet be available when searching. This means that it may not appear in the response. This delay can take a few minutes. If you need to be instantly notified it is recommended to use webhooks and iterate to see if they match your search filters.

+ *

Nesting & Limitations

+ *

You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). + * There are some limitations to the amount of multiple's there can be:

+ *
    + *
  • There's a limit of max 2 nested filters
  • + *
  • There's a limit of max 15 filters for each AND or OR group
  • + *
+ *

Searching for Timestamp Fields

+ *

All timestamp fields (created_at, updated_at etc.) are indexed as Dates for Contact Search queries; Datetime queries are not currently supported. This means you can only query for timestamp fields by day - not hour, minute or second. + * For example, if you search for all Contacts with a created_at value greater (>) than 1577869200 (the UNIX timestamp for January 1st, 2020 9:00 AM), that will be interpreted as 1577836800 (January 1st, 2020 12:00 AM). The search results will then include Contacts created from January 2nd, 2020 12:00 AM onwards. + * If you'd like to get contacts created on January 1st, 2020 you should search with a created_at value equal (=) to 1577836800 (January 1st, 2020 12:00 AM). + * This behaviour applies only to timestamps used in search queries. The search results will still contain the full UNIX timestamp and be sorted accordingly.

+ *

Accepted Fields

+ *

Most key listed as part of the Contacts Model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as created_at accepts a date, the value cannot be a string such as "foorbar").

+ *

| Field | Type | + * | ---------------------------------- | ------------------------------ | + * | id | String | + * | role | String<br>Accepts user or lead | + * | name | String | + * | avatar | String | + * | owner_id | Integer | + * | email | String | + * | email_domain | String | + * | phone | String | + * | external_id | String | + * | created_at | Date (UNIX Timestamp) | + * | signed_up_at | Date (UNIX Timestamp) | + * | updated_at | Date (UNIX Timestamp) | + * | last_seen_at | Date (UNIX Timestamp) | + * | last_contacted_at | Date (UNIX Timestamp) | + * | last_replied_at | Date (UNIX Timestamp) | + * | last_email_opened_at | Date (UNIX Timestamp) | + * | last_email_clicked_at | Date (UNIX Timestamp) | + * | language_override | String | + * | browser | String | + * | browser_language | String | + * | os | String | + * | location.country | String | + * | location.region | String | + * | location.city | String | + * | unsubscribed_from_emails | Boolean | + * | marked_email_as_spam | Boolean | + * | has_hard_bounced | Boolean | + * | ios_last_seen_at | Date (UNIX Timestamp) | + * | ios_app_version | String | + * | ios_device | String | + * | ios_app_device | String | + * | ios_os_version | String | + * | ios_app_name | String | + * | ios_sdk_version | String | + * | android_last_seen_at | Date (UNIX Timestamp) | + * | android_app_version | String | + * | android_device | String | + * | android_app_name | String | + * | andoid_sdk_version | String | + * | segment_id | String | + * | tag_id | String | + * | custom_attributes.{attribute_name} | String |

+ *

Accepted Operators

+ *

{% admonition type="warning" name="Searching based on created_at" %} + * You cannot use the <= or >= operators to search by created_at. + * {% /admonition %}

+ *

The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string ("="). The operator has to be compatible with the field's type (eg. you cannot search with > for a given string value as it's only compatible for integer's and dates).

+ *

| Operator | Valid Types | Description | + * | :------- | :------------------------------- | :--------------------------------------------------------------- | + * | = | All | Equals | + * | != | All | Doesn't Equal | + * | IN | All | In<br>Shortcut for OR queries<br>Values must be in Array | + * | NIN | All | Not In<br>Shortcut for OR ! queries<br>Values must be in Array | + * | > | Integer<br>Date (UNIX Timestamp) | Greater than | + * | < | Integer<br>Date (UNIX Timestamp) | Lower than | + * | ~ | String | Contains | + * | !~ | String | Doesn't Contain | + * | ^ | String | Starts With | + * | $ | String | Ends With |

+ */ + public SyncPagingIterable search(SearchRequest request) { + return search(request, null); + } + + /** + * You can search for multiple contacts by the value of their attributes in order to fetch exactly who you want. + *

To search for contacts, you need to send a POST request to https://api.intercom.io/contacts/search.

+ *

This will accept a query object in the body which will define your filters in order to search for contacts.

+ *

{% admonition type="warning" name="Optimizing search queries" %} + * Search queries can be complex, so optimizing them can help the performance of your search. + * Use the AND and OR operators to combine multiple filters to get the exact results you need and utilize + * pagination to limit the number of results returned. The default is 50 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ *

Contact Creation Delay

+ *

If a contact has recently been created, there is a possibility that it will not yet be available when searching. This means that it may not appear in the response. This delay can take a few minutes. If you need to be instantly notified it is recommended to use webhooks and iterate to see if they match your search filters.

+ *

Nesting & Limitations

+ *

You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). + * There are some limitations to the amount of multiple's there can be:

+ *
    + *
  • There's a limit of max 2 nested filters
  • + *
  • There's a limit of max 15 filters for each AND or OR group
  • + *
+ *

Searching for Timestamp Fields

+ *

All timestamp fields (created_at, updated_at etc.) are indexed as Dates for Contact Search queries; Datetime queries are not currently supported. This means you can only query for timestamp fields by day - not hour, minute or second. + * For example, if you search for all Contacts with a created_at value greater (>) than 1577869200 (the UNIX timestamp for January 1st, 2020 9:00 AM), that will be interpreted as 1577836800 (January 1st, 2020 12:00 AM). The search results will then include Contacts created from January 2nd, 2020 12:00 AM onwards. + * If you'd like to get contacts created on January 1st, 2020 you should search with a created_at value equal (=) to 1577836800 (January 1st, 2020 12:00 AM). + * This behaviour applies only to timestamps used in search queries. The search results will still contain the full UNIX timestamp and be sorted accordingly.

+ *

Accepted Fields

+ *

Most key listed as part of the Contacts Model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as created_at accepts a date, the value cannot be a string such as "foorbar").

+ *

| Field | Type | + * | ---------------------------------- | ------------------------------ | + * | id | String | + * | role | String<br>Accepts user or lead | + * | name | String | + * | avatar | String | + * | owner_id | Integer | + * | email | String | + * | email_domain | String | + * | phone | String | + * | external_id | String | + * | created_at | Date (UNIX Timestamp) | + * | signed_up_at | Date (UNIX Timestamp) | + * | updated_at | Date (UNIX Timestamp) | + * | last_seen_at | Date (UNIX Timestamp) | + * | last_contacted_at | Date (UNIX Timestamp) | + * | last_replied_at | Date (UNIX Timestamp) | + * | last_email_opened_at | Date (UNIX Timestamp) | + * | last_email_clicked_at | Date (UNIX Timestamp) | + * | language_override | String | + * | browser | String | + * | browser_language | String | + * | os | String | + * | location.country | String | + * | location.region | String | + * | location.city | String | + * | unsubscribed_from_emails | Boolean | + * | marked_email_as_spam | Boolean | + * | has_hard_bounced | Boolean | + * | ios_last_seen_at | Date (UNIX Timestamp) | + * | ios_app_version | String | + * | ios_device | String | + * | ios_app_device | String | + * | ios_os_version | String | + * | ios_app_name | String | + * | ios_sdk_version | String | + * | android_last_seen_at | Date (UNIX Timestamp) | + * | android_app_version | String | + * | android_device | String | + * | android_app_name | String | + * | andoid_sdk_version | String | + * | segment_id | String | + * | tag_id | String | + * | custom_attributes.{attribute_name} | String |

+ *

Accepted Operators

+ *

{% admonition type="warning" name="Searching based on created_at" %} + * You cannot use the <= or >= operators to search by created_at. + * {% /admonition %}

+ *

The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string ("="). The operator has to be compatible with the field's type (eg. you cannot search with > for a given string value as it's only compatible for integer's and dates).

+ *

| Operator | Valid Types | Description | + * | :------- | :------------------------------- | :--------------------------------------------------------------- | + * | = | All | Equals | + * | != | All | Doesn't Equal | + * | IN | All | In<br>Shortcut for OR queries<br>Values must be in Array | + * | NIN | All | Not In<br>Shortcut for OR ! queries<br>Values must be in Array | + * | > | Integer<br>Date (UNIX Timestamp) | Greater than | + * | < | Integer<br>Date (UNIX Timestamp) | Lower than | + * | ~ | String | Contains | + * | !~ | String | Doesn't Contain | + * | ^ | String | Starts With | + * | $ | String | Ends With |

+ */ + public SyncPagingIterable search(SearchRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts/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()) { + ContactList parsedResponse = + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ContactList.class); + Optional startingAfter = parsedResponse + .getPages() + .flatMap(CursorPages::getNext) + .flatMap(StartingAfterPaging::getStartingAfter); + Optional pagination = request.getPagination() + .map(pagination_ -> StartingAfterPaging.builder() + .from(pagination_) + .startingAfter(startingAfter) + .build()); + SearchRequest nextRequest = SearchRequest.builder() + .from(request) + .pagination(pagination) + .build(); + List result = parsedResponse.getData(); + return new SyncPagingIterable( + startingAfter.isPresent(), result, () -> search(nextRequest, requestOptions)); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can fetch a list of all contacts (ie. users or leads) in your workspace. + * {% admonition type="warning" name="Pagination" %} + * You can use pagination to limit the number of results returned. The default is 50 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %} + */ + public SyncPagingIterable list() { + return list(ListContactsRequest.builder().build()); + } + + /** + * You can fetch a list of all contacts (ie. users or leads) in your workspace. + * {% admonition type="warning" name="Pagination" %} + * You can use pagination to limit the number of results returned. The default is 50 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %} + */ + public SyncPagingIterable list(ListContactsRequest request) { + return list(request, null); + } + + /** + * You can fetch a list of all contacts (ie. users or leads) in your workspace. + * {% admonition type="warning" name="Pagination" %} + * You can use pagination to limit the number of results returned. The default is 50 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %} + */ + public SyncPagingIterable list(ListContactsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .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); + } + if (request.getStartingAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "starting_after", request.getStartingAfter().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()) { + ContactList parsedResponse = + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ContactList.class); + Optional startingAfter = parsedResponse + .getPages() + .flatMap(CursorPages::getNext) + .flatMap(StartingAfterPaging::getStartingAfter); + ListContactsRequest nextRequest = ListContactsRequest.builder() + .from(request) + .startingAfter(startingAfter) + .build(); + List result = parsedResponse.getData(); + return new SyncPagingIterable( + startingAfter.isPresent(), result, () -> list(nextRequest, requestOptions)); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can create a new contact (ie. user or lead). + */ + public Contact create(CreateContactRequest request) { + return create(request, null); + } + + /** + * You can create a new contact (ie. user or lead). + */ + public Contact create(CreateContactRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Contact.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can archive a single contact. + */ + public ContactArchived archive(ArchiveContactRequest request) { + return archive(request, null); + } + + /** + * You can archive a single contact. + */ + public ContactArchived archive(ArchiveContactRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getContactId()) + .addPathSegments("archive") + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ContactArchived.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can unarchive a single contact. + */ + public ContactUnarchived unarchive(UnarchiveContactRequest request) { + return unarchive(request, null); + } + + /** + * You can unarchive a single contact. + */ + public ContactUnarchived unarchive(UnarchiveContactRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getContactId()) + .addPathSegments("unarchive") + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ContactUnarchived.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } 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 new file mode 100644 index 00000000..b0fbe132 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/contacts/requests/ArchiveContactRequest.java @@ -0,0 +1,109 @@ +/** + * 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 = ArchiveContactRequest.Builder.class) +public final class ArchiveContactRequest { + private final String contactId; + + private final Map additionalProperties; + + private ArchiveContactRequest(String contactId, Map additionalProperties) { + this.contactId = contactId; + this.additionalProperties = additionalProperties; + } + + /** + * @return 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 ArchiveContactRequest && equalTo((ArchiveContactRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ArchiveContactRequest 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 { + _FinalStage contactId(@NotNull String contactId); + + Builder from(ArchiveContactRequest other); + } + + public interface _FinalStage { + ArchiveContactRequest 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(ArchiveContactRequest other) { + contactId(other.getContactId()); + return this; + } + + /** + *

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 ArchiveContactRequest build() { + return new ArchiveContactRequest(contactId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/contacts/requests/AttachSubscriptionToContactRequest.java b/src/main/java/com/intercom/api/resources/contacts/requests/AttachSubscriptionToContactRequest.java new file mode 100644 index 00000000..bb940a60 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/contacts/requests/AttachSubscriptionToContactRequest.java @@ -0,0 +1,171 @@ +/** + * 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 = AttachSubscriptionToContactRequest.Builder.class) +public final class AttachSubscriptionToContactRequest { + private final String contactId; + + private final String subscriptionId; + + private final String consentType; + + private final Map additionalProperties; + + private AttachSubscriptionToContactRequest( + String contactId, String subscriptionId, String consentType, Map additionalProperties) { + this.contactId = contactId; + this.subscriptionId = subscriptionId; + this.consentType = consentType; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the contact which is given by Intercom + */ + @JsonProperty("contact_id") + public String getContactId() { + return contactId; + } + + /** + * @return The unique identifier for the subscription which is given by Intercom + */ + @JsonProperty("id") + public String getSubscriptionId() { + return subscriptionId; + } + + /** + * @return The consent_type of a subscription, opt_out or opt_in. + */ + @JsonProperty("consent_type") + public String getConsentType() { + return consentType; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AttachSubscriptionToContactRequest + && equalTo((AttachSubscriptionToContactRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(AttachSubscriptionToContactRequest other) { + return contactId.equals(other.contactId) + && subscriptionId.equals(other.subscriptionId) + && consentType.equals(other.consentType); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.contactId, this.subscriptionId, this.consentType); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ContactIdStage builder() { + return new Builder(); + } + + public interface ContactIdStage { + SubscriptionIdStage contactId(@NotNull String contactId); + + Builder from(AttachSubscriptionToContactRequest other); + } + + public interface SubscriptionIdStage { + ConsentTypeStage subscriptionId(@NotNull String subscriptionId); + } + + public interface ConsentTypeStage { + _FinalStage consentType(@NotNull String consentType); + } + + public interface _FinalStage { + AttachSubscriptionToContactRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ContactIdStage, SubscriptionIdStage, ConsentTypeStage, _FinalStage { + private String contactId; + + private String subscriptionId; + + private String consentType; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(AttachSubscriptionToContactRequest other) { + contactId(other.getContactId()); + subscriptionId(other.getSubscriptionId()); + consentType(other.getConsentType()); + return this; + } + + /** + *

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("contact_id") + public SubscriptionIdStage contactId(@NotNull String contactId) { + this.contactId = Objects.requireNonNull(contactId, "contactId must not be null"); + return this; + } + + /** + *

The unique identifier for the subscription which is given by Intercom

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

The consent_type of a subscription, opt_out or opt_in.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("consent_type") + public _FinalStage consentType(@NotNull String consentType) { + this.consentType = Objects.requireNonNull(consentType, "consentType must not be null"); + return this; + } + + @java.lang.Override + public AttachSubscriptionToContactRequest build() { + return new AttachSubscriptionToContactRequest(contactId, subscriptionId, consentType, 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 new file mode 100644 index 00000000..1d0f355f --- /dev/null +++ b/src/main/java/com/intercom/api/resources/contacts/requests/DeleteContactRequest.java @@ -0,0 +1,109 @@ +/** + * 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 = DeleteContactRequest.Builder.class) +public final class DeleteContactRequest { + private final String contactId; + + private final Map additionalProperties; + + private DeleteContactRequest(String contactId, Map additionalProperties) { + this.contactId = contactId; + this.additionalProperties = additionalProperties; + } + + /** + * @return 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 DeleteContactRequest && equalTo((DeleteContactRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeleteContactRequest 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 { + _FinalStage contactId(@NotNull String contactId); + + Builder from(DeleteContactRequest other); + } + + public interface _FinalStage { + DeleteContactRequest 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(DeleteContactRequest other) { + contactId(other.getContactId()); + return this; + } + + /** + *

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 DeleteContactRequest build() { + return new DeleteContactRequest(contactId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/contacts/requests/DetachSubscriptionFromContactRequest.java b/src/main/java/com/intercom/api/resources/contacts/requests/DetachSubscriptionFromContactRequest.java new file mode 100644 index 00000000..2928b095 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/contacts/requests/DetachSubscriptionFromContactRequest.java @@ -0,0 +1,140 @@ +/** + * 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 = DetachSubscriptionFromContactRequest.Builder.class) +public final class DetachSubscriptionFromContactRequest { + private final String contactId; + + private final String subscriptionId; + + private final Map additionalProperties; + + private DetachSubscriptionFromContactRequest( + String contactId, String subscriptionId, Map additionalProperties) { + this.contactId = contactId; + this.subscriptionId = subscriptionId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the contact which is given by Intercom + */ + @JsonProperty("contact_id") + public String getContactId() { + return contactId; + } + + /** + * @return The unique identifier for the subscription type which is given by Intercom + */ + @JsonProperty("subscription_id") + public String getSubscriptionId() { + return subscriptionId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DetachSubscriptionFromContactRequest + && equalTo((DetachSubscriptionFromContactRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DetachSubscriptionFromContactRequest other) { + return contactId.equals(other.contactId) && subscriptionId.equals(other.subscriptionId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.contactId, this.subscriptionId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ContactIdStage builder() { + return new Builder(); + } + + public interface ContactIdStage { + SubscriptionIdStage contactId(@NotNull String contactId); + + Builder from(DetachSubscriptionFromContactRequest other); + } + + public interface SubscriptionIdStage { + _FinalStage subscriptionId(@NotNull String subscriptionId); + } + + public interface _FinalStage { + DetachSubscriptionFromContactRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ContactIdStage, SubscriptionIdStage, _FinalStage { + private String contactId; + + private String subscriptionId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DetachSubscriptionFromContactRequest other) { + contactId(other.getContactId()); + subscriptionId(other.getSubscriptionId()); + return this; + } + + /** + *

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("contact_id") + public SubscriptionIdStage contactId(@NotNull String contactId) { + this.contactId = Objects.requireNonNull(contactId, "contactId must not be null"); + return this; + } + + /** + *

The unique identifier for the subscription type which is given by Intercom

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("subscription_id") + public _FinalStage subscriptionId(@NotNull String subscriptionId) { + this.subscriptionId = Objects.requireNonNull(subscriptionId, "subscriptionId must not be null"); + return this; + } + + @java.lang.Override + public DetachSubscriptionFromContactRequest build() { + return new DetachSubscriptionFromContactRequest(contactId, subscriptionId, additionalProperties); + } + } +} 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 new file mode 100644 index 00000000..21a43e98 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/contacts/requests/FindContactRequest.java @@ -0,0 +1,109 @@ +/** + * 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 = FindContactRequest.Builder.class) +public final class FindContactRequest { + private final String contactId; + + private final Map additionalProperties; + + private FindContactRequest(String contactId, Map additionalProperties) { + this.contactId = contactId; + this.additionalProperties = additionalProperties; + } + + /** + * @return 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 FindContactRequest && equalTo((FindContactRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(FindContactRequest 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 { + _FinalStage contactId(@NotNull String contactId); + + Builder from(FindContactRequest other); + } + + public interface _FinalStage { + FindContactRequest 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(FindContactRequest other) { + contactId(other.getContactId()); + return this; + } + + /** + *

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 FindContactRequest build() { + return new FindContactRequest(contactId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/contacts/requests/ListAttachedCompaniesRequest.java b/src/main/java/com/intercom/api/resources/contacts/requests/ListAttachedCompaniesRequest.java new file mode 100644 index 00000000..91883da9 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/contacts/requests/ListAttachedCompaniesRequest.java @@ -0,0 +1,185 @@ +/** + * 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.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 = ListAttachedCompaniesRequest.Builder.class) +public final class ListAttachedCompaniesRequest { + private final String contactId; + + private final Optional page; + + private final Optional perPage; + + private final Map additionalProperties; + + private ListAttachedCompaniesRequest( + String contactId, + Optional page, + Optional perPage, + Map additionalProperties) { + this.contactId = contactId; + this.page = page; + this.perPage = perPage; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the contact which is given by Intercom + */ + @JsonProperty("contact_id") + public String getContactId() { + return contactId; + } + + /** + * @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 15 + */ + @JsonProperty("per_page") + public Optional getPerPage() { + return perPage; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListAttachedCompaniesRequest && equalTo((ListAttachedCompaniesRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListAttachedCompaniesRequest other) { + return contactId.equals(other.contactId) && page.equals(other.page) && perPage.equals(other.perPage); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.contactId, this.page, this.perPage); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ContactIdStage builder() { + return new Builder(); + } + + public interface ContactIdStage { + _FinalStage contactId(@NotNull String contactId); + + Builder from(ListAttachedCompaniesRequest other); + } + + public interface _FinalStage { + ListAttachedCompaniesRequest build(); + + _FinalStage page(Optional page); + + _FinalStage page(Integer page); + + _FinalStage perPage(Optional perPage); + + _FinalStage perPage(Integer perPage); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ContactIdStage, _FinalStage { + private String contactId; + + private Optional perPage = Optional.empty(); + + private Optional page = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ListAttachedCompaniesRequest other) { + contactId(other.getContactId()); + page(other.getPage()); + perPage(other.getPerPage()); + return this; + } + + /** + *

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("contact_id") + public _FinalStage contactId(@NotNull String contactId) { + this.contactId = Objects.requireNonNull(contactId, "contactId must not be null"); + return this; + } + + /** + *

How many results to display 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; + } + + @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; + } + + @java.lang.Override + @JsonSetter(value = "page", nulls = Nulls.SKIP) + public _FinalStage page(Optional page) { + this.page = page; + return this; + } + + @java.lang.Override + public ListAttachedCompaniesRequest build() { + return new ListAttachedCompaniesRequest(contactId, page, perPage, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/contacts/requests/ListAttachedSubscriptionsRequest.java b/src/main/java/com/intercom/api/resources/contacts/requests/ListAttachedSubscriptionsRequest.java new file mode 100644 index 00000000..e280e4ad --- /dev/null +++ b/src/main/java/com/intercom/api/resources/contacts/requests/ListAttachedSubscriptionsRequest.java @@ -0,0 +1,109 @@ +/** + * 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 = ListAttachedSubscriptionsRequest.Builder.class) +public final class ListAttachedSubscriptionsRequest { + private final String contactId; + + private final Map additionalProperties; + + private ListAttachedSubscriptionsRequest(String contactId, Map additionalProperties) { + this.contactId = contactId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the contact which is given by Intercom + */ + @JsonProperty("contact_id") + public String getContactId() { + return contactId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListAttachedSubscriptionsRequest && equalTo((ListAttachedSubscriptionsRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListAttachedSubscriptionsRequest 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 { + _FinalStage contactId(@NotNull String contactId); + + Builder from(ListAttachedSubscriptionsRequest other); + } + + public interface _FinalStage { + ListAttachedSubscriptionsRequest 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(ListAttachedSubscriptionsRequest other) { + contactId(other.getContactId()); + return this; + } + + /** + *

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("contact_id") + public _FinalStage contactId(@NotNull String contactId) { + this.contactId = Objects.requireNonNull(contactId, "contactId must not be null"); + return this; + } + + @java.lang.Override + public ListAttachedSubscriptionsRequest build() { + return new ListAttachedSubscriptionsRequest(contactId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/contacts/requests/ListContactsRequest.java b/src/main/java/com/intercom/api/resources/contacts/requests/ListContactsRequest.java new file mode 100644 index 00000000..5eab6089 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/contacts/requests/ListContactsRequest.java @@ -0,0 +1,152 @@ +/** + * 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.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 = ListContactsRequest.Builder.class) +public final class ListContactsRequest { + private final Optional page; + + private final Optional perPage; + + private final Optional startingAfter; + + private final Map additionalProperties; + + private ListContactsRequest( + Optional page, + Optional perPage, + Optional startingAfter, + Map additionalProperties) { + this.page = page; + this.perPage = perPage; + this.startingAfter = startingAfter; + 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 15 + */ + @JsonProperty("per_page") + public Optional getPerPage() { + return perPage; + } + + /** + * @return String used to get the next page of conversations. + */ + @JsonProperty("starting_after") + public Optional getStartingAfter() { + return startingAfter; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListContactsRequest && equalTo((ListContactsRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListContactsRequest other) { + return page.equals(other.page) && perPage.equals(other.perPage) && startingAfter.equals(other.startingAfter); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.page, this.perPage, this.startingAfter); + } + + @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(); + + private Optional startingAfter = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ListContactsRequest other) { + page(other.getPage()); + perPage(other.getPerPage()); + startingAfter(other.getStartingAfter()); + return this; + } + + @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; + } + + @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; + } + + @JsonSetter(value = "starting_after", nulls = Nulls.SKIP) + public Builder startingAfter(Optional startingAfter) { + this.startingAfter = startingAfter; + return this; + } + + public Builder startingAfter(String startingAfter) { + this.startingAfter = Optional.ofNullable(startingAfter); + return this; + } + + public ListContactsRequest build() { + return new ListContactsRequest(page, perPage, startingAfter, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/contacts/requests/ListSegmentsAttachedToContactRequest.java b/src/main/java/com/intercom/api/resources/contacts/requests/ListSegmentsAttachedToContactRequest.java new file mode 100644 index 00000000..86c5f6b6 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/contacts/requests/ListSegmentsAttachedToContactRequest.java @@ -0,0 +1,110 @@ +/** + * 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 = ListSegmentsAttachedToContactRequest.Builder.class) +public final class ListSegmentsAttachedToContactRequest { + private final String contactId; + + private final Map additionalProperties; + + private ListSegmentsAttachedToContactRequest(String contactId, Map additionalProperties) { + this.contactId = contactId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the contact which is given by Intercom + */ + @JsonProperty("contact_id") + public String getContactId() { + return contactId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListSegmentsAttachedToContactRequest + && equalTo((ListSegmentsAttachedToContactRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListSegmentsAttachedToContactRequest 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 { + _FinalStage contactId(@NotNull String contactId); + + Builder from(ListSegmentsAttachedToContactRequest other); + } + + public interface _FinalStage { + ListSegmentsAttachedToContactRequest 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(ListSegmentsAttachedToContactRequest other) { + contactId(other.getContactId()); + return this; + } + + /** + *

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("contact_id") + public _FinalStage contactId(@NotNull String contactId) { + this.contactId = Objects.requireNonNull(contactId, "contactId must not be null"); + return this; + } + + @java.lang.Override + public ListSegmentsAttachedToContactRequest build() { + return new ListSegmentsAttachedToContactRequest(contactId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/contacts/requests/ListTagsAttachedToContactRequest.java b/src/main/java/com/intercom/api/resources/contacts/requests/ListTagsAttachedToContactRequest.java new file mode 100644 index 00000000..d7b518e3 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/contacts/requests/ListTagsAttachedToContactRequest.java @@ -0,0 +1,109 @@ +/** + * 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 = ListTagsAttachedToContactRequest.Builder.class) +public final class ListTagsAttachedToContactRequest { + private final String contactId; + + private final Map additionalProperties; + + private ListTagsAttachedToContactRequest(String contactId, Map additionalProperties) { + this.contactId = contactId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the contact which is given by Intercom + */ + @JsonProperty("contact_id") + public String getContactId() { + return contactId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListTagsAttachedToContactRequest && equalTo((ListTagsAttachedToContactRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListTagsAttachedToContactRequest 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 { + _FinalStage contactId(@NotNull String contactId); + + Builder from(ListTagsAttachedToContactRequest other); + } + + public interface _FinalStage { + ListTagsAttachedToContactRequest 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(ListTagsAttachedToContactRequest other) { + contactId(other.getContactId()); + return this; + } + + /** + *

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("contact_id") + public _FinalStage contactId(@NotNull String contactId) { + this.contactId = Objects.requireNonNull(contactId, "contactId must not be null"); + return this; + } + + @java.lang.Override + public ListTagsAttachedToContactRequest build() { + return new ListTagsAttachedToContactRequest(contactId, additionalProperties); + } + } +} 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 new file mode 100644 index 00000000..d69c753b --- /dev/null +++ b/src/main/java/com/intercom/api/resources/contacts/requests/MergeContactsRequest.java @@ -0,0 +1,138 @@ +/** + * 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 = MergeContactsRequest.Builder.class) +public final class MergeContactsRequest { + private final String leadId; + + private final String contactId; + + private final Map additionalProperties; + + private MergeContactsRequest(String leadId, String contactId, Map additionalProperties) { + this.leadId = leadId; + this.contactId = contactId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the contact to merge away from. Must be a lead. + */ + @JsonProperty("from") + public String getLeadId() { + return leadId; + } + + /** + * @return The unique identifier for the contact to merge into. Must be a user. + */ + @JsonProperty("into") + public String getContactId() { + return contactId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof MergeContactsRequest && equalTo((MergeContactsRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(MergeContactsRequest other) { + return leadId.equals(other.leadId) && contactId.equals(other.contactId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.leadId, this.contactId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static LeadIdStage builder() { + return new Builder(); + } + + public interface LeadIdStage { + ContactIdStage leadId(@NotNull String leadId); + + Builder from(MergeContactsRequest other); + } + + public interface ContactIdStage { + _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; + + private String contactId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(MergeContactsRequest other) { + leadId(other.getLeadId()); + contactId(other.getContactId()); + return this; + } + + /** + *

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. + */ + @java.lang.Override + @JsonSetter("from") + public ContactIdStage leadId(@NotNull String leadId) { + this.leadId = Objects.requireNonNull(leadId, "leadId must not be null"); + return this; + } + + /** + *

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. + */ + @java.lang.Override + @JsonSetter("into") + public _FinalStage contactId(@NotNull String contactId) { + this.contactId = Objects.requireNonNull(contactId, "contactId must not be null"); + 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/UnarchiveContactRequest.java b/src/main/java/com/intercom/api/resources/contacts/requests/UnarchiveContactRequest.java new file mode 100644 index 00000000..9482a4b4 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/contacts/requests/UnarchiveContactRequest.java @@ -0,0 +1,109 @@ +/** + * 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 = UnarchiveContactRequest.Builder.class) +public final class UnarchiveContactRequest { + private final String contactId; + + private final Map additionalProperties; + + private UnarchiveContactRequest(String contactId, Map additionalProperties) { + this.contactId = contactId; + this.additionalProperties = additionalProperties; + } + + /** + * @return 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 UnarchiveContactRequest && equalTo((UnarchiveContactRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UnarchiveContactRequest 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 { + _FinalStage contactId(@NotNull String contactId); + + Builder from(UnarchiveContactRequest other); + } + + public interface _FinalStage { + UnarchiveContactRequest 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(UnarchiveContactRequest other) { + contactId(other.getContactId()); + return this; + } + + /** + *

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 UnarchiveContactRequest build() { + return new UnarchiveContactRequest(contactId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/contacts/requests/UpdateContactRequest.java b/src/main/java/com/intercom/api/resources/contacts/requests/UpdateContactRequest.java new file mode 100644 index 00000000..81d58f39 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/contacts/requests/UpdateContactRequest.java @@ -0,0 +1,545 @@ +/** + * 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.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 = UpdateContactRequest.Builder.class) +public final class UpdateContactRequest { + private final String contactId; + + private final Optional role; + + private final Optional externalId; + + private final Optional email; + + private final Optional phone; + + private final Optional name; + + private final Optional avatar; + + private final Optional signedUpAt; + + private final Optional lastSeenAt; + + private final Optional ownerId; + + private final Optional unsubscribedFromEmails; + + private final Optional> customAttributes; + + private final Map additionalProperties; + + private UpdateContactRequest( + String contactId, + Optional role, + Optional externalId, + Optional email, + Optional phone, + Optional name, + Optional avatar, + Optional signedUpAt, + Optional lastSeenAt, + Optional ownerId, + Optional unsubscribedFromEmails, + Optional> customAttributes, + Map additionalProperties) { + this.contactId = contactId; + this.role = role; + this.externalId = externalId; + this.email = email; + this.phone = phone; + this.name = name; + this.avatar = avatar; + this.signedUpAt = signedUpAt; + this.lastSeenAt = lastSeenAt; + this.ownerId = ownerId; + this.unsubscribedFromEmails = unsubscribedFromEmails; + this.customAttributes = customAttributes; + this.additionalProperties = additionalProperties; + } + + /** + * @return id + */ + @JsonProperty("contact_id") + public String getContactId() { + return contactId; + } + + /** + * @return The role of the contact. + */ + @JsonProperty("role") + public Optional getRole() { + return role; + } + + /** + * @return A unique identifier for the contact which is given to Intercom + */ + @JsonProperty("external_id") + public Optional getExternalId() { + return externalId; + } + + /** + * @return The contacts email + */ + @JsonProperty("email") + public Optional getEmail() { + return email; + } + + /** + * @return The contacts phone + */ + @JsonProperty("phone") + public Optional getPhone() { + return phone; + } + + /** + * @return The contacts name + */ + @JsonProperty("name") + public Optional getName() { + return name; + } + + /** + * @return An image URL containing the avatar of a contact + */ + @JsonProperty("avatar") + public Optional getAvatar() { + return avatar; + } + + /** + * @return The time specified for when a contact signed up + */ + @JsonProperty("signed_up_at") + public Optional getSignedUpAt() { + return signedUpAt; + } + + /** + * @return 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 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 is unsubscribed from emails + */ + @JsonProperty("unsubscribed_from_emails") + public Optional getUnsubscribedFromEmails() { + return unsubscribedFromEmails; + } + + /** + * @return The custom attributes which are set for the contact + */ + @JsonProperty("custom_attributes") + public Optional> getCustomAttributes() { + return customAttributes; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UpdateContactRequest && equalTo((UpdateContactRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UpdateContactRequest other) { + return contactId.equals(other.contactId) + && role.equals(other.role) + && externalId.equals(other.externalId) + && email.equals(other.email) + && phone.equals(other.phone) + && name.equals(other.name) + && avatar.equals(other.avatar) + && signedUpAt.equals(other.signedUpAt) + && lastSeenAt.equals(other.lastSeenAt) + && ownerId.equals(other.ownerId) + && unsubscribedFromEmails.equals(other.unsubscribedFromEmails) + && customAttributes.equals(other.customAttributes); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.contactId, + this.role, + this.externalId, + this.email, + this.phone, + this.name, + this.avatar, + this.signedUpAt, + this.lastSeenAt, + this.ownerId, + this.unsubscribedFromEmails, + this.customAttributes); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ContactIdStage builder() { + return new Builder(); + } + + public interface ContactIdStage { + _FinalStage contactId(@NotNull String contactId); + + Builder from(UpdateContactRequest other); + } + + public interface _FinalStage { + UpdateContactRequest build(); + + _FinalStage role(Optional role); + + _FinalStage role(String role); + + _FinalStage externalId(Optional externalId); + + _FinalStage externalId(String externalId); + + _FinalStage email(Optional email); + + _FinalStage email(String email); + + _FinalStage phone(Optional phone); + + _FinalStage phone(String phone); + + _FinalStage name(Optional name); + + _FinalStage name(String name); + + _FinalStage avatar(Optional avatar); + + _FinalStage avatar(String avatar); + + _FinalStage signedUpAt(Optional signedUpAt); + + _FinalStage signedUpAt(Integer signedUpAt); + + _FinalStage lastSeenAt(Optional lastSeenAt); + + _FinalStage lastSeenAt(Integer lastSeenAt); + + _FinalStage ownerId(Optional ownerId); + + _FinalStage ownerId(Integer ownerId); + + _FinalStage unsubscribedFromEmails(Optional unsubscribedFromEmails); + + _FinalStage unsubscribedFromEmails(Boolean unsubscribedFromEmails); + + _FinalStage customAttributes(Optional> customAttributes); + + _FinalStage customAttributes(Map customAttributes); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ContactIdStage, _FinalStage { + private String contactId; + + private Optional> customAttributes = Optional.empty(); + + private Optional unsubscribedFromEmails = Optional.empty(); + + private Optional ownerId = Optional.empty(); + + private Optional lastSeenAt = Optional.empty(); + + private Optional signedUpAt = Optional.empty(); + + private Optional avatar = Optional.empty(); + + private Optional name = Optional.empty(); + + private Optional phone = Optional.empty(); + + private Optional email = Optional.empty(); + + private Optional externalId = Optional.empty(); + + private Optional role = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(UpdateContactRequest other) { + contactId(other.getContactId()); + role(other.getRole()); + externalId(other.getExternalId()); + email(other.getEmail()); + phone(other.getPhone()); + name(other.getName()); + avatar(other.getAvatar()); + signedUpAt(other.getSignedUpAt()); + lastSeenAt(other.getLastSeenAt()); + ownerId(other.getOwnerId()); + unsubscribedFromEmails(other.getUnsubscribedFromEmails()); + customAttributes(other.getCustomAttributes()); + return this; + } + + /** + *

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; + } + + /** + *

The custom attributes which are set for the contact

+ * @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; + } + + @java.lang.Override + @JsonSetter(value = "custom_attributes", nulls = Nulls.SKIP) + public _FinalStage customAttributes(Optional> customAttributes) { + this.customAttributes = customAttributes; + return this; + } + + /** + *

Whether the contact is unsubscribed from emails

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage unsubscribedFromEmails(Boolean unsubscribedFromEmails) { + this.unsubscribedFromEmails = Optional.ofNullable(unsubscribedFromEmails); + return this; + } + + @java.lang.Override + @JsonSetter(value = "unsubscribed_from_emails", nulls = Nulls.SKIP) + public _FinalStage unsubscribedFromEmails(Optional unsubscribedFromEmails) { + this.unsubscribedFromEmails = unsubscribedFromEmails; + 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "owner_id", nulls = Nulls.SKIP) + public _FinalStage ownerId(Optional ownerId) { + this.ownerId = ownerId; + return this; + } + + /** + *

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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "last_seen_at", nulls = Nulls.SKIP) + public _FinalStage lastSeenAt(Optional lastSeenAt) { + this.lastSeenAt = lastSeenAt; + return this; + } + + /** + *

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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "signed_up_at", nulls = Nulls.SKIP) + public _FinalStage signedUpAt(Optional signedUpAt) { + this.signedUpAt = signedUpAt; + return this; + } + + /** + *

An image URL containing the avatar of a contact

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage avatar(String avatar) { + this.avatar = Optional.ofNullable(avatar); + return this; + } + + @java.lang.Override + @JsonSetter(value = "avatar", nulls = Nulls.SKIP) + public _FinalStage avatar(Optional avatar) { + this.avatar = avatar; + 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public _FinalStage name(Optional name) { + this.name = name; + 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "phone", nulls = Nulls.SKIP) + public _FinalStage phone(Optional phone) { + this.phone = phone; + return this; + } + + /** + *

The contacts 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "email", nulls = Nulls.SKIP) + public _FinalStage email(Optional email) { + this.email = email; + return this; + } + + /** + *

A unique identifier for the contact which is given to Intercom

+ * @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; + } + + @java.lang.Override + @JsonSetter(value = "external_id", nulls = Nulls.SKIP) + public _FinalStage externalId(Optional externalId) { + this.externalId = externalId; + return this; + } + + /** + *

The role of the contact.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage role(String role) { + this.role = Optional.ofNullable(role); + return this; + } + + @java.lang.Override + @JsonSetter(value = "role", nulls = Nulls.SKIP) + public _FinalStage role(Optional role) { + this.role = role; + return this; + } + + @java.lang.Override + public UpdateContactRequest build() { + return new UpdateContactRequest( + contactId, + role, + externalId, + email, + phone, + name, + avatar, + signedUpAt, + lastSeenAt, + ownerId, + unsubscribedFromEmails, + customAttributes, + additionalProperties); + } + } +} 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 new file mode 100644 index 00000000..f8d60376 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/contacts/types/Contact.java @@ -0,0 +1,1798 @@ +/** + * 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; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = Contact.Builder.class) +public final class Contact { + private final Optional type; + + private final String id; + + private final Optional externalId; + + private final String workspaceId; + + private final String role; + + private final Optional email; + + private final Optional emailDomain; + + private final Optional phone; + + private final Optional formattedPhone; + + private final Optional name; + + private final Optional ownerId; + + private final boolean hasHardBounced; + + private final boolean markedEmailAsSpam; + + private final boolean unsubscribedFromEmails; + + private final int createdAt; + + private final int 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 ContactLocation location; + + private final ContactSocialProfiles socialProfiles; + + private final Map additionalProperties; + + private Contact( + Optional type, + String id, + Optional externalId, + String workspaceId, + String role, + Optional email, + Optional emailDomain, + Optional phone, + Optional formattedPhone, + Optional name, + Optional ownerId, + boolean hasHardBounced, + boolean markedEmailAsSpam, + boolean unsubscribedFromEmails, + int createdAt, + int 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, + ContactLocation location, + ContactSocialProfiles socialProfiles, + 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.formattedPhone = formattedPhone; + 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.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 String 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 String getWorkspaceId() { + return workspaceId; + } + + /** + * @return The role of the contact. + */ + @JsonProperty("role") + public String 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 phone number normalized to the E164 format + */ + @JsonProperty("formatted_phone") + public Optional getFormattedPhone() { + return formattedPhone; + } + + /** + * @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 boolean getHasHardBounced() { + return hasHardBounced; + } + + /** + * @return Whether the contact has marked an email sent to them as spam. + */ + @JsonProperty("marked_email_as_spam") + public boolean getMarkedEmailAsSpam() { + return markedEmailAsSpam; + } + + /** + * @return Whether the contact is unsubscribed from emails. + */ + @JsonProperty("unsubscribed_from_emails") + public boolean getUnsubscribedFromEmails() { + return unsubscribedFromEmails; + } + + /** + * @return (UNIX timestamp) The time when the contact was created. + */ + @JsonProperty("created_at") + public int getCreatedAt() { + return createdAt; + } + + /** + * @return (UNIX timestamp) The time when the contact was last updated. + */ + @JsonProperty("updated_at") + public int 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 ContactLocation getLocation() { + return location; + } + + @JsonProperty("social_profiles") + public ContactSocialProfiles getSocialProfiles() { + return socialProfiles; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Contact && equalTo((Contact) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Contact 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) + && 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 + && 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); + } + + @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.formattedPhone, + 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); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + WorkspaceIdStage id(@NotNull String id); + + Builder from(Contact other); + } + + public interface WorkspaceIdStage { + RoleStage workspaceId(@NotNull String workspaceId); + } + + public interface RoleStage { + HasHardBouncedStage role(@NotNull String role); + } + + public interface HasHardBouncedStage { + MarkedEmailAsSpamStage hasHardBounced(boolean hasHardBounced); + } + + public interface MarkedEmailAsSpamStage { + UnsubscribedFromEmailsStage markedEmailAsSpam(boolean markedEmailAsSpam); + } + + public interface UnsubscribedFromEmailsStage { + CreatedAtStage unsubscribedFromEmails(boolean unsubscribedFromEmails); + } + + public interface CreatedAtStage { + UpdatedAtStage createdAt(int createdAt); + } + + public interface UpdatedAtStage { + LocationStage updatedAt(int updatedAt); + } + + public interface LocationStage { + SocialProfilesStage location(@NotNull ContactLocation location); + } + + public interface SocialProfilesStage { + _FinalStage socialProfiles(@NotNull ContactSocialProfiles socialProfiles); + } + + public interface _FinalStage { + Contact build(); + + _FinalStage type(Optional type); + + _FinalStage type(String type); + + _FinalStage externalId(Optional externalId); + + _FinalStage externalId(String externalId); + + _FinalStage email(Optional email); + + _FinalStage email(String email); + + _FinalStage emailDomain(Optional emailDomain); + + _FinalStage emailDomain(String emailDomain); + + _FinalStage phone(Optional phone); + + _FinalStage phone(String phone); + + _FinalStage formattedPhone(Optional formattedPhone); + + _FinalStage formattedPhone(String formattedPhone); + + _FinalStage name(Optional name); + + _FinalStage name(String name); + + _FinalStage ownerId(Optional ownerId); + + _FinalStage ownerId(Integer ownerId); + + _FinalStage signedUpAt(Optional signedUpAt); + + _FinalStage signedUpAt(Integer signedUpAt); + + _FinalStage lastSeenAt(Optional lastSeenAt); + + _FinalStage lastSeenAt(Integer lastSeenAt); + + _FinalStage lastRepliedAt(Optional lastRepliedAt); + + _FinalStage lastRepliedAt(Integer lastRepliedAt); + + _FinalStage lastContactedAt(Optional lastContactedAt); + + _FinalStage lastContactedAt(Integer lastContactedAt); + + _FinalStage lastEmailOpenedAt(Optional lastEmailOpenedAt); + + _FinalStage lastEmailOpenedAt(Integer lastEmailOpenedAt); + + _FinalStage lastEmailClickedAt(Optional lastEmailClickedAt); + + _FinalStage lastEmailClickedAt(Integer lastEmailClickedAt); + + _FinalStage languageOverride(Optional languageOverride); + + _FinalStage languageOverride(String languageOverride); + + _FinalStage browser(Optional browser); + + _FinalStage browser(String browser); + + _FinalStage browserVersion(Optional browserVersion); + + _FinalStage browserVersion(String browserVersion); + + _FinalStage browserLanguage(Optional browserLanguage); + + _FinalStage browserLanguage(String browserLanguage); + + _FinalStage os(Optional os); + + _FinalStage os(String os); + + _FinalStage androidAppName(Optional androidAppName); + + _FinalStage androidAppName(String androidAppName); + + _FinalStage androidAppVersion(Optional androidAppVersion); + + _FinalStage androidAppVersion(String androidAppVersion); + + _FinalStage androidDevice(Optional androidDevice); + + _FinalStage androidDevice(String androidDevice); + + _FinalStage androidOsVersion(Optional androidOsVersion); + + _FinalStage androidOsVersion(String androidOsVersion); + + _FinalStage androidSdkVersion(Optional androidSdkVersion); + + _FinalStage androidSdkVersion(String androidSdkVersion); + + _FinalStage androidLastSeenAt(Optional androidLastSeenAt); + + _FinalStage androidLastSeenAt(Integer androidLastSeenAt); + + _FinalStage iosAppName(Optional iosAppName); + + _FinalStage iosAppName(String iosAppName); + + _FinalStage iosAppVersion(Optional iosAppVersion); + + _FinalStage iosAppVersion(String iosAppVersion); + + _FinalStage iosDevice(Optional iosDevice); + + _FinalStage iosDevice(String iosDevice); + + _FinalStage iosOsVersion(Optional iosOsVersion); + + _FinalStage iosOsVersion(String iosOsVersion); + + _FinalStage iosSdkVersion(Optional iosSdkVersion); + + _FinalStage iosSdkVersion(String iosSdkVersion); + + _FinalStage iosLastSeenAt(Optional iosLastSeenAt); + + _FinalStage iosLastSeenAt(Integer iosLastSeenAt); + + _FinalStage customAttributes(Optional> customAttributes); + + _FinalStage customAttributes(Map customAttributes); + + _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.

+ * @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.

+ * @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.

+ * @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.

+ * @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.

+ * @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) { + this.markedEmailAsSpam = markedEmailAsSpam; + return this; + } + + /** + *

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.

+ * @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.

+ * @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; + return this; + } + + /** + *

An image URL containing the avatar of a contact.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage avatar(String avatar) { + this.avatar = Optional.ofNullable(avatar); + return this; + } + + @java.lang.Override + @JsonSetter(value = "avatar", nulls = Nulls.SKIP) + public _FinalStage avatar(Optional avatar) { + this.avatar = avatar; + return this; + } + + /** + *

The custom attributes which are set for the contact.

+ * @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; + } + + @java.lang.Override + @JsonSetter(value = "custom_attributes", nulls = Nulls.SKIP) + public _FinalStage customAttributes(Optional> customAttributes) { + this.customAttributes = customAttributes; + 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "ios_last_seen_at", nulls = Nulls.SKIP) + public _FinalStage iosLastSeenAt(Optional iosLastSeenAt) { + this.iosLastSeenAt = iosLastSeenAt; + 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "ios_sdk_version", nulls = Nulls.SKIP) + public _FinalStage iosSdkVersion(Optional iosSdkVersion) { + this.iosSdkVersion = iosSdkVersion; + 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "ios_os_version", nulls = Nulls.SKIP) + public _FinalStage iosOsVersion(Optional iosOsVersion) { + this.iosOsVersion = iosOsVersion; + 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "ios_device", nulls = Nulls.SKIP) + public _FinalStage iosDevice(Optional iosDevice) { + this.iosDevice = iosDevice; + 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "ios_app_version", nulls = Nulls.SKIP) + public _FinalStage iosAppVersion(Optional iosAppVersion) { + this.iosAppVersion = iosAppVersion; + 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "ios_app_name", nulls = Nulls.SKIP) + public _FinalStage iosAppName(Optional iosAppName) { + this.iosAppName = iosAppName; + 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "android_last_seen_at", nulls = Nulls.SKIP) + public _FinalStage androidLastSeenAt(Optional androidLastSeenAt) { + this.androidLastSeenAt = androidLastSeenAt; + 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "android_sdk_version", nulls = Nulls.SKIP) + public _FinalStage androidSdkVersion(Optional androidSdkVersion) { + this.androidSdkVersion = androidSdkVersion; + 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "android_os_version", nulls = Nulls.SKIP) + public _FinalStage androidOsVersion(Optional androidOsVersion) { + this.androidOsVersion = androidOsVersion; + 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "android_device", nulls = Nulls.SKIP) + public _FinalStage androidDevice(Optional androidDevice) { + this.androidDevice = androidDevice; + 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "android_app_version", nulls = Nulls.SKIP) + public _FinalStage androidAppVersion(Optional androidAppVersion) { + this.androidAppVersion = androidAppVersion; + 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "android_app_name", nulls = Nulls.SKIP) + public _FinalStage androidAppName(Optional androidAppName) { + this.androidAppName = androidAppName; + 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) { + this.os = Optional.ofNullable(os); + return this; + } + + @java.lang.Override + @JsonSetter(value = "os", nulls = Nulls.SKIP) + public _FinalStage os(Optional os) { + this.os = os; + 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "browser_language", nulls = Nulls.SKIP) + public _FinalStage browserLanguage(Optional browserLanguage) { + this.browserLanguage = browserLanguage; + 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "browser_version", nulls = Nulls.SKIP) + public _FinalStage browserVersion(Optional browserVersion) { + this.browserVersion = browserVersion; + 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "browser", nulls = Nulls.SKIP) + public _FinalStage browser(Optional browser) { + this.browser = browser; + 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "language_override", nulls = Nulls.SKIP) + public _FinalStage languageOverride(Optional languageOverride) { + this.languageOverride = languageOverride; + 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "last_email_clicked_at", nulls = Nulls.SKIP) + public _FinalStage lastEmailClickedAt(Optional lastEmailClickedAt) { + this.lastEmailClickedAt = lastEmailClickedAt; + 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "last_email_opened_at", nulls = Nulls.SKIP) + public _FinalStage lastEmailOpenedAt(Optional lastEmailOpenedAt) { + this.lastEmailOpenedAt = lastEmailOpenedAt; + 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "last_contacted_at", nulls = Nulls.SKIP) + public _FinalStage lastContactedAt(Optional lastContactedAt) { + this.lastContactedAt = lastContactedAt; + 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "last_replied_at", nulls = Nulls.SKIP) + public _FinalStage lastRepliedAt(Optional lastRepliedAt) { + this.lastRepliedAt = lastRepliedAt; + 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "last_seen_at", nulls = Nulls.SKIP) + public _FinalStage lastSeenAt(Optional lastSeenAt) { + this.lastSeenAt = lastSeenAt; + 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "signed_up_at", nulls = Nulls.SKIP) + public _FinalStage signedUpAt(Optional signedUpAt) { + this.signedUpAt = signedUpAt; + 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "owner_id", nulls = Nulls.SKIP) + public _FinalStage ownerId(Optional ownerId) { + this.ownerId = ownerId; + 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public _FinalStage name(Optional name) { + this.name = name; + 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "formatted_phone", nulls = Nulls.SKIP) + public _FinalStage formattedPhone(Optional formattedPhone) { + this.formattedPhone = formattedPhone; + 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "phone", nulls = Nulls.SKIP) + public _FinalStage phone(Optional phone) { + this.phone = phone; + 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "email_domain", nulls = Nulls.SKIP) + public _FinalStage emailDomain(Optional emailDomain) { + this.emailDomain = emailDomain; + 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "email", nulls = Nulls.SKIP) + public _FinalStage email(Optional email) { + this.email = email; + 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "external_id", nulls = Nulls.SKIP) + public _FinalStage externalId(Optional externalId) { + this.externalId = externalId; + 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public _FinalStage type(Optional type) { + this.type = type; + return this; + } + + @java.lang.Override + public Contact build() { + return new Contact( + type, + id, + externalId, + workspaceId, + role, + email, + emailDomain, + phone, + formattedPhone, + 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, + 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 new file mode 100644 index 00000000..17a5f98f --- /dev/null +++ b/src/main/java/com/intercom/api/resources/conversations/AsyncConversationsClient.java @@ -0,0 +1,1313 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.conversations; + +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.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.QueryStringMapper; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.core.pagination.SyncPagingIterable; +import com.intercom.api.errors.BadRequestError; +import com.intercom.api.errors.ForbiddenError; +import com.intercom.api.errors.NotFoundError; +import com.intercom.api.errors.UnauthorizedError; +import com.intercom.api.errors.UnprocessableEntityError; +import com.intercom.api.resources.conversations.requests.AttachContactToConversationRequest; +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.DetachContactFromConversationRequest; +import com.intercom.api.resources.conversations.requests.FindConversationRequest; +import com.intercom.api.resources.conversations.requests.ListConversationsRequest; +import com.intercom.api.resources.conversations.requests.ManageConversationPartsRequest; +import com.intercom.api.resources.conversations.requests.ReplyToConversationRequest; +import com.intercom.api.resources.conversations.requests.UpdateConversationRequest; +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.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.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; +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 AsyncConversationsClient { + protected final ClientOptions clientOptions; + + public AsyncConversationsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can fetch a list of all conversations. + *

You can optionally request the result page size and the cursor to start after to fetch the result. + * {% admonition type="warning" name="Pagination" %} + * You can use pagination to limit the number of results returned. The default is 20 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ */ + public CompletableFuture> list() { + return list(ListConversationsRequest.builder().build()); + } + + /** + * You can fetch a list of all conversations. + *

You can optionally request the result page size and the cursor to start after to fetch the result. + * {% admonition type="warning" name="Pagination" %} + * You can use pagination to limit the number of results returned. The default is 20 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ */ + public CompletableFuture> list(ListConversationsRequest request) { + return list(request, null); + } + + /** + * You can fetch a list of all conversations. + *

You can optionally request the result page size and the cursor to start after to fetch the result. + * {% admonition type="warning" name="Pagination" %} + * You can use pagination to limit the number of results returned. The default is 20 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ */ + public CompletableFuture> list( + ListConversationsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations"); + if (request.getPerPage().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "per_page", request.getPerPage().get().toString(), false); + } + if (request.getStartingAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "starting_after", request.getStartingAfter().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()) { + PaginatedConversationResponse parsedResponse = ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedConversationResponse.class); + Optional startingAfter = parsedResponse + .getPages() + .flatMap(CursorPages::getNext) + .flatMap(StartingAfterPaging::getStartingAfter); + ListConversationsRequest nextRequest = ListConversationsRequest.builder() + .from(request) + .startingAfter(startingAfter) + .build(); + List result = parsedResponse.getConversations(); + future.complete(new SyncPagingIterable(startingAfter.isPresent(), result, () -> { + try { + return list(nextRequest, requestOptions).get(); + } catch (InterruptedException | ExecutionException e) { + throw new RuntimeException(e); + } + })); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + 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))); + 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 conversation that has been initiated by a contact (ie. user or lead). + * The conversation can be an in-app message only. + *

{% admonition type="info" name="Sending for visitors" %} + * You can also send a message from a visitor by specifying their user_id or id value in the from field, along with a type field value of contact. + * This visitor will be automatically converted to a contact with a lead role once the conversation is created. + * {% /admonition %}

+ *

This will return the Message model that has been created.

+ */ + public CompletableFuture create(CreateConversationRequest request) { + return create(request, null); + } + + /** + * You can create a conversation that has been initiated by a contact (ie. user or lead). + * The conversation can be an in-app message only. + *

{% admonition type="info" name="Sending for visitors" %} + * You can also send a message from a visitor by specifying their user_id or id value in the from field, along with a type field value of contact. + * This visitor will be automatically converted to a contact with a lead role once the conversation is created. + * {% /admonition %}

+ *

This will return the Message model that has been created.

+ */ + public CompletableFuture create(CreateConversationRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations") + .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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Message.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + 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))); + 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 conversation. + *

This will return a single Conversation model with all its conversation parts.

+ *

{% admonition type="warning" name="Hard limit of 500 parts" %} + * The maximum number of conversation parts that can be returned via the API is 500. If you have more than that we will return the 500 most recent conversation parts. + * {% /admonition %}

+ *

For AI agent conversation metadata, please note that you need to have the agent enabled in your workspace, which is a paid feature.

+ */ + public CompletableFuture find(FindConversationRequest request) { + return find(request, null); + } + + /** + * You can fetch the details of a single conversation. + *

This will return a single Conversation model with all its conversation parts.

+ *

{% admonition type="warning" name="Hard limit of 500 parts" %} + * The maximum number of conversation parts that can be returned via the API is 500. If you have more than that we will return the 500 most recent conversation parts. + * {% /admonition %}

+ *

For AI agent conversation metadata, please note that you need to have the agent enabled in your workspace, which is a paid feature.

+ */ + public CompletableFuture find(FindConversationRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations") + .addPathSegment(request.getConversationId()); + if (request.getDisplayAs().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "display_as", request.getDisplayAs().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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Conversation.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + 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))); + 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 conversation. + *

{% admonition type="info" name="Replying and other actions" %} + * If you want to reply to a coveration or take an action such as assign, unassign, open, close or snooze, take a look at the reply and manage endpoints. + * {% /admonition %}

+ */ + public CompletableFuture update(UpdateConversationRequest request) { + return update(request, null); + } + + /** + * You can update an existing conversation. + *

{% admonition type="info" name="Replying and other actions" %} + * If you want to reply to a coveration or take an action such as assign, unassign, open, close or snooze, take a look at the reply and manage endpoints. + * {% /admonition %}

+ */ + public CompletableFuture update(UpdateConversationRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations") + .addPathSegment(request.getConversationId()); + if (request.getDisplayAs().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "display_as", request.getDisplayAs().get(), false); + } + Map properties = new HashMap<>(); + if (request.getRead().isPresent()) { + properties.put("read", request.getRead()); + } + if (request.getCustomAttributes().isPresent()) { + properties.put("custom_attributes", request.getCustomAttributes()); + } + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("PUT", body) + .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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Conversation.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + 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))); + 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.

+ *

This will accept a query object in the body which will define your filters in order to search for conversations. + * {% admonition type="warning" name="Optimizing search queries" %} + * Search queries can be complex, so optimizing them can help the performance of your search. + * Use the AND and OR operators to combine multiple filters to get the exact results you need and utilize + * pagination to limit the number of results returned. The default is 20 results per page and maximum is 150. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ *

Nesting & Limitations

+ *

You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). + * There are some limitations to the amount of multiple's there can be:

+ *
    + *
  • There's a limit of max 2 nested filters
  • + *
  • There's a limit of max 15 filters for each AND or OR group
  • + *
+ *

Accepted Fields

+ *

Most keys listed as part of the The conversation model is searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as created_at accepts a date, the value cannot be a string such as "foorbar"). + * The source.body field is unique as the search will not be performed against the entire value, but instead against every element of the value separately. For example, when searching for a conversation with a "I need support" body - the query should contain a = operator with the value "support" for such conversation to be returned. A query with a = operator and a "need support" value will not yield a result.

+ *

| Field | Type | + * | :---------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------- | + * | id | String | + * | created_at | Date (UNIX timestamp) | + * | updated_at | Date (UNIX timestamp) | + * | source.type | String<br>Accepted fields are conversation, email, facebook, instagram, phone_call, phone_switch, push, sms, twitter and whatsapp. | + * | source.id | String | + * | source.delivered_as | String | + * | source.subject | String | + * | source.body | String | + * | source.author.id | String | + * | source.author.type | String | + * | source.author.name | String | + * | source.author.email | String | + * | source.url | String | + * | contact_ids | String | + * | teammate_ids | String | + * | admin_assignee_id | String | + * | team_assignee_id | String | + * | channel_initiated | String | + * | open | Boolean | + * | read | Boolean | + * | state | String | + * | waiting_since | Date (UNIX timestamp) | + * | snoozed_until | Date (UNIX timestamp) | + * | tag_ids | String | + * | priority | String | + * | statistics.time_to_assignment | Integer | + * | statistics.time_to_admin_reply | Integer | + * | statistics.time_to_first_close | Integer | + * | statistics.time_to_last_close | Integer | + * | statistics.median_time_to_reply | Integer | + * | statistics.first_contact_reply_at | Date (UNIX timestamp) | + * | statistics.first_assignment_at | Date (UNIX timestamp) | + * | statistics.first_admin_reply_at | Date (UNIX timestamp) | + * | statistics.first_close_at | Date (UNIX timestamp) | + * | statistics.last_assignment_at | Date (UNIX timestamp) | + * | statistics.last_assignment_admin_reply_at | Date (UNIX timestamp) | + * | statistics.last_contact_reply_at | Date (UNIX timestamp) | + * | statistics.last_admin_reply_at | Date (UNIX timestamp) | + * | statistics.last_close_at | Date (UNIX timestamp) | + * | statistics.last_closed_by_id | String | + * | statistics.count_reopens | Integer | + * | statistics.count_assignments | Integer | + * | statistics.count_conversation_parts | Integer | + * | conversation_rating.requested_at | Date (UNIX timestamp) | + * | conversation_rating.replied_at | Date (UNIX timestamp) | + * | conversation_rating.score | Integer | + * | conversation_rating.remark | String | + * | conversation_rating.contact_id | String | + * | conversation_rating.admin_d | String | + * | ai_agent_participated | Boolean | + * | ai_agent.resolution_state | String | + * | ai_agent.last_answer_type | String | + * | ai_agent.rating | Integer | + * | ai_agent.rating_remark | String | + * | ai_agent.source_type | String | + * | ai_agent.source_title | String |

+ *

Accepted Operators

+ *

The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string ("="). The operator has to be compatible with the field's type (eg. you cannot search with > for a given string value as it's only compatible for integer's and dates).

+ *

| Operator | Valid Types | Description | + * | :------- | :----------------------------- | :----------------------------------------------------------- | + * | = | All | Equals | + * | != | All | Doesn't Equal | + * | IN | All | In Shortcut for OR queries Values most be in Array | + * | NIN | All | Not In Shortcut for OR ! queries Values must be in Array | + * | > | Integer Date (UNIX Timestamp) | Greater (or equal) than | + * | < | Integer Date (UNIX Timestamp) | Lower (or equal) than | + * | ~ | String | Contains | + * | !~ | String | Doesn't Contain | + * | ^ | String | Starts With | + * | $ | String | Ends With |

+ */ + public CompletableFuture> search(SearchRequest request) { + return search(request, null); + } + + /** + * You can search for multiple conversations by the value of their attributes in order to fetch exactly which ones you want. + *

To search for conversations, you need to send a POST request to https://api.intercom.io/conversations/search.

+ *

This will accept a query object in the body which will define your filters in order to search for conversations. + * {% admonition type="warning" name="Optimizing search queries" %} + * Search queries can be complex, so optimizing them can help the performance of your search. + * Use the AND and OR operators to combine multiple filters to get the exact results you need and utilize + * pagination to limit the number of results returned. The default is 20 results per page and maximum is 150. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ *

Nesting & Limitations

+ *

You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). + * There are some limitations to the amount of multiple's there can be:

+ *
    + *
  • There's a limit of max 2 nested filters
  • + *
  • There's a limit of max 15 filters for each AND or OR group
  • + *
+ *

Accepted Fields

+ *

Most keys listed as part of the The conversation model is searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as created_at accepts a date, the value cannot be a string such as "foorbar"). + * The source.body field is unique as the search will not be performed against the entire value, but instead against every element of the value separately. For example, when searching for a conversation with a "I need support" body - the query should contain a = operator with the value "support" for such conversation to be returned. A query with a = operator and a "need support" value will not yield a result.

+ *

| Field | Type | + * | :---------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------- | + * | id | String | + * | created_at | Date (UNIX timestamp) | + * | updated_at | Date (UNIX timestamp) | + * | source.type | String<br>Accepted fields are conversation, email, facebook, instagram, phone_call, phone_switch, push, sms, twitter and whatsapp. | + * | source.id | String | + * | source.delivered_as | String | + * | source.subject | String | + * | source.body | String | + * | source.author.id | String | + * | source.author.type | String | + * | source.author.name | String | + * | source.author.email | String | + * | source.url | String | + * | contact_ids | String | + * | teammate_ids | String | + * | admin_assignee_id | String | + * | team_assignee_id | String | + * | channel_initiated | String | + * | open | Boolean | + * | read | Boolean | + * | state | String | + * | waiting_since | Date (UNIX timestamp) | + * | snoozed_until | Date (UNIX timestamp) | + * | tag_ids | String | + * | priority | String | + * | statistics.time_to_assignment | Integer | + * | statistics.time_to_admin_reply | Integer | + * | statistics.time_to_first_close | Integer | + * | statistics.time_to_last_close | Integer | + * | statistics.median_time_to_reply | Integer | + * | statistics.first_contact_reply_at | Date (UNIX timestamp) | + * | statistics.first_assignment_at | Date (UNIX timestamp) | + * | statistics.first_admin_reply_at | Date (UNIX timestamp) | + * | statistics.first_close_at | Date (UNIX timestamp) | + * | statistics.last_assignment_at | Date (UNIX timestamp) | + * | statistics.last_assignment_admin_reply_at | Date (UNIX timestamp) | + * | statistics.last_contact_reply_at | Date (UNIX timestamp) | + * | statistics.last_admin_reply_at | Date (UNIX timestamp) | + * | statistics.last_close_at | Date (UNIX timestamp) | + * | statistics.last_closed_by_id | String | + * | statistics.count_reopens | Integer | + * | statistics.count_assignments | Integer | + * | statistics.count_conversation_parts | Integer | + * | conversation_rating.requested_at | Date (UNIX timestamp) | + * | conversation_rating.replied_at | Date (UNIX timestamp) | + * | conversation_rating.score | Integer | + * | conversation_rating.remark | String | + * | conversation_rating.contact_id | String | + * | conversation_rating.admin_d | String | + * | ai_agent_participated | Boolean | + * | ai_agent.resolution_state | String | + * | ai_agent.last_answer_type | String | + * | ai_agent.rating | Integer | + * | ai_agent.rating_remark | String | + * | ai_agent.source_type | String | + * | ai_agent.source_title | String |

+ *

Accepted Operators

+ *

The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string ("="). The operator has to be compatible with the field's type (eg. you cannot search with > for a given string value as it's only compatible for integer's and dates).

+ *

| Operator | Valid Types | Description | + * | :------- | :----------------------------- | :----------------------------------------------------------- | + * | = | All | Equals | + * | != | All | Doesn't Equal | + * | IN | All | In Shortcut for OR queries Values most be in Array | + * | NIN | All | Not In Shortcut for OR ! queries Values must be in Array | + * | > | Integer Date (UNIX Timestamp) | Greater (or equal) than | + * | < | Integer Date (UNIX Timestamp) | Lower (or equal) than | + * | ~ | String | Contains | + * | !~ | String | Doesn't Contain | + * | ^ | String | Starts With | + * | $ | String | Ends With |

+ */ + public CompletableFuture> search( + SearchRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations/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()) { + PaginatedConversationResponse parsedResponse = ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedConversationResponse.class); + Optional startingAfter = parsedResponse + .getPages() + .flatMap(CursorPages::getNext) + .flatMap(StartingAfterPaging::getStartingAfter); + Optional pagination = request.getPagination() + .map(pagination_ -> StartingAfterPaging.builder() + .from(pagination_) + .startingAfter(startingAfter) + .build()); + SearchRequest nextRequest = SearchRequest.builder() + .from(request) + .pagination(pagination) + .build(); + List result = parsedResponse.getConversations(); + future.complete(new SyncPagingIterable(startingAfter.isPresent(), result, () -> { + try { + return search(nextRequest, requestOptions).get(); + } catch (InterruptedException | ExecutionException e) { + throw new RuntimeException(e); + } + })); + 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))); + 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 reply to a conversation with a message from an admin or on behalf of a contact, or with a note for admins. + */ + public CompletableFuture reply(ReplyToConversationRequest request) { + return reply(request, null); + } + + /** + * You can reply to a conversation with a message from an admin or on behalf of a contact, or with a note for admins. + */ + public CompletableFuture reply(ReplyToConversationRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations") + .addPathSegment(request.getConversationId()) + .addPathSegments("reply") + .build(); + RequestBody body; + try { + 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("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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Conversation.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + 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))); + 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; + } + + /** + * For managing conversations you can: + *
    + *
  • Close a conversation
  • + *
  • Snooze a conversation to reopen on a future date
  • + *
  • Open a conversation which is snoozed or closed
  • + *
  • Assign a conversation to an admin and/or team.
  • + *
+ */ + public CompletableFuture manage(ManageConversationPartsRequest request) { + return manage(request, null); + } + + /** + * For managing conversations you can: + *
    + *
  • Close a conversation
  • + *
  • Snooze a conversation to reopen on a future date
  • + *
  • Open a conversation which is snoozed or closed
  • + *
  • Assign a conversation to an admin and/or team.
  • + *
+ */ + public CompletableFuture manage( + ManageConversationPartsRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations") + .addPathSegment(request.getConversationId()) + .addPathSegments("parts") + .build(); + RequestBody body; + try { + 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("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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Conversation.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + 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))); + 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; + } + + /** + * {% 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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Conversation.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + 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))); + 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" %} + * If you add a contact via the email parameter and there is no user/lead found on that workspace with he given email, then we will create a new contact with role set to lead. + * {% /admonition %}

+ */ + public CompletableFuture attachContactAsAdmin(AttachContactToConversationRequest request) { + return attachContactAsAdmin(request, null); + } + + /** + * You can add participants who are contacts to a conversation, on behalf of either another contact or an admin. + *

{% admonition type="warning" name="Contacts without an email" %} + * If you add a contact via the email parameter and there is no user/lead found on that workspace with he given email, then we will create a new contact with role set to lead. + * {% /admonition %}

+ */ + public CompletableFuture attachContactAsAdmin( + AttachContactToConversationRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations") + .addPathSegment(request.getConversationId()) + .addPathSegments("customers") + .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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Conversation.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + 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))); + 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" %} + * If you add a contact via the email parameter and there is no user/lead found on that workspace with he given email, then we will create a new contact with role set to lead. + * {% /admonition %}

+ */ + public CompletableFuture detachContactAsAdmin(DetachContactFromConversationRequest request) { + return detachContactAsAdmin(request, null); + } + + /** + * You can add participants who are contacts to a conversation, on behalf of either another contact or an admin. + *

{% admonition type="warning" name="Contacts without an email" %} + * If you add a contact via the email parameter and there is no user/lead found on that workspace with he given email, then we will create a new contact with role set to lead. + * {% /admonition %}

+ */ + public CompletableFuture detachContactAsAdmin( + DetachContactFromConversationRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations") + .addPathSegment(request.getConversationId()) + .addPathSegments("customers") + .addPathSegment(request.getContactId()) + .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("DELETE", 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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Conversation.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + return; + case 422: + future.completeExceptionally(new UnprocessableEntityError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + 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))); + 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 redact a conversation part or the source message of a conversation (as seen in the source object). + *

{% admonition type="info" name="Redacting parts and messages" %} + * If you are redacting a conversation part, it must have a body. If you are redacting a source message, it must have been created by a contact. We will return a conversation_part_not_redactable error if these criteria are not met. + * {% /admonition %}

+ */ + public CompletableFuture redactConversationPart(RedactConversationRequest request) { + return redactConversationPart(request, null); + } + + /** + * You can redact a conversation part or the source message of a conversation (as seen in the source object). + *

{% admonition type="info" name="Redacting parts and messages" %} + * If you are redacting a conversation part, it must have a body. If you are redacting a source message, it must have been created by a contact. We will return a conversation_part_not_redactable error if these criteria are not met. + * {% /admonition %}

+ */ + public CompletableFuture redactConversationPart( + RedactConversationRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations/redact") + .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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Conversation.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + 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))); + 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 convert a conversation to a ticket. + */ + public CompletableFuture convertToTicket(ConvertConversationToTicketRequest request) { + return convertToTicket(request, null); + } + + /** + * You can convert a conversation to a ticket. + */ + public CompletableFuture convertToTicket( + ConvertConversationToTicketRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations") + .addPathSegment(request.getConversationId()) + .addPathSegments("convert") + .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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Ticket.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 400) { + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + 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))); + 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 new file mode 100644 index 00000000..080adceb --- /dev/null +++ b/src/main/java/com/intercom/api/resources/conversations/ConversationsClient.java @@ -0,0 +1,1087 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.conversations; + +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.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.QueryStringMapper; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.core.pagination.SyncPagingIterable; +import com.intercom.api.errors.BadRequestError; +import com.intercom.api.errors.ForbiddenError; +import com.intercom.api.errors.NotFoundError; +import com.intercom.api.errors.UnauthorizedError; +import com.intercom.api.errors.UnprocessableEntityError; +import com.intercom.api.resources.conversations.requests.AttachContactToConversationRequest; +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.DetachContactFromConversationRequest; +import com.intercom.api.resources.conversations.requests.FindConversationRequest; +import com.intercom.api.resources.conversations.requests.ListConversationsRequest; +import com.intercom.api.resources.conversations.requests.ManageConversationPartsRequest; +import com.intercom.api.resources.conversations.requests.ReplyToConversationRequest; +import com.intercom.api.resources.conversations.requests.UpdateConversationRequest; +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.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.HashMap; +import java.util.List; +import java.util.Map; +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 ConversationsClient { + protected final ClientOptions clientOptions; + + public ConversationsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can fetch a list of all conversations. + *

You can optionally request the result page size and the cursor to start after to fetch the result. + * {% admonition type="warning" name="Pagination" %} + * You can use pagination to limit the number of results returned. The default is 20 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ */ + public SyncPagingIterable list() { + return list(ListConversationsRequest.builder().build()); + } + + /** + * You can fetch a list of all conversations. + *

You can optionally request the result page size and the cursor to start after to fetch the result. + * {% admonition type="warning" name="Pagination" %} + * You can use pagination to limit the number of results returned. The default is 20 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ */ + public SyncPagingIterable list(ListConversationsRequest request) { + return list(request, null); + } + + /** + * You can fetch a list of all conversations. + *

You can optionally request the result page size and the cursor to start after to fetch the result. + * {% admonition type="warning" name="Pagination" %} + * You can use pagination to limit the number of results returned. The default is 20 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ */ + public SyncPagingIterable list(ListConversationsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations"); + if (request.getPerPage().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "per_page", request.getPerPage().get().toString(), false); + } + if (request.getStartingAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "starting_after", request.getStartingAfter().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()) { + PaginatedConversationResponse parsedResponse = + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedConversationResponse.class); + Optional startingAfter = parsedResponse + .getPages() + .flatMap(CursorPages::getNext) + .flatMap(StartingAfterPaging::getStartingAfter); + ListConversationsRequest nextRequest = ListConversationsRequest.builder() + .from(request) + .startingAfter(startingAfter) + .build(); + List result = parsedResponse.getConversations(); + return new SyncPagingIterable( + startingAfter.isPresent(), result, () -> list(nextRequest, requestOptions)); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 403: + throw new ForbiddenError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can create a conversation that has been initiated by a contact (ie. user or lead). + * The conversation can be an in-app message only. + *

{% admonition type="info" name="Sending for visitors" %} + * You can also send a message from a visitor by specifying their user_id or id value in the from field, along with a type field value of contact. + * This visitor will be automatically converted to a contact with a lead role once the conversation is created. + * {% /admonition %}

+ *

This will return the Message model that has been created.

+ */ + public Message create(CreateConversationRequest request) { + return create(request, null); + } + + /** + * You can create a conversation that has been initiated by a contact (ie. user or lead). + * The conversation can be an in-app message only. + *

{% admonition type="info" name="Sending for visitors" %} + * You can also send a message from a visitor by specifying their user_id or id value in the from field, along with a type field value of contact. + * This visitor will be automatically converted to a contact with a lead role once the conversation is created. + * {% /admonition %}

+ *

This will return the Message model that has been created.

+ */ + public Message create(CreateConversationRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations") + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Message.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 403: + throw new ForbiddenError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can fetch the details of a single conversation. + *

This will return a single Conversation model with all its conversation parts.

+ *

{% admonition type="warning" name="Hard limit of 500 parts" %} + * The maximum number of conversation parts that can be returned via the API is 500. If you have more than that we will return the 500 most recent conversation parts. + * {% /admonition %}

+ *

For AI agent conversation metadata, please note that you need to have the agent enabled in your workspace, which is a paid feature.

+ */ + public Conversation find(FindConversationRequest request) { + return find(request, null); + } + + /** + * You can fetch the details of a single conversation. + *

This will return a single Conversation model with all its conversation parts.

+ *

{% admonition type="warning" name="Hard limit of 500 parts" %} + * The maximum number of conversation parts that can be returned via the API is 500. If you have more than that we will return the 500 most recent conversation parts. + * {% /admonition %}

+ *

For AI agent conversation metadata, please note that you need to have the agent enabled in your workspace, which is a paid feature.

+ */ + public Conversation find(FindConversationRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations") + .addPathSegment(request.getConversationId()); + if (request.getDisplayAs().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "display_as", request.getDisplayAs().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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Conversation.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 403: + throw new ForbiddenError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can update an existing conversation. + *

{% admonition type="info" name="Replying and other actions" %} + * If you want to reply to a coveration or take an action such as assign, unassign, open, close or snooze, take a look at the reply and manage endpoints. + * {% /admonition %}

+ */ + public Conversation update(UpdateConversationRequest request) { + return update(request, null); + } + + /** + * You can update an existing conversation. + *

{% admonition type="info" name="Replying and other actions" %} + * If you want to reply to a coveration or take an action such as assign, unassign, open, close or snooze, take a look at the reply and manage endpoints. + * {% /admonition %}

+ */ + public Conversation update(UpdateConversationRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations") + .addPathSegment(request.getConversationId()); + if (request.getDisplayAs().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "display_as", request.getDisplayAs().get(), false); + } + Map properties = new HashMap<>(); + if (request.getRead().isPresent()) { + properties.put("read", request.getRead()); + } + if (request.getCustomAttributes().isPresent()) { + properties.put("custom_attributes", request.getCustomAttributes()); + } + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("PUT", body) + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Conversation.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 403: + throw new ForbiddenError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } 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.

+ *

This will accept a query object in the body which will define your filters in order to search for conversations. + * {% admonition type="warning" name="Optimizing search queries" %} + * Search queries can be complex, so optimizing them can help the performance of your search. + * Use the AND and OR operators to combine multiple filters to get the exact results you need and utilize + * pagination to limit the number of results returned. The default is 20 results per page and maximum is 150. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ *

Nesting & Limitations

+ *

You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). + * There are some limitations to the amount of multiple's there can be:

+ *
    + *
  • There's a limit of max 2 nested filters
  • + *
  • There's a limit of max 15 filters for each AND or OR group
  • + *
+ *

Accepted Fields

+ *

Most keys listed as part of the The conversation model is searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as created_at accepts a date, the value cannot be a string such as "foorbar"). + * The source.body field is unique as the search will not be performed against the entire value, but instead against every element of the value separately. For example, when searching for a conversation with a "I need support" body - the query should contain a = operator with the value "support" for such conversation to be returned. A query with a = operator and a "need support" value will not yield a result.

+ *

| Field | Type | + * | :---------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------- | + * | id | String | + * | created_at | Date (UNIX timestamp) | + * | updated_at | Date (UNIX timestamp) | + * | source.type | String<br>Accepted fields are conversation, email, facebook, instagram, phone_call, phone_switch, push, sms, twitter and whatsapp. | + * | source.id | String | + * | source.delivered_as | String | + * | source.subject | String | + * | source.body | String | + * | source.author.id | String | + * | source.author.type | String | + * | source.author.name | String | + * | source.author.email | String | + * | source.url | String | + * | contact_ids | String | + * | teammate_ids | String | + * | admin_assignee_id | String | + * | team_assignee_id | String | + * | channel_initiated | String | + * | open | Boolean | + * | read | Boolean | + * | state | String | + * | waiting_since | Date (UNIX timestamp) | + * | snoozed_until | Date (UNIX timestamp) | + * | tag_ids | String | + * | priority | String | + * | statistics.time_to_assignment | Integer | + * | statistics.time_to_admin_reply | Integer | + * | statistics.time_to_first_close | Integer | + * | statistics.time_to_last_close | Integer | + * | statistics.median_time_to_reply | Integer | + * | statistics.first_contact_reply_at | Date (UNIX timestamp) | + * | statistics.first_assignment_at | Date (UNIX timestamp) | + * | statistics.first_admin_reply_at | Date (UNIX timestamp) | + * | statistics.first_close_at | Date (UNIX timestamp) | + * | statistics.last_assignment_at | Date (UNIX timestamp) | + * | statistics.last_assignment_admin_reply_at | Date (UNIX timestamp) | + * | statistics.last_contact_reply_at | Date (UNIX timestamp) | + * | statistics.last_admin_reply_at | Date (UNIX timestamp) | + * | statistics.last_close_at | Date (UNIX timestamp) | + * | statistics.last_closed_by_id | String | + * | statistics.count_reopens | Integer | + * | statistics.count_assignments | Integer | + * | statistics.count_conversation_parts | Integer | + * | conversation_rating.requested_at | Date (UNIX timestamp) | + * | conversation_rating.replied_at | Date (UNIX timestamp) | + * | conversation_rating.score | Integer | + * | conversation_rating.remark | String | + * | conversation_rating.contact_id | String | + * | conversation_rating.admin_d | String | + * | ai_agent_participated | Boolean | + * | ai_agent.resolution_state | String | + * | ai_agent.last_answer_type | String | + * | ai_agent.rating | Integer | + * | ai_agent.rating_remark | String | + * | ai_agent.source_type | String | + * | ai_agent.source_title | String |

+ *

Accepted Operators

+ *

The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string ("="). The operator has to be compatible with the field's type (eg. you cannot search with > for a given string value as it's only compatible for integer's and dates).

+ *

| Operator | Valid Types | Description | + * | :------- | :----------------------------- | :----------------------------------------------------------- | + * | = | All | Equals | + * | != | All | Doesn't Equal | + * | IN | All | In Shortcut for OR queries Values most be in Array | + * | NIN | All | Not In Shortcut for OR ! queries Values must be in Array | + * | > | Integer Date (UNIX Timestamp) | Greater (or equal) than | + * | < | Integer Date (UNIX Timestamp) | Lower (or equal) than | + * | ~ | String | Contains | + * | !~ | String | Doesn't Contain | + * | ^ | String | Starts With | + * | $ | String | Ends With |

+ */ + public SyncPagingIterable search(SearchRequest request) { + return search(request, null); + } + + /** + * You can search for multiple conversations by the value of their attributes in order to fetch exactly which ones you want. + *

To search for conversations, you need to send a POST request to https://api.intercom.io/conversations/search.

+ *

This will accept a query object in the body which will define your filters in order to search for conversations. + * {% admonition type="warning" name="Optimizing search queries" %} + * Search queries can be complex, so optimizing them can help the performance of your search. + * Use the AND and OR operators to combine multiple filters to get the exact results you need and utilize + * pagination to limit the number of results returned. The default is 20 results per page and maximum is 150. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ *

Nesting & Limitations

+ *

You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). + * There are some limitations to the amount of multiple's there can be:

+ *
    + *
  • There's a limit of max 2 nested filters
  • + *
  • There's a limit of max 15 filters for each AND or OR group
  • + *
+ *

Accepted Fields

+ *

Most keys listed as part of the The conversation model is searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as created_at accepts a date, the value cannot be a string such as "foorbar"). + * The source.body field is unique as the search will not be performed against the entire value, but instead against every element of the value separately. For example, when searching for a conversation with a "I need support" body - the query should contain a = operator with the value "support" for such conversation to be returned. A query with a = operator and a "need support" value will not yield a result.

+ *

| Field | Type | + * | :---------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------- | + * | id | String | + * | created_at | Date (UNIX timestamp) | + * | updated_at | Date (UNIX timestamp) | + * | source.type | String<br>Accepted fields are conversation, email, facebook, instagram, phone_call, phone_switch, push, sms, twitter and whatsapp. | + * | source.id | String | + * | source.delivered_as | String | + * | source.subject | String | + * | source.body | String | + * | source.author.id | String | + * | source.author.type | String | + * | source.author.name | String | + * | source.author.email | String | + * | source.url | String | + * | contact_ids | String | + * | teammate_ids | String | + * | admin_assignee_id | String | + * | team_assignee_id | String | + * | channel_initiated | String | + * | open | Boolean | + * | read | Boolean | + * | state | String | + * | waiting_since | Date (UNIX timestamp) | + * | snoozed_until | Date (UNIX timestamp) | + * | tag_ids | String | + * | priority | String | + * | statistics.time_to_assignment | Integer | + * | statistics.time_to_admin_reply | Integer | + * | statistics.time_to_first_close | Integer | + * | statistics.time_to_last_close | Integer | + * | statistics.median_time_to_reply | Integer | + * | statistics.first_contact_reply_at | Date (UNIX timestamp) | + * | statistics.first_assignment_at | Date (UNIX timestamp) | + * | statistics.first_admin_reply_at | Date (UNIX timestamp) | + * | statistics.first_close_at | Date (UNIX timestamp) | + * | statistics.last_assignment_at | Date (UNIX timestamp) | + * | statistics.last_assignment_admin_reply_at | Date (UNIX timestamp) | + * | statistics.last_contact_reply_at | Date (UNIX timestamp) | + * | statistics.last_admin_reply_at | Date (UNIX timestamp) | + * | statistics.last_close_at | Date (UNIX timestamp) | + * | statistics.last_closed_by_id | String | + * | statistics.count_reopens | Integer | + * | statistics.count_assignments | Integer | + * | statistics.count_conversation_parts | Integer | + * | conversation_rating.requested_at | Date (UNIX timestamp) | + * | conversation_rating.replied_at | Date (UNIX timestamp) | + * | conversation_rating.score | Integer | + * | conversation_rating.remark | String | + * | conversation_rating.contact_id | String | + * | conversation_rating.admin_d | String | + * | ai_agent_participated | Boolean | + * | ai_agent.resolution_state | String | + * | ai_agent.last_answer_type | String | + * | ai_agent.rating | Integer | + * | ai_agent.rating_remark | String | + * | ai_agent.source_type | String | + * | ai_agent.source_title | String |

+ *

Accepted Operators

+ *

The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string ("="). The operator has to be compatible with the field's type (eg. you cannot search with > for a given string value as it's only compatible for integer's and dates).

+ *

| Operator | Valid Types | Description | + * | :------- | :----------------------------- | :----------------------------------------------------------- | + * | = | All | Equals | + * | != | All | Doesn't Equal | + * | IN | All | In Shortcut for OR queries Values most be in Array | + * | NIN | All | Not In Shortcut for OR ! queries Values must be in Array | + * | > | Integer Date (UNIX Timestamp) | Greater (or equal) than | + * | < | Integer Date (UNIX Timestamp) | Lower (or equal) than | + * | ~ | String | Contains | + * | !~ | String | Doesn't Contain | + * | ^ | String | Starts With | + * | $ | String | Ends With |

+ */ + public SyncPagingIterable search(SearchRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations/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()) { + PaginatedConversationResponse parsedResponse = + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedConversationResponse.class); + Optional startingAfter = parsedResponse + .getPages() + .flatMap(CursorPages::getNext) + .flatMap(StartingAfterPaging::getStartingAfter); + Optional pagination = request.getPagination() + .map(pagination_ -> StartingAfterPaging.builder() + .from(pagination_) + .startingAfter(startingAfter) + .build()); + SearchRequest nextRequest = SearchRequest.builder() + .from(request) + .pagination(pagination) + .build(); + List result = parsedResponse.getConversations(); + return new SyncPagingIterable( + startingAfter.isPresent(), result, () -> search(nextRequest, requestOptions)); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can reply to a conversation with a message from an admin or on behalf of a contact, or with a note for admins. + */ + public Conversation reply(ReplyToConversationRequest request) { + return reply(request, null); + } + + /** + * You can reply to a conversation with a message from an admin or on behalf of a contact, or with a note for admins. + */ + public Conversation reply(ReplyToConversationRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations") + .addPathSegment(request.getConversationId()) + .addPathSegments("reply") + .build(); + RequestBody body; + try { + 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("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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Conversation.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 403: + throw new ForbiddenError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * For managing conversations you can: + *
    + *
  • Close a conversation
  • + *
  • Snooze a conversation to reopen on a future date
  • + *
  • Open a conversation which is snoozed or closed
  • + *
  • Assign a conversation to an admin and/or team.
  • + *
+ */ + public Conversation manage(ManageConversationPartsRequest request) { + return manage(request, null); + } + + /** + * For managing conversations you can: + *
    + *
  • Close a conversation
  • + *
  • Snooze a conversation to reopen on a future date
  • + *
  • Open a conversation which is snoozed or closed
  • + *
  • Assign a conversation to an admin and/or team.
  • + *
+ */ + public Conversation manage(ManageConversationPartsRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations") + .addPathSegment(request.getConversationId()) + .addPathSegments("parts") + .build(); + RequestBody body; + try { + 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("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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Conversation.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 403: + throw new ForbiddenError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * {% 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 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 Conversation 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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Conversation.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 403: + throw new ForbiddenError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } 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" %} + * If you add a contact via the email parameter and there is no user/lead found on that workspace with he given email, then we will create a new contact with role set to lead. + * {% /admonition %}

+ */ + public Conversation attachContactAsAdmin(AttachContactToConversationRequest request) { + return attachContactAsAdmin(request, null); + } + + /** + * You can add participants who are contacts to a conversation, on behalf of either another contact or an admin. + *

{% admonition type="warning" name="Contacts without an email" %} + * If you add a contact via the email parameter and there is no user/lead found on that workspace with he given email, then we will create a new contact with role set to lead. + * {% /admonition %}

+ */ + public Conversation attachContactAsAdmin( + AttachContactToConversationRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations") + .addPathSegment(request.getConversationId()) + .addPathSegments("customers") + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Conversation.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 403: + throw new ForbiddenError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } 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" %} + * If you add a contact via the email parameter and there is no user/lead found on that workspace with he given email, then we will create a new contact with role set to lead. + * {% /admonition %}

+ */ + public Conversation detachContactAsAdmin(DetachContactFromConversationRequest request) { + return detachContactAsAdmin(request, null); + } + + /** + * You can add participants who are contacts to a conversation, on behalf of either another contact or an admin. + *

{% admonition type="warning" name="Contacts without an email" %} + * If you add a contact via the email parameter and there is no user/lead found on that workspace with he given email, then we will create a new contact with role set to lead. + * {% /admonition %}

+ */ + public Conversation detachContactAsAdmin( + DetachContactFromConversationRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations") + .addPathSegment(request.getConversationId()) + .addPathSegments("customers") + .addPathSegment(request.getContactId()) + .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("DELETE", 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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Conversation.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 403: + throw new ForbiddenError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 422: + throw new UnprocessableEntityError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can redact a conversation part or the source message of a conversation (as seen in the source object). + *

{% admonition type="info" name="Redacting parts and messages" %} + * If you are redacting a conversation part, it must have a body. If you are redacting a source message, it must have been created by a contact. We will return a conversation_part_not_redactable error if these criteria are not met. + * {% /admonition %}

+ */ + public Conversation redactConversationPart(RedactConversationRequest request) { + return redactConversationPart(request, null); + } + + /** + * You can redact a conversation part or the source message of a conversation (as seen in the source object). + *

{% admonition type="info" name="Redacting parts and messages" %} + * If you are redacting a conversation part, it must have a body. If you are redacting a source message, it must have been created by a contact. We will return a conversation_part_not_redactable error if these criteria are not met. + * {% /admonition %}

+ */ + public Conversation redactConversationPart(RedactConversationRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations/redact") + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Conversation.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can convert a conversation to a ticket. + */ + public Ticket convertToTicket(ConvertConversationToTicketRequest request) { + return convertToTicket(request, null); + } + + /** + * You can convert a conversation to a ticket. + */ + public Ticket convertToTicket(ConvertConversationToTicketRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations") + .addPathSegment(request.getConversationId()) + .addPathSegments("convert") + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Ticket.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 400) { + throw new BadRequestError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/conversations/requests/AttachContactToConversationRequest.java b/src/main/java/com/intercom/api/resources/conversations/requests/AttachContactToConversationRequest.java new file mode 100644 index 00000000..1fba65c8 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/conversations/requests/AttachContactToConversationRequest.java @@ -0,0 +1,645 @@ +/** + * 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.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.CustomerRequest; +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 = AttachContactToConversationRequest.Builder.class) +public final class AttachContactToConversationRequest { + private final String conversationId; + + private final Optional adminId; + + private final Optional customer; + + private final Map additionalProperties; + + private AttachContactToConversationRequest( + String conversationId, + Optional adminId, + Optional customer, + Map additionalProperties) { + this.conversationId = conversationId; + this.adminId = adminId; + this.customer = customer; + this.additionalProperties = additionalProperties; + } + + /** + * @return The identifier for the conversation as given by Intercom. + */ + @JsonProperty("conversation_id") + public String getConversationId() { + return conversationId; + } + + /** + * @return The id of the admin who is adding the new participant. + */ + @JsonProperty("admin_id") + public Optional getAdminId() { + return adminId; + } + + @JsonProperty("customer") + public Optional getCustomer() { + return customer; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AttachContactToConversationRequest + && equalTo((AttachContactToConversationRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(AttachContactToConversationRequest other) { + return conversationId.equals(other.conversationId) + && adminId.equals(other.adminId) + && customer.equals(other.customer); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.conversationId, this.adminId, this.customer); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ConversationIdStage builder() { + return new Builder(); + } + + public interface ConversationIdStage { + _FinalStage conversationId(@NotNull String conversationId); + + Builder from(AttachContactToConversationRequest other); + } + + public interface _FinalStage { + AttachContactToConversationRequest build(); + + _FinalStage adminId(Optional adminId); + + _FinalStage adminId(String adminId); + + _FinalStage customer(Optional customer); + + _FinalStage customer(Customer customer); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ConversationIdStage, _FinalStage { + private String conversationId; + + private Optional customer = Optional.empty(); + + private Optional adminId = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(AttachContactToConversationRequest other) { + conversationId(other.getConversationId()); + adminId(other.getAdminId()); + customer(other.getCustomer()); + return this; + } + + /** + *

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) { + this.conversationId = Objects.requireNonNull(conversationId, "conversationId must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage customer(Customer customer) { + this.customer = Optional.ofNullable(customer); + return this; + } + + @java.lang.Override + @JsonSetter(value = "customer", nulls = Nulls.SKIP) + public _FinalStage customer(Optional customer) { + this.customer = customer; + return this; + } + + /** + *

The id of the admin who is adding the new participant.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage adminId(String adminId) { + this.adminId = Optional.ofNullable(adminId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "admin_id", nulls = Nulls.SKIP) + public _FinalStage adminId(Optional adminId) { + this.adminId = adminId; + return this; + } + + @java.lang.Override + public AttachContactToConversationRequest build() { + return new AttachContactToConversationRequest(conversationId, adminId, customer, additionalProperties); + } + } + + @JsonDeserialize(using = Customer.Deserializer.class) + public static final class Customer { + private final Object value; + + private final int type; + + private Customer(Object value, int type) { + this.value = value; + this.type = type; + } + + @JsonValue + public Object get() { + return this.value; + } + + public T visit(Visitor visitor) { + if (this.type == 0) { + return visitor.visit((IntercomUserId) this.value); + } else if (this.type == 1) { + return visitor.visit((UserId) this.value); + } else if (this.type == 2) { + return visitor.visit((Customer_) 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 Customer && equalTo((Customer) other); + } + + private boolean equalTo(Customer 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 Customer of(IntercomUserId value) { + return new Customer(value, 0); + } + + public static Customer of(UserId value) { + return new Customer(value, 1); + } + + public static Customer of(Customer_ value) { + return new Customer(value, 2); + } + + public interface Visitor { + T visit(IntercomUserId value); + + T visit(UserId value); + + T visit(Customer_ value); + } + + static final class Deserializer extends StdDeserializer { + Deserializer() { + super(Customer.class); + } + + @java.lang.Override + public Customer deserialize(JsonParser p, DeserializationContext context) throws IOException { + Object value = p.readValueAs(Object.class); + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, IntercomUserId.class)); + } catch (IllegalArgumentException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, UserId.class)); + } catch (IllegalArgumentException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, Customer_.class)); + } catch (IllegalArgumentException e) { + } + throw new JsonParseException(p, "Failed to deserialize"); + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = UserId.Builder.class) + public static final class UserId { + private final String userId; + + private final Optional customer; + + private final Map additionalProperties; + + private UserId( + String userId, Optional customer, Map additionalProperties) { + this.userId = userId; + this.customer = customer; + this.additionalProperties = additionalProperties; + } + + /** + * @return The external_id you have defined for the contact who is being added as a participant. + */ + @JsonProperty("user_id") + public String getUserId() { + return userId; + } + + @JsonProperty("customer") + public Optional getCustomer() { + return customer; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UserId && equalTo((UserId) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UserId other) { + return userId.equals(other.userId) && customer.equals(other.customer); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.userId, this.customer); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static UserIdStage builder() { + return new Builder(); + } + + public interface UserIdStage { + _FinalStage userId(@NotNull String userId); + + Builder from(UserId other); + } + + public interface _FinalStage { + UserId build(); + + _FinalStage customer(Optional customer); + + _FinalStage customer(CustomerRequest customer); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements UserIdStage, _FinalStage { + private String userId; + + private Optional customer = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(UserId other) { + userId(other.getUserId()); + customer(other.getCustomer()); + return this; + } + + /** + *

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("user_id") + public _FinalStage userId(@NotNull String userId) { + this.userId = Objects.requireNonNull(userId, "userId must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage customer(CustomerRequest customer) { + this.customer = Optional.ofNullable(customer); + return this; + } + + @java.lang.Override + @JsonSetter(value = "customer", nulls = Nulls.SKIP) + public _FinalStage customer(Optional customer) { + this.customer = customer; + return this; + } + + @java.lang.Override + public UserId build() { + return new UserId(userId, customer, additionalProperties); + } + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = Customer_.Builder.class) + public static final class Customer_ { + private final String email; + + private final Optional customer; + + private final Map additionalProperties; + + private Customer_( + String email, Optional customer, Map additionalProperties) { + this.email = email; + this.customer = customer; + this.additionalProperties = additionalProperties; + } + + /** + * @return The email you have defined for the contact who is being added as a participant. + */ + @JsonProperty("email") + public String getEmail() { + return email; + } + + @JsonProperty("customer") + public Optional getCustomer() { + return customer; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Customer_ && equalTo((Customer_) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Customer_ other) { + return email.equals(other.email) && customer.equals(other.customer); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.email, this.customer); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static EmailStage builder() { + return new Builder(); + } + + public interface EmailStage { + _FinalStage email(@NotNull String email); + + Builder from(Customer_ other); + } + + public interface _FinalStage { + Customer_ build(); + + _FinalStage customer(Optional customer); + + _FinalStage customer(CustomerRequest customer); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements EmailStage, _FinalStage { + private String email; + + private Optional customer = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(Customer_ other) { + email(other.getEmail()); + customer(other.getCustomer()); + return this; + } + + /** + *

The email 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("email") + public _FinalStage email(@NotNull String email) { + this.email = Objects.requireNonNull(email, "email must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage customer(CustomerRequest customer) { + this.customer = Optional.ofNullable(customer); + return this; + } + + @java.lang.Override + @JsonSetter(value = "customer", nulls = Nulls.SKIP) + public _FinalStage customer(Optional customer) { + this.customer = customer; + return this; + } + + @java.lang.Override + public Customer_ build() { + return new Customer_(email, customer, additionalProperties); + } + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = IntercomUserId.Builder.class) + public static final class IntercomUserId { + private final String intercomUserId; + + private final Optional customer; + + private final Map additionalProperties; + + private IntercomUserId( + String intercomUserId, + Optional customer, + Map additionalProperties) { + this.intercomUserId = intercomUserId; + this.customer = customer; + this.additionalProperties = additionalProperties; + } + + /** + * @return The identifier for the contact as given by Intercom. + */ + @JsonProperty("intercom_user_id") + public String getIntercomUserId() { + return intercomUserId; + } + + @JsonProperty("customer") + public Optional getCustomer() { + return customer; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof IntercomUserId && equalTo((IntercomUserId) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(IntercomUserId other) { + return intercomUserId.equals(other.intercomUserId) && customer.equals(other.customer); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.intercomUserId, this.customer); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IntercomUserIdStage builder() { + return new Builder(); + } + + public interface IntercomUserIdStage { + _FinalStage intercomUserId(@NotNull String intercomUserId); + + Builder from(IntercomUserId other); + } + + public interface _FinalStage { + IntercomUserId build(); + + _FinalStage customer(Optional customer); + + _FinalStage customer(CustomerRequest customer); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IntercomUserIdStage, _FinalStage { + private String intercomUserId; + + private Optional customer = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(IntercomUserId other) { + intercomUserId(other.getIntercomUserId()); + customer(other.getCustomer()); + return this; + } + + /** + *

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("intercom_user_id") + public _FinalStage intercomUserId(@NotNull String intercomUserId) { + this.intercomUserId = Objects.requireNonNull(intercomUserId, "intercomUserId must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage customer(CustomerRequest customer) { + this.customer = Optional.ofNullable(customer); + return this; + } + + @java.lang.Override + @JsonSetter(value = "customer", nulls = Nulls.SKIP) + public _FinalStage customer(Optional customer) { + this.customer = customer; + return this; + } + + @java.lang.Override + public IntercomUserId build() { + return new IntercomUserId(intercomUserId, customer, additionalProperties); + } + } + } + } +} 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 new file mode 100644 index 00000000..c5843392 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/conversations/requests/AutoAssignConversationRequest.java @@ -0,0 +1,109 @@ +/** + * 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; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = AutoAssignConversationRequest.Builder.class) +public final class AutoAssignConversationRequest { + private final String conversationId; + + private final Map additionalProperties; + + private AutoAssignConversationRequest(String conversationId, Map additionalProperties) { + this.conversationId = conversationId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The identifier for the conversation as given by Intercom. + */ + @JsonProperty("conversation_id") + public String getConversationId() { + return conversationId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AutoAssignConversationRequest && equalTo((AutoAssignConversationRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(AutoAssignConversationRequest other) { + return conversationId.equals(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 { + _FinalStage conversationId(@NotNull String conversationId); + + Builder from(AutoAssignConversationRequest other); + } + + public interface _FinalStage { + AutoAssignConversationRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ConversationIdStage, _FinalStage { + private String conversationId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(AutoAssignConversationRequest other) { + conversationId(other.getConversationId()); + return this; + } + + /** + *

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) { + this.conversationId = Objects.requireNonNull(conversationId, "conversationId must not be null"); + return this; + } + + @java.lang.Override + public AutoAssignConversationRequest build() { + return new AutoAssignConversationRequest(conversationId, additionalProperties); + } + } +} 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 new file mode 100644 index 00000000..1f83e6b3 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/conversations/requests/ConvertConversationToTicketRequest.java @@ -0,0 +1,286 @@ +/** + * 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.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 java.io.IOException; +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 = ConvertConversationToTicketRequest.Builder.class) +public final class ConvertConversationToTicketRequest { + private final String conversationId; + + private final String ticketTypeId; + + private final Optional> attributes; + + private final Map additionalProperties; + + private ConvertConversationToTicketRequest( + String conversationId, + String ticketTypeId, + Optional> attributes, + Map additionalProperties) { + this.conversationId = conversationId; + this.ticketTypeId = ticketTypeId; + this.attributes = attributes; + this.additionalProperties = additionalProperties; + } + + /** + * @return The id of the conversation to target + */ + @JsonProperty("conversation_id") + public String getConversationId() { + return conversationId; + } + + /** + * @return The ID of the type of ticket you want to convert the conversation to + */ + @JsonProperty("ticket_type_id") + public String getTicketTypeId() { + return ticketTypeId; + } + + @JsonProperty("attributes") + public Optional> getAttributes() { + return attributes; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ConvertConversationToTicketRequest + && equalTo((ConvertConversationToTicketRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ConvertConversationToTicketRequest other) { + return conversationId.equals(other.conversationId) + && ticketTypeId.equals(other.ticketTypeId) + && attributes.equals(other.attributes); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.conversationId, this.ticketTypeId, this.attributes); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ConversationIdStage builder() { + return new Builder(); + } + + public interface ConversationIdStage { + TicketTypeIdStage conversationId(@NotNull String conversationId); + + Builder from(ConvertConversationToTicketRequest other); + } + + public interface TicketTypeIdStage { + _FinalStage ticketTypeId(@NotNull String ticketTypeId); + } + + public interface _FinalStage { + ConvertConversationToTicketRequest build(); + + _FinalStage attributes(Optional> attributes); + + _FinalStage attributes(Map attributes); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ConversationIdStage, TicketTypeIdStage, _FinalStage { + private String conversationId; + + private String ticketTypeId; + + private Optional> attributes = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ConvertConversationToTicketRequest other) { + conversationId(other.getConversationId()); + ticketTypeId(other.getTicketTypeId()); + attributes(other.getAttributes()); + return this; + } + + /** + *

The id of the conversation to target

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

The ID of the type of ticket you want to convert the conversation to

+ * @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; + } + + @java.lang.Override + public _FinalStage attributes(Map attributes) { + this.attributes = Optional.ofNullable(attributes); + return this; + } + + @java.lang.Override + @JsonSetter(value = "attributes", nulls = Nulls.SKIP) + public _FinalStage attributes(Optional> attributes) { + this.attributes = attributes; + return this; + } + + @java.lang.Override + public ConvertConversationToTicketRequest build() { + return new ConvertConversationToTicketRequest( + conversationId, ticketTypeId, attributes, additionalProperties); + } + } + + @JsonDeserialize(using = AttributesValue.Deserializer.class) + public static final class AttributesValue { + private final Object value; + + private final int type; + + private AttributesValue(Object value, int type) { + this.value = value; + this.type = type; + } + + @JsonValue + public Object get() { + return this.value; + } + + public T visit(Visitor visitor) { + if (this.type == 0) { + return visitor.visit((Optional) this.value); + } else if (this.type == 1) { + return visitor.visit((double) this.value); + } else if (this.type == 2) { + return visitor.visit((boolean) this.value); + } else if (this.type == 3) { + 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 AttributesValue && equalTo((AttributesValue) other); + } + + private boolean equalTo(AttributesValue 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 AttributesValue of(Optional value) { + return new AttributesValue(value, 0); + } + + public static AttributesValue of(double value) { + return new AttributesValue(value, 1); + } + + public static AttributesValue of(boolean value) { + return new AttributesValue(value, 2); + } + + public static AttributesValue of(List value) { + return new AttributesValue(value, 3); + } + + public interface Visitor { + T visit(Optional value); + + T visit(double value); + + T visit(boolean value); + + T visit(List value); + } + + static final class Deserializer extends StdDeserializer { + Deserializer() { + super(AttributesValue.class); + } + + @java.lang.Override + public AttributesValue deserialize(JsonParser p, DeserializationContext context) throws IOException { + Object value = p.readValueAs(Object.class); + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, new TypeReference>() {})); + } catch (IllegalArgumentException e) { + } + if (value instanceof Double) { + return of((Double) value); + } + if (value instanceof Boolean) { + return of((Boolean) value); + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, new TypeReference>() {})); + } catch (IllegalArgumentException e) { + } + throw new JsonParseException(p, "Failed to deserialize"); + } + } + } +} diff --git a/src/main/java/com/intercom/api/resources/conversations/requests/CreateConversationRequest.java b/src/main/java/com/intercom/api/resources/conversations/requests/CreateConversationRequest.java new file mode 100644 index 00000000..44b22728 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/conversations/requests/CreateConversationRequest.java @@ -0,0 +1,377 @@ +/** + * 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.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 = CreateConversationRequest.Builder.class) +public final class CreateConversationRequest { + private final From from; + + private final String body; + + private final Optional createdAt; + + private final Map additionalProperties; + + private CreateConversationRequest( + From from, String body, Optional createdAt, Map additionalProperties) { + this.from = from; + this.body = body; + this.createdAt = createdAt; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("from") + public From getFrom() { + return from; + } + + /** + * @return The content of the message. HTML is not supported. + */ + @JsonProperty("body") + public String getBody() { + return body; + } + + /** + * @return The time the conversation was created as a UTC Unix timestamp. If not provided, the current time will be used. This field is only recommneded for migrating past conversations from another source into Intercom. + */ + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreateConversationRequest && equalTo((CreateConversationRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreateConversationRequest other) { + return from.equals(other.from) && body.equals(other.body) && createdAt.equals(other.createdAt); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.from, this.body, this.createdAt); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static FromStage builder() { + return new Builder(); + } + + public interface FromStage { + BodyStage from(@NotNull From from); + + Builder from(CreateConversationRequest other); + } + + public interface BodyStage { + _FinalStage body(@NotNull String body); + } + + public interface _FinalStage { + CreateConversationRequest build(); + + _FinalStage createdAt(Optional createdAt); + + _FinalStage createdAt(Integer createdAt); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements FromStage, BodyStage, _FinalStage { + private From from; + + private String body; + + private Optional createdAt = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CreateConversationRequest other) { + from(other.getFrom()); + body(other.getBody()); + createdAt(other.getCreatedAt()); + return this; + } + + @java.lang.Override + @JsonSetter("from") + public BodyStage from(@NotNull From from) { + this.from = Objects.requireNonNull(from, "from must not be null"); + return this; + } + + /** + *

The content of the message. HTML is not supported.

+ * @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; + } + + /** + *

The time the conversation was created as a UTC Unix timestamp. If not provided, the current time will be used. This field is only recommneded for migrating past conversations from another source into Intercom.

+ * @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; + } + + @java.lang.Override + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public _FinalStage createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + @java.lang.Override + public CreateConversationRequest build() { + return new CreateConversationRequest(from, body, createdAt, additionalProperties); + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = From.Builder.class) + public static final class From { + private final Type type; + + private final String id; + + private final Map additionalProperties; + + private From(Type type, String id, Map additionalProperties) { + this.type = type; + this.id = id; + this.additionalProperties = additionalProperties; + } + + /** + * @return The role associated to the contact - user or lead. + */ + @JsonProperty("type") + public Type getType() { + return type; + } + + /** + * @return The identifier for the contact which is 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 From && equalTo((From) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(From other) { + return type.equals(other.type) && id.equals(other.id); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.id); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TypeStage builder() { + return new Builder(); + } + + public interface TypeStage { + IdStage type(@NotNull Type type); + + Builder from(From other); + } + + public interface IdStage { + _FinalStage id(@NotNull String id); + } + + public interface _FinalStage { + From build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements TypeStage, IdStage, _FinalStage { + private Type type; + + private String id; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(From other) { + type(other.getType()); + id(other.getId()); + return this; + } + + /** + *

The role associated to the contact - user or lead.

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

The 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 _FinalStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + public From build() { + return new From(type, id, additionalProperties); + } + } + + public final class Type { + public static final Type USER = new Type(Value.USER, "user"); + + public static final Type CONTACT = new Type(Value.CONTACT, "contact"); + + public static final Type LEAD = new Type(Value.LEAD, "lead"); + + private final Value value; + + private final String string; + + Type(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 Type && this.string.equals(((Type) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case USER: + return visitor.visitUser(); + case CONTACT: + return visitor.visitContact(); + case LEAD: + return visitor.visitLead(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static Type valueOf(String value) { + switch (value) { + case "user": + return USER; + case "contact": + return CONTACT; + case "lead": + return LEAD; + default: + return new Type(Value.UNKNOWN, value); + } + } + + public enum Value { + LEAD, + + USER, + + CONTACT, + + UNKNOWN + } + + public interface Visitor { + T visitLead(); + + T visitUser(); + + T visitContact(); + + T visitUnknown(String unknownType); + } + } + } +} diff --git a/src/main/java/com/intercom/api/resources/conversations/requests/DetachContactFromConversationRequest.java b/src/main/java/com/intercom/api/resources/conversations/requests/DetachContactFromConversationRequest.java new file mode 100644 index 00000000..7c0881a6 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/conversations/requests/DetachContactFromConversationRequest.java @@ -0,0 +1,171 @@ +/** + * 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; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = DetachContactFromConversationRequest.Builder.class) +public final class DetachContactFromConversationRequest { + private final String conversationId; + + private final String contactId; + + private final String adminId; + + private final Map additionalProperties; + + private DetachContactFromConversationRequest( + String conversationId, String contactId, String adminId, Map additionalProperties) { + this.conversationId = conversationId; + this.contactId = contactId; + this.adminId = adminId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The identifier for the conversation as given by Intercom. + */ + @JsonProperty("conversation_id") + public String getConversationId() { + return conversationId; + } + + /** + * @return The identifier for the contact as given by Intercom. + */ + @JsonProperty("contact_id") + public String getContactId() { + return contactId; + } + + /** + * @return The id of the admin who is performing the action. + */ + @JsonProperty("admin_id") + public String getAdminId() { + return adminId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DetachContactFromConversationRequest + && equalTo((DetachContactFromConversationRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DetachContactFromConversationRequest other) { + return conversationId.equals(other.conversationId) + && contactId.equals(other.contactId) + && adminId.equals(other.adminId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.conversationId, this.contactId, this.adminId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ConversationIdStage builder() { + return new Builder(); + } + + public interface ConversationIdStage { + ContactIdStage conversationId(@NotNull String conversationId); + + Builder from(DetachContactFromConversationRequest other); + } + + public interface ContactIdStage { + AdminIdStage contactId(@NotNull String contactId); + } + + public interface AdminIdStage { + _FinalStage adminId(@NotNull String adminId); + } + + public interface _FinalStage { + DetachContactFromConversationRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ConversationIdStage, ContactIdStage, AdminIdStage, _FinalStage { + private String conversationId; + + private String contactId; + + private String adminId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DetachContactFromConversationRequest other) { + conversationId(other.getConversationId()); + contactId(other.getContactId()); + adminId(other.getAdminId()); + return this; + } + + /** + *

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 ContactIdStage conversationId(@NotNull String conversationId) { + this.conversationId = Objects.requireNonNull(conversationId, "conversationId must not be null"); + return this; + } + + /** + *

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("contact_id") + public AdminIdStage contactId(@NotNull String contactId) { + this.contactId = Objects.requireNonNull(contactId, "contactId must not be null"); + return this; + } + + /** + *

The id of the admin who is performing the action.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("admin_id") + public _FinalStage adminId(@NotNull String adminId) { + this.adminId = Objects.requireNonNull(adminId, "adminId must not be null"); + return this; + } + + @java.lang.Override + public DetachContactFromConversationRequest build() { + return new DetachContactFromConversationRequest(conversationId, contactId, adminId, 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 new file mode 100644 index 00000000..044ce4d1 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/conversations/requests/FindConversationRequest.java @@ -0,0 +1,147 @@ +/** + * 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.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 = FindConversationRequest.Builder.class) +public final class FindConversationRequest { + private final String conversationId; + + private final Optional displayAs; + + private final Map additionalProperties; + + private FindConversationRequest( + String conversationId, Optional displayAs, Map additionalProperties) { + this.conversationId = conversationId; + this.displayAs = displayAs; + this.additionalProperties = additionalProperties; + } + + /** + * @return The id of the conversation to target + */ + @JsonProperty("conversation_id") + public String getConversationId() { + return conversationId; + } + + /** + * @return Set to plaintext to retrieve conversation messages in plain text. + */ + @JsonProperty("display_as") + public Optional getDisplayAs() { + return displayAs; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof FindConversationRequest && equalTo((FindConversationRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(FindConversationRequest other) { + return conversationId.equals(other.conversationId) && displayAs.equals(other.displayAs); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.conversationId, this.displayAs); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ConversationIdStage builder() { + return new Builder(); + } + + public interface ConversationIdStage { + _FinalStage conversationId(@NotNull String conversationId); + + Builder from(FindConversationRequest other); + } + + public interface _FinalStage { + FindConversationRequest build(); + + _FinalStage displayAs(Optional displayAs); + + _FinalStage displayAs(String displayAs); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ConversationIdStage, _FinalStage { + private String conversationId; + + private Optional displayAs = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(FindConversationRequest other) { + conversationId(other.getConversationId()); + displayAs(other.getDisplayAs()); + return this; + } + + /** + *

The id of the conversation to target

+ * @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"); + return this; + } + + /** + *

Set to plaintext to retrieve conversation messages in plain text.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage displayAs(String displayAs) { + this.displayAs = Optional.ofNullable(displayAs); + return this; + } + + @java.lang.Override + @JsonSetter(value = "display_as", nulls = Nulls.SKIP) + public _FinalStage displayAs(Optional displayAs) { + this.displayAs = displayAs; + return this; + } + + @java.lang.Override + public FindConversationRequest build() { + return new FindConversationRequest(conversationId, displayAs, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/conversations/requests/ListConversationsRequest.java b/src/main/java/com/intercom/api/resources/conversations/requests/ListConversationsRequest.java new file mode 100644 index 00000000..ee840bba --- /dev/null +++ b/src/main/java/com/intercom/api/resources/conversations/requests/ListConversationsRequest.java @@ -0,0 +1,124 @@ +/** + * 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.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 = ListConversationsRequest.Builder.class) +public final class ListConversationsRequest { + private final Optional perPage; + + private final Optional startingAfter; + + private final Map additionalProperties; + + private ListConversationsRequest( + Optional perPage, Optional startingAfter, Map additionalProperties) { + this.perPage = perPage; + this.startingAfter = startingAfter; + this.additionalProperties = additionalProperties; + } + + /** + * @return How many results per page + */ + @JsonProperty("per_page") + public Optional getPerPage() { + return perPage; + } + + /** + * @return String used to get the next page of conversations. + */ + @JsonProperty("starting_after") + public Optional getStartingAfter() { + return startingAfter; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListConversationsRequest && equalTo((ListConversationsRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListConversationsRequest other) { + return perPage.equals(other.perPage) && startingAfter.equals(other.startingAfter); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.perPage, this.startingAfter); + } + + @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 perPage = Optional.empty(); + + private Optional startingAfter = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ListConversationsRequest other) { + perPage(other.getPerPage()); + startingAfter(other.getStartingAfter()); + return this; + } + + @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; + } + + @JsonSetter(value = "starting_after", nulls = Nulls.SKIP) + public Builder startingAfter(Optional startingAfter) { + this.startingAfter = startingAfter; + return this; + } + + public Builder startingAfter(String startingAfter) { + this.startingAfter = Optional.ofNullable(startingAfter); + return this; + } + + public ListConversationsRequest build() { + return new ListConversationsRequest(perPage, startingAfter, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/conversations/requests/ManageConversationPartsRequest.java b/src/main/java/com/intercom/api/resources/conversations/requests/ManageConversationPartsRequest.java new file mode 100644 index 00000000..70794197 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/conversations/requests/ManageConversationPartsRequest.java @@ -0,0 +1,133 @@ +/** + * 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 com.intercom.api.resources.conversations.types.ConversationsManageRequestBody; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ManageConversationPartsRequest.Builder.class) +public final class ManageConversationPartsRequest { + private final String conversationId; + + private final ConversationsManageRequestBody body; + + private final Map additionalProperties; + + private ManageConversationPartsRequest( + String conversationId, ConversationsManageRequestBody body, Map additionalProperties) { + this.conversationId = conversationId; + this.body = body; + this.additionalProperties = additionalProperties; + } + + /** + * @return The identifier for the conversation as given by Intercom. + */ + @JsonProperty("conversation_id") + public String getConversationId() { + return conversationId; + } + + @JsonProperty("body") + public ConversationsManageRequestBody getBody() { + return body; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ManageConversationPartsRequest && equalTo((ManageConversationPartsRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ManageConversationPartsRequest other) { + return conversationId.equals(other.conversationId) && body.equals(other.body); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.conversationId, this.body); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ConversationIdStage builder() { + return new Builder(); + } + + public interface ConversationIdStage { + BodyStage conversationId(@NotNull String conversationId); + + Builder from(ManageConversationPartsRequest other); + } + + public interface BodyStage { + _FinalStage body(@NotNull ConversationsManageRequestBody body); + } + + public interface _FinalStage { + ManageConversationPartsRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ConversationIdStage, BodyStage, _FinalStage { + private String conversationId; + + private ConversationsManageRequestBody body; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ManageConversationPartsRequest other) { + conversationId(other.getConversationId()); + body(other.getBody()); + return this; + } + + /** + *

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 BodyStage conversationId(@NotNull String conversationId) { + this.conversationId = Objects.requireNonNull(conversationId, "conversationId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("body") + public _FinalStage body(@NotNull ConversationsManageRequestBody body) { + this.body = Objects.requireNonNull(body, "body must not be null"); + return this; + } + + @java.lang.Override + public ManageConversationPartsRequest build() { + return new ManageConversationPartsRequest(conversationId, body, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/conversations/requests/ReplyToConversationRequest.java b/src/main/java/com/intercom/api/resources/conversations/requests/ReplyToConversationRequest.java new file mode 100644 index 00000000..43c87d98 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/conversations/requests/ReplyToConversationRequest.java @@ -0,0 +1,133 @@ +/** + * 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 com.intercom.api.types.ReplyConversationRequest; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ReplyToConversationRequest.Builder.class) +public final class ReplyToConversationRequest { + private final String conversationId; + + private final ReplyConversationRequest body; + + private final Map additionalProperties; + + private ReplyToConversationRequest( + String conversationId, ReplyConversationRequest body, Map additionalProperties) { + this.conversationId = conversationId; + this.body = body; + this.additionalProperties = additionalProperties; + } + + /** + * @return The Intercom provisioned identifier for the conversation or the string "last" to reply to the last part of the conversation + */ + @JsonProperty("conversation_id") + public String getConversationId() { + return conversationId; + } + + @JsonProperty("body") + public ReplyConversationRequest getBody() { + return body; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ReplyToConversationRequest && equalTo((ReplyToConversationRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ReplyToConversationRequest other) { + return conversationId.equals(other.conversationId) && body.equals(other.body); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.conversationId, this.body); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ConversationIdStage builder() { + return new Builder(); + } + + public interface ConversationIdStage { + BodyStage conversationId(@NotNull String conversationId); + + Builder from(ReplyToConversationRequest other); + } + + public interface BodyStage { + _FinalStage body(@NotNull ReplyConversationRequest body); + } + + public interface _FinalStage { + ReplyToConversationRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ConversationIdStage, BodyStage, _FinalStage { + private String conversationId; + + private ReplyConversationRequest body; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ReplyToConversationRequest other) { + conversationId(other.getConversationId()); + body(other.getBody()); + return this; + } + + /** + *

The Intercom provisioned identifier for the conversation or the string "last" to reply to the last part of the conversation

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("conversation_id") + public BodyStage conversationId(@NotNull String conversationId) { + this.conversationId = Objects.requireNonNull(conversationId, "conversationId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("body") + public _FinalStage body(@NotNull ReplyConversationRequest body) { + this.body = Objects.requireNonNull(body, "body must not be null"); + return this; + } + + @java.lang.Override + public ReplyToConversationRequest build() { + return new ReplyToConversationRequest(conversationId, body, 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 new file mode 100644 index 00000000..3157f998 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/conversations/requests/UpdateConversationRequest.java @@ -0,0 +1,218 @@ +/** + * 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.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 = UpdateConversationRequest.Builder.class) +public final class UpdateConversationRequest { + private final String conversationId; + + private final Optional displayAs; + + private final Optional read; + + private final Optional> customAttributes; + + private final Map additionalProperties; + + private UpdateConversationRequest( + String conversationId, + Optional displayAs, + Optional read, + Optional> customAttributes, + Map additionalProperties) { + this.conversationId = conversationId; + this.displayAs = displayAs; + this.read = read; + this.customAttributes = customAttributes; + this.additionalProperties = additionalProperties; + } + + /** + * @return The id of the conversation to target + */ + @JsonProperty("conversation_id") + public String getConversationId() { + return conversationId; + } + + /** + * @return Set to plaintext to retrieve conversation messages in plain text. + */ + @JsonProperty("display_as") + public Optional getDisplayAs() { + return displayAs; + } + + /** + * @return Mark a conversation as read within Intercom. + */ + @JsonProperty("read") + public Optional getRead() { + return read; + } + + @JsonProperty("custom_attributes") + public Optional> getCustomAttributes() { + return customAttributes; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UpdateConversationRequest && equalTo((UpdateConversationRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UpdateConversationRequest other) { + return conversationId.equals(other.conversationId) + && displayAs.equals(other.displayAs) + && read.equals(other.read) + && customAttributes.equals(other.customAttributes); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.conversationId, this.displayAs, this.read, this.customAttributes); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ConversationIdStage builder() { + return new Builder(); + } + + public interface ConversationIdStage { + _FinalStage conversationId(@NotNull String conversationId); + + Builder from(UpdateConversationRequest other); + } + + public interface _FinalStage { + UpdateConversationRequest build(); + + _FinalStage displayAs(Optional displayAs); + + _FinalStage displayAs(String displayAs); + + _FinalStage read(Optional read); + + _FinalStage read(Boolean read); + + _FinalStage customAttributes(Optional> customAttributes); + + _FinalStage customAttributes(Map customAttributes); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ConversationIdStage, _FinalStage { + private String conversationId; + + private Optional> customAttributes = Optional.empty(); + + private Optional read = Optional.empty(); + + private Optional displayAs = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(UpdateConversationRequest other) { + conversationId(other.getConversationId()); + displayAs(other.getDisplayAs()); + read(other.getRead()); + customAttributes(other.getCustomAttributes()); + return this; + } + + /** + *

The id of the conversation to target

+ * @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"); + 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; + } + + /** + *

Mark a conversation as read within Intercom.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage read(Boolean read) { + this.read = Optional.ofNullable(read); + return this; + } + + @java.lang.Override + @JsonSetter(value = "read", nulls = Nulls.SKIP) + public _FinalStage read(Optional read) { + this.read = read; + return this; + } + + /** + *

Set to plaintext to retrieve conversation messages in plain text.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage displayAs(String displayAs) { + this.displayAs = Optional.ofNullable(displayAs); + return this; + } + + @java.lang.Override + @JsonSetter(value = "display_as", nulls = Nulls.SKIP) + public _FinalStage displayAs(Optional displayAs) { + this.displayAs = displayAs; + return this; + } + + @java.lang.Override + public UpdateConversationRequest build() { + return new UpdateConversationRequest( + conversationId, displayAs, read, customAttributes, additionalProperties); + } + } +} 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 new file mode 100644 index 00000000..ea7dbc4e --- /dev/null +++ b/src/main/java/com/intercom/api/resources/conversations/types/Conversation.java @@ -0,0 +1,1152 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.conversations.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 com.intercom.api.resources.aiagent.types.AiAgent; +import com.intercom.api.types.ConversationContacts; +import com.intercom.api.types.ConversationFirstContactReply; +import com.intercom.api.types.ConversationParts; +import com.intercom.api.types.ConversationRating; +import com.intercom.api.types.ConversationSource; +import com.intercom.api.types.ConversationStatistics; +import com.intercom.api.types.ConversationTeammates; +import com.intercom.api.types.LinkedObjectList; +import com.intercom.api.types.SlaApplied; +import com.intercom.api.types.Tags; +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 title; + + private final int createdAt; + + private final int updatedAt; + + private final Optional waitingSince; + + private final Optional snoozedUntil; + + private final boolean open; + + private final State state; + + private final boolean read; + + private final Optional priority; + + private final Optional adminAssigneeId; + + private final Optional teamAssigneeId; + + private final Optional tags; + + private final Optional conversationRating; + + private final ConversationSource source; + + private final ConversationContacts contacts; + + private final ConversationTeammates teammates; + + private final Map customAttributes; + + private final Optional firstContactReply; + + private final Optional slaApplied; + + private final Optional statistics; + + private final Optional conversationParts; + + private final Optional linkedObjects; + + private final Optional aiAgentParticipated; + + private final Optional aiAgent; + + private final Map additionalProperties; + + private Conversation( + Optional type, + String id, + Optional title, + int createdAt, + int updatedAt, + Optional waitingSince, + Optional snoozedUntil, + boolean open, + State state, + boolean read, + Optional priority, + Optional adminAssigneeId, + Optional teamAssigneeId, + Optional tags, + Optional conversationRating, + ConversationSource source, + ConversationContacts contacts, + ConversationTeammates teammates, + Map customAttributes, + Optional firstContactReply, + Optional slaApplied, + Optional statistics, + Optional conversationParts, + Optional linkedObjects, + Optional aiAgentParticipated, + Optional aiAgent, + Map additionalProperties) { + this.type = type; + this.id = id; + this.title = title; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.waitingSince = waitingSince; + this.snoozedUntil = snoozedUntil; + this.open = open; + this.state = state; + this.read = read; + this.priority = priority; + this.adminAssigneeId = adminAssigneeId; + this.teamAssigneeId = teamAssigneeId; + this.tags = tags; + this.conversationRating = conversationRating; + this.source = source; + this.contacts = contacts; + this.teammates = teammates; + this.customAttributes = customAttributes; + this.firstContactReply = firstContactReply; + this.slaApplied = slaApplied; + this.statistics = statistics; + this.conversationParts = conversationParts; + this.linkedObjects = linkedObjects; + this.aiAgentParticipated = aiAgentParticipated; + this.aiAgent = aiAgent; + this.additionalProperties = additionalProperties; + } + + /** + * @return Always conversation. + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return The id representing the conversation. + */ + @JsonProperty("id") + public String getId() { + return id; + } + + /** + * @return The title given to the conversation. + */ + @JsonProperty("title") + public Optional getTitle() { + return title; + } + + /** + * @return The time the conversation was created. + */ + @JsonProperty("created_at") + public int getCreatedAt() { + return createdAt; + } + + /** + * @return The last time the conversation was updated. + */ + @JsonProperty("updated_at") + public int getUpdatedAt() { + return updatedAt; + } + + /** + * @return 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. + */ + @JsonProperty("waiting_since") + public Optional getWaitingSince() { + return waitingSince; + } + + /** + * @return 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. + */ + @JsonProperty("snoozed_until") + public Optional getSnoozedUntil() { + return snoozedUntil; + } + + /** + * @return Indicates whether a conversation is open (true) or closed (false). + */ + @JsonProperty("open") + public boolean getOpen() { + return open; + } + + /** + * @return Can be set to "open", "closed" or "snoozed". + */ + @JsonProperty("state") + public State getState() { + return state; + } + + /** + * @return Indicates whether a conversation has been read. + */ + @JsonProperty("read") + public boolean getRead() { + return read; + } + + /** + * @return If marked as priority, it will return priority or else not_priority. + */ + @JsonProperty("priority") + public Optional getPriority() { + return priority; + } + + /** + * @return The id of the admin assigned to the conversation. If it's not assigned to an admin it will return null. + */ + @JsonProperty("admin_assignee_id") + public Optional getAdminAssigneeId() { + return adminAssigneeId; + } + + /** + * @return The id of the team assigned to the conversation. If it's not assigned to a team it will return null. + */ + @JsonProperty("team_assignee_id") + public Optional getTeamAssigneeId() { + return teamAssigneeId; + } + + @JsonProperty("tags") + public Optional getTags() { + return tags; + } + + @JsonProperty("conversation_rating") + public Optional getConversationRating() { + return conversationRating; + } + + @JsonProperty("source") + public ConversationSource getSource() { + return source; + } + + @JsonProperty("contacts") + public ConversationContacts getContacts() { + return contacts; + } + + @JsonProperty("teammates") + public ConversationTeammates getTeammates() { + return teammates; + } + + @JsonProperty("custom_attributes") + public Map getCustomAttributes() { + return customAttributes; + } + + @JsonProperty("first_contact_reply") + public Optional getFirstContactReply() { + return firstContactReply; + } + + @JsonProperty("sla_applied") + public Optional getSlaApplied() { + return slaApplied; + } + + @JsonProperty("statistics") + public Optional getStatistics() { + return statistics; + } + + @JsonProperty("conversation_parts") + public Optional getConversationParts() { + return conversationParts; + } + + @JsonProperty("linked_objects") + public Optional getLinkedObjects() { + return linkedObjects; + } + + /** + * @return Indicates whether the AI Agent participated in the conversation. + */ + @JsonProperty("ai_agent_participated") + public Optional getAiAgentParticipated() { + return aiAgentParticipated; + } + + @JsonProperty("ai_agent") + public Optional getAiAgent() { + return aiAgent; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Conversation && equalTo((Conversation) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Conversation other) { + return type.equals(other.type) + && id.equals(other.id) + && title.equals(other.title) + && createdAt == other.createdAt + && updatedAt == other.updatedAt + && waitingSince.equals(other.waitingSince) + && snoozedUntil.equals(other.snoozedUntil) + && open == other.open + && state.equals(other.state) + && read == other.read + && priority.equals(other.priority) + && adminAssigneeId.equals(other.adminAssigneeId) + && teamAssigneeId.equals(other.teamAssigneeId) + && tags.equals(other.tags) + && conversationRating.equals(other.conversationRating) + && source.equals(other.source) + && contacts.equals(other.contacts) + && teammates.equals(other.teammates) + && customAttributes.equals(other.customAttributes) + && firstContactReply.equals(other.firstContactReply) + && slaApplied.equals(other.slaApplied) + && statistics.equals(other.statistics) + && conversationParts.equals(other.conversationParts) + && linkedObjects.equals(other.linkedObjects) + && aiAgentParticipated.equals(other.aiAgentParticipated) + && aiAgent.equals(other.aiAgent); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.type, + this.id, + this.title, + this.createdAt, + this.updatedAt, + this.waitingSince, + this.snoozedUntil, + this.open, + this.state, + this.read, + this.priority, + this.adminAssigneeId, + this.teamAssigneeId, + this.tags, + this.conversationRating, + this.source, + this.contacts, + this.teammates, + this.customAttributes, + this.firstContactReply, + this.slaApplied, + this.statistics, + this.conversationParts, + this.linkedObjects, + this.aiAgentParticipated, + this.aiAgent); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + CreatedAtStage id(@NotNull String id); + + Builder from(Conversation other); + } + + public interface CreatedAtStage { + UpdatedAtStage createdAt(int createdAt); + } + + public interface UpdatedAtStage { + OpenStage updatedAt(int updatedAt); + } + + public interface OpenStage { + StateStage open(boolean open); + } + + public interface StateStage { + ReadStage state(@NotNull State state); + } + + public interface ReadStage { + 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(); + + _FinalStage type(Optional type); + + _FinalStage type(String type); + + _FinalStage title(Optional title); + + _FinalStage title(String title); + + _FinalStage waitingSince(Optional waitingSince); + + _FinalStage waitingSince(Integer waitingSince); + + _FinalStage snoozedUntil(Optional snoozedUntil); + + _FinalStage snoozedUntil(Integer snoozedUntil); + + _FinalStage priority(Optional priority); + + _FinalStage priority(Priority priority); + + _FinalStage adminAssigneeId(Optional adminAssigneeId); + + _FinalStage adminAssigneeId(Integer adminAssigneeId); + + _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); + + _FinalStage aiAgentParticipated(Optional aiAgentParticipated); + + _FinalStage aiAgentParticipated(Boolean aiAgentParticipated); + + _FinalStage aiAgent(Optional aiAgent); + + _FinalStage aiAgent(AiAgent aiAgent); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements IdStage, + CreatedAtStage, + UpdatedAtStage, + OpenStage, + StateStage, + ReadStage, + SourceStage, + ContactsStage, + TeammatesStage, + _FinalStage { + private String id; + + private int createdAt; + + private int updatedAt; + + private boolean open; + + private State state; + + private boolean read; + + private ConversationSource source; + + private ConversationContacts contacts; + + private ConversationTeammates teammates; + + private Optional aiAgent = Optional.empty(); + + private Optional aiAgentParticipated = Optional.empty(); + + private Optional linkedObjects = Optional.empty(); + + private Optional conversationParts = Optional.empty(); + + private Optional statistics = Optional.empty(); + + private Optional slaApplied = 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 priority = Optional.empty(); + + private Optional snoozedUntil = Optional.empty(); + + private Optional waitingSince = Optional.empty(); + + private Optional title = Optional.empty(); + + private Optional type = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(Conversation other) { + type(other.getType()); + id(other.getId()); + title(other.getTitle()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + waitingSince(other.getWaitingSince()); + snoozedUntil(other.getSnoozedUntil()); + open(other.getOpen()); + state(other.getState()); + read(other.getRead()); + priority(other.getPriority()); + adminAssigneeId(other.getAdminAssigneeId()); + teamAssigneeId(other.getTeamAssigneeId()); + tags(other.getTags()); + conversationRating(other.getConversationRating()); + source(other.getSource()); + contacts(other.getContacts()); + teammates(other.getTeammates()); + customAttributes(other.getCustomAttributes()); + firstContactReply(other.getFirstContactReply()); + slaApplied(other.getSlaApplied()); + statistics(other.getStatistics()); + conversationParts(other.getConversationParts()); + linkedObjects(other.getLinkedObjects()); + aiAgentParticipated(other.getAiAgentParticipated()); + aiAgent(other.getAiAgent()); + return this; + } + + /** + *

The id representing the conversation.

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

The time the conversation 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 last time the conversation was updated.

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

Indicates whether a conversation is open (true) or closed (false).

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

Can be set to "open", "closed" or "snoozed".

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

Indicates whether a conversation has been read.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("read") + public SourceStage read(boolean read) { + this.read = read; + return this; + } + + @java.lang.Override + @JsonSetter("source") + public ContactsStage source(@NotNull ConversationSource source) { + this.source = Objects.requireNonNull(source, "source must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("contacts") + public TeammatesStage contacts(@NotNull ConversationContacts contacts) { + this.contacts = Objects.requireNonNull(contacts, "contacts must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("teammates") + public _FinalStage teammates(@NotNull ConversationTeammates teammates) { + this.teammates = Objects.requireNonNull(teammates, "teammates must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage aiAgent(AiAgent aiAgent) { + this.aiAgent = Optional.ofNullable(aiAgent); + return this; + } + + @java.lang.Override + @JsonSetter(value = "ai_agent", nulls = Nulls.SKIP) + public _FinalStage aiAgent(Optional aiAgent) { + this.aiAgent = aiAgent; + return this; + } + + /** + *

Indicates whether the AI Agent participated in the conversation.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage aiAgentParticipated(Boolean aiAgentParticipated) { + this.aiAgentParticipated = Optional.ofNullable(aiAgentParticipated); + return this; + } + + @java.lang.Override + @JsonSetter(value = "ai_agent_participated", nulls = Nulls.SKIP) + public _FinalStage aiAgentParticipated(Optional aiAgentParticipated) { + this.aiAgentParticipated = aiAgentParticipated; + return this; + } + + @java.lang.Override + public _FinalStage linkedObjects(LinkedObjectList linkedObjects) { + this.linkedObjects = Optional.ofNullable(linkedObjects); + return this; + } + + @java.lang.Override + @JsonSetter(value = "linked_objects", nulls = Nulls.SKIP) + public _FinalStage linkedObjects(Optional linkedObjects) { + this.linkedObjects = linkedObjects; + return this; + } + + @java.lang.Override + public _FinalStage conversationParts(ConversationParts conversationParts) { + this.conversationParts = Optional.ofNullable(conversationParts); + return this; + } + + @java.lang.Override + @JsonSetter(value = "conversation_parts", nulls = Nulls.SKIP) + public _FinalStage conversationParts(Optional conversationParts) { + this.conversationParts = conversationParts; + return this; + } + + @java.lang.Override + public _FinalStage statistics(ConversationStatistics 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 + public _FinalStage slaApplied(SlaApplied slaApplied) { + this.slaApplied = Optional.ofNullable(slaApplied); + return this; + } + + @java.lang.Override + @JsonSetter(value = "sla_applied", nulls = Nulls.SKIP) + public _FinalStage slaApplied(Optional slaApplied) { + this.slaApplied = slaApplied; + return this; + } + + @java.lang.Override + public _FinalStage firstContactReply(ConversationFirstContactReply firstContactReply) { + this.firstContactReply = Optional.ofNullable(firstContactReply); + return this; + } + + @java.lang.Override + @JsonSetter(value = "first_contact_reply", nulls = Nulls.SKIP) + public _FinalStage firstContactReply(Optional firstContactReply) { + this.firstContactReply = firstContactReply; + return this; + } + + @java.lang.Override + public _FinalStage customAttributes(String key, Object value) { + this.customAttributes.put(key, value); + return this; + } + + @java.lang.Override + public _FinalStage putAllCustomAttributes(Map customAttributes) { + this.customAttributes.putAll(customAttributes); + return this; + } + + @java.lang.Override + @JsonSetter(value = "custom_attributes", nulls = Nulls.SKIP) + public _FinalStage customAttributes(Map customAttributes) { + this.customAttributes.clear(); + this.customAttributes.putAll(customAttributes); + return this; + } + + @java.lang.Override + public _FinalStage conversationRating(ConversationRating conversationRating) { + this.conversationRating = Optional.ofNullable(conversationRating); + return this; + } + + @java.lang.Override + @JsonSetter(value = "conversation_rating", nulls = Nulls.SKIP) + public _FinalStage conversationRating(Optional conversationRating) { + this.conversationRating = conversationRating; + return this; + } + + @java.lang.Override + public _FinalStage tags(Tags 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; + 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "team_assignee_id", nulls = Nulls.SKIP) + public _FinalStage teamAssigneeId(Optional teamAssigneeId) { + this.teamAssigneeId = teamAssigneeId; + 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "admin_assignee_id", nulls = Nulls.SKIP) + public _FinalStage adminAssigneeId(Optional adminAssigneeId) { + this.adminAssigneeId = adminAssigneeId; + 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "priority", nulls = Nulls.SKIP) + public _FinalStage priority(Optional priority) { + this.priority = priority; + 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "snoozed_until", nulls = Nulls.SKIP) + public _FinalStage snoozedUntil(Optional snoozedUntil) { + this.snoozedUntil = snoozedUntil; + 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "waiting_since", nulls = Nulls.SKIP) + public _FinalStage waitingSince(Optional waitingSince) { + this.waitingSince = waitingSince; + 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; + } + + @java.lang.Override + @JsonSetter(value = "title", nulls = Nulls.SKIP) + public _FinalStage title(Optional title) { + this.title = title; + 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public _FinalStage type(Optional type) { + this.type = type; + return this; + } + + @java.lang.Override + public Conversation build() { + return new Conversation( + type, + id, + title, + createdAt, + updatedAt, + waitingSince, + snoozedUntil, + open, + state, + read, + priority, + adminAssigneeId, + teamAssigneeId, + tags, + conversationRating, + source, + contacts, + teammates, + customAttributes, + firstContactReply, + slaApplied, + statistics, + conversationParts, + linkedObjects, + aiAgentParticipated, + aiAgent, + additionalProperties); + } + } + + public final class Priority { + public static final Priority PRIORITY = new Priority(Value.PRIORITY, "priority"); + + public static final Priority NOT_PRIORITY = new Priority(Value.NOT_PRIORITY, "not_priority"); + + private final Value value; + + private final String string; + + Priority(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 Priority && this.string.equals(((Priority) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case PRIORITY: + return visitor.visitPriority(); + case NOT_PRIORITY: + return visitor.visitNotPriority(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static Priority valueOf(String value) { + switch (value) { + case "priority": + return PRIORITY; + case "not_priority": + return NOT_PRIORITY; + default: + return new Priority(Value.UNKNOWN, value); + } + } + + public enum Value { + PRIORITY, + + NOT_PRIORITY, + + UNKNOWN + } + + public interface Visitor { + T visitPriority(); + + T visitNotPriority(); + + T visitUnknown(String unknownType); + } + } + + public final class State { + public static final State SNOOZED = new State(Value.SNOOZED, "snoozed"); + + public static final State CLOSED = new State(Value.CLOSED, "closed"); + + public static final State OPEN = new State(Value.OPEN, "open"); + + 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 SNOOZED: + return visitor.visitSnoozed(); + case CLOSED: + return visitor.visitClosed(); + case OPEN: + return visitor.visitOpen(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static State valueOf(String value) { + switch (value) { + case "snoozed": + return SNOOZED; + case "closed": + return CLOSED; + case "open": + return OPEN; + default: + return new State(Value.UNKNOWN, value); + } + } + + public enum Value { + OPEN, + + CLOSED, + + SNOOZED, + + UNKNOWN + } + + public interface Visitor { + T visitOpen(); + + T visitClosed(); + + T visitSnoozed(); + + T visitUnknown(String unknownType); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/conversations/types/ConversationsManageRequestBody.java b/src/main/java/com/intercom/api/resources/conversations/types/ConversationsManageRequestBody.java new file mode 100644 index 00000000..e40cfdc6 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/conversations/types/ConversationsManageRequestBody.java @@ -0,0 +1,328 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.conversations.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonUnwrapped; +import com.fasterxml.jackson.annotation.JsonValue; +import com.intercom.api.types.AssignConversationRequest; +import com.intercom.api.types.CloseConversationRequest; +import com.intercom.api.types.OpenConversationRequest; +import com.intercom.api.types.SnoozeConversationRequest; +import java.util.Objects; +import java.util.Optional; + +public final class ConversationsManageRequestBody { + private final Value value; + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + private ConversationsManageRequestBody(Value value) { + this.value = value; + } + + public T visit(Visitor visitor) { + return value.visit(visitor); + } + + public static ConversationsManageRequestBody close(CloseConversationRequest value) { + return new ConversationsManageRequestBody(new CloseValue(value)); + } + + public static ConversationsManageRequestBody snoozed(SnoozeConversationRequest value) { + return new ConversationsManageRequestBody(new SnoozedValue(value)); + } + + public static ConversationsManageRequestBody open(OpenConversationRequest value) { + return new ConversationsManageRequestBody(new OpenValue(value)); + } + + public static ConversationsManageRequestBody assignment(AssignConversationRequest value) { + return new ConversationsManageRequestBody(new AssignmentValue(value)); + } + + public boolean isClose() { + return value instanceof CloseValue; + } + + public boolean isSnoozed() { + return value instanceof SnoozedValue; + } + + public boolean isOpen() { + return value instanceof OpenValue; + } + + public boolean isAssignment() { + return value instanceof AssignmentValue; + } + + public boolean _isUnknown() { + return value instanceof _UnknownValue; + } + + public Optional getClose() { + if (isClose()) { + return Optional.of(((CloseValue) value).value); + } + return Optional.empty(); + } + + public Optional getSnoozed() { + if (isSnoozed()) { + return Optional.of(((SnoozedValue) value).value); + } + return Optional.empty(); + } + + public Optional getOpen() { + if (isOpen()) { + return Optional.of(((OpenValue) value).value); + } + return Optional.empty(); + } + + public Optional getAssignment() { + if (isAssignment()) { + return Optional.of(((AssignmentValue) value).value); + } + return Optional.empty(); + } + + public Optional _getUnknown() { + if (_isUnknown()) { + return Optional.of(((_UnknownValue) value).value); + } + return Optional.empty(); + } + + @JsonValue + private Value getValue() { + return this.value; + } + + public interface Visitor { + T visitClose(CloseConversationRequest close); + + T visitSnoozed(SnoozeConversationRequest snoozed); + + T visitOpen(OpenConversationRequest open); + + T visitAssignment(AssignConversationRequest assignment); + + T _visitUnknown(Object unknownType); + } + + @JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + property = "message_type", + visible = true, + defaultImpl = _UnknownValue.class) + @JsonSubTypes({ + @JsonSubTypes.Type(CloseValue.class), + @JsonSubTypes.Type(SnoozedValue.class), + @JsonSubTypes.Type(OpenValue.class), + @JsonSubTypes.Type(AssignmentValue.class) + }) + @JsonIgnoreProperties(ignoreUnknown = true) + private interface Value { + T visit(Visitor visitor); + } + + @JsonTypeName("close") + @JsonIgnoreProperties("message_type") + private static final class CloseValue implements Value { + @JsonUnwrapped + private CloseConversationRequest value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private CloseValue() {} + + private CloseValue(CloseConversationRequest value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitClose(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CloseValue && equalTo((CloseValue) other); + } + + private boolean equalTo(CloseValue other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "ConversationsManageRequestBody{" + "value: " + value + "}"; + } + } + + @JsonTypeName("snoozed") + @JsonIgnoreProperties("message_type") + private static final class SnoozedValue implements Value { + @JsonUnwrapped + private SnoozeConversationRequest value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private SnoozedValue() {} + + private SnoozedValue(SnoozeConversationRequest value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitSnoozed(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof SnoozedValue && equalTo((SnoozedValue) other); + } + + private boolean equalTo(SnoozedValue other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "ConversationsManageRequestBody{" + "value: " + value + "}"; + } + } + + @JsonTypeName("open") + @JsonIgnoreProperties("message_type") + private static final class OpenValue implements Value { + @JsonUnwrapped + private OpenConversationRequest value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private OpenValue() {} + + private OpenValue(OpenConversationRequest value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitOpen(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof OpenValue && equalTo((OpenValue) other); + } + + private boolean equalTo(OpenValue other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "ConversationsManageRequestBody{" + "value: " + value + "}"; + } + } + + @JsonTypeName("assignment") + @JsonIgnoreProperties("message_type") + private static final class AssignmentValue implements Value { + @JsonUnwrapped + private AssignConversationRequest value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private AssignmentValue() {} + + private AssignmentValue(AssignConversationRequest value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitAssignment(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AssignmentValue && equalTo((AssignmentValue) other); + } + + private boolean equalTo(AssignmentValue other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "ConversationsManageRequestBody{" + "value: " + value + "}"; + } + } + + @JsonIgnoreProperties("message_type") + private static final class _UnknownValue implements Value { + private String type; + + @JsonValue + private Object value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private _UnknownValue(@JsonProperty("value") Object value) {} + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor._visitUnknown(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof _UnknownValue && equalTo((_UnknownValue) other); + } + + private boolean equalTo(_UnknownValue other) { + return type.equals(other.type) && value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.value); + } + + @java.lang.Override + public String toString() { + return "ConversationsManageRequestBody{" + "type: " + type + ", value: " + value + "}"; + } + } +} diff --git a/src/main/java/com/intercom/api/resources/dataattributes/AsyncDataAttributesClient.java b/src/main/java/com/intercom/api/resources/dataattributes/AsyncDataAttributesClient.java new file mode 100644 index 00000000..07add2c0 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/dataattributes/AsyncDataAttributesClient.java @@ -0,0 +1,293 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.dataattributes; + +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.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.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.DataAttributeList; +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 AsyncDataAttributesClient { + protected final ClientOptions clientOptions; + + public AsyncDataAttributesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can fetch a list of all data attributes belonging to a workspace for contacts, companies or conversations. + */ + public CompletableFuture list() { + return list(ListDataAttributesRequest.builder().build()); + } + + /** + * You can fetch a list of all data attributes belonging to a workspace for contacts, companies or conversations. + */ + public CompletableFuture list(ListDataAttributesRequest request) { + return list(request, null); + } + + /** + * You can fetch a list of all data attributes belonging to a workspace for contacts, companies or conversations. + */ + public CompletableFuture list(ListDataAttributesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("data_attributes"); + if (request.getModel().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "model", request.getModel().get().toString(), false); + } + if (request.getIncludeArchived().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_archived", + request.getIncludeArchived().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( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DataAttributeList.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + 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))); + 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 data attributes for a contact or a company. + */ + public CompletableFuture create(CreateDataAttributeRequest request) { + return create(request, null); + } + + /** + * You can create a data attributes for a contact or a company. + */ + public CompletableFuture create(CreateDataAttributeRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("data_attributes") + .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( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DataAttribute.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + 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))); + 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 a data attribute. + *
+ *

🚧 Updating the data type is not possible

+ *

It is currently a dangerous action to execute changing a data attribute's type via the API. You will need to update the type via the UI instead.

+ *
+ */ + public CompletableFuture update(UpdateDataAttributeRequest request) { + return update(request, null); + } + + /** + * You can update a data attribute. + *
+ *

🚧 Updating the data type is not possible

+ *

It is currently a dangerous action to execute changing a data attribute's type via the API. You will need to update the type via the UI instead.

+ *
+ */ + public CompletableFuture update(UpdateDataAttributeRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("data_attributes") + .addPathSegment(request.getDataAttributeId()) + .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( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DataAttribute.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + return; + case 422: + future.completeExceptionally(new UnprocessableEntityError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + 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))); + 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/dataattributes/DataAttributesClient.java b/src/main/java/com/intercom/api/resources/dataattributes/DataAttributesClient.java new file mode 100644 index 00000000..2e411c91 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/dataattributes/DataAttributesClient.java @@ -0,0 +1,238 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.dataattributes; + +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.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.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.DataAttributeList; +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 DataAttributesClient { + protected final ClientOptions clientOptions; + + public DataAttributesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can fetch a list of all data attributes belonging to a workspace for contacts, companies or conversations. + */ + public DataAttributeList list() { + return list(ListDataAttributesRequest.builder().build()); + } + + /** + * You can fetch a list of all data attributes belonging to a workspace for contacts, companies or conversations. + */ + public DataAttributeList list(ListDataAttributesRequest request) { + return list(request, null); + } + + /** + * You can fetch a list of all data attributes belonging to a workspace for contacts, companies or conversations. + */ + public DataAttributeList list(ListDataAttributesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("data_attributes"); + if (request.getModel().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "model", request.getModel().get().toString(), false); + } + if (request.getIncludeArchived().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_archived", + request.getIncludeArchived().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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DataAttributeList.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can create a data attributes for a contact or a company. + */ + public DataAttribute create(CreateDataAttributeRequest request) { + return create(request, null); + } + + /** + * You can create a data attributes for a contact or a company. + */ + public DataAttribute create(CreateDataAttributeRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("data_attributes") + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DataAttribute.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can update a data attribute. + *
+ *

🚧 Updating the data type is not possible

+ *

It is currently a dangerous action to execute changing a data attribute's type via the API. You will need to update the type via the UI instead.

+ *
+ */ + public DataAttribute update(UpdateDataAttributeRequest request) { + return update(request, null); + } + + /** + * You can update a data attribute. + *
+ *

🚧 Updating the data type is not possible

+ *

It is currently a dangerous action to execute changing a data attribute's type via the API. You will need to update the type via the UI instead.

+ *
+ */ + public DataAttribute update(UpdateDataAttributeRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("data_attributes") + .addPathSegment(request.getDataAttributeId()) + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DataAttribute.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 422: + throw new UnprocessableEntityError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP 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 new file mode 100644 index 00000000..613b4cd8 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/dataattributes/requests/CreateDataAttributeRequest.java @@ -0,0 +1,481 @@ +/** + * 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 { + ModelStage name(@NotNull String name); + + Builder from(CreateDataAttributeRequest other); + } + + public interface ModelStage { + DataTypeStage model(@NotNull Model model); + } + + public interface DataTypeStage { + _FinalStage dataType(@NotNull DataType dataType); + } + + public interface _FinalStage { + CreateDataAttributeRequest build(); + + _FinalStage description(Optional description); + + _FinalStage description(String description); + + _FinalStage options(Optional> options); + + _FinalStage options(List options); + + _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.

+ * @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.

+ * @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.

+ * @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; + } + + @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; + } + + @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; + } + + @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 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 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/ListDataAttributesRequest.java b/src/main/java/com/intercom/api/resources/dataattributes/requests/ListDataAttributesRequest.java new file mode 100644 index 00000000..210ecb71 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/dataattributes/requests/ListDataAttributesRequest.java @@ -0,0 +1,127 @@ +/** + * 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.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.resources.dataattributes.types.DataAttributesListRequestModel; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListDataAttributesRequest.Builder.class) +public final class ListDataAttributesRequest { + private final Optional model; + + private final Optional includeArchived; + + private final Map additionalProperties; + + private ListDataAttributesRequest( + Optional model, + Optional includeArchived, + Map additionalProperties) { + this.model = model; + this.includeArchived = includeArchived; + this.additionalProperties = additionalProperties; + } + + /** + * @return Specify the data attribute model to return. + */ + @JsonProperty("model") + public Optional getModel() { + return model; + } + + /** + * @return Include archived attributes in the list. By default we return only non archived data attributes. + */ + @JsonProperty("include_archived") + public Optional getIncludeArchived() { + return includeArchived; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListDataAttributesRequest && equalTo((ListDataAttributesRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListDataAttributesRequest other) { + return model.equals(other.model) && includeArchived.equals(other.includeArchived); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.model, this.includeArchived); + } + + @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 model = Optional.empty(); + + private Optional includeArchived = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ListDataAttributesRequest other) { + model(other.getModel()); + includeArchived(other.getIncludeArchived()); + return this; + } + + @JsonSetter(value = "model", nulls = Nulls.SKIP) + public Builder model(Optional model) { + this.model = model; + return this; + } + + public Builder model(DataAttributesListRequestModel model) { + this.model = Optional.ofNullable(model); + return this; + } + + @JsonSetter(value = "include_archived", nulls = Nulls.SKIP) + public Builder includeArchived(Optional includeArchived) { + this.includeArchived = includeArchived; + return this; + } + + public Builder includeArchived(Boolean includeArchived) { + this.includeArchived = Optional.ofNullable(includeArchived); + return this; + } + + public ListDataAttributesRequest build() { + return new ListDataAttributesRequest(model, includeArchived, additionalProperties); + } + } +} 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 new file mode 100644 index 00000000..392b7aef --- /dev/null +++ b/src/main/java/com/intercom/api/resources/dataattributes/requests/UpdateDataAttributeRequest.java @@ -0,0 +1,349 @@ +/** + * 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.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; +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 Optional archived; + + private final Optional description; + + private final Optional> options; + + private final Optional messengerWritable; + + private final Map additionalProperties; + + private UpdateDataAttributeRequest( + String dataAttributeId, + Optional archived, + Optional description, + Optional> options, + Optional messengerWritable, + Map additionalProperties) { + this.dataAttributeId = dataAttributeId; + this.archived = archived; + this.description = description; + this.options = options; + this.messengerWritable = messengerWritable; + this.additionalProperties = additionalProperties; + } + + /** + * @return The data attribute id + */ + @JsonProperty("data_attribute_id") + public String 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; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UpdateDataAttributeRequest && equalTo((UpdateDataAttributeRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + 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); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.dataAttributeId, this.archived, this.description, this.options, this.messengerWritable); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static DataAttributeIdStage builder() { + return new Builder(); + } + + public interface DataAttributeIdStage { + _FinalStage dataAttributeId(@NotNull String dataAttributeId); + + Builder from(UpdateDataAttributeRequest other); + } + + public interface _FinalStage { + UpdateDataAttributeRequest build(); + + _FinalStage archived(Optional archived); + + _FinalStage archived(Boolean archived); + + _FinalStage description(Optional description); + + _FinalStage description(String description); + + _FinalStage options(Optional> options); + + _FinalStage options(List options); + + _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(); + + private Optional archived = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + 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()); + return this; + } + + /** + *

The data attribute id

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @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; + } + + @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; + } + + @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; + } + + @java.lang.Override + @JsonSetter(value = "description", nulls = Nulls.SKIP) + public _FinalStage description(Optional description) { + this.description = description; + 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; + } + + @java.lang.Override + @JsonSetter(value = "archived", nulls = Nulls.SKIP) + public _FinalStage archived(Optional archived) { + this.archived = archived; + 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); + } + } + } +} 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 new file mode 100644 index 00000000..03a0ccc9 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/dataattributes/types/DataAttribute.java @@ -0,0 +1,869 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.dataattributes.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.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 = DataAttribute.Builder.class) +public final class DataAttribute { + private final Optional id; + + private final Optional model; + + private final String name; + + private final String fullName; + + private final String label; + + private final String description; + + private final DataType dataType; + + private final Optional> options; + + private final Optional apiWritable; + + private final Optional messengerWritable; + + private final Optional uiWritable; + + private final Optional custom; + + private final Optional archived; + + private final Optional createdAt; + + private final Optional updatedAt; + + private final Optional adminId; + + private final Map additionalProperties; + + private DataAttribute( + Optional id, + Optional model, + String name, + String fullName, + String label, + String description, + DataType dataType, + Optional> options, + Optional apiWritable, + Optional messengerWritable, + Optional uiWritable, + Optional custom, + Optional archived, + Optional createdAt, + Optional updatedAt, + Optional adminId, + Map additionalProperties) { + this.id = id; + this.model = model; + this.name = name; + this.fullName = fullName; + this.label = label; + this.description = description; + this.dataType = dataType; + this.options = options; + this.apiWritable = apiWritable; + this.messengerWritable = messengerWritable; + this.uiWritable = uiWritable; + this.custom = custom; + this.archived = archived; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.adminId = adminId; + this.additionalProperties = additionalProperties; + } + + /** + * @return Value is data_attribute. + */ + @JsonProperty("type") + public String getType() { + return "data_attribute"; + } + + /** + * @return The unique identifier for the data attribute which is given by Intercom. Only available for custom attributes. + */ + @JsonProperty("id") + public Optional getId() { + return id; + } + + /** + * @return Value is contact for user/lead attributes and company for company attributes. + */ + @JsonProperty("model") + public Optional getModel() { + return model; + } + + /** + * @return Name of the attribute. + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * @return Full name of the attribute. Should match the name unless it's a nested attribute. We can split full_name on . to access nested user object values. + */ + @JsonProperty("full_name") + public String getFullName() { + return fullName; + } + + /** + * @return Readable name of the attribute (i.e. name you see in the UI) + */ + @JsonProperty("label") + public String getLabel() { + return label; + } + + /** + * @return Readable description of the attribute. + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * @return The data type of the attribute. + */ + @JsonProperty("data_type") + public DataType getDataType() { + return dataType; + } + + /** + * @return List of predefined options for attribute value. + */ + @JsonProperty("options") + public Optional> getOptions() { + return options; + } + + /** + * @return Can this attribute be updated through API + */ + @JsonProperty("api_writable") + public Optional getApiWritable() { + return apiWritable; + } + + /** + * @return Can this attribute be updated by the Messenger + */ + @JsonProperty("messenger_writable") + public Optional getMessengerWritable() { + return messengerWritable; + } + + /** + * @return Can this attribute be updated in the UI + */ + @JsonProperty("ui_writable") + public Optional getUiWritable() { + return uiWritable; + } + + /** + * @return Set to true if this is a CDA + */ + @JsonProperty("custom") + public Optional getCustom() { + return custom; + } + + /** + * @return Is this attribute archived. (Only applicable to CDAs) + */ + @JsonProperty("archived") + public Optional getArchived() { + return archived; + } + + /** + * @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 Teammate who created the attribute. Only applicable to CDAs + */ + @JsonProperty("admin_id") + public Optional getAdminId() { + return adminId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DataAttribute && equalTo((DataAttribute) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DataAttribute other) { + return id.equals(other.id) + && model.equals(other.model) + && name.equals(other.name) + && fullName.equals(other.fullName) + && label.equals(other.label) + && description.equals(other.description) + && dataType.equals(other.dataType) + && options.equals(other.options) + && apiWritable.equals(other.apiWritable) + && messengerWritable.equals(other.messengerWritable) + && uiWritable.equals(other.uiWritable) + && custom.equals(other.custom) + && archived.equals(other.archived) + && createdAt.equals(other.createdAt) + && updatedAt.equals(other.updatedAt) + && adminId.equals(other.adminId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.id, + this.model, + this.name, + this.fullName, + this.label, + this.description, + this.dataType, + this.options, + this.apiWritable, + this.messengerWritable, + this.uiWritable, + this.custom, + this.archived, + this.createdAt, + this.updatedAt, + this.adminId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static NameStage builder() { + return new Builder(); + } + + public interface NameStage { + FullNameStage name(@NotNull String name); + + Builder from(DataAttribute other); + } + + public interface FullNameStage { + LabelStage fullName(@NotNull String fullName); + } + + public interface LabelStage { + DescriptionStage label(@NotNull String label); + } + + public interface DescriptionStage { + DataTypeStage description(@NotNull String description); + } + + public interface DataTypeStage { + _FinalStage dataType(@NotNull DataType dataType); + } + + public interface _FinalStage { + DataAttribute build(); + + _FinalStage id(Optional id); + + _FinalStage id(Integer id); + + _FinalStage model(Optional model); + + _FinalStage model(Model model); + + _FinalStage options(Optional> options); + + _FinalStage options(List options); + + _FinalStage apiWritable(Optional apiWritable); + + _FinalStage apiWritable(Boolean apiWritable); + + _FinalStage messengerWritable(Optional messengerWritable); + + _FinalStage messengerWritable(Boolean messengerWritable); + + _FinalStage uiWritable(Optional uiWritable); + + _FinalStage uiWritable(Boolean uiWritable); + + _FinalStage custom(Optional custom); + + _FinalStage custom(Boolean custom); + + _FinalStage archived(Optional archived); + + _FinalStage archived(Boolean archived); + + _FinalStage createdAt(Optional createdAt); + + _FinalStage createdAt(Integer createdAt); + + _FinalStage updatedAt(Optional updatedAt); + + _FinalStage updatedAt(Integer updatedAt); + + _FinalStage adminId(Optional adminId); + + _FinalStage adminId(String adminId); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements NameStage, FullNameStage, LabelStage, DescriptionStage, DataTypeStage, _FinalStage { + private String name; + + private String fullName; + + private String label; + + private String description; + + private DataType dataType; + + private Optional adminId = Optional.empty(); + + private Optional updatedAt = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + private Optional archived = Optional.empty(); + + private Optional custom = Optional.empty(); + + private Optional uiWritable = Optional.empty(); + + private Optional messengerWritable = Optional.empty(); + + private Optional apiWritable = Optional.empty(); + + private Optional> options = Optional.empty(); + + private Optional model = Optional.empty(); + + private Optional id = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DataAttribute other) { + id(other.getId()); + model(other.getModel()); + name(other.getName()); + fullName(other.getFullName()); + label(other.getLabel()); + description(other.getDescription()); + dataType(other.getDataType()); + options(other.getOptions()); + apiWritable(other.getApiWritable()); + messengerWritable(other.getMessengerWritable()); + uiWritable(other.getUiWritable()); + custom(other.getCustom()); + archived(other.getArchived()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + adminId(other.getAdminId()); + return this; + } + + /** + *

Name of the attribute.

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

Full name of the attribute. Should match the name unless it's a nested attribute. We can split full_name on . to access nested user object values.

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

Readable name of the attribute (i.e. name you see in the UI)

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

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.

+ * @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; + } + + /** + *

Teammate who created the attribute. Only applicable to CDAs

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage adminId(String adminId) { + this.adminId = Optional.ofNullable(adminId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "admin_id", nulls = Nulls.SKIP) + public _FinalStage adminId(Optional adminId) { + this.adminId = adminId; + return this; + } + + /** + *

The time the attribute was last updated as a UTC Unix timestamp

+ * @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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) + public _FinalStage updatedAt(Optional updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + /** + *

The time the attribute 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public _FinalStage createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + /** + *

Is this attribute archived. (Only applicable to CDAs)

+ * @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; + } + + @java.lang.Override + @JsonSetter(value = "archived", nulls = Nulls.SKIP) + public _FinalStage archived(Optional archived) { + this.archived = archived; + return this; + } + + /** + *

Set to true if this is a CDA

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage custom(Boolean custom) { + this.custom = Optional.ofNullable(custom); + return this; + } + + @java.lang.Override + @JsonSetter(value = "custom", nulls = Nulls.SKIP) + public _FinalStage custom(Optional custom) { + this.custom = custom; + return this; + } + + /** + *

Can this attribute be updated in the UI

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage uiWritable(Boolean uiWritable) { + this.uiWritable = Optional.ofNullable(uiWritable); + return this; + } + + @java.lang.Override + @JsonSetter(value = "ui_writable", nulls = Nulls.SKIP) + public _FinalStage uiWritable(Optional uiWritable) { + this.uiWritable = uiWritable; + 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; + } + + @java.lang.Override + @JsonSetter(value = "messenger_writable", nulls = Nulls.SKIP) + public _FinalStage messengerWritable(Optional messengerWritable) { + this.messengerWritable = messengerWritable; + return this; + } + + /** + *

Can this attribute be updated through API

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage apiWritable(Boolean apiWritable) { + this.apiWritable = Optional.ofNullable(apiWritable); + return this; + } + + @java.lang.Override + @JsonSetter(value = "api_writable", nulls = Nulls.SKIP) + public _FinalStage apiWritable(Optional apiWritable) { + this.apiWritable = apiWritable; + return this; + } + + /** + *

List of predefined options for attribute value.

+ * @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; + } + + @java.lang.Override + @JsonSetter(value = "options", nulls = Nulls.SKIP) + public _FinalStage options(Optional> options) { + this.options = options; + 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. + */ + @java.lang.Override + public _FinalStage model(Model model) { + this.model = Optional.ofNullable(model); + return this; + } + + @java.lang.Override + @JsonSetter(value = "model", nulls = Nulls.SKIP) + public _FinalStage model(Optional model) { + this.model = model; + return this; + } + + /** + *

The unique identifier for the data attribute which is given by Intercom. Only available for custom attributes.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage id(Integer id) { + this.id = Optional.ofNullable(id); + return this; + } + + @java.lang.Override + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public _FinalStage id(Optional id) { + this.id = id; + return this; + } + + @java.lang.Override + public DataAttribute build() { + return new DataAttribute( + id, + model, + name, + fullName, + label, + description, + dataType, + options, + apiWritable, + messengerWritable, + uiWritable, + custom, + archived, + createdAt, + updatedAt, + adminId, + additionalProperties); + } + } + + public 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 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 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 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 "boolean": + return BOOLEAN; + case "date": + return DATE; + default: + return new DataType(Value.UNKNOWN, value); + } + } + + public enum Value { + STRING, + + INTEGER, + + FLOAT, + + BOOLEAN, + + DATE, + + UNKNOWN + } + + public interface Visitor { + T visitString(); + + T visitInteger(); + + T visitFloat(); + + T visitBoolean(); + + T visitDate(); + + T visitUnknown(String unknownType); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/dataattributes/types/DataAttributesListRequestModel.java b/src/main/java/com/intercom/api/resources/dataattributes/types/DataAttributesListRequestModel.java new file mode 100644 index 00000000..9180fe18 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/dataattributes/types/DataAttributesListRequestModel.java @@ -0,0 +1,97 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.dataattributes.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class DataAttributesListRequestModel { + public static final DataAttributesListRequestModel CONTACT = + new DataAttributesListRequestModel(Value.CONTACT, "contact"); + + public static final DataAttributesListRequestModel CONVERSATION = + new DataAttributesListRequestModel(Value.CONVERSATION, "conversation"); + + public static final DataAttributesListRequestModel COMPANY = + new DataAttributesListRequestModel(Value.COMPANY, "company"); + + private final Value value; + + private final String string; + + DataAttributesListRequestModel(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 DataAttributesListRequestModel + && this.string.equals(((DataAttributesListRequestModel) 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 CONVERSATION: + return visitor.visitConversation(); + case COMPANY: + return visitor.visitCompany(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static DataAttributesListRequestModel valueOf(String value) { + switch (value) { + case "contact": + return CONTACT; + case "conversation": + return CONVERSATION; + case "company": + return COMPANY; + default: + return new DataAttributesListRequestModel(Value.UNKNOWN, value); + } + } + + public enum Value { + CONTACT, + + COMPANY, + + CONVERSATION, + + UNKNOWN + } + + public interface Visitor { + T visitContact(); + + T visitCompany(); + + T visitConversation(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/intercom/api/resources/dataevents/types/DataEvent.java b/src/main/java/com/intercom/api/resources/dataevents/types/DataEvent.java new file mode 100644 index 00000000..3ea858ff --- /dev/null +++ b/src/main/java/com/intercom/api/resources/dataevents/types/DataEvent.java @@ -0,0 +1,375 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.dataevents.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 = DataEvent.Builder.class) +public final class DataEvent { + private final Optional type; + + private final String eventName; + + private final int createdAt; + + private final Optional userId; + + private final Optional id; + + private final Optional intercomUserId; + + private final Optional email; + + private final Optional> metadata; + + private final Map additionalProperties; + + private DataEvent( + Optional type, + String eventName, + int createdAt, + Optional userId, + Optional id, + Optional intercomUserId, + Optional email, + Optional> metadata, + Map additionalProperties) { + this.type = type; + this.eventName = eventName; + this.createdAt = createdAt; + this.userId = userId; + this.id = id; + this.intercomUserId = intercomUserId; + this.email = email; + this.metadata = metadata; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of the object + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return The name of the event that occurred. This is presented to your App's admins when filtering and creating segments - a good event name is typically a past tense 'verb-noun' combination, to improve readability, for example updated-plan. + */ + @JsonProperty("event_name") + public String getEventName() { + return eventName; + } + + /** + * @return The time the event occurred as a UTC Unix timestamp + */ + @JsonProperty("created_at") + public int getCreatedAt() { + return createdAt; + } + + /** + * @return Your identifier for the user. + */ + @JsonProperty("user_id") + public Optional getUserId() { + return userId; + } + + /** + * @return Your identifier for a lead or a user. + */ + @JsonProperty("id") + public Optional getId() { + return id; + } + + /** + * @return The Intercom identifier for the user. + */ + @JsonProperty("intercom_user_id") + public Optional getIntercomUserId() { + return intercomUserId; + } + + /** + * @return An email address for your user. An email should only be used where your application uses email to uniquely identify users. + */ + @JsonProperty("email") + public Optional getEmail() { + return email; + } + + /** + * @return Optional metadata about the event. + */ + @JsonProperty("metadata") + public Optional> getMetadata() { + return metadata; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DataEvent && equalTo((DataEvent) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DataEvent other) { + return type.equals(other.type) + && eventName.equals(other.eventName) + && createdAt == other.createdAt + && userId.equals(other.userId) + && id.equals(other.id) + && intercomUserId.equals(other.intercomUserId) + && email.equals(other.email) + && metadata.equals(other.metadata); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.type, + this.eventName, + this.createdAt, + this.userId, + this.id, + this.intercomUserId, + this.email, + this.metadata); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static EventNameStage builder() { + return new Builder(); + } + + public interface EventNameStage { + CreatedAtStage eventName(@NotNull String eventName); + + Builder from(DataEvent other); + } + + public interface CreatedAtStage { + _FinalStage createdAt(int createdAt); + } + + public interface _FinalStage { + DataEvent build(); + + _FinalStage type(Optional type); + + _FinalStage type(String type); + + _FinalStage userId(Optional userId); + + _FinalStage userId(String userId); + + _FinalStage id(Optional id); + + _FinalStage id(String id); + + _FinalStage intercomUserId(Optional intercomUserId); + + _FinalStage intercomUserId(String intercomUserId); + + _FinalStage email(Optional email); + + _FinalStage email(String email); + + _FinalStage metadata(Optional> metadata); + + _FinalStage metadata(Map metadata); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements EventNameStage, CreatedAtStage, _FinalStage { + private String eventName; + + private int createdAt; + + private Optional> metadata = Optional.empty(); + + private Optional email = Optional.empty(); + + private Optional intercomUserId = Optional.empty(); + + private Optional id = Optional.empty(); + + private Optional userId = Optional.empty(); + + private Optional type = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DataEvent other) { + type(other.getType()); + eventName(other.getEventName()); + createdAt(other.getCreatedAt()); + userId(other.getUserId()); + id(other.getId()); + intercomUserId(other.getIntercomUserId()); + email(other.getEmail()); + metadata(other.getMetadata()); + return this; + } + + /** + *

The name of the event that occurred. This is presented to your App's admins when filtering and creating segments - a good event name is typically a past tense 'verb-noun' combination, to improve readability, for example updated-plan.

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

The time the event occurred as a UTC Unix timestamp

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

Optional metadata about the event.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage metadata(Map metadata) { + this.metadata = Optional.ofNullable(metadata); + return this; + } + + @java.lang.Override + @JsonSetter(value = "metadata", nulls = Nulls.SKIP) + public _FinalStage metadata(Optional> metadata) { + this.metadata = metadata; + return this; + } + + /** + *

An email address for your user. An email should only be used where your application uses email to uniquely identify users.

+ * @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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "email", nulls = Nulls.SKIP) + public _FinalStage email(Optional email) { + this.email = email; + return this; + } + + /** + *

The Intercom identifier for the user.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage intercomUserId(String intercomUserId) { + this.intercomUserId = Optional.ofNullable(intercomUserId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "intercom_user_id", nulls = Nulls.SKIP) + public _FinalStage intercomUserId(Optional intercomUserId) { + this.intercomUserId = intercomUserId; + return this; + } + + /** + *

Your identifier for a lead or a user.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage id(String id) { + this.id = Optional.ofNullable(id); + return this; + } + + @java.lang.Override + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public _FinalStage id(Optional id) { + this.id = id; + return this; + } + + /** + *

Your identifier for the user.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage userId(String userId) { + this.userId = Optional.ofNullable(userId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "user_id", nulls = Nulls.SKIP) + public _FinalStage userId(Optional userId) { + this.userId = userId; + 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; + } + + @java.lang.Override + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public _FinalStage type(Optional type) { + this.type = type; + return this; + } + + @java.lang.Override + public DataEvent build() { + return new DataEvent( + type, eventName, createdAt, userId, id, intercomUserId, email, metadata, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/dataexport/AsyncDataExportClient.java b/src/main/java/com/intercom/api/resources/dataexport/AsyncDataExportClient.java new file mode 100644 index 00000000..2d094d9b --- /dev/null +++ b/src/main/java/com/intercom/api/resources/dataexport/AsyncDataExportClient.java @@ -0,0 +1,307 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.dataexport; + +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.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.RequestOptions; +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.FindDataExportRequest; +import com.intercom.api.resources.dataexport.types.DataExport; +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 AsyncDataExportClient { + protected final ClientOptions clientOptions; + + public AsyncDataExportClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * To create your export job, you need to send a POST request to the export endpoint https://api.intercom.io/export/content/data. + *

The only parameters you need to provide are the range of dates that you want exported.

+ *
+ *

🚧 Limit of one active job

+ *

You can only have one active job per workspace. You will receive a HTTP status code of 429 with the message Exceeded rate limit of 1 pending message data export jobs if you attempt to create a second concurrent job.

+ *
+ *
+ *

❗️ Updated_at not included

+ *

It should be noted that the timeframe only includes messages sent during the time period and not messages that were only updated during this period. For example, if a message was updated yesterday but sent two days ago, you would need to set the created_at_after date before the message was sent to include that in your retrieval job.

+ *
+ *
+ *

📘 Date ranges are inclusive

+ *

Requesting data for 2018-06-01 until 2018-06-30 will get all data for those days including those specified - e.g. 2018-06-01 00:00:00 until 2018-06-30 23:59:99.

+ *
+ */ + public CompletableFuture create(CreateDataExportRequest request) { + return create(request, null); + } + + /** + * To create your export job, you need to send a POST request to the export endpoint https://api.intercom.io/export/content/data. + *

The only parameters you need to provide are the range of dates that you want exported.

+ *
+ *

🚧 Limit of one active job

+ *

You can only have one active job per workspace. You will receive a HTTP status code of 429 with the message Exceeded rate limit of 1 pending message data export jobs if you attempt to create a second concurrent job.

+ *
+ *
+ *

❗️ Updated_at not included

+ *

It should be noted that the timeframe only includes messages sent during the time period and not messages that were only updated during this period. For example, if a message was updated yesterday but sent two days ago, you would need to set the created_at_after date before the message was sent to include that in your retrieval job.

+ *
+ *
+ *

📘 Date ranges are inclusive

+ *

Requesting data for 2018-06-01 until 2018-06-30 will get all data for those days including those specified - e.g. 2018-06-01 00:00:00 until 2018-06-30 23:59:99.

+ *
+ */ + public CompletableFuture create(CreateDataExportRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("export/content/data") + .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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DataExport.class)); + 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))); + 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 view the status of your job by sending a GET request to the URL + * https://api.intercom.io/export/content/data/{job_identifier} - the {job_identifier} is the value returned in the response when you first created the export job. More on it can be seen in the Export Job Model. + *
+ *

🚧 Jobs expire after two days + * All jobs that have completed processing (and are thus available to download from the provided URL) will have an expiry limit of two days from when the export ob completed. After this, the data will no longer be available.

+ *
+ */ + public CompletableFuture find(FindDataExportRequest request) { + return find(request, null); + } + + /** + * You can view the status of your job by sending a GET request to the URL + * https://api.intercom.io/export/content/data/{job_identifier} - the {job_identifier} is the value returned in the response when you first created the export job. More on it can be seen in the Export Job Model. + *
+ *

🚧 Jobs expire after two days + * All jobs that have completed processing (and are thus available to download from the provided URL) will have an expiry limit of two days from when the export ob completed. After this, the data will no longer be available.

+ *
+ */ + public CompletableFuture find(FindDataExportRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("export/content/data") + .addPathSegment(request.getJobIdentifier()) + .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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DataExport.class)); + 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))); + 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 cancel your job + */ + public CompletableFuture cancel(CancelDataExportRequest request) { + return cancel(request, null); + } + + /** + * You can cancel your job + */ + public CompletableFuture cancel(CancelDataExportRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("export/cancel") + .addPathSegment(request.getJobIdentifier()) + .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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DataExport.class)); + 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))); + 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; + } + + /** + * When a job has a status of complete, and thus a filled download_url, you can download your data by hitting that provided URL, formatted like so: https://api.intercom.io/download/content/data/xyz1234. + *

Your exported message data will be streamed continuously back down to you in a gzipped CSV format.

+ *
+ *

📘 Octet header required

+ *

You will have to specify the header Accept: application/octet-stream when hitting this endpoint.

+ *
+ */ + public CompletableFuture download(DownloadDataExportRequest request) { + return download(request, null); + } + + /** + * When a job has a status of complete, and thus a filled download_url, you can download your data by hitting that provided URL, formatted like so: https://api.intercom.io/download/content/data/xyz1234. + *

Your exported message data will be streamed continuously back down to you in a gzipped CSV format.

+ *
+ *

📘 Octet header required

+ *

You will have to specify the header Accept: application/octet-stream when hitting this endpoint.

+ *
+ */ + public CompletableFuture download(DownloadDataExportRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("download/content/data") + .addPathSegment(request.getJobIdentifier()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", 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(null); + 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))); + 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/dataexport/DataExportClient.java b/src/main/java/com/intercom/api/resources/dataexport/DataExportClient.java new file mode 100644 index 00000000..d628ae41 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/dataexport/DataExportClient.java @@ -0,0 +1,251 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.dataexport; + +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.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.RequestOptions; +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.FindDataExportRequest; +import com.intercom.api.resources.dataexport.types.DataExport; +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 DataExportClient { + protected final ClientOptions clientOptions; + + public DataExportClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * To create your export job, you need to send a POST request to the export endpoint https://api.intercom.io/export/content/data. + *

The only parameters you need to provide are the range of dates that you want exported.

+ *
+ *

🚧 Limit of one active job

+ *

You can only have one active job per workspace. You will receive a HTTP status code of 429 with the message Exceeded rate limit of 1 pending message data export jobs if you attempt to create a second concurrent job.

+ *
+ *
+ *

❗️ Updated_at not included

+ *

It should be noted that the timeframe only includes messages sent during the time period and not messages that were only updated during this period. For example, if a message was updated yesterday but sent two days ago, you would need to set the created_at_after date before the message was sent to include that in your retrieval job.

+ *
+ *
+ *

📘 Date ranges are inclusive

+ *

Requesting data for 2018-06-01 until 2018-06-30 will get all data for those days including those specified - e.g. 2018-06-01 00:00:00 until 2018-06-30 23:59:99.

+ *
+ */ + public DataExport create(CreateDataExportRequest request) { + return create(request, null); + } + + /** + * To create your export job, you need to send a POST request to the export endpoint https://api.intercom.io/export/content/data. + *

The only parameters you need to provide are the range of dates that you want exported.

+ *
+ *

🚧 Limit of one active job

+ *

You can only have one active job per workspace. You will receive a HTTP status code of 429 with the message Exceeded rate limit of 1 pending message data export jobs if you attempt to create a second concurrent job.

+ *
+ *
+ *

❗️ Updated_at not included

+ *

It should be noted that the timeframe only includes messages sent during the time period and not messages that were only updated during this period. For example, if a message was updated yesterday but sent two days ago, you would need to set the created_at_after date before the message was sent to include that in your retrieval job.

+ *
+ *
+ *

📘 Date ranges are inclusive

+ *

Requesting data for 2018-06-01 until 2018-06-30 will get all data for those days including those specified - e.g. 2018-06-01 00:00:00 until 2018-06-30 23:59:99.

+ *
+ */ + public DataExport create(CreateDataExportRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("export/content/data") + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DataExport.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can view the status of your job by sending a GET request to the URL + * https://api.intercom.io/export/content/data/{job_identifier} - the {job_identifier} is the value returned in the response when you first created the export job. More on it can be seen in the Export Job Model. + *
+ *

🚧 Jobs expire after two days + * All jobs that have completed processing (and are thus available to download from the provided URL) will have an expiry limit of two days from when the export ob completed. After this, the data will no longer be available.

+ *
+ */ + public DataExport find(FindDataExportRequest request) { + return find(request, null); + } + + /** + * You can view the status of your job by sending a GET request to the URL + * https://api.intercom.io/export/content/data/{job_identifier} - the {job_identifier} is the value returned in the response when you first created the export job. More on it can be seen in the Export Job Model. + *
+ *

🚧 Jobs expire after two days + * All jobs that have completed processing (and are thus available to download from the provided URL) will have an expiry limit of two days from when the export ob completed. After this, the data will no longer be available.

+ *
+ */ + public DataExport find(FindDataExportRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("export/content/data") + .addPathSegment(request.getJobIdentifier()) + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DataExport.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can cancel your job + */ + public DataExport cancel(CancelDataExportRequest request) { + return cancel(request, null); + } + + /** + * You can cancel your job + */ + public DataExport cancel(CancelDataExportRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("export/cancel") + .addPathSegment(request.getJobIdentifier()) + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DataExport.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * When a job has a status of complete, and thus a filled download_url, you can download your data by hitting that provided URL, formatted like so: https://api.intercom.io/download/content/data/xyz1234. + *

Your exported message data will be streamed continuously back down to you in a gzipped CSV format.

+ *
+ *

📘 Octet header required

+ *

You will have to specify the header Accept: application/octet-stream when hitting this endpoint.

+ *
+ */ + public void download(DownloadDataExportRequest request) { + download(request, null); + } + + /** + * When a job has a status of complete, and thus a filled download_url, you can download your data by hitting that provided URL, formatted like so: https://api.intercom.io/download/content/data/xyz1234. + *

Your exported message data will be streamed continuously back down to you in a gzipped CSV format.

+ *
+ *

📘 Octet header required

+ *

You will have to specify the header Accept: application/octet-stream when hitting this endpoint.

+ *
+ */ + public void download(DownloadDataExportRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("download/content/data") + .addPathSegment(request.getJobIdentifier()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", 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; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/dataexport/requests/CancelDataExportRequest.java b/src/main/java/com/intercom/api/resources/dataexport/requests/CancelDataExportRequest.java new file mode 100644 index 00000000..2894247d --- /dev/null +++ b/src/main/java/com/intercom/api/resources/dataexport/requests/CancelDataExportRequest.java @@ -0,0 +1,109 @@ +/** + * 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 = CancelDataExportRequest.Builder.class) +public final class CancelDataExportRequest { + private final String jobIdentifier; + + private final Map additionalProperties; + + private CancelDataExportRequest(String jobIdentifier, Map additionalProperties) { + this.jobIdentifier = jobIdentifier; + this.additionalProperties = additionalProperties; + } + + /** + * @return job_identifier + */ + @JsonProperty("job_identifier") + public String getJobIdentifier() { + return jobIdentifier; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CancelDataExportRequest && equalTo((CancelDataExportRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CancelDataExportRequest other) { + return jobIdentifier.equals(other.jobIdentifier); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.jobIdentifier); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static JobIdentifierStage builder() { + return new Builder(); + } + + public interface JobIdentifierStage { + _FinalStage jobIdentifier(@NotNull String jobIdentifier); + + Builder from(CancelDataExportRequest other); + } + + public interface _FinalStage { + CancelDataExportRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements JobIdentifierStage, _FinalStage { + private String jobIdentifier; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CancelDataExportRequest other) { + jobIdentifier(other.getJobIdentifier()); + return this; + } + + /** + *

job_identifier

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("job_identifier") + public _FinalStage jobIdentifier(@NotNull String jobIdentifier) { + this.jobIdentifier = Objects.requireNonNull(jobIdentifier, "jobIdentifier must not be null"); + return this; + } + + @java.lang.Override + public CancelDataExportRequest build() { + return new CancelDataExportRequest(jobIdentifier, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/dataexport/requests/CreateDataExportRequest.java b/src/main/java/com/intercom/api/resources/dataexport/requests/CreateDataExportRequest.java new file mode 100644 index 00000000..7c1dd826 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/dataexport/requests/CreateDataExportRequest.java @@ -0,0 +1,137 @@ +/** + * 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; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CreateDataExportRequest.Builder.class) +public final class CreateDataExportRequest { + private final int createdAtAfter; + + private final int createdAtBefore; + + private final Map additionalProperties; + + private CreateDataExportRequest(int createdAtAfter, int createdAtBefore, Map additionalProperties) { + this.createdAtAfter = createdAtAfter; + this.createdAtBefore = createdAtBefore; + this.additionalProperties = additionalProperties; + } + + /** + * @return The start date that you request data for. It must be formatted as a unix timestamp. + */ + @JsonProperty("created_at_after") + public int getCreatedAtAfter() { + return createdAtAfter; + } + + /** + * @return The end date that you request data for. It must be formatted as a unix timestamp. + */ + @JsonProperty("created_at_before") + public int getCreatedAtBefore() { + return createdAtBefore; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreateDataExportRequest && equalTo((CreateDataExportRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreateDataExportRequest other) { + return createdAtAfter == other.createdAtAfter && createdAtBefore == other.createdAtBefore; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.createdAtAfter, this.createdAtBefore); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static CreatedAtAfterStage builder() { + return new Builder(); + } + + public interface CreatedAtAfterStage { + CreatedAtBeforeStage createdAtAfter(int createdAtAfter); + + Builder from(CreateDataExportRequest other); + } + + public interface CreatedAtBeforeStage { + _FinalStage createdAtBefore(int createdAtBefore); + } + + public interface _FinalStage { + CreateDataExportRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements CreatedAtAfterStage, CreatedAtBeforeStage, _FinalStage { + private int createdAtAfter; + + private int createdAtBefore; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CreateDataExportRequest other) { + createdAtAfter(other.getCreatedAtAfter()); + createdAtBefore(other.getCreatedAtBefore()); + return this; + } + + /** + *

The start date that you request data for. It must be formatted as a unix timestamp.

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

The end date that you request data for. It must be formatted as a unix timestamp.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("created_at_before") + public _FinalStage createdAtBefore(int createdAtBefore) { + this.createdAtBefore = createdAtBefore; + return this; + } + + @java.lang.Override + public CreateDataExportRequest build() { + return new CreateDataExportRequest(createdAtAfter, createdAtBefore, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/dataexport/requests/DownloadDataExportRequest.java b/src/main/java/com/intercom/api/resources/dataexport/requests/DownloadDataExportRequest.java new file mode 100644 index 00000000..72bc9281 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/dataexport/requests/DownloadDataExportRequest.java @@ -0,0 +1,109 @@ +/** + * 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 = DownloadDataExportRequest.Builder.class) +public final class DownloadDataExportRequest { + private final String jobIdentifier; + + private final Map additionalProperties; + + private DownloadDataExportRequest(String jobIdentifier, Map additionalProperties) { + this.jobIdentifier = jobIdentifier; + this.additionalProperties = additionalProperties; + } + + /** + * @return job_identifier + */ + @JsonProperty("job_identifier") + public String getJobIdentifier() { + return jobIdentifier; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DownloadDataExportRequest && equalTo((DownloadDataExportRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DownloadDataExportRequest other) { + return jobIdentifier.equals(other.jobIdentifier); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.jobIdentifier); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static JobIdentifierStage builder() { + return new Builder(); + } + + public interface JobIdentifierStage { + _FinalStage jobIdentifier(@NotNull String jobIdentifier); + + Builder from(DownloadDataExportRequest other); + } + + public interface _FinalStage { + DownloadDataExportRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements JobIdentifierStage, _FinalStage { + private String jobIdentifier; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DownloadDataExportRequest other) { + jobIdentifier(other.getJobIdentifier()); + return this; + } + + /** + *

job_identifier

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("job_identifier") + public _FinalStage jobIdentifier(@NotNull String jobIdentifier) { + this.jobIdentifier = Objects.requireNonNull(jobIdentifier, "jobIdentifier must not be null"); + return this; + } + + @java.lang.Override + public DownloadDataExportRequest build() { + return new DownloadDataExportRequest(jobIdentifier, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/dataexport/requests/FindDataExportRequest.java b/src/main/java/com/intercom/api/resources/dataexport/requests/FindDataExportRequest.java new file mode 100644 index 00000000..17684138 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/dataexport/requests/FindDataExportRequest.java @@ -0,0 +1,109 @@ +/** + * 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 = FindDataExportRequest.Builder.class) +public final class FindDataExportRequest { + private final String jobIdentifier; + + private final Map additionalProperties; + + private FindDataExportRequest(String jobIdentifier, Map additionalProperties) { + this.jobIdentifier = jobIdentifier; + this.additionalProperties = additionalProperties; + } + + /** + * @return job_identifier + */ + @JsonProperty("job_identifier") + public String getJobIdentifier() { + return jobIdentifier; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof FindDataExportRequest && equalTo((FindDataExportRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(FindDataExportRequest other) { + return jobIdentifier.equals(other.jobIdentifier); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.jobIdentifier); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static JobIdentifierStage builder() { + return new Builder(); + } + + public interface JobIdentifierStage { + _FinalStage jobIdentifier(@NotNull String jobIdentifier); + + Builder from(FindDataExportRequest other); + } + + public interface _FinalStage { + FindDataExportRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements JobIdentifierStage, _FinalStage { + private String jobIdentifier; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(FindDataExportRequest other) { + jobIdentifier(other.getJobIdentifier()); + return this; + } + + /** + *

job_identifier

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("job_identifier") + public _FinalStage jobIdentifier(@NotNull String jobIdentifier) { + this.jobIdentifier = Objects.requireNonNull(jobIdentifier, "jobIdentifier must not be null"); + return this; + } + + @java.lang.Override + public FindDataExportRequest build() { + return new FindDataExportRequest(jobIdentifier, 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 new file mode 100644 index 00000000..3a0ea13c --- /dev/null +++ b/src/main/java/com/intercom/api/resources/dataexport/types/DataExport.java @@ -0,0 +1,322 @@ +/** + * 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.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 = DataExport.Builder.class) +public final class DataExport { + private final String jobIdentifier; + + private final Status status; + + private final String downloadExpiresAt; + + private final String downloadUrl; + + private final Map additionalProperties; + + private DataExport( + String jobIdentifier, + Status status, + String downloadExpiresAt, + String downloadUrl, + Map additionalProperties) { + this.jobIdentifier = jobIdentifier; + this.status = status; + this.downloadExpiresAt = downloadExpiresAt; + this.downloadUrl = downloadUrl; + this.additionalProperties = additionalProperties; + } + + /** + * @return The identifier for your job. + */ + @JsonProperty("job_identifier") + public String getJobIdentifier() { + return jobIdentifier; + } + + /** + * @return The current state of your job. + */ + @JsonProperty("status") + public Status getStatus() { + return status; + } + + /** + * @return The time after which you will not be able to access the data. + */ + @JsonProperty("download_expires_at") + public String getDownloadExpiresAt() { + return downloadExpiresAt; + } + + /** + * @return The location where you can download your data. + */ + @JsonProperty("download_url") + public String getDownloadUrl() { + return downloadUrl; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DataExport && equalTo((DataExport) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DataExport other) { + return jobIdentifier.equals(other.jobIdentifier) + && status.equals(other.status) + && downloadExpiresAt.equals(other.downloadExpiresAt) + && downloadUrl.equals(other.downloadUrl); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.jobIdentifier, this.status, this.downloadExpiresAt, this.downloadUrl); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static JobIdentifierStage builder() { + return new Builder(); + } + + public interface JobIdentifierStage { + StatusStage jobIdentifier(@NotNull String jobIdentifier); + + Builder from(DataExport other); + } + + public interface StatusStage { + DownloadExpiresAtStage status(@NotNull Status status); + } + + public interface DownloadExpiresAtStage { + DownloadUrlStage downloadExpiresAt(@NotNull String downloadExpiresAt); + } + + public interface DownloadUrlStage { + _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; + + private Status status; + + private String downloadExpiresAt; + + private String downloadUrl; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DataExport other) { + jobIdentifier(other.getJobIdentifier()); + status(other.getStatus()); + downloadExpiresAt(other.getDownloadExpiresAt()); + downloadUrl(other.getDownloadUrl()); + return this; + } + + /** + *

The identifier for your job.

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

The current state of your job.

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

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. + */ + @java.lang.Override + @JsonSetter("download_expires_at") + public DownloadUrlStage downloadExpiresAt(@NotNull String downloadExpiresAt) { + this.downloadExpiresAt = Objects.requireNonNull(downloadExpiresAt, "downloadExpiresAt must not be null"); + return this; + } + + /** + *

The location where you can download your data.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("download_url") + public _FinalStage downloadUrl(@NotNull String downloadUrl) { + this.downloadUrl = Objects.requireNonNull(downloadUrl, "downloadUrl must not be null"); + return this; + } + + @java.lang.Override + public DataExport build() { + return new DataExport(jobIdentifier, status, downloadExpiresAt, downloadUrl, additionalProperties); + } + } + + public final class Status { + public static final Status FAILED = new Status(Value.FAILED, "failed"); + + public static final Status COMPLETED = new Status(Value.COMPLETED, "completed"); + + public static final Status NO_DATA = new Status(Value.NO_DATA, "no_data"); + + public static final Status PENDING = new Status(Value.PENDING, "pending"); + + public static final Status IN_PROGRESS = new Status(Value.IN_PROGRESS, "in_progress"); + + public static final Status CANCELED = new Status(Value.CANCELED, "canceled"); + + 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 FAILED: + return visitor.visitFailed(); + case COMPLETED: + return visitor.visitCompleted(); + case NO_DATA: + return visitor.visitNoData(); + case PENDING: + return visitor.visitPending(); + case IN_PROGRESS: + return visitor.visitInProgress(); + case CANCELED: + return visitor.visitCanceled(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static Status valueOf(String value) { + switch (value) { + case "failed": + return FAILED; + case "completed": + return COMPLETED; + case "no_data": + return NO_DATA; + case "pending": + return PENDING; + case "in_progress": + return IN_PROGRESS; + case "canceled": + return CANCELED; + default: + return new Status(Value.UNKNOWN, value); + } + } + + public enum Value { + PENDING, + + IN_PROGRESS, + + FAILED, + + COMPLETED, + + NO_DATA, + + CANCELED, + + UNKNOWN + } + + public interface Visitor { + T visitPending(); + + T visitInProgress(); + + T visitFailed(); + + T visitCompleted(); + + T visitNoData(); + + T visitCanceled(); + + T visitUnknown(String unknownType); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/events/AsyncEventsClient.java b/src/main/java/com/intercom/api/resources/events/AsyncEventsClient.java new file mode 100644 index 00000000..8ff61c67 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/events/AsyncEventsClient.java @@ -0,0 +1,352 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.events; + +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.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.QueryStringMapper; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.errors.UnauthorizedError; +import com.intercom.api.resources.events.requests.ListEventSummariesRequest; +import com.intercom.api.resources.events.requests.ListEventsRequest; +import com.intercom.api.types.CreateDataEventRequest; +import com.intercom.api.types.DataEventSummary; +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 AsyncEventsClient { + protected final ClientOptions clientOptions; + + public AsyncEventsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + *
+ * 🚧 + *

Please note that you can only 'list' events that are less than 90 days old. Event counts and summaries will still include your events older than 90 days but you cannot 'list' these events individually if they are older than 90 days

+ *
+ *

The events belonging to a customer can be listed by sending a GET request to https://api.intercom.io/events with a user or lead identifier along with a type parameter. The identifier parameter can be one of user_id, email or intercom_user_id. The type parameter value must be user.

+ *
    + *
  • https://api.intercom.io/events?type=user&user_id={user_id}
  • + *
  • https://api.intercom.io/events?type=user&email={email}
  • + *
  • https://api.intercom.io/events?type=user&intercom_user_id={id} (this call can be used to list leads)
  • + *
+ *

The email parameter value should be url encoded when sending.

+ *

You can optionally define the result page size as well with the per_page parameter.

+ */ + public CompletableFuture list(ListEventsRequest request) { + return list(request, null); + } + + /** + *
+ * 🚧 + *

Please note that you can only 'list' events that are less than 90 days old. Event counts and summaries will still include your events older than 90 days but you cannot 'list' these events individually if they are older than 90 days

+ *
+ *

The events belonging to a customer can be listed by sending a GET request to https://api.intercom.io/events with a user or lead identifier along with a type parameter. The identifier parameter can be one of user_id, email or intercom_user_id. The type parameter value must be user.

+ *
    + *
  • https://api.intercom.io/events?type=user&user_id={user_id}
  • + *
  • https://api.intercom.io/events?type=user&email={email}
  • + *
  • https://api.intercom.io/events?type=user&intercom_user_id={id} (this call can be used to list leads)
  • + *
+ *

The email parameter value should be url encoded when sending.

+ *

You can optionally define the result page size as well with the per_page parameter.

+ */ + public CompletableFuture list(ListEventsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("events"); + if (request.getUserId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "user_id", request.getUserId().get(), false); + } + if (request.getIntercomUserId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "intercom_user_id", request.getIntercomUserId().get(), false); + } + if (request.getEmail().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "email", request.getEmail().get(), false); + } + QueryStringMapper.addQueryParameter(httpUrl, "type", request.getType(), false); + if (request.getSummary().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "summary", request.getSummary().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( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DataEventSummary.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + 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))); + 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 will need an Access Token that has write permissions to send Events. Once you have a key you can submit events via POST to the Events resource, which is located at https://api.intercom.io/events, or you can send events using one of the client libraries. When working with the HTTP API directly a client should send the event with a Content-Type of application/json. + *

When using the JavaScript API, adding the code to your app makes the Events API available. Once added, you can submit an event using the trackEvent method. This will associate the event with the Lead or currently logged-in user or logged-out visitor/lead and send it to Intercom. The final parameter is a map that can be used to send optional metadata about the event.

+ *

With the Ruby client you pass a hash describing the event to Intercom::Event.create, or call the track_user method directly on the current user object (e.g. user.track_event).

+ *

NB: For the JSON object types, please note that we do not currently support nested JSON structure.

+ *

| Type | Description | Example | + * | :-------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------- | + * | String | The value is a JSON String | "source":"desktop" | + * | Number | The value is a JSON Number | "load": 3.67 | + * | Date | The key ends with the String _date and the value is a Unix timestamp, assumed to be in the UTC timezone. | "contact_date": 1392036272 | + * | Link | The value is a HTTP or HTTPS URI. | "article": "https://example.org/ab1de.html" | + * | Rich Link | The value is a JSON object that contains url and value keys. | "article": {"url": "https://example.org/ab1de.html", "value":"the dude abides"} | + * | Monetary Amount | The value is a JSON object that contains amount and currency keys. The amount key is a positive integer representing the amount in cents. The price in the example to the right denotes €349.99. | "price": {"amount": 34999, "currency": "eur"} |

+ *

Lead Events

+ *

When submitting events for Leads, you will need to specify the Lead's id.

+ *

Metadata behaviour

+ *
    + *
  • We currently limit the number of tracked metadata keys to 10 per event. Once the quota is reached, we ignore any further keys we receive. The first 10 metadata keys are determined by the order in which they are sent in with the event.
  • + *
  • It is not possible to change the metadata keys once the event has been sent. A new event will need to be created with the new keys and you can archive the old one.
  • + *
  • There might be up to 24 hrs delay when you send a new metadata for an existing event.
  • + *
+ *

Event de-duplication

+ *

The API may detect and ignore duplicate events. Each event is uniquely identified as a combination of the following data - the Workspace identifier, the Contact external identifier, the Data Event name and the Data Event created time. As a result, it is strongly recommended to send a second granularity Unix timestamp in the created_at field.

+ *

Duplicated events are responded to using the normal 202 Accepted code - an error is not thrown, however repeat requests will be counted against any rate limit that is in place.

+ *

HTTP API Responses

+ *
    + *
  • Successful responses to submitted events return 202 Accepted with an empty body.
  • + *
  • Unauthorised access will be rejected with a 401 Unauthorized or 403 Forbidden response code.
  • + *
  • Events sent about users that cannot be found will return a 404 Not Found.
  • + *
  • Event lists containing duplicate events will have those duplicates ignored.
  • + *
  • Server errors will return a 500 response code and may contain an error message in the body.
  • + *
+ */ + public CompletableFuture create(CreateDataEventRequest request) { + return create(request, null); + } + + /** + * You will need an Access Token that has write permissions to send Events. Once you have a key you can submit events via POST to the Events resource, which is located at https://api.intercom.io/events, or you can send events using one of the client libraries. When working with the HTTP API directly a client should send the event with a Content-Type of application/json. + *

When using the JavaScript API, adding the code to your app makes the Events API available. Once added, you can submit an event using the trackEvent method. This will associate the event with the Lead or currently logged-in user or logged-out visitor/lead and send it to Intercom. The final parameter is a map that can be used to send optional metadata about the event.

+ *

With the Ruby client you pass a hash describing the event to Intercom::Event.create, or call the track_user method directly on the current user object (e.g. user.track_event).

+ *

NB: For the JSON object types, please note that we do not currently support nested JSON structure.

+ *

| Type | Description | Example | + * | :-------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------- | + * | String | The value is a JSON String | "source":"desktop" | + * | Number | The value is a JSON Number | "load": 3.67 | + * | Date | The key ends with the String _date and the value is a Unix timestamp, assumed to be in the UTC timezone. | "contact_date": 1392036272 | + * | Link | The value is a HTTP or HTTPS URI. | "article": "https://example.org/ab1de.html" | + * | Rich Link | The value is a JSON object that contains url and value keys. | "article": {"url": "https://example.org/ab1de.html", "value":"the dude abides"} | + * | Monetary Amount | The value is a JSON object that contains amount and currency keys. The amount key is a positive integer representing the amount in cents. The price in the example to the right denotes €349.99. | "price": {"amount": 34999, "currency": "eur"} |

+ *

Lead Events

+ *

When submitting events for Leads, you will need to specify the Lead's id.

+ *

Metadata behaviour

+ *
    + *
  • We currently limit the number of tracked metadata keys to 10 per event. Once the quota is reached, we ignore any further keys we receive. The first 10 metadata keys are determined by the order in which they are sent in with the event.
  • + *
  • It is not possible to change the metadata keys once the event has been sent. A new event will need to be created with the new keys and you can archive the old one.
  • + *
  • There might be up to 24 hrs delay when you send a new metadata for an existing event.
  • + *
+ *

Event de-duplication

+ *

The API may detect and ignore duplicate events. Each event is uniquely identified as a combination of the following data - the Workspace identifier, the Contact external identifier, the Data Event name and the Data Event created time. As a result, it is strongly recommended to send a second granularity Unix timestamp in the created_at field.

+ *

Duplicated events are responded to using the normal 202 Accepted code - an error is not thrown, however repeat requests will be counted against any rate limit that is in place.

+ *

HTTP API Responses

+ *
    + *
  • Successful responses to submitted events return 202 Accepted with an empty body.
  • + *
  • Unauthorised access will be rejected with a 401 Unauthorized or 403 Forbidden response code.
  • + *
  • Events sent about users that cannot be found will return a 404 Not Found.
  • + *
  • Event lists containing duplicate events will have those duplicates ignored.
  • + *
  • Server errors will return a 500 response code and may contain an error message in the body.
  • + *
+ */ + public CompletableFuture create(CreateDataEventRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("events") + .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(null); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + 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))); + 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 event summaries for a user. Event summaries are used to track the number of times an event has occurred, the first time it occurred and the last time it occurred. + */ + public CompletableFuture summaries() { + return summaries(ListEventSummariesRequest.builder().build()); + } + + /** + * Create event summaries for a user. Event summaries are used to track the number of times an event has occurred, the first time it occurred and the last time it occurred. + */ + public CompletableFuture summaries(ListEventSummariesRequest request) { + return summaries(request, null); + } + + /** + * Create event summaries for a user. Event summaries are used to track the number of times an event has occurred, the first time it occurred and the last time it occurred. + */ + public CompletableFuture summaries(ListEventSummariesRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("events/summaries") + .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(null); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + 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))); + 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/events/EventsClient.java b/src/main/java/com/intercom/api/resources/events/EventsClient.java new file mode 100644 index 00000000..fe42161d --- /dev/null +++ b/src/main/java/com/intercom/api/resources/events/EventsClient.java @@ -0,0 +1,302 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.events; + +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.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.QueryStringMapper; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.errors.UnauthorizedError; +import com.intercom.api.resources.events.requests.ListEventSummariesRequest; +import com.intercom.api.resources.events.requests.ListEventsRequest; +import com.intercom.api.types.CreateDataEventRequest; +import com.intercom.api.types.DataEventSummary; +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 EventsClient { + protected final ClientOptions clientOptions; + + public EventsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + *
+ * 🚧 + *

Please note that you can only 'list' events that are less than 90 days old. Event counts and summaries will still include your events older than 90 days but you cannot 'list' these events individually if they are older than 90 days

+ *
+ *

The events belonging to a customer can be listed by sending a GET request to https://api.intercom.io/events with a user or lead identifier along with a type parameter. The identifier parameter can be one of user_id, email or intercom_user_id. The type parameter value must be user.

+ *
    + *
  • https://api.intercom.io/events?type=user&user_id={user_id}
  • + *
  • https://api.intercom.io/events?type=user&email={email}
  • + *
  • https://api.intercom.io/events?type=user&intercom_user_id={id} (this call can be used to list leads)
  • + *
+ *

The email parameter value should be url encoded when sending.

+ *

You can optionally define the result page size as well with the per_page parameter.

+ */ + public DataEventSummary list(ListEventsRequest request) { + return list(request, null); + } + + /** + *
+ * 🚧 + *

Please note that you can only 'list' events that are less than 90 days old. Event counts and summaries will still include your events older than 90 days but you cannot 'list' these events individually if they are older than 90 days

+ *
+ *

The events belonging to a customer can be listed by sending a GET request to https://api.intercom.io/events with a user or lead identifier along with a type parameter. The identifier parameter can be one of user_id, email or intercom_user_id. The type parameter value must be user.

+ *
    + *
  • https://api.intercom.io/events?type=user&user_id={user_id}
  • + *
  • https://api.intercom.io/events?type=user&email={email}
  • + *
  • https://api.intercom.io/events?type=user&intercom_user_id={id} (this call can be used to list leads)
  • + *
+ *

The email parameter value should be url encoded when sending.

+ *

You can optionally define the result page size as well with the per_page parameter.

+ */ + public DataEventSummary list(ListEventsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("events"); + if (request.getUserId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "user_id", request.getUserId().get(), false); + } + if (request.getIntercomUserId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "intercom_user_id", request.getIntercomUserId().get(), false); + } + if (request.getEmail().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "email", request.getEmail().get(), false); + } + QueryStringMapper.addQueryParameter(httpUrl, "type", request.getType(), false); + if (request.getSummary().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "summary", request.getSummary().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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DataEventSummary.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You will need an Access Token that has write permissions to send Events. Once you have a key you can submit events via POST to the Events resource, which is located at https://api.intercom.io/events, or you can send events using one of the client libraries. When working with the HTTP API directly a client should send the event with a Content-Type of application/json. + *

When using the JavaScript API, adding the code to your app makes the Events API available. Once added, you can submit an event using the trackEvent method. This will associate the event with the Lead or currently logged-in user or logged-out visitor/lead and send it to Intercom. The final parameter is a map that can be used to send optional metadata about the event.

+ *

With the Ruby client you pass a hash describing the event to Intercom::Event.create, or call the track_user method directly on the current user object (e.g. user.track_event).

+ *

NB: For the JSON object types, please note that we do not currently support nested JSON structure.

+ *

| Type | Description | Example | + * | :-------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------- | + * | String | The value is a JSON String | "source":"desktop" | + * | Number | The value is a JSON Number | "load": 3.67 | + * | Date | The key ends with the String _date and the value is a Unix timestamp, assumed to be in the UTC timezone. | "contact_date": 1392036272 | + * | Link | The value is a HTTP or HTTPS URI. | "article": "https://example.org/ab1de.html" | + * | Rich Link | The value is a JSON object that contains url and value keys. | "article": {"url": "https://example.org/ab1de.html", "value":"the dude abides"} | + * | Monetary Amount | The value is a JSON object that contains amount and currency keys. The amount key is a positive integer representing the amount in cents. The price in the example to the right denotes €349.99. | "price": {"amount": 34999, "currency": "eur"} |

+ *

Lead Events

+ *

When submitting events for Leads, you will need to specify the Lead's id.

+ *

Metadata behaviour

+ *
    + *
  • We currently limit the number of tracked metadata keys to 10 per event. Once the quota is reached, we ignore any further keys we receive. The first 10 metadata keys are determined by the order in which they are sent in with the event.
  • + *
  • It is not possible to change the metadata keys once the event has been sent. A new event will need to be created with the new keys and you can archive the old one.
  • + *
  • There might be up to 24 hrs delay when you send a new metadata for an existing event.
  • + *
+ *

Event de-duplication

+ *

The API may detect and ignore duplicate events. Each event is uniquely identified as a combination of the following data - the Workspace identifier, the Contact external identifier, the Data Event name and the Data Event created time. As a result, it is strongly recommended to send a second granularity Unix timestamp in the created_at field.

+ *

Duplicated events are responded to using the normal 202 Accepted code - an error is not thrown, however repeat requests will be counted against any rate limit that is in place.

+ *

HTTP API Responses

+ *
    + *
  • Successful responses to submitted events return 202 Accepted with an empty body.
  • + *
  • Unauthorised access will be rejected with a 401 Unauthorized or 403 Forbidden response code.
  • + *
  • Events sent about users that cannot be found will return a 404 Not Found.
  • + *
  • Event lists containing duplicate events will have those duplicates ignored.
  • + *
  • Server errors will return a 500 response code and may contain an error message in the body.
  • + *
+ */ + public void create(CreateDataEventRequest request) { + create(request, null); + } + + /** + * You will need an Access Token that has write permissions to send Events. Once you have a key you can submit events via POST to the Events resource, which is located at https://api.intercom.io/events, or you can send events using one of the client libraries. When working with the HTTP API directly a client should send the event with a Content-Type of application/json. + *

When using the JavaScript API, adding the code to your app makes the Events API available. Once added, you can submit an event using the trackEvent method. This will associate the event with the Lead or currently logged-in user or logged-out visitor/lead and send it to Intercom. The final parameter is a map that can be used to send optional metadata about the event.

+ *

With the Ruby client you pass a hash describing the event to Intercom::Event.create, or call the track_user method directly on the current user object (e.g. user.track_event).

+ *

NB: For the JSON object types, please note that we do not currently support nested JSON structure.

+ *

| Type | Description | Example | + * | :-------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------- | + * | String | The value is a JSON String | "source":"desktop" | + * | Number | The value is a JSON Number | "load": 3.67 | + * | Date | The key ends with the String _date and the value is a Unix timestamp, assumed to be in the UTC timezone. | "contact_date": 1392036272 | + * | Link | The value is a HTTP or HTTPS URI. | "article": "https://example.org/ab1de.html" | + * | Rich Link | The value is a JSON object that contains url and value keys. | "article": {"url": "https://example.org/ab1de.html", "value":"the dude abides"} | + * | Monetary Amount | The value is a JSON object that contains amount and currency keys. The amount key is a positive integer representing the amount in cents. The price in the example to the right denotes €349.99. | "price": {"amount": 34999, "currency": "eur"} |

+ *

Lead Events

+ *

When submitting events for Leads, you will need to specify the Lead's id.

+ *

Metadata behaviour

+ *
    + *
  • We currently limit the number of tracked metadata keys to 10 per event. Once the quota is reached, we ignore any further keys we receive. The first 10 metadata keys are determined by the order in which they are sent in with the event.
  • + *
  • It is not possible to change the metadata keys once the event has been sent. A new event will need to be created with the new keys and you can archive the old one.
  • + *
  • There might be up to 24 hrs delay when you send a new metadata for an existing event.
  • + *
+ *

Event de-duplication

+ *

The API may detect and ignore duplicate events. Each event is uniquely identified as a combination of the following data - the Workspace identifier, the Contact external identifier, the Data Event name and the Data Event created time. As a result, it is strongly recommended to send a second granularity Unix timestamp in the created_at field.

+ *

Duplicated events are responded to using the normal 202 Accepted code - an error is not thrown, however repeat requests will be counted against any rate limit that is in place.

+ *

HTTP API Responses

+ *
    + *
  • Successful responses to submitted events return 202 Accepted with an empty body.
  • + *
  • Unauthorised access will be rejected with a 401 Unauthorized or 403 Forbidden response code.
  • + *
  • Events sent about users that cannot be found will return a 404 Not Found.
  • + *
  • Event lists containing duplicate events will have those duplicates ignored.
  • + *
  • Server errors will return a 500 response code and may contain an error message in the body.
  • + *
+ */ + public void create(CreateDataEventRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("events") + .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; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * Create event summaries for a user. Event summaries are used to track the number of times an event has occurred, the first time it occurred and the last time it occurred. + */ + public void summaries() { + summaries(ListEventSummariesRequest.builder().build()); + } + + /** + * Create event summaries for a user. Event summaries are used to track the number of times an event has occurred, the first time it occurred and the last time it occurred. + */ + public void summaries(ListEventSummariesRequest request) { + summaries(request, null); + } + + /** + * Create event summaries for a user. Event summaries are used to track the number of times an event has occurred, the first time it occurred and the last time it occurred. + */ + public void summaries(ListEventSummariesRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("events/summaries") + .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; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/events/requests/ListEventSummariesRequest.java b/src/main/java/com/intercom/api/resources/events/requests/ListEventSummariesRequest.java new file mode 100644 index 00000000..d22a31f0 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/events/requests/ListEventSummariesRequest.java @@ -0,0 +1,289 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.events.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 = ListEventSummariesRequest.Builder.class) +public final class ListEventSummariesRequest { + private final Optional userId; + + private final Optional eventSummaries; + + private final Map additionalProperties; + + private ListEventSummariesRequest( + Optional userId, + Optional eventSummaries, + Map additionalProperties) { + this.userId = userId; + this.eventSummaries = eventSummaries; + this.additionalProperties = additionalProperties; + } + + /** + * @return Your identifier for the user. + */ + @JsonProperty("user_id") + public Optional getUserId() { + return userId; + } + + /** + * @return A list of event summaries for the user. Each event summary should contain the event name, the time the event occurred, and the number of times the event occurred. The event name should be a past tense 'verb-noun' combination, to improve readability, for example updated-plan. + */ + @JsonProperty("event_summaries") + public Optional getEventSummaries() { + return eventSummaries; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListEventSummariesRequest && equalTo((ListEventSummariesRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListEventSummariesRequest other) { + return userId.equals(other.userId) && eventSummaries.equals(other.eventSummaries); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.userId, this.eventSummaries); + } + + @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 userId = Optional.empty(); + + private Optional eventSummaries = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ListEventSummariesRequest other) { + userId(other.getUserId()); + eventSummaries(other.getEventSummaries()); + return this; + } + + @JsonSetter(value = "user_id", nulls = Nulls.SKIP) + public Builder userId(Optional userId) { + this.userId = userId; + return this; + } + + public Builder userId(String userId) { + this.userId = Optional.ofNullable(userId); + return this; + } + + @JsonSetter(value = "event_summaries", nulls = Nulls.SKIP) + public Builder eventSummaries(Optional eventSummaries) { + this.eventSummaries = eventSummaries; + return this; + } + + public Builder eventSummaries(EventSummaries eventSummaries) { + this.eventSummaries = Optional.ofNullable(eventSummaries); + return this; + } + + public ListEventSummariesRequest build() { + return new ListEventSummariesRequest(userId, eventSummaries, additionalProperties); + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = EventSummaries.Builder.class) + public static final class EventSummaries { + private final Optional eventName; + + private final Optional count; + + private final Optional first; + + private final Optional last; + + private final Map additionalProperties; + + private EventSummaries( + Optional eventName, + Optional count, + Optional first, + Optional last, + Map additionalProperties) { + this.eventName = eventName; + this.count = count; + this.first = first; + this.last = last; + this.additionalProperties = additionalProperties; + } + + /** + * @return The name of the event that occurred. A good event name is typically a past tense 'verb-noun' combination, to improve readability, for example updated-plan. + */ + @JsonProperty("event_name") + public Optional getEventName() { + return eventName; + } + + /** + * @return The number of times the event occurred. + */ + @JsonProperty("count") + public Optional getCount() { + return count; + } + + /** + * @return The first time the event was sent + */ + @JsonProperty("first") + public Optional getFirst() { + return first; + } + + /** + * @return The last time the event was sent + */ + @JsonProperty("last") + public Optional getLast() { + return last; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof EventSummaries && equalTo((EventSummaries) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(EventSummaries other) { + return eventName.equals(other.eventName) + && count.equals(other.count) + && first.equals(other.first) + && last.equals(other.last); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.eventName, this.count, this.first, this.last); + } + + @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 eventName = Optional.empty(); + + private Optional count = Optional.empty(); + + private Optional first = Optional.empty(); + + private Optional last = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(EventSummaries other) { + eventName(other.getEventName()); + count(other.getCount()); + first(other.getFirst()); + last(other.getLast()); + return this; + } + + @JsonSetter(value = "event_name", nulls = Nulls.SKIP) + public Builder eventName(Optional eventName) { + this.eventName = eventName; + return this; + } + + public Builder eventName(String eventName) { + this.eventName = Optional.ofNullable(eventName); + return this; + } + + @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; + } + + @JsonSetter(value = "first", nulls = Nulls.SKIP) + public Builder first(Optional first) { + this.first = first; + return this; + } + + public Builder first(Integer first) { + this.first = Optional.ofNullable(first); + return this; + } + + @JsonSetter(value = "last", nulls = Nulls.SKIP) + public Builder last(Optional last) { + this.last = last; + return this; + } + + public Builder last(Integer last) { + this.last = Optional.ofNullable(last); + return this; + } + + public EventSummaries build() { + return new EventSummaries(eventName, count, first, last, additionalProperties); + } + } + } +} diff --git a/src/main/java/com/intercom/api/resources/events/requests/ListEventsRequest.java b/src/main/java/com/intercom/api/resources/events/requests/ListEventsRequest.java new file mode 100644 index 00000000..e36c34ca --- /dev/null +++ b/src/main/java/com/intercom/api/resources/events/requests/ListEventsRequest.java @@ -0,0 +1,298 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.events.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 = ListEventsRequest.Builder.class) +public final class ListEventsRequest { + private final Optional userId; + + private final Optional intercomUserId; + + private final Optional email; + + private final String type; + + private final Optional summary; + + private final Optional perPage; + + private final Map additionalProperties; + + private ListEventsRequest( + Optional userId, + Optional intercomUserId, + Optional email, + String type, + Optional summary, + Optional perPage, + Map additionalProperties) { + this.userId = userId; + this.intercomUserId = intercomUserId; + this.email = email; + this.type = type; + this.summary = summary; + this.perPage = perPage; + this.additionalProperties = additionalProperties; + } + + /** + * @return user_id query parameter + */ + @JsonProperty("user_id") + public Optional getUserId() { + return userId; + } + + /** + * @return intercom_user_id query parameter + */ + @JsonProperty("intercom_user_id") + public Optional getIntercomUserId() { + return intercomUserId; + } + + /** + * @return email query parameter + */ + @JsonProperty("email") + public Optional getEmail() { + return email; + } + + /** + * @return The value must be user + */ + @JsonProperty("type") + public String getType() { + return type; + } + + /** + * @return summary flag + */ + @JsonProperty("summary") + public Optional getSummary() { + return summary; + } + + /** + * @return How many results to display 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; + return other instanceof ListEventsRequest && equalTo((ListEventsRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListEventsRequest other) { + return userId.equals(other.userId) + && intercomUserId.equals(other.intercomUserId) + && email.equals(other.email) + && type.equals(other.type) + && summary.equals(other.summary) + && perPage.equals(other.perPage); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.userId, this.intercomUserId, this.email, this.type, this.summary, this.perPage); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TypeStage builder() { + return new Builder(); + } + + public interface TypeStage { + _FinalStage type(@NotNull String type); + + Builder from(ListEventsRequest other); + } + + public interface _FinalStage { + ListEventsRequest build(); + + _FinalStage userId(Optional userId); + + _FinalStage userId(String userId); + + _FinalStage intercomUserId(Optional intercomUserId); + + _FinalStage intercomUserId(String intercomUserId); + + _FinalStage email(Optional email); + + _FinalStage email(String email); + + _FinalStage summary(Optional summary); + + _FinalStage summary(Boolean summary); + + _FinalStage perPage(Optional perPage); + + _FinalStage perPage(Integer perPage); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements TypeStage, _FinalStage { + private String type; + + private Optional perPage = Optional.empty(); + + private Optional summary = Optional.empty(); + + private Optional email = Optional.empty(); + + private Optional intercomUserId = Optional.empty(); + + private Optional userId = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ListEventsRequest other) { + userId(other.getUserId()); + intercomUserId(other.getIntercomUserId()); + email(other.getEmail()); + type(other.getType()); + summary(other.getSummary()); + perPage(other.getPerPage()); + return this; + } + + /** + *

The value must be user

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

How many results to display 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; + } + + @java.lang.Override + @JsonSetter(value = "per_page", nulls = Nulls.SKIP) + public _FinalStage perPage(Optional perPage) { + this.perPage = perPage; + return this; + } + + /** + *

summary flag

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage summary(Boolean summary) { + this.summary = Optional.ofNullable(summary); + return this; + } + + @java.lang.Override + @JsonSetter(value = "summary", nulls = Nulls.SKIP) + public _FinalStage summary(Optional summary) { + this.summary = summary; + return this; + } + + /** + *

email query parameter

+ * @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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "email", nulls = Nulls.SKIP) + public _FinalStage email(Optional email) { + this.email = email; + return this; + } + + /** + *

intercom_user_id query parameter

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage intercomUserId(String intercomUserId) { + this.intercomUserId = Optional.ofNullable(intercomUserId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "intercom_user_id", nulls = Nulls.SKIP) + public _FinalStage intercomUserId(Optional intercomUserId) { + this.intercomUserId = intercomUserId; + return this; + } + + /** + *

user_id query parameter

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage userId(String userId) { + this.userId = Optional.ofNullable(userId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "user_id", nulls = Nulls.SKIP) + public _FinalStage userId(Optional userId) { + this.userId = userId; + return this; + } + + @java.lang.Override + public ListEventsRequest build() { + return new ListEventsRequest(userId, intercomUserId, email, type, summary, perPage, 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 new file mode 100644 index 00000000..bf4d9161 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/helpcenter/types/Collection.java @@ -0,0 +1,555 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.helpcenter.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.GroupTranslatedContent; +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 = Collection.Builder.class) +public final class Collection { + private final String id; + + private final String workspaceId; + + private final String name; + + private final Optional description; + + private final int createdAt; + + private final Optional updatedAt; + + private final Optional url; + + private final Optional icon; + + private final int order; + + private final String defaultLocale; + + private final Optional translatedContent; + + private final Optional parentId; + + private final Optional helpCenterId; + + private final Map additionalProperties; + + private Collection( + String id, + String workspaceId, + String name, + Optional description, + int createdAt, + Optional updatedAt, + Optional url, + Optional icon, + int order, + String defaultLocale, + Optional translatedContent, + Optional parentId, + Optional helpCenterId, + Map additionalProperties) { + this.id = id; + this.workspaceId = workspaceId; + this.name = name; + this.description = description; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.url = url; + this.icon = icon; + this.order = order; + this.defaultLocale = defaultLocale; + this.translatedContent = translatedContent; + this.parentId = parentId; + this.helpCenterId = helpCenterId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the collection which is given by Intercom. + */ + @JsonProperty("id") + public String getId() { + return id; + } + + /** + * @return The id of the workspace which the collection belongs to. + */ + @JsonProperty("workspace_id") + public String getWorkspaceId() { + return workspaceId; + } + + /** + * @return The name of the collection. For multilingual collections, this will be the name of the default language's content. + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * @return The description of the collection. For multilingual help centers, this will be the description of the collection for the default language. + */ + @JsonProperty("description") + public Optional getDescription() { + return description; + } + + /** + * @return The time when the article was created (seconds). For multilingual articles, this will be the timestamp of creation of the default language's content. + */ + @JsonProperty("created_at") + public int getCreatedAt() { + return createdAt; + } + + /** + * @return The time when the article was last updated (seconds). For multilingual articles, this will be the timestamp of last update of the default language's content. + */ + @JsonProperty("updated_at") + public Optional getUpdatedAt() { + return updatedAt; + } + + /** + * @return The URL of the collection. For multilingual help centers, this will be the URL of the collection for the default language. + */ + @JsonProperty("url") + public Optional getUrl() { + return url; + } + + /** + * @return The icon of the collection. + */ + @JsonProperty("icon") + public Optional getIcon() { + return icon; + } + + /** + * @return 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. + */ + @JsonProperty("order") + public int getOrder() { + return order; + } + + /** + * @return The default locale of the help center. This field is only returned for multilingual help centers. + */ + @JsonProperty("default_locale") + public String getDefaultLocale() { + return defaultLocale; + } + + @JsonProperty("translated_content") + public Optional getTranslatedContent() { + return translatedContent; + } + + /** + * @return The id of the parent collection. If null then it is the first level collection. + */ + @JsonProperty("parent_id") + public Optional getParentId() { + return parentId; + } + + /** + * @return The id of the help center the collection is in. + */ + @JsonProperty("help_center_id") + public Optional getHelpCenterId() { + return helpCenterId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Collection && equalTo((Collection) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Collection other) { + return id.equals(other.id) + && workspaceId.equals(other.workspaceId) + && name.equals(other.name) + && description.equals(other.description) + && createdAt == other.createdAt + && updatedAt.equals(other.updatedAt) + && url.equals(other.url) + && icon.equals(other.icon) + && order == other.order + && defaultLocale.equals(other.defaultLocale) + && translatedContent.equals(other.translatedContent) + && parentId.equals(other.parentId) + && helpCenterId.equals(other.helpCenterId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.id, + this.workspaceId, + this.name, + this.description, + this.createdAt, + this.updatedAt, + this.url, + this.icon, + this.order, + this.defaultLocale, + this.translatedContent, + this.parentId, + this.helpCenterId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + WorkspaceIdStage id(@NotNull String id); + + Builder from(Collection other); + } + + public interface WorkspaceIdStage { + NameStage workspaceId(@NotNull String workspaceId); + } + + public interface NameStage { + CreatedAtStage name(@NotNull String name); + } + + public interface CreatedAtStage { + OrderStage createdAt(int createdAt); + } + + public interface OrderStage { + DefaultLocaleStage order(int order); + } + + public interface DefaultLocaleStage { + _FinalStage defaultLocale(@NotNull String defaultLocale); + } + + public interface _FinalStage { + Collection build(); + + _FinalStage description(Optional description); + + _FinalStage description(String description); + + _FinalStage updatedAt(Optional updatedAt); + + _FinalStage updatedAt(Integer updatedAt); + + _FinalStage url(Optional url); + + _FinalStage url(String url); + + _FinalStage icon(Optional icon); + + _FinalStage icon(String icon); + + _FinalStage translatedContent(Optional translatedContent); + + _FinalStage translatedContent(GroupTranslatedContent translatedContent); + + _FinalStage parentId(Optional parentId); + + _FinalStage parentId(String parentId); + + _FinalStage helpCenterId(Optional helpCenterId); + + _FinalStage helpCenterId(Integer helpCenterId); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements IdStage, + WorkspaceIdStage, + NameStage, + CreatedAtStage, + OrderStage, + DefaultLocaleStage, + _FinalStage { + private String id; + + private String workspaceId; + + private String name; + + private int createdAt; + + private int order; + + private String defaultLocale; + + private Optional helpCenterId = Optional.empty(); + + private Optional parentId = Optional.empty(); + + private Optional translatedContent = Optional.empty(); + + private Optional icon = Optional.empty(); + + private Optional url = Optional.empty(); + + private Optional updatedAt = Optional.empty(); + + private Optional description = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(Collection other) { + id(other.getId()); + workspaceId(other.getWorkspaceId()); + name(other.getName()); + description(other.getDescription()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + url(other.getUrl()); + icon(other.getIcon()); + order(other.getOrder()); + defaultLocale(other.getDefaultLocale()); + translatedContent(other.getTranslatedContent()); + parentId(other.getParentId()); + helpCenterId(other.getHelpCenterId()); + return this; + } + + /** + *

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("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 collection belongs to.

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

The name of the collection. For multilingual collections, this will be the name of the default language's content.

+ * @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"); + return this; + } + + /** + *

The time when the article was created (seconds). For multilingual articles, this will be the timestamp of creation of the default language's content.

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

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.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("order") + public DefaultLocaleStage order(int order) { + this.order = order; + 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 + @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. + */ + @java.lang.Override + public _FinalStage helpCenterId(Integer helpCenterId) { + this.helpCenterId = Optional.ofNullable(helpCenterId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "help_center_id", nulls = Nulls.SKIP) + public _FinalStage helpCenterId(Optional helpCenterId) { + this.helpCenterId = helpCenterId; + return this; + } + + /** + *

The id of the parent collection. If null then it is the first level collection.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage parentId(String parentId) { + this.parentId = Optional.ofNullable(parentId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "parent_id", nulls = Nulls.SKIP) + public _FinalStage parentId(Optional parentId) { + this.parentId = parentId; + return this; + } + + @java.lang.Override + public _FinalStage translatedContent(GroupTranslatedContent 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 icon of the collection.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage icon(String icon) { + this.icon = Optional.ofNullable(icon); + return this; + } + + @java.lang.Override + @JsonSetter(value = "icon", nulls = Nulls.SKIP) + public _FinalStage icon(Optional icon) { + this.icon = icon; + return this; + } + + /** + *

The URL of the collection. For multilingual help centers, this will be the URL of the collection for the default language.

+ * @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; + } + + @java.lang.Override + @JsonSetter(value = "url", nulls = Nulls.SKIP) + public _FinalStage url(Optional url) { + this.url = url; + return this; + } + + /** + *

The time when the article was last updated (seconds). For multilingual articles, this will be the timestamp of last update of the default language's content.

+ * @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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) + public _FinalStage updatedAt(Optional updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + /** + *

The description of the collection. For multilingual help centers, this will be the description of the collection for the default language.

+ * @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; + } + + @java.lang.Override + @JsonSetter(value = "description", nulls = Nulls.SKIP) + public _FinalStage description(Optional description) { + this.description = description; + return this; + } + + @java.lang.Override + public Collection build() { + return new Collection( + id, + workspaceId, + name, + description, + createdAt, + updatedAt, + url, + icon, + order, + defaultLocale, + translatedContent, + parentId, + helpCenterId, + additionalProperties); + } + } +} 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 new file mode 100644 index 00000000..dbd21b00 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/helpcenter/types/HelpCenter.java @@ -0,0 +1,327 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.helpcenter.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 = HelpCenter.Builder.class) +public final class HelpCenter { + private final String id; + + private final String workspaceId; + + private final int createdAt; + + private final Optional updatedAt; + + private final String identifier; + + private final boolean websiteTurnedOn; + + private final String displayName; + + private final Map additionalProperties; + + private HelpCenter( + String id, + String workspaceId, + int createdAt, + Optional updatedAt, + String identifier, + boolean websiteTurnedOn, + String displayName, + Map additionalProperties) { + this.id = id; + this.workspaceId = workspaceId; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.identifier = identifier; + this.websiteTurnedOn = websiteTurnedOn; + this.displayName = displayName; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the Help Center which is given by Intercom. + */ + @JsonProperty("id") + public String getId() { + return id; + } + + /** + * @return The id of the workspace which the Help Center belongs to. + */ + @JsonProperty("workspace_id") + public String getWorkspaceId() { + return workspaceId; + } + + /** + * @return The time when the Help Center was created. + */ + @JsonProperty("created_at") + public int getCreatedAt() { + return createdAt; + } + + /** + * @return The time when the Help Center was last updated. + */ + @JsonProperty("updated_at") + public Optional getUpdatedAt() { + return updatedAt; + } + + /** + * @return The identifier of the Help Center. This is used in the URL of the Help Center. + */ + @JsonProperty("identifier") + public String getIdentifier() { + return identifier; + } + + /** + * @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() { + return websiteTurnedOn; + } + + /** + * @return The display name of the Help Center only seen by teammates. + */ + @JsonProperty("display_name") + public String getDisplayName() { + return displayName; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof HelpCenter && equalTo((HelpCenter) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(HelpCenter other) { + return id.equals(other.id) + && workspaceId.equals(other.workspaceId) + && createdAt == other.createdAt + && updatedAt.equals(other.updatedAt) + && identifier.equals(other.identifier) + && websiteTurnedOn == other.websiteTurnedOn + && displayName.equals(other.displayName); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.id, + this.workspaceId, + this.createdAt, + this.updatedAt, + this.identifier, + this.websiteTurnedOn, + this.displayName); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + WorkspaceIdStage id(@NotNull String id); + + Builder from(HelpCenter other); + } + + public interface WorkspaceIdStage { + CreatedAtStage workspaceId(@NotNull String workspaceId); + } + + public interface CreatedAtStage { + IdentifierStage createdAt(int createdAt); + } + + public interface IdentifierStage { + WebsiteTurnedOnStage identifier(@NotNull String identifier); + } + + public interface WebsiteTurnedOnStage { + DisplayNameStage websiteTurnedOn(boolean websiteTurnedOn); + } + + public interface DisplayNameStage { + _FinalStage displayName(@NotNull String displayName); + } + + public interface _FinalStage { + HelpCenter build(); + + _FinalStage updatedAt(Optional updatedAt); + + _FinalStage updatedAt(Integer updatedAt); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements IdStage, + WorkspaceIdStage, + CreatedAtStage, + IdentifierStage, + WebsiteTurnedOnStage, + DisplayNameStage, + _FinalStage { + private String id; + + private String workspaceId; + + private int createdAt; + + private String identifier; + + private boolean websiteTurnedOn; + + private String displayName; + + private Optional updatedAt = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(HelpCenter other) { + id(other.getId()); + workspaceId(other.getWorkspaceId()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + identifier(other.getIdentifier()); + websiteTurnedOn(other.getWebsiteTurnedOn()); + displayName(other.getDisplayName()); + return this; + } + + /** + *

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. + */ + @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 Help Center belongs to.

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

The time when the Help Center was created.

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

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. + */ + @java.lang.Override + @JsonSetter("identifier") + public WebsiteTurnedOnStage identifier(@NotNull String identifier) { + this.identifier = Objects.requireNonNull(identifier, "identifier must not be null"); + return this; + } + + /** + *

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. + */ + @java.lang.Override + @JsonSetter("website_turned_on") + public DisplayNameStage websiteTurnedOn(boolean websiteTurnedOn) { + this.websiteTurnedOn = websiteTurnedOn; + return this; + } + + /** + *

The display name of the Help Center only seen by teammates.

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

The time when the Help Center 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) + public _FinalStage updatedAt(Optional updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + @java.lang.Override + public HelpCenter build() { + return new HelpCenter( + id, + workspaceId, + createdAt, + updatedAt, + identifier, + websiteTurnedOn, + displayName, + 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 new file mode 100644 index 00000000..3cfb6bd1 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/helpcenter/types/HelpCenterList.java @@ -0,0 +1,113 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.helpcenter.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.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = HelpCenterList.Builder.class) +public final class HelpCenterList { + private final List data; + + private final Map additionalProperties; + + private HelpCenterList(List data, Map additionalProperties) { + this.data = data; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of the object - list. + */ + @JsonProperty("type") + public String getType() { + return "list"; + } + + /** + * @return An array of Help Center objects + */ + @JsonProperty("data") + public List getData() { + return data; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof HelpCenterList && equalTo((HelpCenterList) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(HelpCenterList other) { + return data.equals(other.data); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(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 List data = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(HelpCenterList other) { + data(other.getData()); + return this; + } + + @JsonSetter(value = "data", nulls = Nulls.SKIP) + public Builder data(List data) { + this.data.clear(); + this.data.addAll(data); + return this; + } + + public Builder addData(HelpCenter data) { + this.data.add(data); + return this; + } + + public Builder addAllData(List data) { + this.data.addAll(data); + return this; + } + + public HelpCenterList build() { + return new HelpCenterList(data, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/helpcenters/AsyncHelpCentersClient.java b/src/main/java/com/intercom/api/resources/helpcenters/AsyncHelpCentersClient.java new file mode 100644 index 00000000..0c4aad32 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/helpcenters/AsyncHelpCentersClient.java @@ -0,0 +1,213 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.helpcenters; + +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.ObjectMappers; +import com.intercom.api.core.QueryStringMapper; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.core.Suppliers; +import com.intercom.api.core.pagination.SyncPagingIterable; +import com.intercom.api.errors.NotFoundError; +import com.intercom.api.errors.UnauthorizedError; +import com.intercom.api.resources.helpcenter.types.HelpCenter; +import com.intercom.api.resources.helpcenter.types.HelpCenterList; +import com.intercom.api.resources.helpcenters.collections.AsyncCollectionsClient; +import com.intercom.api.resources.helpcenters.requests.FindHelpCenterRequest; +import com.intercom.api.resources.helpcenters.requests.ListHelpCentersRequest; +import com.intercom.api.types.Error; +import java.io.IOException; +import java.util.List; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; +import java.util.function.Supplier; +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 AsyncHelpCentersClient { + protected final ClientOptions clientOptions; + + protected final Supplier collectionsClient; + + public AsyncHelpCentersClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.collectionsClient = Suppliers.memoize(() -> new AsyncCollectionsClient(clientOptions)); + } + + /** + * You can fetch the details of a single Help Center by making a GET request to https://api.intercom.io/help_center/help_center/<id>. + */ + public CompletableFuture find(FindHelpCenterRequest request) { + return find(request, null); + } + + /** + * You can fetch the details of a single Help Center by making a GET request to https://api.intercom.io/help_center/help_center/<id>. + */ + public CompletableFuture find(FindHelpCenterRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("help_center/help_centers") + .addPathSegment(request.getHelpCenterId()) + .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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), HelpCenter.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + 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))); + 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 list all Help Centers by making a GET request to https://api.intercom.io/help_center/help_centers. + */ + public CompletableFuture> list() { + return list(ListHelpCentersRequest.builder().build()); + } + + /** + * You can list all Help Centers by making a GET request to https://api.intercom.io/help_center/help_centers. + */ + public CompletableFuture> list(ListHelpCentersRequest request) { + return list(request, null); + } + + /** + * You can list all Help Centers by making a GET request to https://api.intercom.io/help_center/help_centers. + */ + public CompletableFuture> list( + ListHelpCentersRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("help_center/help_centers"); + 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()) { + HelpCenterList parsedResponse = + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), HelpCenterList.class); + int newPageNumber = + request.getPage().map(page -> page + 1).orElse(1); + ListHelpCentersRequest nextRequest = ListHelpCentersRequest.builder() + .from(request) + .page(newPageNumber) + .build(); + List result = parsedResponse.getData(); + future.complete(new SyncPagingIterable(true, result, () -> { + try { + return list(nextRequest, requestOptions).get(); + } catch (InterruptedException | ExecutionException e) { + throw new RuntimeException(e); + } + })); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + 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))); + 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 AsyncCollectionsClient collections() { + return this.collectionsClient.get(); + } +} diff --git a/src/main/java/com/intercom/api/resources/helpcenters/HelpCentersClient.java b/src/main/java/com/intercom/api/resources/helpcenters/HelpCentersClient.java new file mode 100644 index 00000000..43a4c819 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/helpcenters/HelpCentersClient.java @@ -0,0 +1,169 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.helpcenters; + +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.ObjectMappers; +import com.intercom.api.core.QueryStringMapper; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.core.Suppliers; +import com.intercom.api.core.pagination.SyncPagingIterable; +import com.intercom.api.errors.NotFoundError; +import com.intercom.api.errors.UnauthorizedError; +import com.intercom.api.resources.helpcenter.types.HelpCenter; +import com.intercom.api.resources.helpcenter.types.HelpCenterList; +import com.intercom.api.resources.helpcenters.collections.CollectionsClient; +import com.intercom.api.resources.helpcenters.requests.FindHelpCenterRequest; +import com.intercom.api.resources.helpcenters.requests.ListHelpCentersRequest; +import com.intercom.api.types.Error; +import java.io.IOException; +import java.util.List; +import java.util.function.Supplier; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class HelpCentersClient { + protected final ClientOptions clientOptions; + + protected final Supplier collectionsClient; + + public HelpCentersClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.collectionsClient = Suppliers.memoize(() -> new CollectionsClient(clientOptions)); + } + + /** + * You can fetch the details of a single Help Center by making a GET request to https://api.intercom.io/help_center/help_center/<id>. + */ + public HelpCenter find(FindHelpCenterRequest request) { + return find(request, null); + } + + /** + * You can fetch the details of a single Help Center by making a GET request to https://api.intercom.io/help_center/help_center/<id>. + */ + public HelpCenter find(FindHelpCenterRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("help_center/help_centers") + .addPathSegment(request.getHelpCenterId()) + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), HelpCenter.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can list all Help Centers by making a GET request to https://api.intercom.io/help_center/help_centers. + */ + public SyncPagingIterable list() { + return list(ListHelpCentersRequest.builder().build()); + } + + /** + * You can list all Help Centers by making a GET request to https://api.intercom.io/help_center/help_centers. + */ + public SyncPagingIterable list(ListHelpCentersRequest request) { + return list(request, null); + } + + /** + * You can list all Help Centers by making a GET request to https://api.intercom.io/help_center/help_centers. + */ + public SyncPagingIterable list(ListHelpCentersRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("help_center/help_centers"); + 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()) { + HelpCenterList parsedResponse = + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), HelpCenterList.class); + int newPageNumber = request.getPage().map(page -> page + 1).orElse(1); + ListHelpCentersRequest nextRequest = ListHelpCentersRequest.builder() + .from(request) + .page(newPageNumber) + .build(); + List result = parsedResponse.getData(); + return new SyncPagingIterable(true, result, () -> list(nextRequest, requestOptions)); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + public CollectionsClient collections() { + return this.collectionsClient.get(); + } +} diff --git a/src/main/java/com/intercom/api/resources/helpcenters/collections/AsyncCollectionsClient.java b/src/main/java/com/intercom/api/resources/helpcenters/collections/AsyncCollectionsClient.java new file mode 100644 index 00000000..26b01ce7 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/helpcenters/collections/AsyncCollectionsClient.java @@ -0,0 +1,435 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.helpcenters.collections; + +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.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.QueryStringMapper; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.core.pagination.SyncPagingIterable; +import com.intercom.api.errors.BadRequestError; +import com.intercom.api.errors.NotFoundError; +import com.intercom.api.errors.UnauthorizedError; +import com.intercom.api.resources.helpcenter.types.Collection; +import com.intercom.api.resources.helpcenters.collections.requests.CreateCollectionRequest; +import com.intercom.api.resources.helpcenters.collections.requests.DeleteCollectionRequest; +import com.intercom.api.resources.helpcenters.collections.requests.FindCollectionRequest; +import com.intercom.api.resources.helpcenters.collections.requests.ListCollectionsRequest; +import com.intercom.api.resources.helpcenters.collections.requests.UpdateCollectionRequest; +import com.intercom.api.types.CollectionList; +import com.intercom.api.types.DeletedCollectionObject; +import com.intercom.api.types.Error; +import java.io.IOException; +import java.util.List; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; +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 AsyncCollectionsClient { + protected final ClientOptions clientOptions; + + public AsyncCollectionsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can fetch a list of all collections by making a GET request to https://api.intercom.io/help_center/collections. + *

Collections will be returned in descending order on the updated_at attribute. This means if you need to iterate through results then we'll show the most recently updated collections first.

+ */ + public CompletableFuture> list() { + return list(ListCollectionsRequest.builder().build()); + } + + /** + * You can fetch a list of all collections by making a GET request to https://api.intercom.io/help_center/collections. + *

Collections will be returned in descending order on the updated_at attribute. This means if you need to iterate through results then we'll show the most recently updated collections first.

+ */ + public CompletableFuture> list(ListCollectionsRequest request) { + return list(request, null); + } + + /** + * You can fetch a list of all collections by making a GET request to https://api.intercom.io/help_center/collections. + *

Collections will be returned in descending order on the updated_at attribute. This means if you need to iterate through results then we'll show the most recently updated collections first.

+ */ + public CompletableFuture> list( + ListCollectionsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("help_center/collections"); + 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()) { + CollectionList parsedResponse = + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CollectionList.class); + int newPageNumber = + request.getPage().map(page -> page + 1).orElse(1); + ListCollectionsRequest nextRequest = ListCollectionsRequest.builder() + .from(request) + .page(newPageNumber) + .build(); + List result = parsedResponse.getData(); + future.complete(new SyncPagingIterable(true, result, () -> { + try { + return list(nextRequest, requestOptions).get(); + } catch (InterruptedException | ExecutionException e) { + throw new RuntimeException(e); + } + })); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + 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))); + 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 collection by making a POST request to https://api.intercom.io/help_center/collections. + */ + public CompletableFuture create(CreateCollectionRequest request) { + return create(request, null); + } + + /** + * You can create a new collection by making a POST request to https://api.intercom.io/help_center/collections. + */ + public CompletableFuture create(CreateCollectionRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("help_center/collections") + .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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Collection.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + 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))); + 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 collection by making a GET request to https://api.intercom.io/help_center/collections/<id>. + */ + public CompletableFuture find(FindCollectionRequest request) { + return find(request, null); + } + + /** + * You can fetch the details of a single collection by making a GET request to https://api.intercom.io/help_center/collections/<id>. + */ + public CompletableFuture find(FindCollectionRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("help_center/collections") + .addPathSegment(request.getCollectionId()) + .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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Collection.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + 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))); + 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 collection by making a PUT request to https://api.intercom.io/collections/<id>. + */ + public CompletableFuture update(UpdateCollectionRequest request) { + return update(request, null); + } + + /** + * You can update the details of a single collection by making a PUT request to https://api.intercom.io/collections/<id>. + */ + public CompletableFuture update(UpdateCollectionRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("help_center/collections") + .addPathSegment(request.getCollectionId()) + .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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Collection.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + 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))); + 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 collection by making a DELETE request to https://api.intercom.io/collections/<id>. + */ + public CompletableFuture delete(DeleteCollectionRequest request) { + return delete(request, null); + } + + /** + * You can delete a single collection by making a DELETE request to https://api.intercom.io/collections/<id>. + */ + public CompletableFuture delete( + DeleteCollectionRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("help_center/collections") + .addPathSegment(request.getCollectionId()) + .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(ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), DeletedCollectionObject.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + 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))); + 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/helpcenters/collections/CollectionsClient.java b/src/main/java/com/intercom/api/resources/helpcenters/collections/CollectionsClient.java new file mode 100644 index 00000000..bfe8c746 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/helpcenters/collections/CollectionsClient.java @@ -0,0 +1,342 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.helpcenters.collections; + +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.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.QueryStringMapper; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.core.pagination.SyncPagingIterable; +import com.intercom.api.errors.BadRequestError; +import com.intercom.api.errors.NotFoundError; +import com.intercom.api.errors.UnauthorizedError; +import com.intercom.api.resources.helpcenter.types.Collection; +import com.intercom.api.resources.helpcenters.collections.requests.CreateCollectionRequest; +import com.intercom.api.resources.helpcenters.collections.requests.DeleteCollectionRequest; +import com.intercom.api.resources.helpcenters.collections.requests.FindCollectionRequest; +import com.intercom.api.resources.helpcenters.collections.requests.ListCollectionsRequest; +import com.intercom.api.resources.helpcenters.collections.requests.UpdateCollectionRequest; +import com.intercom.api.types.CollectionList; +import com.intercom.api.types.DeletedCollectionObject; +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.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class CollectionsClient { + protected final ClientOptions clientOptions; + + public CollectionsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can fetch a list of all collections by making a GET request to https://api.intercom.io/help_center/collections. + *

Collections will be returned in descending order on the updated_at attribute. This means if you need to iterate through results then we'll show the most recently updated collections first.

+ */ + public SyncPagingIterable list() { + return list(ListCollectionsRequest.builder().build()); + } + + /** + * You can fetch a list of all collections by making a GET request to https://api.intercom.io/help_center/collections. + *

Collections will be returned in descending order on the updated_at attribute. This means if you need to iterate through results then we'll show the most recently updated collections first.

+ */ + public SyncPagingIterable list(ListCollectionsRequest request) { + return list(request, null); + } + + /** + * You can fetch a list of all collections by making a GET request to https://api.intercom.io/help_center/collections. + *

Collections will be returned in descending order on the updated_at attribute. This means if you need to iterate through results then we'll show the most recently updated collections first.

+ */ + public SyncPagingIterable list(ListCollectionsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("help_center/collections"); + 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()) { + CollectionList parsedResponse = + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CollectionList.class); + int newPageNumber = request.getPage().map(page -> page + 1).orElse(1); + ListCollectionsRequest nextRequest = ListCollectionsRequest.builder() + .from(request) + .page(newPageNumber) + .build(); + List result = parsedResponse.getData(); + return new SyncPagingIterable(true, result, () -> list(nextRequest, requestOptions)); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can create a new collection by making a POST request to https://api.intercom.io/help_center/collections. + */ + public Collection create(CreateCollectionRequest request) { + return create(request, null); + } + + /** + * You can create a new collection by making a POST request to https://api.intercom.io/help_center/collections. + */ + public Collection create(CreateCollectionRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("help_center/collections") + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Collection.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can fetch the details of a single collection by making a GET request to https://api.intercom.io/help_center/collections/<id>. + */ + public Collection find(FindCollectionRequest request) { + return find(request, null); + } + + /** + * You can fetch the details of a single collection by making a GET request to https://api.intercom.io/help_center/collections/<id>. + */ + public Collection find(FindCollectionRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("help_center/collections") + .addPathSegment(request.getCollectionId()) + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Collection.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can update the details of a single collection by making a PUT request to https://api.intercom.io/collections/<id>. + */ + public Collection update(UpdateCollectionRequest request) { + return update(request, null); + } + + /** + * You can update the details of a single collection by making a PUT request to https://api.intercom.io/collections/<id>. + */ + public Collection update(UpdateCollectionRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("help_center/collections") + .addPathSegment(request.getCollectionId()) + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Collection.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can delete a single collection by making a DELETE request to https://api.intercom.io/collections/<id>. + */ + public DeletedCollectionObject delete(DeleteCollectionRequest request) { + return delete(request, null); + } + + /** + * You can delete a single collection by making a DELETE request to https://api.intercom.io/collections/<id>. + */ + public DeletedCollectionObject delete(DeleteCollectionRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("help_center/collections") + .addPathSegment(request.getCollectionId()) + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeletedCollectionObject.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/helpcenters/collections/requests/CreateCollectionRequest.java b/src/main/java/com/intercom/api/resources/helpcenters/collections/requests/CreateCollectionRequest.java new file mode 100644 index 00000000..1f7453dd --- /dev/null +++ b/src/main/java/com/intercom/api/resources/helpcenters/collections/requests/CreateCollectionRequest.java @@ -0,0 +1,256 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.helpcenters.collections.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 com.intercom.api.types.GroupTranslatedContent; +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 = CreateCollectionRequest.Builder.class) +public final class CreateCollectionRequest { + private final String name; + + private final Optional description; + + private final Optional translatedContent; + + private final Optional parentId; + + private final Optional helpCenterId; + + private final Map additionalProperties; + + private CreateCollectionRequest( + String name, + Optional description, + Optional translatedContent, + Optional parentId, + Optional helpCenterId, + Map additionalProperties) { + this.name = name; + this.description = description; + this.translatedContent = translatedContent; + this.parentId = parentId; + this.helpCenterId = helpCenterId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The name of the collection. For multilingual collections, this will be the name of the default language's content. + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * @return The description of the collection. For multilingual collections, this will be the description of the default language's content. + */ + @JsonProperty("description") + public Optional getDescription() { + return description; + } + + @JsonProperty("translated_content") + public Optional getTranslatedContent() { + return translatedContent; + } + + /** + * @return The id of the parent collection. If null then it will be created as the first level collection. + */ + @JsonProperty("parent_id") + public Optional getParentId() { + return parentId; + } + + /** + * @return The id of the help center where the collection will be created. If null then it will be created in the default help center. + */ + @JsonProperty("help_center_id") + public Optional getHelpCenterId() { + return helpCenterId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreateCollectionRequest && equalTo((CreateCollectionRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreateCollectionRequest other) { + return name.equals(other.name) + && description.equals(other.description) + && translatedContent.equals(other.translatedContent) + && parentId.equals(other.parentId) + && helpCenterId.equals(other.helpCenterId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.name, this.description, this.translatedContent, this.parentId, this.helpCenterId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static NameStage builder() { + return new Builder(); + } + + public interface NameStage { + _FinalStage name(@NotNull String name); + + Builder from(CreateCollectionRequest other); + } + + public interface _FinalStage { + CreateCollectionRequest build(); + + _FinalStage description(Optional description); + + _FinalStage description(String description); + + _FinalStage translatedContent(Optional translatedContent); + + _FinalStage translatedContent(GroupTranslatedContent translatedContent); + + _FinalStage parentId(Optional parentId); + + _FinalStage parentId(String parentId); + + _FinalStage helpCenterId(Optional helpCenterId); + + _FinalStage helpCenterId(Integer helpCenterId); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements NameStage, _FinalStage { + private String name; + + private Optional helpCenterId = Optional.empty(); + + private Optional parentId = Optional.empty(); + + private Optional translatedContent = Optional.empty(); + + private Optional description = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CreateCollectionRequest other) { + name(other.getName()); + description(other.getDescription()); + translatedContent(other.getTranslatedContent()); + parentId(other.getParentId()); + helpCenterId(other.getHelpCenterId()); + return this; + } + + /** + *

The name of the collection. For multilingual collections, this will be the name of the default language's content.

+ * @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"); + return this; + } + + /** + *

The id of the help center where the collection will be created. If null then it will be created in the default help center.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage helpCenterId(Integer helpCenterId) { + this.helpCenterId = Optional.ofNullable(helpCenterId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "help_center_id", nulls = Nulls.SKIP) + public _FinalStage helpCenterId(Optional helpCenterId) { + this.helpCenterId = helpCenterId; + return this; + } + + /** + *

The id of the parent collection. If null then it will be created as the first level collection.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage parentId(String parentId) { + this.parentId = Optional.ofNullable(parentId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "parent_id", nulls = Nulls.SKIP) + public _FinalStage parentId(Optional parentId) { + this.parentId = parentId; + return this; + } + + @java.lang.Override + public _FinalStage translatedContent(GroupTranslatedContent 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 description of the collection. For multilingual collections, this will be the description of the default language's content.

+ * @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; + } + + @java.lang.Override + @JsonSetter(value = "description", nulls = Nulls.SKIP) + public _FinalStage description(Optional description) { + this.description = description; + return this; + } + + @java.lang.Override + public CreateCollectionRequest build() { + return new CreateCollectionRequest( + name, description, translatedContent, parentId, helpCenterId, additionalProperties); + } + } +} 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 new file mode 100644 index 00000000..57552626 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/helpcenters/collections/requests/DeleteCollectionRequest.java @@ -0,0 +1,109 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.helpcenters.collections.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 = DeleteCollectionRequest.Builder.class) +public final class DeleteCollectionRequest { + private final String collectionId; + + private final Map additionalProperties; + + private DeleteCollectionRequest(String collectionId, Map additionalProperties) { + this.collectionId = collectionId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the collection which is given by Intercom. + */ + @JsonProperty("collection_id") + public String getCollectionId() { + return collectionId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeleteCollectionRequest && equalTo((DeleteCollectionRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeleteCollectionRequest other) { + return collectionId.equals(other.collectionId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.collectionId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static CollectionIdStage builder() { + return new Builder(); + } + + public interface CollectionIdStage { + _FinalStage collectionId(@NotNull String collectionId); + + Builder from(DeleteCollectionRequest other); + } + + public interface _FinalStage { + DeleteCollectionRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements CollectionIdStage, _FinalStage { + private String collectionId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DeleteCollectionRequest other) { + collectionId(other.getCollectionId()); + return this; + } + + /** + *

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("collection_id") + public _FinalStage collectionId(@NotNull String collectionId) { + this.collectionId = Objects.requireNonNull(collectionId, "collectionId must not be null"); + return this; + } + + @java.lang.Override + public DeleteCollectionRequest build() { + return new DeleteCollectionRequest(collectionId, additionalProperties); + } + } +} 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 new file mode 100644 index 00000000..70aef5fd --- /dev/null +++ b/src/main/java/com/intercom/api/resources/helpcenters/collections/requests/FindCollectionRequest.java @@ -0,0 +1,109 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.helpcenters.collections.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 = FindCollectionRequest.Builder.class) +public final class FindCollectionRequest { + private final String collectionId; + + private final Map additionalProperties; + + private FindCollectionRequest(String collectionId, Map additionalProperties) { + this.collectionId = collectionId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the collection which is given by Intercom. + */ + @JsonProperty("collection_id") + public String getCollectionId() { + return collectionId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof FindCollectionRequest && equalTo((FindCollectionRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(FindCollectionRequest other) { + return collectionId.equals(other.collectionId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.collectionId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static CollectionIdStage builder() { + return new Builder(); + } + + public interface CollectionIdStage { + _FinalStage collectionId(@NotNull String collectionId); + + Builder from(FindCollectionRequest other); + } + + public interface _FinalStage { + FindCollectionRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements CollectionIdStage, _FinalStage { + private String collectionId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(FindCollectionRequest other) { + collectionId(other.getCollectionId()); + return this; + } + + /** + *

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("collection_id") + public _FinalStage collectionId(@NotNull String collectionId) { + this.collectionId = Objects.requireNonNull(collectionId, "collectionId must not be null"); + return this; + } + + @java.lang.Override + public FindCollectionRequest build() { + return new FindCollectionRequest(collectionId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/helpcenters/collections/requests/ListCollectionsRequest.java b/src/main/java/com/intercom/api/resources/helpcenters/collections/requests/ListCollectionsRequest.java new file mode 100644 index 00000000..63230d73 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/helpcenters/collections/requests/ListCollectionsRequest.java @@ -0,0 +1,124 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.helpcenters.collections.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 = ListCollectionsRequest.Builder.class) +public final class ListCollectionsRequest { + private final Optional page; + + private final Optional perPage; + + private final Map additionalProperties; + + private ListCollectionsRequest( + 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 15 + */ + @JsonProperty("per_page") + public Optional getPerPage() { + return perPage; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListCollectionsRequest && equalTo((ListCollectionsRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListCollectionsRequest 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(ListCollectionsRequest other) { + page(other.getPage()); + perPage(other.getPerPage()); + return this; + } + + @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; + } + + @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 ListCollectionsRequest build() { + return new ListCollectionsRequest(page, perPage, additionalProperties); + } + } +} 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 new file mode 100644 index 00000000..f8491872 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/helpcenters/collections/requests/UpdateCollectionRequest.java @@ -0,0 +1,256 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.helpcenters.collections.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 com.intercom.api.types.GroupTranslatedContent; +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 = UpdateCollectionRequest.Builder.class) +public final class UpdateCollectionRequest { + private final String collectionId; + + private final Optional name; + + private final Optional description; + + private final Optional translatedContent; + + private final Optional parentId; + + private final Map additionalProperties; + + private UpdateCollectionRequest( + String collectionId, + Optional name, + Optional description, + Optional translatedContent, + Optional parentId, + Map additionalProperties) { + this.collectionId = collectionId; + this.name = name; + this.description = description; + this.translatedContent = translatedContent; + this.parentId = parentId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the collection which is given by Intercom. + */ + @JsonProperty("collection_id") + public String getCollectionId() { + return collectionId; + } + + /** + * @return The name of the collection. For multilingual collections, this will be the name of the default language's content. + */ + @JsonProperty("name") + public Optional getName() { + return name; + } + + /** + * @return The description of the collection. For multilingual collections, this will be the description of the default language's content. + */ + @JsonProperty("description") + public Optional getDescription() { + return description; + } + + @JsonProperty("translated_content") + public Optional getTranslatedContent() { + return translatedContent; + } + + /** + * @return The id of the parent collection. If null then it will be updated as the first level collection. + */ + @JsonProperty("parent_id") + public Optional getParentId() { + return parentId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UpdateCollectionRequest && equalTo((UpdateCollectionRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UpdateCollectionRequest other) { + return collectionId.equals(other.collectionId) + && name.equals(other.name) + && description.equals(other.description) + && translatedContent.equals(other.translatedContent) + && parentId.equals(other.parentId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.collectionId, this.name, this.description, this.translatedContent, this.parentId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static CollectionIdStage builder() { + return new Builder(); + } + + public interface CollectionIdStage { + _FinalStage collectionId(@NotNull String collectionId); + + Builder from(UpdateCollectionRequest other); + } + + public interface _FinalStage { + UpdateCollectionRequest build(); + + _FinalStage name(Optional name); + + _FinalStage name(String name); + + _FinalStage description(Optional description); + + _FinalStage description(String description); + + _FinalStage translatedContent(Optional translatedContent); + + _FinalStage translatedContent(GroupTranslatedContent translatedContent); + + _FinalStage parentId(Optional parentId); + + _FinalStage parentId(String parentId); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements CollectionIdStage, _FinalStage { + private String collectionId; + + private Optional parentId = Optional.empty(); + + private Optional translatedContent = Optional.empty(); + + private Optional description = Optional.empty(); + + private Optional name = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(UpdateCollectionRequest other) { + collectionId(other.getCollectionId()); + name(other.getName()); + description(other.getDescription()); + translatedContent(other.getTranslatedContent()); + parentId(other.getParentId()); + return this; + } + + /** + *

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("collection_id") + public _FinalStage collectionId(@NotNull String collectionId) { + this.collectionId = Objects.requireNonNull(collectionId, "collectionId must not be null"); + return this; + } + + /** + *

The id of the parent collection. If null then it will be updated as the first level collection.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage parentId(String parentId) { + this.parentId = Optional.ofNullable(parentId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "parent_id", nulls = Nulls.SKIP) + public _FinalStage parentId(Optional parentId) { + this.parentId = parentId; + return this; + } + + @java.lang.Override + public _FinalStage translatedContent(GroupTranslatedContent 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 description of the collection. For multilingual collections, this will be the description of the default language's content.

+ * @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; + } + + @java.lang.Override + @JsonSetter(value = "description", nulls = Nulls.SKIP) + public _FinalStage description(Optional description) { + this.description = description; + return this; + } + + /** + *

The name of the collection. For multilingual collections, this will be the name of the default language's content.

+ * @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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public _FinalStage name(Optional name) { + this.name = name; + return this; + } + + @java.lang.Override + public UpdateCollectionRequest build() { + return new UpdateCollectionRequest( + collectionId, name, description, translatedContent, parentId, additionalProperties); + } + } +} 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 new file mode 100644 index 00000000..d6c4a40a --- /dev/null +++ b/src/main/java/com/intercom/api/resources/helpcenters/requests/FindHelpCenterRequest.java @@ -0,0 +1,109 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.helpcenters.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 = FindHelpCenterRequest.Builder.class) +public final class FindHelpCenterRequest { + private final String helpCenterId; + + private final Map additionalProperties; + + private FindHelpCenterRequest(String helpCenterId, Map additionalProperties) { + this.helpCenterId = helpCenterId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the Help Center which is given by Intercom. + */ + @JsonProperty("help_center_id") + public String getHelpCenterId() { + return helpCenterId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof FindHelpCenterRequest && equalTo((FindHelpCenterRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(FindHelpCenterRequest other) { + return helpCenterId.equals(other.helpCenterId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.helpCenterId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static HelpCenterIdStage builder() { + return new Builder(); + } + + public interface HelpCenterIdStage { + _FinalStage helpCenterId(@NotNull String helpCenterId); + + Builder from(FindHelpCenterRequest other); + } + + public interface _FinalStage { + FindHelpCenterRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements HelpCenterIdStage, _FinalStage { + private String helpCenterId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(FindHelpCenterRequest other) { + helpCenterId(other.getHelpCenterId()); + return this; + } + + /** + *

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. + */ + @java.lang.Override + @JsonSetter("help_center_id") + public _FinalStage helpCenterId(@NotNull String helpCenterId) { + this.helpCenterId = Objects.requireNonNull(helpCenterId, "helpCenterId must not be null"); + return this; + } + + @java.lang.Override + public FindHelpCenterRequest build() { + return new FindHelpCenterRequest(helpCenterId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/helpcenters/requests/ListHelpCentersRequest.java b/src/main/java/com/intercom/api/resources/helpcenters/requests/ListHelpCentersRequest.java new file mode 100644 index 00000000..4d694fbb --- /dev/null +++ b/src/main/java/com/intercom/api/resources/helpcenters/requests/ListHelpCentersRequest.java @@ -0,0 +1,124 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.helpcenters.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 = ListHelpCentersRequest.Builder.class) +public final class ListHelpCentersRequest { + private final Optional page; + + private final Optional perPage; + + private final Map additionalProperties; + + private ListHelpCentersRequest( + 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 15 + */ + @JsonProperty("per_page") + public Optional getPerPage() { + return perPage; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListHelpCentersRequest && equalTo((ListHelpCentersRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListHelpCentersRequest 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(ListHelpCentersRequest other) { + page(other.getPage()); + perPage(other.getPerPage()); + return this; + } + + @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; + } + + @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 ListHelpCentersRequest build() { + return new ListHelpCentersRequest(page, perPage, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/messages/AsyncMessagesClient.java b/src/main/java/com/intercom/api/resources/messages/AsyncMessagesClient.java new file mode 100644 index 00000000..ac08b55d --- /dev/null +++ b/src/main/java/com/intercom/api/resources/messages/AsyncMessagesClient.java @@ -0,0 +1,140 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.messages; + +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.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.errors.BadRequestError; +import com.intercom.api.errors.ForbiddenError; +import com.intercom.api.errors.UnauthorizedError; +import com.intercom.api.errors.UnprocessableEntityError; +import com.intercom.api.resources.messages.types.Message; +import com.intercom.api.types.CreateMessageRequest; +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 AsyncMessagesClient { + protected final ClientOptions clientOptions; + + public AsyncMessagesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * 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(CreateMessageRequest request) { + return create(request, null); + } + + /** + * 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(CreateMessageRequest 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); + } 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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Message.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 422: + future.completeExceptionally(new UnprocessableEntityError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + 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))); + 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/messages/MessagesClient.java b/src/main/java/com/intercom/api/resources/messages/MessagesClient.java new file mode 100644 index 00000000..0ec9a2db --- /dev/null +++ b/src/main/java/com/intercom/api/resources/messages/MessagesClient.java @@ -0,0 +1,118 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.messages; + +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.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.errors.BadRequestError; +import com.intercom.api.errors.ForbiddenError; +import com.intercom.api.errors.UnauthorizedError; +import com.intercom.api.errors.UnprocessableEntityError; +import com.intercom.api.resources.messages.types.Message; +import com.intercom.api.types.CreateMessageRequest; +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 MessagesClient { + protected final ClientOptions clientOptions; + + public MessagesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * 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(CreateMessageRequest request) { + return create(request, null); + } + + /** + * 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(CreateMessageRequest 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); + } 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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Message.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 403: + throw new ForbiddenError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 422: + throw new UnprocessableEntityError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP 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 new file mode 100644 index 00000000..d380a92b --- /dev/null +++ b/src/main/java/com/intercom/api/resources/messages/types/Message.java @@ -0,0 +1,404 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.messages.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 = Message.Builder.class) +public final class Message { + private final String type; + + private final String id; + + private final int createdAt; + + private final String subject; + + private final String body; + + private final MessageType messageType; + + private final String conversationId; + + private final Map additionalProperties; + + private Message( + String type, + String id, + int createdAt, + String subject, + String body, + MessageType messageType, + String conversationId, + Map additionalProperties) { + this.type = type; + this.id = id; + this.createdAt = createdAt; + this.subject = subject; + this.body = body; + this.messageType = messageType; + this.conversationId = conversationId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of the message + */ + @JsonProperty("type") + public String getType() { + return type; + } + + /** + * @return The id representing the message. + */ + @JsonProperty("id") + public String getId() { + return id; + } + + /** + * @return The time the conversation was created. + */ + @JsonProperty("created_at") + public int getCreatedAt() { + return createdAt; + } + + /** + * @return The subject of the message. Only present if message_type: email. + */ + @JsonProperty("subject") + public String getSubject() { + return subject; + } + + /** + * @return The message body, which may contain HTML. + */ + @JsonProperty("body") + public String getBody() { + return body; + } + + /** + * @return The type of message that was sent. Can be email, inapp, facebook or twitter. + */ + @JsonProperty("message_type") + public MessageType getMessageType() { + return messageType; + } + + /** + * @return The associated conversation_id + */ + @JsonProperty("conversation_id") + public String getConversationId() { + return conversationId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Message && equalTo((Message) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Message other) { + return type.equals(other.type) + && id.equals(other.id) + && createdAt == other.createdAt + && subject.equals(other.subject) + && body.equals(other.body) + && messageType.equals(other.messageType) + && conversationId.equals(other.conversationId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.type, this.id, this.createdAt, this.subject, this.body, this.messageType, this.conversationId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TypeStage builder() { + return new Builder(); + } + + public interface TypeStage { + IdStage type(@NotNull String type); + + Builder from(Message other); + } + + public interface IdStage { + CreatedAtStage id(@NotNull String id); + } + + public interface CreatedAtStage { + SubjectStage createdAt(int createdAt); + } + + public interface SubjectStage { + BodyStage subject(@NotNull String subject); + } + + public interface BodyStage { + MessageTypeStage body(@NotNull String body); + } + + public interface MessageTypeStage { + ConversationIdStage messageType(@NotNull MessageType messageType); + } + + public interface ConversationIdStage { + _FinalStage conversationId(@NotNull String conversationId); + } + + public interface _FinalStage { + Message build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements TypeStage, + IdStage, + CreatedAtStage, + SubjectStage, + BodyStage, + MessageTypeStage, + ConversationIdStage, + _FinalStage { + private String type; + + private String id; + + private int createdAt; + + private String subject; + + private String body; + + private MessageType messageType; + + private String conversationId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(Message other) { + type(other.getType()); + id(other.getId()); + createdAt(other.getCreatedAt()); + subject(other.getSubject()); + body(other.getBody()); + messageType(other.getMessageType()); + conversationId(other.getConversationId()); + return this; + } + + /** + *

The type of the message

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

The id representing the message.

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

The time the conversation was created.

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

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

The type of message that was sent. Can be email, inapp, facebook or twitter.

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

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"); + return this; + } + + @java.lang.Override + public Message build() { + return new Message(type, id, createdAt, subject, body, messageType, conversationId, additionalProperties); + } + } + + public final class MessageType { + public static final MessageType EMAIL = new MessageType(Value.EMAIL, "email"); + + public static final MessageType FACEBOOK = new MessageType(Value.FACEBOOK, "facebook"); + + public static final MessageType INAPP = new MessageType(Value.INAPP, "inapp"); + + public static final MessageType TWITTER = new MessageType(Value.TWITTER, "twitter"); + + private final Value value; + + private final String string; + + MessageType(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 MessageType && this.string.equals(((MessageType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case EMAIL: + return visitor.visitEmail(); + case FACEBOOK: + return visitor.visitFacebook(); + case INAPP: + return visitor.visitInapp(); + case TWITTER: + return visitor.visitTwitter(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static MessageType valueOf(String value) { + switch (value) { + case "email": + return EMAIL; + case "facebook": + return FACEBOOK; + case "inapp": + return INAPP; + case "twitter": + return TWITTER; + default: + return new MessageType(Value.UNKNOWN, value); + } + } + + public enum Value { + EMAIL, + + INAPP, + + FACEBOOK, + + TWITTER, + + UNKNOWN + } + + public interface Visitor { + T visitEmail(); + + T visitInapp(); + + T visitFacebook(); + + T visitTwitter(); + + T visitUnknown(String unknownType); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/news/AsyncNewsClient.java b/src/main/java/com/intercom/api/resources/news/AsyncNewsClient.java new file mode 100644 index 00000000..97c6a79d --- /dev/null +++ b/src/main/java/com/intercom/api/resources/news/AsyncNewsClient.java @@ -0,0 +1,32 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.news; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.Suppliers; +import com.intercom.api.resources.news.feeds.AsyncFeedsClient; +import com.intercom.api.resources.news.items.AsyncItemsClient; +import java.util.function.Supplier; + +public class AsyncNewsClient { + protected final ClientOptions clientOptions; + + protected final Supplier itemsClient; + + protected final Supplier feedsClient; + + public AsyncNewsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.itemsClient = Suppliers.memoize(() -> new AsyncItemsClient(clientOptions)); + this.feedsClient = Suppliers.memoize(() -> new AsyncFeedsClient(clientOptions)); + } + + public AsyncItemsClient items() { + return this.itemsClient.get(); + } + + public AsyncFeedsClient feeds() { + return this.feedsClient.get(); + } +} diff --git a/src/main/java/com/intercom/api/resources/news/NewsClient.java b/src/main/java/com/intercom/api/resources/news/NewsClient.java new file mode 100644 index 00000000..b3dcd25c --- /dev/null +++ b/src/main/java/com/intercom/api/resources/news/NewsClient.java @@ -0,0 +1,32 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.news; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.Suppliers; +import com.intercom.api.resources.news.feeds.FeedsClient; +import com.intercom.api.resources.news.items.ItemsClient; +import java.util.function.Supplier; + +public class NewsClient { + protected final ClientOptions clientOptions; + + protected final Supplier itemsClient; + + protected final Supplier feedsClient; + + public NewsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.itemsClient = Suppliers.memoize(() -> new ItemsClient(clientOptions)); + this.feedsClient = Suppliers.memoize(() -> new FeedsClient(clientOptions)); + } + + public ItemsClient items() { + return this.itemsClient.get(); + } + + public FeedsClient feeds() { + return this.feedsClient.get(); + } +} 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 new file mode 100644 index 00000000..9c5a9524 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/news/feeds/AsyncFeedsClient.java @@ -0,0 +1,232 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.news.feeds; + +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.ObjectMappers; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.errors.UnauthorizedError; +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.Error; +import com.intercom.api.types.PaginatedNewsItemResponse; +import com.intercom.api.types.PaginatedNewsfeedResponse; +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 AsyncFeedsClient { + protected final ClientOptions clientOptions; + + public AsyncFeedsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can fetch a list of all news items that are live on a given newsfeed + */ + 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( + ListNewsFeedItemsRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("news/newsfeeds") + .addPathSegment(request.getNewsfeedId()) + .addPathSegments("items") + .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(ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedNewsItemResponse.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + 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))); + 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 a list of all newsfeeds + */ + public CompletableFuture list() { + return list(null); + } + + /** + * You can fetch a list of all newsfeeds + */ + public CompletableFuture list(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("news/newsfeeds") + .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(ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedNewsfeedResponse.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + 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))); + 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 newsfeed + */ + public CompletableFuture find(FindNewsFeedRequest request) { + return find(request, null); + } + + /** + * You can fetch the details of a single newsfeed + */ + public CompletableFuture find(FindNewsFeedRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("news/newsfeeds") + .addPathSegment(request.getNewsfeedId()) + .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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Newsfeed.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + 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))); + 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/news/feeds/FeedsClient.java b/src/main/java/com/intercom/api/resources/news/feeds/FeedsClient.java new file mode 100644 index 00000000..da96d873 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/news/feeds/FeedsClient.java @@ -0,0 +1,180 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.news.feeds; + +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.ObjectMappers; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.errors.UnauthorizedError; +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.Error; +import com.intercom.api.types.PaginatedNewsItemResponse; +import com.intercom.api.types.PaginatedNewsfeedResponse; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class FeedsClient { + protected final ClientOptions clientOptions; + + public FeedsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can fetch a list of all news items that are live on a given newsfeed + */ + public PaginatedNewsItemResponse listItems(ListNewsFeedItemsRequest request) { + return listItems(request, null); + } + + /** + * You can fetch a list of all news items that are live on a given newsfeed + */ + public PaginatedNewsItemResponse listItems(ListNewsFeedItemsRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("news/newsfeeds") + .addPathSegment(request.getNewsfeedId()) + .addPathSegments("items") + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedNewsItemResponse.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can fetch a list of all newsfeeds + */ + public PaginatedNewsfeedResponse list() { + return list(null); + } + + /** + * You can fetch a list of all newsfeeds + */ + public PaginatedNewsfeedResponse list(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("news/newsfeeds") + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedNewsfeedResponse.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can fetch the details of a single newsfeed + */ + public Newsfeed find(FindNewsFeedRequest request) { + return find(request, null); + } + + /** + * You can fetch the details of a single newsfeed + */ + public Newsfeed find(FindNewsFeedRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("news/newsfeeds") + .addPathSegment(request.getNewsfeedId()) + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Newsfeed.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/news/feeds/requests/FindNewsFeedRequest.java b/src/main/java/com/intercom/api/resources/news/feeds/requests/FindNewsFeedRequest.java new file mode 100644 index 00000000..74dadb56 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/news/feeds/requests/FindNewsFeedRequest.java @@ -0,0 +1,109 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.news.feeds.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 = FindNewsFeedRequest.Builder.class) +public final class FindNewsFeedRequest { + private final String newsfeedId; + + private final Map additionalProperties; + + private FindNewsFeedRequest(String newsfeedId, Map additionalProperties) { + this.newsfeedId = newsfeedId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the news feed item which is given by Intercom. + */ + @JsonProperty("newsfeed_id") + public String getNewsfeedId() { + return newsfeedId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof FindNewsFeedRequest && equalTo((FindNewsFeedRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(FindNewsFeedRequest other) { + return newsfeedId.equals(other.newsfeedId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.newsfeedId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static NewsfeedIdStage builder() { + return new Builder(); + } + + public interface NewsfeedIdStage { + _FinalStage newsfeedId(@NotNull String newsfeedId); + + Builder from(FindNewsFeedRequest other); + } + + public interface _FinalStage { + FindNewsFeedRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements NewsfeedIdStage, _FinalStage { + private String newsfeedId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(FindNewsFeedRequest other) { + newsfeedId(other.getNewsfeedId()); + return this; + } + + /** + *

The unique identifier for the news feed item which is given by Intercom.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("newsfeed_id") + public _FinalStage newsfeedId(@NotNull String newsfeedId) { + this.newsfeedId = Objects.requireNonNull(newsfeedId, "newsfeedId must not be null"); + return this; + } + + @java.lang.Override + public FindNewsFeedRequest build() { + return new FindNewsFeedRequest(newsfeedId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/news/feeds/requests/ListNewsFeedItemsRequest.java b/src/main/java/com/intercom/api/resources/news/feeds/requests/ListNewsFeedItemsRequest.java new file mode 100644 index 00000000..b48246b0 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/news/feeds/requests/ListNewsFeedItemsRequest.java @@ -0,0 +1,109 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.news.feeds.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 = ListNewsFeedItemsRequest.Builder.class) +public final class ListNewsFeedItemsRequest { + private final String newsfeedId; + + private final Map additionalProperties; + + private ListNewsFeedItemsRequest(String newsfeedId, Map additionalProperties) { + this.newsfeedId = newsfeedId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the news feed item which is given by Intercom. + */ + @JsonProperty("newsfeed_id") + public String getNewsfeedId() { + return newsfeedId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListNewsFeedItemsRequest && equalTo((ListNewsFeedItemsRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListNewsFeedItemsRequest other) { + return newsfeedId.equals(other.newsfeedId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.newsfeedId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static NewsfeedIdStage builder() { + return new Builder(); + } + + public interface NewsfeedIdStage { + _FinalStage newsfeedId(@NotNull String newsfeedId); + + Builder from(ListNewsFeedItemsRequest other); + } + + public interface _FinalStage { + ListNewsFeedItemsRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements NewsfeedIdStage, _FinalStage { + private String newsfeedId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ListNewsFeedItemsRequest other) { + newsfeedId(other.getNewsfeedId()); + return this; + } + + /** + *

The unique identifier for the news feed item which is given by Intercom.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("newsfeed_id") + public _FinalStage newsfeedId(@NotNull String newsfeedId) { + this.newsfeedId = Objects.requireNonNull(newsfeedId, "newsfeedId must not be null"); + return this; + } + + @java.lang.Override + public ListNewsFeedItemsRequest build() { + return new ListNewsFeedItemsRequest(newsfeedId, additionalProperties); + } + } +} 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 new file mode 100644 index 00000000..c0d76e29 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/news/items/AsyncItemsClient.java @@ -0,0 +1,385 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.news.items; + +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.MediaTypes; +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.news.items.requests.DeleteNewsItemRequest; +import com.intercom.api.resources.news.items.requests.FindNewsItemRequest; +import com.intercom.api.resources.news.items.requests.UpdateNewsItemRequest; +import com.intercom.api.resources.news.types.NewsItem; +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 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 AsyncItemsClient { + protected final ClientOptions clientOptions; + + public AsyncItemsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can fetch a list of all news items + */ + public CompletableFuture list() { + return list(null); + } + + /** + * You can fetch a list of all news items + */ + public CompletableFuture list(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("news/news_items") + .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(ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedNewsItemResponse.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + 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))); + 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 news item + */ + public CompletableFuture create(NewsItemRequest request) { + return create(request, null); + } + + /** + * You can create a news item + */ + public CompletableFuture create(NewsItemRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("news/news_items") + .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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), NewsItem.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + 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))); + 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 news item. + */ + public CompletableFuture find(FindNewsItemRequest request) { + return find(request, null); + } + + /** + * You can fetch the details of a single news item. + */ + public CompletableFuture find(FindNewsItemRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("news/news_items") + .addPathSegment(request.getNewsItemId()) + .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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), NewsItem.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + 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))); + 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 update(UpdateNewsItemRequest request) { + return update(request, null); + } + + public CompletableFuture update(UpdateNewsItemRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("news/news_items") + .addPathSegment(request.getNewsItemId()) + .build(); + RequestBody body; + try { + 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", 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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), NewsItem.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + 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))); + 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 news item. + */ + public CompletableFuture delete(DeleteNewsItemRequest request) { + return delete(request, null); + } + + /** + * You can delete a single news item. + */ + public CompletableFuture delete(DeleteNewsItemRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("news/news_items") + .addPathSegment(request.getNewsItemId()) + .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( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeletedObject.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + 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))); + 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/news/items/ItemsClient.java b/src/main/java/com/intercom/api/resources/news/items/ItemsClient.java new file mode 100644 index 00000000..0ccdbaac --- /dev/null +++ b/src/main/java/com/intercom/api/resources/news/items/ItemsClient.java @@ -0,0 +1,301 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.news.items; + +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.MediaTypes; +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.news.items.requests.DeleteNewsItemRequest; +import com.intercom.api.resources.news.items.requests.FindNewsItemRequest; +import com.intercom.api.resources.news.items.requests.UpdateNewsItemRequest; +import com.intercom.api.resources.news.types.NewsItem; +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 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 ItemsClient { + protected final ClientOptions clientOptions; + + public ItemsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can fetch a list of all news items + */ + public PaginatedNewsItemResponse list() { + return list(null); + } + + /** + * You can fetch a list of all news items + */ + public PaginatedNewsItemResponse list(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("news/news_items") + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedNewsItemResponse.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can create a news item + */ + public NewsItem create(NewsItemRequest request) { + return create(request, null); + } + + /** + * You can create a news item + */ + public NewsItem create(NewsItemRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("news/news_items") + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), NewsItem.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can fetch the details of a single news item. + */ + public NewsItem find(FindNewsItemRequest request) { + return find(request, null); + } + + /** + * You can fetch the details of a single news item. + */ + public NewsItem find(FindNewsItemRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("news/news_items") + .addPathSegment(request.getNewsItemId()) + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), NewsItem.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + public NewsItem update(UpdateNewsItemRequest request) { + return update(request, null); + } + + public NewsItem update(UpdateNewsItemRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("news/news_items") + .addPathSegment(request.getNewsItemId()) + .build(); + RequestBody body; + try { + 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", 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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), NewsItem.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can delete a single news item. + */ + public DeletedObject delete(DeleteNewsItemRequest request) { + return delete(request, null); + } + + /** + * You can delete a single news item. + */ + public DeletedObject delete(DeleteNewsItemRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("news/news_items") + .addPathSegment(request.getNewsItemId()) + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeletedObject.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} 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 new file mode 100644 index 00000000..d72eb7c9 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/news/items/requests/DeleteNewsItemRequest.java @@ -0,0 +1,109 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.news.items.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 = DeleteNewsItemRequest.Builder.class) +public final class DeleteNewsItemRequest { + private final String newsItemId; + + private final Map additionalProperties; + + private DeleteNewsItemRequest(String newsItemId, Map additionalProperties) { + this.newsItemId = newsItemId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the news item which is given by Intercom. + */ + @JsonProperty("news_item_id") + public String getNewsItemId() { + return newsItemId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeleteNewsItemRequest && equalTo((DeleteNewsItemRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeleteNewsItemRequest other) { + return newsItemId.equals(other.newsItemId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.newsItemId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static NewsItemIdStage builder() { + return new Builder(); + } + + public interface NewsItemIdStage { + _FinalStage newsItemId(@NotNull String newsItemId); + + Builder from(DeleteNewsItemRequest other); + } + + public interface _FinalStage { + DeleteNewsItemRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements NewsItemIdStage, _FinalStage { + private String newsItemId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DeleteNewsItemRequest other) { + newsItemId(other.getNewsItemId()); + return this; + } + + /** + *

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. + */ + @java.lang.Override + @JsonSetter("news_item_id") + public _FinalStage newsItemId(@NotNull String newsItemId) { + this.newsItemId = Objects.requireNonNull(newsItemId, "newsItemId must not be null"); + return this; + } + + @java.lang.Override + public DeleteNewsItemRequest build() { + return new DeleteNewsItemRequest(newsItemId, additionalProperties); + } + } +} 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 new file mode 100644 index 00000000..db2422ea --- /dev/null +++ b/src/main/java/com/intercom/api/resources/news/items/requests/FindNewsItemRequest.java @@ -0,0 +1,109 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.news.items.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 = FindNewsItemRequest.Builder.class) +public final class FindNewsItemRequest { + private final String newsItemId; + + private final Map additionalProperties; + + private FindNewsItemRequest(String newsItemId, Map additionalProperties) { + this.newsItemId = newsItemId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the news item which is given by Intercom. + */ + @JsonProperty("news_item_id") + public String getNewsItemId() { + return newsItemId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof FindNewsItemRequest && equalTo((FindNewsItemRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(FindNewsItemRequest other) { + return newsItemId.equals(other.newsItemId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.newsItemId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static NewsItemIdStage builder() { + return new Builder(); + } + + public interface NewsItemIdStage { + _FinalStage newsItemId(@NotNull String newsItemId); + + Builder from(FindNewsItemRequest other); + } + + public interface _FinalStage { + FindNewsItemRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements NewsItemIdStage, _FinalStage { + private String newsItemId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(FindNewsItemRequest other) { + newsItemId(other.getNewsItemId()); + return this; + } + + /** + *

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. + */ + @java.lang.Override + @JsonSetter("news_item_id") + public _FinalStage newsItemId(@NotNull String newsItemId) { + this.newsItemId = Objects.requireNonNull(newsItemId, "newsItemId must not be null"); + return this; + } + + @java.lang.Override + public FindNewsItemRequest build() { + return new FindNewsItemRequest(newsItemId, additionalProperties); + } + } +} 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 new file mode 100644 index 00000000..266f995d --- /dev/null +++ b/src/main/java/com/intercom/api/resources/news/items/requests/UpdateNewsItemRequest.java @@ -0,0 +1,132 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.news.items.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.NewsItemRequest; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = UpdateNewsItemRequest.Builder.class) +public final class UpdateNewsItemRequest { + private final String newsItemId; + + private final NewsItemRequest body; + + private final Map additionalProperties; + + private UpdateNewsItemRequest(String newsItemId, NewsItemRequest body, Map additionalProperties) { + this.newsItemId = newsItemId; + this.body = body; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the news item which is given by Intercom. + */ + @JsonProperty("news_item_id") + public String getNewsItemId() { + return newsItemId; + } + + @JsonProperty("body") + public NewsItemRequest getBody() { + return body; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UpdateNewsItemRequest && equalTo((UpdateNewsItemRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UpdateNewsItemRequest other) { + return newsItemId.equals(other.newsItemId) && body.equals(other.body); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.newsItemId, this.body); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static NewsItemIdStage builder() { + return new Builder(); + } + + public interface NewsItemIdStage { + BodyStage newsItemId(@NotNull String newsItemId); + + Builder from(UpdateNewsItemRequest other); + } + + public interface BodyStage { + _FinalStage body(@NotNull NewsItemRequest body); + } + + public interface _FinalStage { + UpdateNewsItemRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements NewsItemIdStage, BodyStage, _FinalStage { + private String newsItemId; + + private NewsItemRequest body; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(UpdateNewsItemRequest other) { + newsItemId(other.getNewsItemId()); + body(other.getBody()); + return this; + } + + /** + *

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. + */ + @java.lang.Override + @JsonSetter("news_item_id") + public BodyStage newsItemId(@NotNull String newsItemId) { + this.newsItemId = Objects.requireNonNull(newsItemId, "newsItemId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("body") + public _FinalStage body(@NotNull NewsItemRequest body) { + this.body = Objects.requireNonNull(body, "body must not be null"); + return this; + } + + @java.lang.Override + public UpdateNewsItemRequest build() { + return new UpdateNewsItemRequest(newsItemId, body, additionalProperties); + } + } +} 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 new file mode 100644 index 00000000..b8d1457d --- /dev/null +++ b/src/main/java/com/intercom/api/resources/news/types/NewsItem.java @@ -0,0 +1,642 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.news.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.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 = NewsItem.Builder.class) +public final class NewsItem { + private final String id; + + private final String workspaceId; + + private final String title; + + private final String body; + + private final int senderId; + + private final State state; + + private final Optional> newsfeedAssignments; + + private final Optional>> labels; + + private final Optional coverImageUrl; + + private final Optional>> reactions; + + private final Optional deliverSilently; + + private final int createdAt; + + private final Optional updatedAt; + + private final Map additionalProperties; + + private NewsItem( + String id, + String workspaceId, + String title, + String body, + int senderId, + State state, + Optional> newsfeedAssignments, + Optional>> labels, + Optional coverImageUrl, + Optional>> reactions, + Optional deliverSilently, + int createdAt, + Optional updatedAt, + Map additionalProperties) { + this.id = id; + this.workspaceId = workspaceId; + this.title = title; + this.body = body; + this.senderId = senderId; + this.state = state; + this.newsfeedAssignments = newsfeedAssignments; + this.labels = labels; + this.coverImageUrl = coverImageUrl; + this.reactions = reactions; + this.deliverSilently = deliverSilently; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + 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() { + return id; + } + + /** + * @return The id of the workspace which the news item belongs to. + */ + @JsonProperty("workspace_id") + public String getWorkspaceId() { + return workspaceId; + } + + /** + * @return The title of the news item. + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * @return The news item body, which may contain HTML. + */ + @JsonProperty("body") + public String getBody() { + return body; + } + + /** + * @return The id of the sender of the news item. Must be a teammate on the workspace. + */ + @JsonProperty("sender_id") + public int getSenderId() { + return senderId; + } + + /** + * @return News items will not be visible to your users in the assigned newsfeeds until they are set live. + */ + @JsonProperty("state") + public State getState() { + return state; + } + + /** + * @return A list of newsfeed_assignments to assign to the specified newsfeed. + */ + @JsonProperty("newsfeed_assignments") + public Optional> getNewsfeedAssignments() { + return newsfeedAssignments; + } + + /** + * @return Label names displayed to users to categorize the news item. + */ + @JsonProperty("labels") + public Optional>> getLabels() { + return labels; + } + + /** + * @return URL of the image used as cover. Must have .jpg or .png extension. + */ + @JsonProperty("cover_image_url") + public Optional getCoverImageUrl() { + return coverImageUrl; + } + + /** + * @return Ordered list of emoji reactions to the news item. When empty, reactions are disabled. + */ + @JsonProperty("reactions") + public Optional>> getReactions() { + return reactions; + } + + /** + * @return When set to true, the news item will appear in the messenger newsfeed without showing a notification badge. + */ + @JsonProperty("deliver_silently") + public Optional getDeliverSilently() { + return deliverSilently; + } + + /** + * @return Timestamp for when the news item was created. + */ + @JsonProperty("created_at") + public int getCreatedAt() { + return createdAt; + } + + /** + * @return Timestamp for when the news item was last updated. + */ + @JsonProperty("updated_at") + public Optional getUpdatedAt() { + return updatedAt; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof NewsItem && equalTo((NewsItem) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(NewsItem other) { + return id.equals(other.id) + && workspaceId.equals(other.workspaceId) + && title.equals(other.title) + && body.equals(other.body) + && senderId == 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 + && updatedAt.equals(other.updatedAt); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.id, + this.workspaceId, + this.title, + this.body, + this.senderId, + this.state, + this.newsfeedAssignments, + this.labels, + this.coverImageUrl, + this.reactions, + this.deliverSilently, + this.createdAt, + this.updatedAt); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + WorkspaceIdStage id(@NotNull String id); + + Builder from(NewsItem other); + } + + public interface WorkspaceIdStage { + TitleStage workspaceId(@NotNull String workspaceId); + } + + public interface TitleStage { + BodyStage title(@NotNull String title); + } + + public interface BodyStage { + SenderIdStage body(@NotNull String body); + } + + public interface SenderIdStage { + StateStage senderId(int senderId); + } + + public interface StateStage { + CreatedAtStage state(@NotNull State state); + } + + public interface CreatedAtStage { + _FinalStage createdAt(int createdAt); + } + + public interface _FinalStage { + NewsItem build(); + + _FinalStage newsfeedAssignments(Optional> newsfeedAssignments); + + _FinalStage newsfeedAssignments(List newsfeedAssignments); + + _FinalStage labels(Optional>> labels); + + _FinalStage labels(List> labels); + + _FinalStage coverImageUrl(Optional coverImageUrl); + + _FinalStage coverImageUrl(String coverImageUrl); + + _FinalStage reactions(Optional>> reactions); + + _FinalStage reactions(List> reactions); + + _FinalStage deliverSilently(Optional deliverSilently); + + _FinalStage deliverSilently(Boolean deliverSilently); + + _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; + + private String workspaceId; + + private String title; + + private String body; + + private int senderId; + + private State state; + + private int createdAt; + + private Optional updatedAt = Optional.empty(); + + private Optional deliverSilently = Optional.empty(); + + private Optional>> reactions = Optional.empty(); + + private Optional coverImageUrl = Optional.empty(); + + private Optional>> labels = Optional.empty(); + + private Optional> newsfeedAssignments = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(NewsItem other) { + id(other.getId()); + workspaceId(other.getWorkspaceId()); + title(other.getTitle()); + body(other.getBody()); + senderId(other.getSenderId()); + state(other.getState()); + newsfeedAssignments(other.getNewsfeedAssignments()); + labels(other.getLabels()); + coverImageUrl(other.getCoverImageUrl()); + reactions(other.getReactions()); + deliverSilently(other.getDeliverSilently()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + return this; + } + + /** + *

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. + */ + @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 news item belongs to.

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

The title of the news item.

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

The news item body, which may contain HTML.

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

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. + */ + @java.lang.Override + @JsonSetter("sender_id") + public StateStage senderId(int senderId) { + this.senderId = senderId; + return this; + } + + /** + *

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"); + return this; + } + + /** + *

Timestamp for when the news item was created.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("created_at") + public _FinalStage createdAt(int createdAt) { + this.createdAt = createdAt; + 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) + public _FinalStage updatedAt(Optional updatedAt) { + this.updatedAt = updatedAt; + 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "deliver_silently", nulls = Nulls.SKIP) + public _FinalStage deliverSilently(Optional deliverSilently) { + this.deliverSilently = deliverSilently; + 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. + */ + @java.lang.Override + public _FinalStage reactions(List> reactions) { + this.reactions = Optional.ofNullable(reactions); + return this; + } + + @java.lang.Override + @JsonSetter(value = "reactions", nulls = Nulls.SKIP) + public _FinalStage 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "cover_image_url", nulls = Nulls.SKIP) + public _FinalStage coverImageUrl(Optional coverImageUrl) { + this.coverImageUrl = coverImageUrl; + 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "labels", nulls = Nulls.SKIP) + public _FinalStage labels(Optional>> labels) { + this.labels = labels; + 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "newsfeed_assignments", nulls = Nulls.SKIP) + public _FinalStage newsfeedAssignments(Optional> newsfeedAssignments) { + this.newsfeedAssignments = newsfeedAssignments; + return this; + } + + @java.lang.Override + public NewsItem build() { + return new NewsItem( + id, + workspaceId, + title, + body, + senderId, + state, + newsfeedAssignments, + labels, + coverImageUrl, + reactions, + deliverSilently, + createdAt, + updatedAt, + additionalProperties); + } + } + + public final class State { + public static final State LIVE = new State(Value.LIVE, "live"); + + public static final State DRAFT = new State(Value.DRAFT, "draft"); + + 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 LIVE: + return visitor.visitLive(); + case DRAFT: + return visitor.visitDraft(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static State valueOf(String value) { + switch (value) { + case "live": + return LIVE; + case "draft": + return DRAFT; + default: + return new State(Value.UNKNOWN, value); + } + } + + public enum Value { + DRAFT, + + LIVE, + + UNKNOWN + } + + public interface Visitor { + T visitDraft(); + + T visitLive(); + + T visitUnknown(String unknownType); + } + } +} 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 new file mode 100644 index 00000000..647865c4 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/news/types/Newsfeed.java @@ -0,0 +1,220 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.news.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 = Newsfeed.Builder.class) +public final class Newsfeed { + private final String id; + + private final String name; + + private final int createdAt; + + private final Optional updatedAt; + + private final Map additionalProperties; + + private Newsfeed( + String id, + String name, + int createdAt, + Optional updatedAt, + Map additionalProperties) { + this.id = id; + this.name = name; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the newsfeed which is given by Intercom. + */ + @JsonProperty("id") + public String 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() { + return name; + } + + /** + * @return Timestamp for when the newsfeed was created. + */ + @JsonProperty("created_at") + public int getCreatedAt() { + return createdAt; + } + + /** + * @return Timestamp for when the newsfeed was last updated. + */ + @JsonProperty("updated_at") + public Optional getUpdatedAt() { + return updatedAt; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Newsfeed && equalTo((Newsfeed) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Newsfeed other) { + return id.equals(other.id) + && name.equals(other.name) + && createdAt == other.createdAt + && updatedAt.equals(other.updatedAt); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id, this.name, this.createdAt, this.updatedAt); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + NameStage id(@NotNull String id); + + Builder from(Newsfeed other); + } + + public interface NameStage { + CreatedAtStage name(@NotNull String name); + } + + public interface CreatedAtStage { + _FinalStage createdAt(int createdAt); + } + + public interface _FinalStage { + Newsfeed build(); + + _FinalStage updatedAt(Optional updatedAt); + + _FinalStage updatedAt(Integer updatedAt); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, NameStage, CreatedAtStage, _FinalStage { + private String id; + + private String name; + + private int createdAt; + + private Optional updatedAt = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(Newsfeed other) { + id(other.getId()); + name(other.getName()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + return this; + } + + /** + *

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

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

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. + */ + @java.lang.Override + @JsonSetter("name") + public CreatedAtStage name(@NotNull String name) { + this.name = Objects.requireNonNull(name, "name must not be null"); + return this; + } + + /** + *

Timestamp for when the newsfeed was created.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("created_at") + public _FinalStage createdAt(int 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) + public _FinalStage updatedAt(Optional updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + @java.lang.Override + 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 new file mode 100644 index 00000000..1a303952 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/news/types/NewsfeedAssignment.java @@ -0,0 +1,137 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.news.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.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 = NewsfeedAssignment.Builder.class) +public final class NewsfeedAssignment { + private final int newsfeedId; + + private final int publishedAt; + + private final Map additionalProperties; + + private NewsfeedAssignment(int newsfeedId, int publishedAt, Map additionalProperties) { + this.newsfeedId = newsfeedId; + this.publishedAt = publishedAt; + this.additionalProperties = additionalProperties; + } + + /** + * @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() { + return newsfeedId; + } + + /** + * @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() { + return publishedAt; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof NewsfeedAssignment && equalTo((NewsfeedAssignment) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(NewsfeedAssignment other) { + return newsfeedId == other.newsfeedId && publishedAt == other.publishedAt; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.newsfeedId, this.publishedAt); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static NewsfeedIdStage builder() { + return new Builder(); + } + + public interface NewsfeedIdStage { + PublishedAtStage newsfeedId(int newsfeedId); + + Builder from(NewsfeedAssignment other); + } + + public interface PublishedAtStage { + _FinalStage publishedAt(int publishedAt); + } + + public interface _FinalStage { + NewsfeedAssignment build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements NewsfeedIdStage, PublishedAtStage, _FinalStage { + private int newsfeedId; + + private int publishedAt; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(NewsfeedAssignment other) { + newsfeedId(other.getNewsfeedId()); + publishedAt(other.getPublishedAt()); + return this; + } + + /** + *

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. + */ + @java.lang.Override + @JsonSetter("newsfeed_id") + public PublishedAtStage newsfeedId(int newsfeedId) { + this.newsfeedId = 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".

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("published_at") + public _FinalStage publishedAt(int publishedAt) { + this.publishedAt = publishedAt; + return this; + } + + @java.lang.Override + public NewsfeedAssignment build() { + return new NewsfeedAssignment(newsfeedId, publishedAt, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/notes/AsyncNotesClient.java b/src/main/java/com/intercom/api/resources/notes/AsyncNotesClient.java new file mode 100644 index 00000000..46f3b098 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/notes/AsyncNotesClient.java @@ -0,0 +1,273 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.notes; + +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.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.QueryStringMapper; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.core.pagination.SyncPagingIterable; +import com.intercom.api.errors.NotFoundError; +import com.intercom.api.errors.UnauthorizedError; +import com.intercom.api.resources.notes.requests.CreateContactNoteRequest; +import com.intercom.api.resources.notes.requests.FindNoteRequest; +import com.intercom.api.resources.notes.requests.ListContactNotesRequest; +import com.intercom.api.resources.notes.types.Note; +import com.intercom.api.types.Error; +import com.intercom.api.types.NoteList; +import java.io.IOException; +import java.util.List; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; +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 AsyncNotesClient { + protected final ClientOptions clientOptions; + + public AsyncNotesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can fetch a list of notes that are associated to a contact. + */ + public CompletableFuture> list(ListContactNotesRequest request) { + return list(request, null); + } + + /** + * You can fetch a list of notes that are associated to a contact. + */ + public CompletableFuture> list( + ListContactNotesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getContactId()) + .addPathSegments("notes"); + 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()) { + NoteList parsedResponse = + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), NoteList.class); + int newPageNumber = + request.getPage().map(page -> page + 1).orElse(1); + ListContactNotesRequest nextRequest = ListContactNotesRequest.builder() + .from(request) + .page(newPageNumber) + .build(); + List result = parsedResponse.getData(); + future.complete(new SyncPagingIterable(true, result, () -> { + try { + return list(nextRequest, requestOptions).get(); + } catch (InterruptedException | ExecutionException e) { + throw new RuntimeException(e); + } + })); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 404) { + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + 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))); + 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 a note to a single contact. + */ + public CompletableFuture create(CreateContactNoteRequest request) { + return create(request, null); + } + + /** + * You can add a note to a single contact. + */ + public CompletableFuture create(CreateContactNoteRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getContactId()) + .addPathSegments("notes") + .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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Note.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 404) { + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + 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))); + 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 note. + */ + public CompletableFuture find(FindNoteRequest request) { + return find(request, null); + } + + /** + * You can fetch the details of a single note. + */ + public CompletableFuture find(FindNoteRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("notes") + .addPathSegment(request.getNoteId()) + .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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Note.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + 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))); + 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/notes/NotesClient.java b/src/main/java/com/intercom/api/resources/notes/NotesClient.java new file mode 100644 index 00000000..ab8a8dee --- /dev/null +++ b/src/main/java/com/intercom/api/resources/notes/NotesClient.java @@ -0,0 +1,213 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.notes; + +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.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.QueryStringMapper; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.core.pagination.SyncPagingIterable; +import com.intercom.api.errors.NotFoundError; +import com.intercom.api.errors.UnauthorizedError; +import com.intercom.api.resources.notes.requests.CreateContactNoteRequest; +import com.intercom.api.resources.notes.requests.FindNoteRequest; +import com.intercom.api.resources.notes.requests.ListContactNotesRequest; +import com.intercom.api.resources.notes.types.Note; +import com.intercom.api.types.Error; +import com.intercom.api.types.NoteList; +import java.io.IOException; +import java.util.List; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class NotesClient { + protected final ClientOptions clientOptions; + + public NotesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can fetch a list of notes that are associated to a contact. + */ + public SyncPagingIterable list(ListContactNotesRequest request) { + return list(request, null); + } + + /** + * You can fetch a list of notes that are associated to a contact. + */ + public SyncPagingIterable list(ListContactNotesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getContactId()) + .addPathSegments("notes"); + 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()) { + NoteList parsedResponse = ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), NoteList.class); + int newPageNumber = request.getPage().map(page -> page + 1).orElse(1); + ListContactNotesRequest nextRequest = ListContactNotesRequest.builder() + .from(request) + .page(newPageNumber) + .build(); + List result = parsedResponse.getData(); + return new SyncPagingIterable(true, result, () -> list(nextRequest, requestOptions)); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 404) { + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can add a note to a single contact. + */ + public Note create(CreateContactNoteRequest request) { + return create(request, null); + } + + /** + * You can add a note to a single contact. + */ + public Note create(CreateContactNoteRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getContactId()) + .addPathSegments("notes") + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Note.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 404) { + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can fetch the details of a single note. + */ + public Note find(FindNoteRequest request) { + return find(request, null); + } + + /** + * You can fetch the details of a single note. + */ + public Note find(FindNoteRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("notes") + .addPathSegment(request.getNoteId()) + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Note.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/notes/requests/CreateContactNoteRequest.java b/src/main/java/com/intercom/api/resources/notes/requests/CreateContactNoteRequest.java new file mode 100644 index 00000000..3805aa93 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/notes/requests/CreateContactNoteRequest.java @@ -0,0 +1,176 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.notes.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 = CreateContactNoteRequest.Builder.class) +public final class CreateContactNoteRequest { + private final String contactId; + + private final String body; + + private final Optional adminId; + + private final Map additionalProperties; + + private CreateContactNoteRequest( + String contactId, String body, Optional adminId, Map additionalProperties) { + this.contactId = contactId; + this.body = body; + this.adminId = adminId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier of a given contact. + */ + @JsonProperty("contact_id") + public String getContactId() { + return contactId; + } + + /** + * @return The text of the note. + */ + @JsonProperty("body") + public String getBody() { + return body; + } + + /** + * @return The unique identifier of a given admin. + */ + @JsonProperty("admin_id") + public Optional getAdminId() { + return adminId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreateContactNoteRequest && equalTo((CreateContactNoteRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreateContactNoteRequest other) { + return contactId.equals(other.contactId) && body.equals(other.body) && adminId.equals(other.adminId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.contactId, this.body, this.adminId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ContactIdStage builder() { + return new Builder(); + } + + public interface ContactIdStage { + BodyStage contactId(@NotNull String contactId); + + Builder from(CreateContactNoteRequest other); + } + + public interface BodyStage { + _FinalStage body(@NotNull String body); + } + + public interface _FinalStage { + CreateContactNoteRequest build(); + + _FinalStage adminId(Optional adminId); + + _FinalStage adminId(String adminId); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ContactIdStage, BodyStage, _FinalStage { + private String contactId; + + private String body; + + private Optional adminId = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CreateContactNoteRequest other) { + contactId(other.getContactId()); + body(other.getBody()); + adminId(other.getAdminId()); + return this; + } + + /** + *

The unique identifier of a given contact.

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

The text of the note.

+ * @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; + } + + /** + *

The unique identifier of a given admin.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage adminId(String adminId) { + this.adminId = Optional.ofNullable(adminId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "admin_id", nulls = Nulls.SKIP) + public _FinalStage adminId(Optional adminId) { + this.adminId = adminId; + return this; + } + + @java.lang.Override + public CreateContactNoteRequest build() { + return new CreateContactNoteRequest(contactId, body, adminId, additionalProperties); + } + } +} 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 new file mode 100644 index 00000000..1388e1af --- /dev/null +++ b/src/main/java/com/intercom/api/resources/notes/requests/FindNoteRequest.java @@ -0,0 +1,109 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.notes.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 = FindNoteRequest.Builder.class) +public final class FindNoteRequest { + private final String noteId; + + private final Map additionalProperties; + + private FindNoteRequest(String noteId, Map additionalProperties) { + this.noteId = noteId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier of a given note + */ + @JsonProperty("note_id") + public String getNoteId() { + return noteId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof FindNoteRequest && equalTo((FindNoteRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(FindNoteRequest other) { + return noteId.equals(other.noteId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.noteId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static NoteIdStage builder() { + return new Builder(); + } + + public interface NoteIdStage { + _FinalStage noteId(@NotNull String noteId); + + Builder from(FindNoteRequest other); + } + + public interface _FinalStage { + FindNoteRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements NoteIdStage, _FinalStage { + private String noteId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(FindNoteRequest other) { + noteId(other.getNoteId()); + return this; + } + + /** + *

The unique identifier of a given note

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("note_id") + public _FinalStage noteId(@NotNull String noteId) { + this.noteId = Objects.requireNonNull(noteId, "noteId must not be null"); + return this; + } + + @java.lang.Override + public FindNoteRequest build() { + return new FindNoteRequest(noteId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/notes/requests/ListContactNotesRequest.java b/src/main/java/com/intercom/api/resources/notes/requests/ListContactNotesRequest.java new file mode 100644 index 00000000..d38cde13 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/notes/requests/ListContactNotesRequest.java @@ -0,0 +1,185 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.notes.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 = ListContactNotesRequest.Builder.class) +public final class ListContactNotesRequest { + private final String contactId; + + private final Optional page; + + private final Optional perPage; + + private final Map additionalProperties; + + private ListContactNotesRequest( + String contactId, + Optional page, + Optional perPage, + Map additionalProperties) { + this.contactId = contactId; + this.page = page; + this.perPage = perPage; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier of a contact. + */ + @JsonProperty("contact_id") + public String getContactId() { + return contactId; + } + + /** + * @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 15 + */ + @JsonProperty("per_page") + public Optional getPerPage() { + return perPage; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListContactNotesRequest && equalTo((ListContactNotesRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListContactNotesRequest other) { + return contactId.equals(other.contactId) && page.equals(other.page) && perPage.equals(other.perPage); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.contactId, this.page, this.perPage); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ContactIdStage builder() { + return new Builder(); + } + + public interface ContactIdStage { + _FinalStage contactId(@NotNull String contactId); + + Builder from(ListContactNotesRequest other); + } + + public interface _FinalStage { + ListContactNotesRequest build(); + + _FinalStage page(Optional page); + + _FinalStage page(Integer page); + + _FinalStage perPage(Optional perPage); + + _FinalStage perPage(Integer perPage); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ContactIdStage, _FinalStage { + private String contactId; + + private Optional perPage = Optional.empty(); + + private Optional page = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ListContactNotesRequest other) { + contactId(other.getContactId()); + page(other.getPage()); + perPage(other.getPerPage()); + return this; + } + + /** + *

The unique identifier of a contact.

+ * @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; + } + + /** + *

How many results to display 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; + } + + @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; + } + + @java.lang.Override + @JsonSetter(value = "page", nulls = Nulls.SKIP) + public _FinalStage page(Optional page) { + this.page = page; + return this; + } + + @java.lang.Override + public ListContactNotesRequest build() { + return new ListContactNotesRequest(contactId, page, perPage, additionalProperties); + } + } +} 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 new file mode 100644 index 00000000..5cdb7d87 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/notes/types/Note.java @@ -0,0 +1,357 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.notes.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.resources.admins.types.Admin; +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 = Note.Builder.class) +public final class Note { + private final String id; + + private final int createdAt; + + private final Optional contact; + + private final Admin author; + + private final String body; + + private final Map additionalProperties; + + private Note( + String id, + int createdAt, + Optional contact, + Admin author, + String body, + Map additionalProperties) { + this.id = id; + this.createdAt = createdAt; + this.contact = contact; + this.author = author; + this.body = body; + this.additionalProperties = additionalProperties; + } + + /** + * @return String representing the object's type. Always has the value note. + */ + @JsonProperty("type") + public String getType() { + return "note"; + } + + /** + * @return The id of the note. + */ + @JsonProperty("id") + public String getId() { + return id; + } + + /** + * @return The time the note was created. + */ + @JsonProperty("created_at") + public int getCreatedAt() { + return createdAt; + } + + /** + * @return Represents the contact that the note was created about. + */ + @JsonProperty("contact") + public Optional getContact() { + return contact; + } + + /** + * @return Optional. Represents the Admin that created the note. + */ + @JsonProperty("author") + public Admin getAuthor() { + return author; + } + + /** + * @return The body text of the note. + */ + @JsonProperty("body") + public String getBody() { + return body; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Note && equalTo((Note) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Note other) { + return id.equals(other.id) + && createdAt == other.createdAt + && contact.equals(other.contact) + && author.equals(other.author) + && body.equals(other.body); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id, this.createdAt, this.contact, this.author, this.body); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + CreatedAtStage id(@NotNull String id); + + Builder from(Note other); + } + + public interface CreatedAtStage { + AuthorStage createdAt(int createdAt); + } + + public interface AuthorStage { + BodyStage author(@NotNull Admin author); + } + + public interface BodyStage { + _FinalStage body(@NotNull String body); + } + + public interface _FinalStage { + Note build(); + + _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; + + private Admin author; + + private String body; + + private Optional contact = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(Note other) { + id(other.getId()); + createdAt(other.getCreatedAt()); + contact(other.getContact()); + author(other.getAuthor()); + body(other.getBody()); + return this; + } + + /** + *

The id of the note.

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

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; + return this; + } + + /** + *

Optional. Represents the Admin that created the note.

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

The body text of the note.

+ * @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; + } + + /** + *

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) { + this.contact = Optional.ofNullable(contact); + return this; + } + + @java.lang.Override + @JsonSetter(value = "contact", nulls = Nulls.SKIP) + public _FinalStage contact(Optional contact) { + this.contact = contact; + return this; + } + + @java.lang.Override + public Note build() { + return new Note(id, createdAt, contact, author, body, additionalProperties); + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = Contact.Builder.class) + public static final class Contact { + private final Optional type; + + private final Optional id; + + private final Map additionalProperties; + + private Contact(Optional type, Optional id, Map additionalProperties) { + this.type = type; + this.id = id; + this.additionalProperties = additionalProperties; + } + + /** + * @return String representing the object's type. Always has the value contact. + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return The id of the contact. + */ + @JsonProperty("id") + public Optional getId() { + return id; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Contact && equalTo((Contact) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Contact other) { + return type.equals(other.type) && id.equals(other.id); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.id); + } + + @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(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(Contact other) { + type(other.getType()); + id(other.getId()); + 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 = "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; + } + + public Contact build() { + return new Contact(type, id, 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 new file mode 100644 index 00000000..fd1c8603 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/phonecallredirects/AsyncPhoneCallRedirectsClient.java @@ -0,0 +1,122 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.phonecallredirects; + +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.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.RequestOptions; +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.Error; +import com.intercom.api.types.PhoneSwitch; +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 AsyncPhoneCallRedirectsClient { + protected final ClientOptions clientOptions; + + public AsyncPhoneCallRedirectsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * 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(CreatePhoneCallRedirectRequest request) { + return create(request, null); + } + + /** + * 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( + CreatePhoneCallRedirectRequest 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); + } 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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PhoneSwitch.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 422: + future.completeExceptionally(new UnprocessableEntityError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + 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))); + 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/phonecallredirects/PhoneCallRedirectsClient.java b/src/main/java/com/intercom/api/resources/phonecallredirects/PhoneCallRedirectsClient.java new file mode 100644 index 00000000..2727a231 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/phonecallredirects/PhoneCallRedirectsClient.java @@ -0,0 +1,101 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.phonecallredirects; + +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.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.RequestOptions; +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.Error; +import com.intercom.api.types.PhoneSwitch; +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 PhoneCallRedirectsClient { + protected final ClientOptions clientOptions; + + public PhoneCallRedirectsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * 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 PhoneSwitch create(CreatePhoneCallRedirectRequest request) { + return create(request, null); + } + + /** + * 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 PhoneSwitch create(CreatePhoneCallRedirectRequest 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); + } 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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PhoneSwitch.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 422: + throw new UnprocessableEntityError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} 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 new file mode 100644 index 00000000..8b4d26b9 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/phonecallredirects/requests/CreatePhoneCallRedirectRequest.java @@ -0,0 +1,140 @@ +/** + * 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 { + _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.

+ * @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/AsyncSegmentsClient.java b/src/main/java/com/intercom/api/resources/segments/AsyncSegmentsClient.java new file mode 100644 index 00000000..15cc464d --- /dev/null +++ b/src/main/java/com/intercom/api/resources/segments/AsyncSegmentsClient.java @@ -0,0 +1,180 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.segments; + +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.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.segments.requests.FindSegmentRequest; +import com.intercom.api.resources.segments.requests.ListSegmentsRequest; +import com.intercom.api.resources.segments.types.Segment; +import com.intercom.api.types.Error; +import com.intercom.api.types.SegmentList; +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 AsyncSegmentsClient { + protected final ClientOptions clientOptions; + + public AsyncSegmentsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can fetch a list of all segments. + */ + public CompletableFuture list() { + return list(ListSegmentsRequest.builder().build()); + } + + /** + * You can fetch a list of all segments. + */ + public CompletableFuture list(ListSegmentsRequest request) { + return list(request, null); + } + + /** + * You can fetch a list of all segments. + */ + public CompletableFuture list(ListSegmentsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("segments"); + if (request.getIncludeCount().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "include_count", request.getIncludeCount().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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SegmentList.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + 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))); + 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 segment. + */ + public CompletableFuture find(FindSegmentRequest request) { + return find(request, null); + } + + /** + * You can fetch the details of a single segment. + */ + public CompletableFuture find(FindSegmentRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("segments") + .addPathSegment(request.getSegmentId()) + .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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Segment.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + 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))); + 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/segments/SegmentsClient.java b/src/main/java/com/intercom/api/resources/segments/SegmentsClient.java new file mode 100644 index 00000000..68e22e16 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/segments/SegmentsClient.java @@ -0,0 +1,145 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.segments; + +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.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.segments.requests.FindSegmentRequest; +import com.intercom.api.resources.segments.requests.ListSegmentsRequest; +import com.intercom.api.resources.segments.types.Segment; +import com.intercom.api.types.Error; +import com.intercom.api.types.SegmentList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class SegmentsClient { + protected final ClientOptions clientOptions; + + public SegmentsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can fetch a list of all segments. + */ + public SegmentList list() { + return list(ListSegmentsRequest.builder().build()); + } + + /** + * You can fetch a list of all segments. + */ + public SegmentList list(ListSegmentsRequest request) { + return list(request, null); + } + + /** + * You can fetch a list of all segments. + */ + public SegmentList list(ListSegmentsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("segments"); + if (request.getIncludeCount().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "include_count", request.getIncludeCount().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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SegmentList.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can fetch the details of a single segment. + */ + public Segment find(FindSegmentRequest request) { + return find(request, null); + } + + /** + * You can fetch the details of a single segment. + */ + public Segment find(FindSegmentRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("segments") + .addPathSegment(request.getSegmentId()) + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Segment.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/segments/requests/FindSegmentRequest.java b/src/main/java/com/intercom/api/resources/segments/requests/FindSegmentRequest.java new file mode 100644 index 00000000..3234207c --- /dev/null +++ b/src/main/java/com/intercom/api/resources/segments/requests/FindSegmentRequest.java @@ -0,0 +1,109 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.segments.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 = FindSegmentRequest.Builder.class) +public final class FindSegmentRequest { + private final String segmentId; + + private final Map additionalProperties; + + private FindSegmentRequest(String segmentId, Map additionalProperties) { + this.segmentId = segmentId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identified of a given segment. + */ + @JsonProperty("segment_id") + public String getSegmentId() { + return segmentId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof FindSegmentRequest && equalTo((FindSegmentRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(FindSegmentRequest other) { + return segmentId.equals(other.segmentId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.segmentId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static SegmentIdStage builder() { + return new Builder(); + } + + public interface SegmentIdStage { + _FinalStage segmentId(@NotNull String segmentId); + + Builder from(FindSegmentRequest other); + } + + public interface _FinalStage { + FindSegmentRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements SegmentIdStage, _FinalStage { + private String segmentId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(FindSegmentRequest other) { + segmentId(other.getSegmentId()); + return this; + } + + /** + *

The unique identified of a given segment.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("segment_id") + public _FinalStage segmentId(@NotNull String segmentId) { + this.segmentId = Objects.requireNonNull(segmentId, "segmentId must not be null"); + return this; + } + + @java.lang.Override + public FindSegmentRequest build() { + return new FindSegmentRequest(segmentId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/segments/requests/ListSegmentsRequest.java b/src/main/java/com/intercom/api/resources/segments/requests/ListSegmentsRequest.java new file mode 100644 index 00000000..c11a504d --- /dev/null +++ b/src/main/java/com/intercom/api/resources/segments/requests/ListSegmentsRequest.java @@ -0,0 +1,98 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.segments.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 = ListSegmentsRequest.Builder.class) +public final class ListSegmentsRequest { + private final Optional includeCount; + + private final Map additionalProperties; + + private ListSegmentsRequest(Optional includeCount, Map additionalProperties) { + this.includeCount = includeCount; + this.additionalProperties = additionalProperties; + } + + /** + * @return It includes the count of contacts that belong to each segment. + */ + @JsonProperty("include_count") + public Optional getIncludeCount() { + return includeCount; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListSegmentsRequest && equalTo((ListSegmentsRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListSegmentsRequest other) { + return includeCount.equals(other.includeCount); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.includeCount); + } + + @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 includeCount = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ListSegmentsRequest other) { + includeCount(other.getIncludeCount()); + return this; + } + + @JsonSetter(value = "include_count", nulls = Nulls.SKIP) + public Builder includeCount(Optional includeCount) { + this.includeCount = includeCount; + return this; + } + + public Builder includeCount(Boolean includeCount) { + this.includeCount = Optional.ofNullable(includeCount); + return this; + } + + public ListSegmentsRequest build() { + return new ListSegmentsRequest(includeCount, 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 new file mode 100644 index 00000000..701d6db2 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/segments/types/Segment.java @@ -0,0 +1,365 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.segments.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 = Segment.Builder.class) +public final class Segment { + private final String id; + + private final String name; + + private final int createdAt; + + private final Optional updatedAt; + + private final PersonType personType; + + private final Optional count; + + private final Map additionalProperties; + + private Segment( + String id, + String name, + int createdAt, + Optional updatedAt, + PersonType personType, + Optional count, + Map additionalProperties) { + this.id = id; + this.name = name; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.personType = personType; + this.count = count; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of object. + */ + @JsonProperty("type") + public String getType() { + return "segment"; + } + + /** + * @return The unique identifier representing the segment. + */ + @JsonProperty("id") + public String getId() { + return id; + } + + /** + * @return The name of the segment. + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * @return The time the segment was created. + */ + @JsonProperty("created_at") + public int getCreatedAt() { + return createdAt; + } + + /** + * @return The time the segment was updated. + */ + @JsonProperty("updated_at") + public Optional getUpdatedAt() { + return updatedAt; + } + + /** + * @return Type of the contact: contact (lead) or user. + */ + @JsonProperty("person_type") + public PersonType getPersonType() { + return personType; + } + + /** + * @return The number of items in the user segment. It's returned when include_count=true is included in the request. + */ + @JsonProperty("count") + public Optional getCount() { + return count; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Segment && equalTo((Segment) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Segment other) { + return id.equals(other.id) + && name.equals(other.name) + && createdAt == other.createdAt + && updatedAt.equals(other.updatedAt) + && personType.equals(other.personType) + && count.equals(other.count); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id, this.name, this.createdAt, this.updatedAt, this.personType, this.count); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + NameStage id(@NotNull String id); + + Builder from(Segment other); + } + + public interface NameStage { + CreatedAtStage name(@NotNull String name); + } + + public interface CreatedAtStage { + PersonTypeStage createdAt(int createdAt); + } + + public interface PersonTypeStage { + _FinalStage personType(@NotNull PersonType personType); + } + + public interface _FinalStage { + Segment build(); + + _FinalStage updatedAt(Optional updatedAt); + + _FinalStage updatedAt(Integer updatedAt); + + _FinalStage count(Optional count); + + _FinalStage count(Integer count); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, NameStage, CreatedAtStage, PersonTypeStage, _FinalStage { + private String id; + + private String name; + + private int createdAt; + + private PersonType personType; + + 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) { + id(other.getId()); + name(other.getName()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + personType(other.getPersonType()); + count(other.getCount()); + return this; + } + + /** + *

The unique identifier representing the segment.

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

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"); + return this; + } + + /** + *

The time the segment was created.

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

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"); + 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. + */ + @java.lang.Override + public _FinalStage count(Integer count) { + this.count = Optional.ofNullable(count); + return this; + } + + @java.lang.Override + @JsonSetter(value = "count", nulls = Nulls.SKIP) + public _FinalStage count(Optional count) { + this.count = count; + 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) { + this.updatedAt = Optional.ofNullable(updatedAt); + return this; + } + + @java.lang.Override + @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) + public _FinalStage updatedAt(Optional updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + @java.lang.Override + public Segment build() { + return new Segment(id, name, createdAt, updatedAt, personType, count, additionalProperties); + } + } + + public final class PersonType { + public static final PersonType USER = new PersonType(Value.USER, "user"); + + public static final PersonType CONTACT = new PersonType(Value.CONTACT, "contact"); + + private final Value value; + + private final String string; + + PersonType(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 PersonType && this.string.equals(((PersonType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case USER: + return visitor.visitUser(); + case CONTACT: + return visitor.visitContact(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static PersonType valueOf(String value) { + switch (value) { + case "user": + return USER; + case "contact": + return CONTACT; + default: + return new PersonType(Value.UNKNOWN, value); + } + } + + public enum Value { + CONTACT, + + USER, + + UNKNOWN + } + + public interface Visitor { + T visitContact(); + + T visitUser(); + + T visitUnknown(String unknownType); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/subscriptiontypes/AsyncSubscriptionTypesClient.java b/src/main/java/com/intercom/api/resources/subscriptiontypes/AsyncSubscriptionTypesClient.java new file mode 100644 index 00000000..ad6e07c1 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/subscriptiontypes/AsyncSubscriptionTypesClient.java @@ -0,0 +1,97 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.subscriptiontypes; + +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.ObjectMappers; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.errors.UnauthorizedError; +import com.intercom.api.types.Error; +import com.intercom.api.types.SubscriptionTypeList; +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 AsyncSubscriptionTypesClient { + protected final ClientOptions clientOptions; + + public AsyncSubscriptionTypesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can list all subscription types. A list of subscription type objects will be returned. + */ + public CompletableFuture list() { + return list(null); + } + + /** + * You can list all subscription types. A list of subscription type objects will be returned. + */ + public CompletableFuture list(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("subscription_types") + .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( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SubscriptionTypeList.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + 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))); + 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/subscriptiontypes/SubscriptionTypesClient.java b/src/main/java/com/intercom/api/resources/subscriptiontypes/SubscriptionTypesClient.java new file mode 100644 index 00000000..95a4b411 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/subscriptiontypes/SubscriptionTypesClient.java @@ -0,0 +1,77 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.subscriptiontypes; + +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.ObjectMappers; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.errors.UnauthorizedError; +import com.intercom.api.types.Error; +import com.intercom.api.types.SubscriptionTypeList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class SubscriptionTypesClient { + protected final ClientOptions clientOptions; + + public SubscriptionTypesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can list all subscription types. A list of subscription type objects will be returned. + */ + public SubscriptionTypeList list() { + return list(null); + } + + /** + * You can list all subscription types. A list of subscription type objects will be returned. + */ + public SubscriptionTypeList list(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("subscription_types") + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SubscriptionTypeList.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} 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 new file mode 100644 index 00000000..27507347 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/subscriptiontypes/types/SubscriptionType.java @@ -0,0 +1,551 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.subscriptiontypes.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 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; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = SubscriptionType.Builder.class) +public final class SubscriptionType { + private final String id; + + private final State state; + + private final Translation defaultTranslation; + + private final List translations; + + private final ConsentType consentType; + + private final List contentTypes; + + private final Map additionalProperties; + + private SubscriptionType( + String id, + State state, + Translation defaultTranslation, + List translations, + ConsentType consentType, + List contentTypes, + Map additionalProperties) { + this.id = id; + this.state = state; + this.defaultTranslation = defaultTranslation; + this.translations = translations; + this.consentType = consentType; + this.contentTypes = contentTypes; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of the object - subscription + */ + @JsonProperty("type") + public String getType() { + return "subscription"; + } + + /** + * @return The unique identifier representing the subscription type. + */ + @JsonProperty("id") + public String getId() { + return id; + } + + /** + * @return The state of the subscription type. + */ + @JsonProperty("state") + public State getState() { + return state; + } + + @JsonProperty("default_translation") + public Translation getDefaultTranslation() { + return defaultTranslation; + } + + /** + * @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() { + return translations; + } + + /** + * @return Describes the type of consent. + */ + @JsonProperty("consent_type") + public ConsentType getConsentType() { + return consentType; + } + + /** + * @return The message types that this subscription supports - can contain email or sms_message. + */ + @JsonProperty("content_types") + public List getContentTypes() { + return contentTypes; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof SubscriptionType && equalTo((SubscriptionType) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(SubscriptionType other) { + return id.equals(other.id) + && state.equals(other.state) + && defaultTranslation.equals(other.defaultTranslation) + && translations.equals(other.translations) + && consentType.equals(other.consentType) + && contentTypes.equals(other.contentTypes); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.id, this.state, this.defaultTranslation, this.translations, this.consentType, this.contentTypes); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + StateStage id(@NotNull String id); + + Builder from(SubscriptionType other); + } + + public interface StateStage { + DefaultTranslationStage state(@NotNull State state); + } + + public interface DefaultTranslationStage { + ConsentTypeStage defaultTranslation(@NotNull Translation defaultTranslation); + } + + public interface ConsentTypeStage { + _FinalStage consentType(@NotNull ConsentType consentType); + } + + public interface _FinalStage { + SubscriptionType build(); + + _FinalStage translations(List translations); + + _FinalStage addTranslations(Translation translations); + + _FinalStage addAllTranslations(List translations); + + _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; + + private State state; + + private Translation defaultTranslation; + + private ConsentType consentType; + + private List contentTypes = new ArrayList<>(); + + private List translations = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(SubscriptionType other) { + id(other.getId()); + state(other.getState()); + defaultTranslation(other.getDefaultTranslation()); + translations(other.getTranslations()); + consentType(other.getConsentType()); + contentTypes(other.getContentTypes()); + return this; + } + + /** + *

The unique identifier representing the subscription type.

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

The state of the subscription type.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("state") + public DefaultTranslationStage state(@NotNull State state) { + this.state = Objects.requireNonNull(state, "state must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("default_translation") + public ConsentTypeStage defaultTranslation(@NotNull Translation defaultTranslation) { + this.defaultTranslation = Objects.requireNonNull(defaultTranslation, "defaultTranslation must not be null"); + return this; + } + + /** + *

Describes the type of consent.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("consent_type") + public _FinalStage consentType(@NotNull ConsentType consentType) { + this.consentType = Objects.requireNonNull(consentType, "consentType must not be null"); + 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); + 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "content_types", nulls = Nulls.SKIP) + public _FinalStage contentTypes(List contentTypes) { + this.contentTypes.clear(); + this.contentTypes.addAll(contentTypes); + 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); + 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 addTranslations(Translation translations) { + this.translations.add(translations); + return this; + } + + @java.lang.Override + @JsonSetter(value = "translations", nulls = Nulls.SKIP) + public _FinalStage translations(List translations) { + this.translations.clear(); + this.translations.addAll(translations); + return this; + } + + @java.lang.Override + public SubscriptionType build() { + return new SubscriptionType( + id, state, defaultTranslation, translations, consentType, contentTypes, additionalProperties); + } + } + + public final class ConsentType { + public static final ConsentType OPT_IN = new ConsentType(Value.OPT_IN, "opt_in"); + + public static final ConsentType OPT_OUT = new ConsentType(Value.OPT_OUT, "opt_out"); + + private final Value value; + + private final String string; + + ConsentType(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 ConsentType && this.string.equals(((ConsentType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case OPT_IN: + return visitor.visitOptIn(); + case OPT_OUT: + return visitor.visitOptOut(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static ConsentType valueOf(String value) { + switch (value) { + case "opt_in": + return OPT_IN; + case "opt_out": + return OPT_OUT; + default: + return new ConsentType(Value.UNKNOWN, value); + } + } + + public enum Value { + OPT_OUT, + + OPT_IN, + + UNKNOWN + } + + public interface Visitor { + T visitOptOut(); + + T visitOptIn(); + + T visitUnknown(String unknownType); + } + } + + public final class State { + public static final State LIVE = new State(Value.LIVE, "live"); + + public static final State ARCHIVED = new State(Value.ARCHIVED, "archived"); + + public static final State DRAFT = new State(Value.DRAFT, "draft"); + + 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 LIVE: + return visitor.visitLive(); + case ARCHIVED: + return visitor.visitArchived(); + case DRAFT: + return visitor.visitDraft(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static State valueOf(String value) { + switch (value) { + case "live": + return LIVE; + case "archived": + return ARCHIVED; + case "draft": + return DRAFT; + default: + return new State(Value.UNKNOWN, value); + } + } + + public enum Value { + LIVE, + + DRAFT, + + ARCHIVED, + + UNKNOWN + } + + public interface Visitor { + T visitLive(); + + T visitDraft(); + + T visitArchived(); + + T visitUnknown(String unknownType); + } + } + + public final class ContentTypesItem { + public static final ContentTypesItem EMAIL = new ContentTypesItem(Value.EMAIL, "email"); + + public static final ContentTypesItem SMS_MESSAGE = new ContentTypesItem(Value.SMS_MESSAGE, "sms_message"); + + private final Value value; + + private final String string; + + ContentTypesItem(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 ContentTypesItem && this.string.equals(((ContentTypesItem) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case EMAIL: + return visitor.visitEmail(); + case SMS_MESSAGE: + return visitor.visitSmsMessage(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static ContentTypesItem valueOf(String value) { + switch (value) { + case "email": + return EMAIL; + case "sms_message": + return SMS_MESSAGE; + default: + return new ContentTypesItem(Value.UNKNOWN, value); + } + } + + public enum Value { + EMAIL, + + SMS_MESSAGE, + + UNKNOWN + } + + public interface Visitor { + T visitEmail(); + + T visitSmsMessage(); + + T visitUnknown(String unknownType); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/tags/AsyncTagsClient.java b/src/main/java/com/intercom/api/resources/tags/AsyncTagsClient.java new file mode 100644 index 00000000..9e45b30c --- /dev/null +++ b/src/main/java/com/intercom/api/resources/tags/AsyncTagsClient.java @@ -0,0 +1,802 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.tags; + +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.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.resources.tags.requests.DeleteTagRequest; +import com.intercom.api.resources.tags.requests.FindTagRequest; +import com.intercom.api.resources.tags.requests.TagContactRequest; +import com.intercom.api.resources.tags.requests.TagConversationRequest; +import com.intercom.api.resources.tags.requests.TagTicketRequest; +import com.intercom.api.resources.tags.requests.UntagContactRequest; +import com.intercom.api.resources.tags.requests.UntagConversationRequest; +import com.intercom.api.resources.tags.requests.UntagTicketRequest; +import com.intercom.api.resources.tags.types.Tag; +import com.intercom.api.resources.tags.types.TagsCreateRequestBody; +import com.intercom.api.types.Error; +import com.intercom.api.types.TagList; +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 AsyncTagsClient { + protected final ClientOptions clientOptions; + + public AsyncTagsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can tag a specific contact. This will return a tag object for the tag that was added to the contact. + */ + public CompletableFuture tagContact(TagContactRequest request) { + return tagContact(request, null); + } + + /** + * You can tag a specific contact. This will return a tag object for the tag that was added to the contact. + */ + public CompletableFuture tagContact(TagContactRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getContactId()) + .addPathSegments("tags") + .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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Tag.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + 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))); + 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 remove tag from a specific contact. This will return a tag object for the tag that was removed from the contact. + */ + public CompletableFuture untagContact(UntagContactRequest request) { + return untagContact(request, null); + } + + /** + * You can remove tag from a specific contact. This will return a tag object for the tag that was removed from the contact. + */ + public CompletableFuture untagContact(UntagContactRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getContactId()) + .addPathSegments("tags") + .addPathSegment(request.getTagId()) + .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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Tag.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + 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))); + 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 tag a specific conversation. This will return a tag object for the tag that was added to the conversation. + */ + public CompletableFuture tagConversation(TagConversationRequest request) { + return tagConversation(request, null); + } + + /** + * You can tag a specific conversation. This will return a tag object for the tag that was added to the conversation. + */ + public CompletableFuture tagConversation(TagConversationRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations") + .addPathSegment(request.getConversationId()) + .addPathSegments("tags") + .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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Tag.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + 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))); + 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 remove tag from a specific conversation. This will return a tag object for the tag that was removed from the conversation. + */ + public CompletableFuture untagConversation(UntagConversationRequest request) { + return untagConversation(request, null); + } + + /** + * You can remove tag from a specific conversation. This will return a tag object for the tag that was removed from the conversation. + */ + public CompletableFuture untagConversation(UntagConversationRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations") + .addPathSegment(request.getConversationId()) + .addPathSegments("tags") + .addPathSegment(request.getTagId()) + .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("DELETE", 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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Tag.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + 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))); + 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 a list of all tags for a given workspace. + */ + public CompletableFuture list() { + return list(null); + } + + /** + * You can fetch a list of all tags for a given workspace. + */ + public CompletableFuture list(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("tags") + .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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TagList.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + 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))); + 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 use this endpoint to perform the following operations: + *

1. Create a new tag: You can create a new tag by passing in the tag name as specified in "Create or Update Tag Request Payload" described below.

+ *

2. Update an existing tag: You can update an existing tag by passing the id of the tag as specified in "Create or Update Tag Request Payload" described below.

+ *

3. Tag Companies: You can tag single company or a list of companies. You can tag a company by passing in the tag name and the company details as specified in "Tag Company Request Payload" described below. Also, if the tag doesn't exist then a new one will be created automatically.

+ *

4. Untag Companies: You can untag a single company or a list of companies. You can untag a company by passing in the tag id and the company details as specified in "Untag Company Request Payload" described below.

+ *

5. Tag Multiple Users: You can tag a list of users. You can tag the users by passing in the tag name and the user details as specified in "Tag Users Request Payload" described below.

+ *

Each operation will return a tag object.

+ */ + public CompletableFuture create(TagsCreateRequestBody request) { + return create(request, null); + } + + /** + * You can use this endpoint to perform the following operations: + *

1. Create a new tag: You can create a new tag by passing in the tag name as specified in "Create or Update Tag Request Payload" described below.

+ *

2. Update an existing tag: You can update an existing tag by passing the id of the tag as specified in "Create or Update Tag Request Payload" described below.

+ *

3. Tag Companies: You can tag single company or a list of companies. You can tag a company by passing in the tag name and the company details as specified in "Tag Company Request Payload" described below. Also, if the tag doesn't exist then a new one will be created automatically.

+ *

4. Untag Companies: You can untag a single company or a list of companies. You can untag a company by passing in the tag id and the company details as specified in "Untag Company Request Payload" described below.

+ *

5. Tag Multiple Users: You can tag a list of users. You can tag the users by passing in the tag name and the user details as specified in "Tag Users Request Payload" described below.

+ *

Each operation will return a tag object.

+ */ + public CompletableFuture create(TagsCreateRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("tags") + .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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Tag.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + 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))); + 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 tags that are on the workspace by their id. + * This will return a tag object. + */ + public CompletableFuture find(FindTagRequest request) { + return find(request, null); + } + + /** + * You can fetch the details of tags that are on the workspace by their id. + * This will return a tag object. + */ + public CompletableFuture find(FindTagRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("tags") + .addPathSegment(request.getTagId()) + .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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Tag.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + 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))); + 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 the details of tags that are on the workspace by passing in the id. + */ + public CompletableFuture delete(DeleteTagRequest request) { + return delete(request, null); + } + + /** + * You can delete the details of tags that are on the workspace by passing in the id. + */ + public CompletableFuture delete(DeleteTagRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("tags") + .addPathSegment(request.getTagId()) + .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(null); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + 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))); + 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 tag a specific ticket. This will return a tag object for the tag that was added to the ticket. + */ + public CompletableFuture tagTicket(TagTicketRequest request) { + return tagTicket(request, null); + } + + /** + * You can tag a specific ticket. This will return a tag object for the tag that was added to the ticket. + */ + public CompletableFuture tagTicket(TagTicketRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("tickets") + .addPathSegment(request.getTicketId()) + .addPathSegments("tags") + .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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Tag.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + 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))); + 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 remove tag from a specific ticket. This will return a tag object for the tag that was removed from the ticket. + */ + public CompletableFuture untagTicket(UntagTicketRequest request) { + return untagTicket(request, null); + } + + /** + * You can remove tag from a specific ticket. This will return a tag object for the tag that was removed from the ticket. + */ + public CompletableFuture untagTicket(UntagTicketRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("tickets") + .addPathSegment(request.getTicketId()) + .addPathSegments("tags") + .addPathSegment(request.getTagId()) + .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("DELETE", 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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Tag.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + 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))); + 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/tags/TagsClient.java b/src/main/java/com/intercom/api/resources/tags/TagsClient.java new file mode 100644 index 00000000..6bfeb252 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/tags/TagsClient.java @@ -0,0 +1,637 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.tags; + +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.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.resources.tags.requests.DeleteTagRequest; +import com.intercom.api.resources.tags.requests.FindTagRequest; +import com.intercom.api.resources.tags.requests.TagContactRequest; +import com.intercom.api.resources.tags.requests.TagConversationRequest; +import com.intercom.api.resources.tags.requests.TagTicketRequest; +import com.intercom.api.resources.tags.requests.UntagContactRequest; +import com.intercom.api.resources.tags.requests.UntagConversationRequest; +import com.intercom.api.resources.tags.requests.UntagTicketRequest; +import com.intercom.api.resources.tags.types.Tag; +import com.intercom.api.resources.tags.types.TagsCreateRequestBody; +import com.intercom.api.types.Error; +import com.intercom.api.types.TagList; +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 TagsClient { + protected final ClientOptions clientOptions; + + public TagsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can tag a specific contact. This will return a tag object for the tag that was added to the contact. + */ + public Tag tagContact(TagContactRequest request) { + return tagContact(request, null); + } + + /** + * You can tag a specific contact. This will return a tag object for the tag that was added to the contact. + */ + public Tag tagContact(TagContactRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getContactId()) + .addPathSegments("tags") + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Tag.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can remove tag from a specific contact. This will return a tag object for the tag that was removed from the contact. + */ + public Tag untagContact(UntagContactRequest request) { + return untagContact(request, null); + } + + /** + * You can remove tag from a specific contact. This will return a tag object for the tag that was removed from the contact. + */ + public Tag untagContact(UntagContactRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getContactId()) + .addPathSegments("tags") + .addPathSegment(request.getTagId()) + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Tag.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can tag a specific conversation. This will return a tag object for the tag that was added to the conversation. + */ + public Tag tagConversation(TagConversationRequest request) { + return tagConversation(request, null); + } + + /** + * You can tag a specific conversation. This will return a tag object for the tag that was added to the conversation. + */ + public Tag tagConversation(TagConversationRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations") + .addPathSegment(request.getConversationId()) + .addPathSegments("tags") + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Tag.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can remove tag from a specific conversation. This will return a tag object for the tag that was removed from the conversation. + */ + public Tag untagConversation(UntagConversationRequest request) { + return untagConversation(request, null); + } + + /** + * You can remove tag from a specific conversation. This will return a tag object for the tag that was removed from the conversation. + */ + public Tag untagConversation(UntagConversationRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations") + .addPathSegment(request.getConversationId()) + .addPathSegments("tags") + .addPathSegment(request.getTagId()) + .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("DELETE", 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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Tag.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can fetch a list of all tags for a given workspace. + */ + public TagList list() { + return list(null); + } + + /** + * You can fetch a list of all tags for a given workspace. + */ + public TagList list(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("tags") + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TagList.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can use this endpoint to perform the following operations: + *

1. Create a new tag: You can create a new tag by passing in the tag name as specified in "Create or Update Tag Request Payload" described below.

+ *

2. Update an existing tag: You can update an existing tag by passing the id of the tag as specified in "Create or Update Tag Request Payload" described below.

+ *

3. Tag Companies: You can tag single company or a list of companies. You can tag a company by passing in the tag name and the company details as specified in "Tag Company Request Payload" described below. Also, if the tag doesn't exist then a new one will be created automatically.

+ *

4. Untag Companies: You can untag a single company or a list of companies. You can untag a company by passing in the tag id and the company details as specified in "Untag Company Request Payload" described below.

+ *

5. Tag Multiple Users: You can tag a list of users. You can tag the users by passing in the tag name and the user details as specified in "Tag Users Request Payload" described below.

+ *

Each operation will return a tag object.

+ */ + public Tag create(TagsCreateRequestBody request) { + return create(request, null); + } + + /** + * You can use this endpoint to perform the following operations: + *

1. Create a new tag: You can create a new tag by passing in the tag name as specified in "Create or Update Tag Request Payload" described below.

+ *

2. Update an existing tag: You can update an existing tag by passing the id of the tag as specified in "Create or Update Tag Request Payload" described below.

+ *

3. Tag Companies: You can tag single company or a list of companies. You can tag a company by passing in the tag name and the company details as specified in "Tag Company Request Payload" described below. Also, if the tag doesn't exist then a new one will be created automatically.

+ *

4. Untag Companies: You can untag a single company or a list of companies. You can untag a company by passing in the tag id and the company details as specified in "Untag Company Request Payload" described below.

+ *

5. Tag Multiple Users: You can tag a list of users. You can tag the users by passing in the tag name and the user details as specified in "Tag Users Request Payload" described below.

+ *

Each operation will return a tag object.

+ */ + public Tag create(TagsCreateRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("tags") + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Tag.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can fetch the details of tags that are on the workspace by their id. + * This will return a tag object. + */ + public Tag find(FindTagRequest request) { + return find(request, null); + } + + /** + * You can fetch the details of tags that are on the workspace by their id. + * This will return a tag object. + */ + public Tag find(FindTagRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("tags") + .addPathSegment(request.getTagId()) + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Tag.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can delete the details of tags that are on the workspace by passing in the id. + */ + public void delete(DeleteTagRequest request) { + delete(request, null); + } + + /** + * You can delete the details of tags that are on the workspace by passing in the id. + */ + public void delete(DeleteTagRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("tags") + .addPathSegment(request.getTagId()) + .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; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can tag a specific ticket. This will return a tag object for the tag that was added to the ticket. + */ + public Tag tagTicket(TagTicketRequest request) { + return tagTicket(request, null); + } + + /** + * You can tag a specific ticket. This will return a tag object for the tag that was added to the ticket. + */ + public Tag tagTicket(TagTicketRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("tickets") + .addPathSegment(request.getTicketId()) + .addPathSegments("tags") + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Tag.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can remove tag from a specific ticket. This will return a tag object for the tag that was removed from the ticket. + */ + public Tag untagTicket(UntagTicketRequest request) { + return untagTicket(request, null); + } + + /** + * You can remove tag from a specific ticket. This will return a tag object for the tag that was removed from the ticket. + */ + public Tag untagTicket(UntagTicketRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("tickets") + .addPathSegment(request.getTicketId()) + .addPathSegments("tags") + .addPathSegment(request.getTagId()) + .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("DELETE", 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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Tag.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/tags/requests/DeleteTagRequest.java b/src/main/java/com/intercom/api/resources/tags/requests/DeleteTagRequest.java new file mode 100644 index 00000000..359272fb --- /dev/null +++ b/src/main/java/com/intercom/api/resources/tags/requests/DeleteTagRequest.java @@ -0,0 +1,109 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.tags.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 = DeleteTagRequest.Builder.class) +public final class DeleteTagRequest { + private final String tagId; + + private final Map additionalProperties; + + private DeleteTagRequest(String tagId, Map additionalProperties) { + this.tagId = tagId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier of a given tag + */ + @JsonProperty("tag_id") + public String getTagId() { + return tagId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeleteTagRequest && equalTo((DeleteTagRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeleteTagRequest other) { + return tagId.equals(other.tagId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.tagId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TagIdStage builder() { + return new Builder(); + } + + public interface TagIdStage { + _FinalStage tagId(@NotNull String tagId); + + Builder from(DeleteTagRequest other); + } + + public interface _FinalStage { + DeleteTagRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements TagIdStage, _FinalStage { + private String tagId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DeleteTagRequest other) { + tagId(other.getTagId()); + return this; + } + + /** + *

The unique identifier of a given tag

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("tag_id") + public _FinalStage tagId(@NotNull String tagId) { + this.tagId = Objects.requireNonNull(tagId, "tagId must not be null"); + return this; + } + + @java.lang.Override + public DeleteTagRequest build() { + return new DeleteTagRequest(tagId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/tags/requests/FindTagRequest.java b/src/main/java/com/intercom/api/resources/tags/requests/FindTagRequest.java new file mode 100644 index 00000000..1b162820 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/tags/requests/FindTagRequest.java @@ -0,0 +1,109 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.tags.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 = FindTagRequest.Builder.class) +public final class FindTagRequest { + private final String tagId; + + private final Map additionalProperties; + + private FindTagRequest(String tagId, Map additionalProperties) { + this.tagId = tagId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier of a given tag + */ + @JsonProperty("tag_id") + public String getTagId() { + return tagId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof FindTagRequest && equalTo((FindTagRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(FindTagRequest other) { + return tagId.equals(other.tagId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.tagId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TagIdStage builder() { + return new Builder(); + } + + public interface TagIdStage { + _FinalStage tagId(@NotNull String tagId); + + Builder from(FindTagRequest other); + } + + public interface _FinalStage { + FindTagRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements TagIdStage, _FinalStage { + private String tagId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(FindTagRequest other) { + tagId(other.getTagId()); + return this; + } + + /** + *

The unique identifier of a given tag

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("tag_id") + public _FinalStage tagId(@NotNull String tagId) { + this.tagId = Objects.requireNonNull(tagId, "tagId must not be null"); + return this; + } + + @java.lang.Override + public FindTagRequest build() { + return new FindTagRequest(tagId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/tags/requests/TagContactRequest.java b/src/main/java/com/intercom/api/resources/tags/requests/TagContactRequest.java new file mode 100644 index 00000000..12d51160 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/tags/requests/TagContactRequest.java @@ -0,0 +1,138 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.tags.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 = TagContactRequest.Builder.class) +public final class TagContactRequest { + private final String contactId; + + private final String tagId; + + private final Map additionalProperties; + + private TagContactRequest(String contactId, String tagId, Map additionalProperties) { + this.contactId = contactId; + this.tagId = tagId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the contact which is given by Intercom + */ + @JsonProperty("contact_id") + public String getContactId() { + return contactId; + } + + /** + * @return The unique identifier for the tag which is given by Intercom + */ + @JsonProperty("id") + public String getTagId() { + return tagId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof TagContactRequest && equalTo((TagContactRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(TagContactRequest other) { + return contactId.equals(other.contactId) && tagId.equals(other.tagId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.contactId, this.tagId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ContactIdStage builder() { + return new Builder(); + } + + public interface ContactIdStage { + TagIdStage contactId(@NotNull String contactId); + + Builder from(TagContactRequest other); + } + + public interface TagIdStage { + _FinalStage tagId(@NotNull String tagId); + } + + public interface _FinalStage { + TagContactRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ContactIdStage, TagIdStage, _FinalStage { + private String contactId; + + private String tagId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(TagContactRequest other) { + contactId(other.getContactId()); + tagId(other.getTagId()); + return this; + } + + /** + *

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("contact_id") + public TagIdStage contactId(@NotNull String contactId) { + this.contactId = Objects.requireNonNull(contactId, "contactId must not be null"); + return this; + } + + /** + *

The unique identifier for the tag which is given by Intercom

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public _FinalStage tagId(@NotNull String tagId) { + this.tagId = Objects.requireNonNull(tagId, "tagId must not be null"); + return this; + } + + @java.lang.Override + public TagContactRequest build() { + return new TagContactRequest(contactId, tagId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/tags/requests/TagConversationRequest.java b/src/main/java/com/intercom/api/resources/tags/requests/TagConversationRequest.java new file mode 100644 index 00000000..8245315b --- /dev/null +++ b/src/main/java/com/intercom/api/resources/tags/requests/TagConversationRequest.java @@ -0,0 +1,170 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.tags.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 = TagConversationRequest.Builder.class) +public final class TagConversationRequest { + private final String conversationId; + + private final String tagId; + + private final String adminId; + + private final Map additionalProperties; + + private TagConversationRequest( + String conversationId, String tagId, String adminId, Map additionalProperties) { + this.conversationId = conversationId; + this.tagId = tagId; + this.adminId = adminId; + this.additionalProperties = additionalProperties; + } + + /** + * @return conversation_id + */ + @JsonProperty("conversation_id") + public String getConversationId() { + return conversationId; + } + + /** + * @return The unique identifier for the tag which is given by Intercom + */ + @JsonProperty("id") + public String getTagId() { + return tagId; + } + + /** + * @return The unique identifier for the admin which is given by Intercom. + */ + @JsonProperty("admin_id") + public String getAdminId() { + return adminId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof TagConversationRequest && equalTo((TagConversationRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(TagConversationRequest other) { + return conversationId.equals(other.conversationId) + && tagId.equals(other.tagId) + && adminId.equals(other.adminId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.conversationId, this.tagId, this.adminId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ConversationIdStage builder() { + return new Builder(); + } + + public interface ConversationIdStage { + TagIdStage conversationId(@NotNull String conversationId); + + Builder from(TagConversationRequest other); + } + + public interface TagIdStage { + AdminIdStage tagId(@NotNull String tagId); + } + + public interface AdminIdStage { + _FinalStage adminId(@NotNull String adminId); + } + + public interface _FinalStage { + TagConversationRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ConversationIdStage, TagIdStage, AdminIdStage, _FinalStage { + private String conversationId; + + private String tagId; + + private String adminId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(TagConversationRequest other) { + conversationId(other.getConversationId()); + tagId(other.getTagId()); + adminId(other.getAdminId()); + return this; + } + + /** + *

conversation_id

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

The unique identifier for the tag which is given by Intercom

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

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

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("admin_id") + public _FinalStage adminId(@NotNull String adminId) { + this.adminId = Objects.requireNonNull(adminId, "adminId must not be null"); + return this; + } + + @java.lang.Override + public TagConversationRequest build() { + return new TagConversationRequest(conversationId, tagId, adminId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/tags/requests/TagTicketRequest.java b/src/main/java/com/intercom/api/resources/tags/requests/TagTicketRequest.java new file mode 100644 index 00000000..193cfa46 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/tags/requests/TagTicketRequest.java @@ -0,0 +1,167 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.tags.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 = TagTicketRequest.Builder.class) +public final class TagTicketRequest { + private final String ticketId; + + private final String tagId; + + private final String adminId; + + private final Map additionalProperties; + + private TagTicketRequest(String ticketId, String tagId, String adminId, Map additionalProperties) { + this.ticketId = ticketId; + this.tagId = tagId; + this.adminId = adminId; + this.additionalProperties = additionalProperties; + } + + /** + * @return ticket_id + */ + @JsonProperty("ticket_id") + public String getTicketId() { + return ticketId; + } + + /** + * @return The unique identifier for the tag which is given by Intercom + */ + @JsonProperty("id") + public String getTagId() { + return tagId; + } + + /** + * @return The unique identifier for the admin which is given by Intercom. + */ + @JsonProperty("admin_id") + public String getAdminId() { + return adminId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof TagTicketRequest && equalTo((TagTicketRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(TagTicketRequest other) { + return ticketId.equals(other.ticketId) && tagId.equals(other.tagId) && adminId.equals(other.adminId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.ticketId, this.tagId, this.adminId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TicketIdStage builder() { + return new Builder(); + } + + public interface TicketIdStage { + TagIdStage ticketId(@NotNull String ticketId); + + Builder from(TagTicketRequest other); + } + + public interface TagIdStage { + AdminIdStage tagId(@NotNull String tagId); + } + + public interface AdminIdStage { + _FinalStage adminId(@NotNull String adminId); + } + + public interface _FinalStage { + TagTicketRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements TicketIdStage, TagIdStage, AdminIdStage, _FinalStage { + private String ticketId; + + private String tagId; + + private String adminId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(TagTicketRequest other) { + ticketId(other.getTicketId()); + tagId(other.getTagId()); + adminId(other.getAdminId()); + return this; + } + + /** + *

ticket_id

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

The unique identifier for the tag which is given by Intercom

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

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

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("admin_id") + public _FinalStage adminId(@NotNull String adminId) { + this.adminId = Objects.requireNonNull(adminId, "adminId must not be null"); + return this; + } + + @java.lang.Override + public TagTicketRequest build() { + return new TagTicketRequest(ticketId, tagId, adminId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/tags/requests/UntagContactRequest.java b/src/main/java/com/intercom/api/resources/tags/requests/UntagContactRequest.java new file mode 100644 index 00000000..469a4d0e --- /dev/null +++ b/src/main/java/com/intercom/api/resources/tags/requests/UntagContactRequest.java @@ -0,0 +1,138 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.tags.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 = UntagContactRequest.Builder.class) +public final class UntagContactRequest { + private final String contactId; + + private final String tagId; + + private final Map additionalProperties; + + private UntagContactRequest(String contactId, String tagId, Map additionalProperties) { + this.contactId = contactId; + this.tagId = tagId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the contact which is given by Intercom + */ + @JsonProperty("contact_id") + public String getContactId() { + return contactId; + } + + /** + * @return The unique identifier for the tag which is given by Intercom + */ + @JsonProperty("tag_id") + public String getTagId() { + return tagId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UntagContactRequest && equalTo((UntagContactRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UntagContactRequest other) { + return contactId.equals(other.contactId) && tagId.equals(other.tagId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.contactId, this.tagId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ContactIdStage builder() { + return new Builder(); + } + + public interface ContactIdStage { + TagIdStage contactId(@NotNull String contactId); + + Builder from(UntagContactRequest other); + } + + public interface TagIdStage { + _FinalStage tagId(@NotNull String tagId); + } + + public interface _FinalStage { + UntagContactRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ContactIdStage, TagIdStage, _FinalStage { + private String contactId; + + private String tagId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(UntagContactRequest other) { + contactId(other.getContactId()); + tagId(other.getTagId()); + return this; + } + + /** + *

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("contact_id") + public TagIdStage contactId(@NotNull String contactId) { + this.contactId = Objects.requireNonNull(contactId, "contactId must not be null"); + return this; + } + + /** + *

The unique identifier for the tag which is given by Intercom

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("tag_id") + public _FinalStage tagId(@NotNull String tagId) { + this.tagId = Objects.requireNonNull(tagId, "tagId must not be null"); + return this; + } + + @java.lang.Override + public UntagContactRequest build() { + return new UntagContactRequest(contactId, tagId, 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 new file mode 100644 index 00000000..4999dd0a --- /dev/null +++ b/src/main/java/com/intercom/api/resources/tags/requests/UntagConversationRequest.java @@ -0,0 +1,170 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.tags.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 = UntagConversationRequest.Builder.class) +public final class UntagConversationRequest { + private final String conversationId; + + private final String tagId; + + private final String adminId; + + private final Map additionalProperties; + + private UntagConversationRequest( + String conversationId, String tagId, String adminId, Map additionalProperties) { + this.conversationId = conversationId; + this.tagId = tagId; + this.adminId = adminId; + this.additionalProperties = additionalProperties; + } + + /** + * @return conversation_id + */ + @JsonProperty("conversation_id") + public String getConversationId() { + return conversationId; + } + + /** + * @return id + */ + @JsonProperty("tag_id") + public String getTagId() { + return tagId; + } + + /** + * @return The unique identifier for the admin which is given by Intercom. + */ + @JsonProperty("admin_id") + public String getAdminId() { + return adminId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UntagConversationRequest && equalTo((UntagConversationRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UntagConversationRequest other) { + return conversationId.equals(other.conversationId) + && tagId.equals(other.tagId) + && adminId.equals(other.adminId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.conversationId, this.tagId, this.adminId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ConversationIdStage builder() { + return new Builder(); + } + + public interface ConversationIdStage { + TagIdStage conversationId(@NotNull String conversationId); + + Builder from(UntagConversationRequest other); + } + + public interface TagIdStage { + AdminIdStage tagId(@NotNull String tagId); + } + + public interface AdminIdStage { + _FinalStage adminId(@NotNull String adminId); + } + + public interface _FinalStage { + UntagConversationRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ConversationIdStage, TagIdStage, AdminIdStage, _FinalStage { + private String conversationId; + + private String tagId; + + private String adminId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(UntagConversationRequest other) { + conversationId(other.getConversationId()); + tagId(other.getTagId()); + adminId(other.getAdminId()); + return this; + } + + /** + *

conversation_id

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

id

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

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

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("admin_id") + public _FinalStage adminId(@NotNull String adminId) { + this.adminId = Objects.requireNonNull(adminId, "adminId must not be null"); + return this; + } + + @java.lang.Override + public UntagConversationRequest build() { + return new UntagConversationRequest(conversationId, tagId, adminId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/tags/requests/UntagTicketRequest.java b/src/main/java/com/intercom/api/resources/tags/requests/UntagTicketRequest.java new file mode 100644 index 00000000..a29cbcd5 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/tags/requests/UntagTicketRequest.java @@ -0,0 +1,168 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.tags.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 = UntagTicketRequest.Builder.class) +public final class UntagTicketRequest { + private final String ticketId; + + private final String tagId; + + private final String adminId; + + private final Map additionalProperties; + + private UntagTicketRequest( + String ticketId, String tagId, String adminId, Map additionalProperties) { + this.ticketId = ticketId; + this.tagId = tagId; + this.adminId = adminId; + this.additionalProperties = additionalProperties; + } + + /** + * @return ticket_id + */ + @JsonProperty("ticket_id") + public String getTicketId() { + return ticketId; + } + + /** + * @return The unique identifier for the tag which is given by Intercom + */ + @JsonProperty("tag_id") + public String getTagId() { + return tagId; + } + + /** + * @return The unique identifier for the admin which is given by Intercom. + */ + @JsonProperty("admin_id") + public String getAdminId() { + return adminId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UntagTicketRequest && equalTo((UntagTicketRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UntagTicketRequest other) { + return ticketId.equals(other.ticketId) && tagId.equals(other.tagId) && adminId.equals(other.adminId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.ticketId, this.tagId, this.adminId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TicketIdStage builder() { + return new Builder(); + } + + public interface TicketIdStage { + TagIdStage ticketId(@NotNull String ticketId); + + Builder from(UntagTicketRequest other); + } + + public interface TagIdStage { + AdminIdStage tagId(@NotNull String tagId); + } + + public interface AdminIdStage { + _FinalStage adminId(@NotNull String adminId); + } + + public interface _FinalStage { + UntagTicketRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements TicketIdStage, TagIdStage, AdminIdStage, _FinalStage { + private String ticketId; + + private String tagId; + + private String adminId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(UntagTicketRequest other) { + ticketId(other.getTicketId()); + tagId(other.getTagId()); + adminId(other.getAdminId()); + return this; + } + + /** + *

ticket_id

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

The unique identifier for the tag which is given by Intercom

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

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

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("admin_id") + public _FinalStage adminId(@NotNull String adminId) { + this.adminId = Objects.requireNonNull(adminId, "adminId must not be null"); + return this; + } + + @java.lang.Override + public UntagTicketRequest build() { + return new UntagTicketRequest(ticketId, tagId, adminId, additionalProperties); + } + } +} 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 new file mode 100644 index 00000000..98bae104 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/tags/types/Tag.java @@ -0,0 +1,201 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.tags.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.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 org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = Tag.Builder.class) +public final class Tag { + private final String id; + + private final String name; + + private final int appliedAt; + + private final Reference appliedBy; + + private final Map additionalProperties; + + private Tag(String id, String name, int appliedAt, Reference appliedBy, Map additionalProperties) { + this.id = id; + this.name = name; + this.appliedAt = appliedAt; + this.appliedBy = appliedBy; + this.additionalProperties = additionalProperties; + } + + /** + * @return value is "tag" + */ + @JsonProperty("type") + public String getType() { + return "tag"; + } + + /** + * @return The id of the tag + */ + @JsonProperty("id") + public String getId() { + return id; + } + + /** + * @return The name of the tag + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * @return The time when the tag was applied to the object + */ + @JsonProperty("applied_at") + public int getAppliedAt() { + return appliedAt; + } + + @JsonProperty("applied_by") + public Reference getAppliedBy() { + return appliedBy; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Tag && equalTo((Tag) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Tag other) { + return id.equals(other.id) + && name.equals(other.name) + && appliedAt == other.appliedAt + && appliedBy.equals(other.appliedBy); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id, this.name, this.appliedAt, this.appliedBy); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + NameStage id(@NotNull String id); + + Builder from(Tag other); + } + + public interface NameStage { + AppliedAtStage name(@NotNull String name); + } + + public interface AppliedAtStage { + AppliedByStage appliedAt(int appliedAt); + } + + public interface AppliedByStage { + _FinalStage appliedBy(@NotNull Reference appliedBy); + } + + public interface _FinalStage { + Tag build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, NameStage, AppliedAtStage, AppliedByStage, _FinalStage { + private String id; + + private String name; + + private int appliedAt; + + private Reference appliedBy; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(Tag other) { + id(other.getId()); + name(other.getName()); + appliedAt(other.getAppliedAt()); + appliedBy(other.getAppliedBy()); + return this; + } + + /** + *

The id of the tag

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

The name of the tag

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

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; + return this; + } + + @java.lang.Override + @JsonSetter("applied_by") + public _FinalStage appliedBy(@NotNull Reference appliedBy) { + this.appliedBy = Objects.requireNonNull(appliedBy, "appliedBy must not be null"); + return this; + } + + @java.lang.Override + public Tag build() { + return new Tag(id, name, appliedAt, appliedBy, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/tags/types/TagsCreateRequestBody.java b/src/main/java/com/intercom/api/resources/tags/types/TagsCreateRequestBody.java new file mode 100644 index 00000000..e170a8a5 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/tags/types/TagsCreateRequestBody.java @@ -0,0 +1,122 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.tags.types; + +import com.fasterxml.jackson.annotation.JsonValue; +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.CreateOrUpdateTagRequest; +import com.intercom.api.types.TagCompanyRequest; +import com.intercom.api.types.TagMultipleUsersRequest; +import com.intercom.api.types.UntagCompanyRequest; +import java.io.IOException; +import java.util.Objects; + +@JsonDeserialize(using = TagsCreateRequestBody.Deserializer.class) +public final class TagsCreateRequestBody { + private final Object value; + + private final int type; + + private TagsCreateRequestBody(Object value, int type) { + this.value = value; + this.type = type; + } + + @JsonValue + public Object get() { + return this.value; + } + + public T visit(Visitor visitor) { + if (this.type == 0) { + return visitor.visit((CreateOrUpdateTagRequest) this.value); + } else if (this.type == 1) { + return visitor.visit((TagCompanyRequest) this.value); + } else if (this.type == 2) { + return visitor.visit((UntagCompanyRequest) this.value); + } else if (this.type == 3) { + return visitor.visit((TagMultipleUsersRequest) 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 TagsCreateRequestBody && equalTo((TagsCreateRequestBody) other); + } + + private boolean equalTo(TagsCreateRequestBody 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 TagsCreateRequestBody of(CreateOrUpdateTagRequest value) { + return new TagsCreateRequestBody(value, 0); + } + + public static TagsCreateRequestBody of(TagCompanyRequest value) { + return new TagsCreateRequestBody(value, 1); + } + + public static TagsCreateRequestBody of(UntagCompanyRequest value) { + return new TagsCreateRequestBody(value, 2); + } + + public static TagsCreateRequestBody of(TagMultipleUsersRequest value) { + return new TagsCreateRequestBody(value, 3); + } + + public interface Visitor { + T visit(CreateOrUpdateTagRequest value); + + T visit(TagCompanyRequest value); + + T visit(UntagCompanyRequest value); + + T visit(TagMultipleUsersRequest value); + } + + static final class Deserializer extends StdDeserializer { + Deserializer() { + super(TagsCreateRequestBody.class); + } + + @java.lang.Override + public TagsCreateRequestBody deserialize(JsonParser p, DeserializationContext context) throws IOException { + Object value = p.readValueAs(Object.class); + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, CreateOrUpdateTagRequest.class)); + } catch (IllegalArgumentException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, TagCompanyRequest.class)); + } catch (IllegalArgumentException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, UntagCompanyRequest.class)); + } catch (IllegalArgumentException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, TagMultipleUsersRequest.class)); + } catch (IllegalArgumentException e) { + } + throw new JsonParseException(p, "Failed to deserialize"); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/teams/AsyncTeamsClient.java b/src/main/java/com/intercom/api/resources/teams/AsyncTeamsClient.java new file mode 100644 index 00000000..b9f824b4 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/teams/AsyncTeamsClient.java @@ -0,0 +1,168 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.teams; + +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.ObjectMappers; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.errors.NotFoundError; +import com.intercom.api.errors.UnauthorizedError; +import com.intercom.api.resources.teams.requests.FindTeamRequest; +import com.intercom.api.resources.teams.types.Team; +import com.intercom.api.types.Error; +import com.intercom.api.types.TeamList; +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 AsyncTeamsClient { + protected final ClientOptions clientOptions; + + public AsyncTeamsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * This will return a list of team objects for the App. + */ + public CompletableFuture list() { + return list(null); + } + + /** + * This will return a list of team objects for the App. + */ + public CompletableFuture list(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("teams") + .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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TeamList.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + 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))); + 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 team, containing an array of admins that belong to this team. + */ + public CompletableFuture find(FindTeamRequest request) { + return find(request, null); + } + + /** + * You can fetch the details of a single team, containing an array of admins that belong to this team. + */ + public CompletableFuture find(FindTeamRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("teams") + .addPathSegment(request.getTeamId()) + .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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Team.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + 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))); + 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/teams/TeamsClient.java b/src/main/java/com/intercom/api/resources/teams/TeamsClient.java new file mode 100644 index 00000000..5c489b82 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/teams/TeamsClient.java @@ -0,0 +1,133 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.teams; + +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.ObjectMappers; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.errors.NotFoundError; +import com.intercom.api.errors.UnauthorizedError; +import com.intercom.api.resources.teams.requests.FindTeamRequest; +import com.intercom.api.resources.teams.types.Team; +import com.intercom.api.types.Error; +import com.intercom.api.types.TeamList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class TeamsClient { + protected final ClientOptions clientOptions; + + public TeamsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * This will return a list of team objects for the App. + */ + public TeamList list() { + return list(null); + } + + /** + * This will return a list of team objects for the App. + */ + public TeamList list(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("teams") + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TeamList.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can fetch the details of a single team, containing an array of admins that belong to this team. + */ + public Team find(FindTeamRequest request) { + return find(request, null); + } + + /** + * You can fetch the details of a single team, containing an array of admins that belong to this team. + */ + public Team find(FindTeamRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("teams") + .addPathSegment(request.getTeamId()) + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Team.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/teams/requests/FindTeamRequest.java b/src/main/java/com/intercom/api/resources/teams/requests/FindTeamRequest.java new file mode 100644 index 00000000..a9f592f7 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/teams/requests/FindTeamRequest.java @@ -0,0 +1,109 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.teams.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 = FindTeamRequest.Builder.class) +public final class FindTeamRequest { + private final String teamId; + + private final Map additionalProperties; + + private FindTeamRequest(String teamId, Map additionalProperties) { + this.teamId = teamId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier of a given team. + */ + @JsonProperty("team_id") + public String getTeamId() { + return teamId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof FindTeamRequest && equalTo((FindTeamRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(FindTeamRequest other) { + return teamId.equals(other.teamId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.teamId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TeamIdStage builder() { + return new Builder(); + } + + public interface TeamIdStage { + _FinalStage teamId(@NotNull String teamId); + + Builder from(FindTeamRequest other); + } + + public interface _FinalStage { + FindTeamRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements TeamIdStage, _FinalStage { + private String teamId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(FindTeamRequest other) { + teamId(other.getTeamId()); + return this; + } + + /** + *

The unique identifier of a given team.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("team_id") + public _FinalStage teamId(@NotNull String teamId) { + this.teamId = Objects.requireNonNull(teamId, "teamId must not be null"); + return this; + } + + @java.lang.Override + public FindTeamRequest build() { + return new FindTeamRequest(teamId, 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 new file mode 100644 index 00000000..707d487f --- /dev/null +++ b/src/main/java/com/intercom/api/resources/teams/types/Team.java @@ -0,0 +1,235 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.teams.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.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 String name; + + private final List adminIds; + + private final Optional adminPriorityLevel; + + private final Map additionalProperties; + + private Team( + String id, + String name, + List adminIds, + Optional adminPriorityLevel, + Map additionalProperties) { + this.id = id; + this.name = name; + this.adminIds = adminIds; + this.adminPriorityLevel = adminPriorityLevel; + this.additionalProperties = additionalProperties; + } + + /** + * @return Value is always "team" + */ + @JsonProperty("type") + public String getType() { + return "team"; + } + + /** + * @return The id of the team + */ + @JsonProperty("id") + public String getId() { + return id; + } + + /** + * @return The name of the team + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * @return The list of admin IDs that are a part of the team. + */ + @JsonProperty("admin_ids") + public List getAdminIds() { + return adminIds; + } + + @JsonProperty("admin_priority_level") + public Optional getAdminPriorityLevel() { + return adminPriorityLevel; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Team && equalTo((Team) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Team other) { + return id.equals(other.id) + && name.equals(other.name) + && adminIds.equals(other.adminIds) + && adminPriorityLevel.equals(other.adminPriorityLevel); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id, this.name, this.adminIds, this.adminPriorityLevel); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + NameStage id(@NotNull String id); + + Builder from(Team other); + } + + public interface NameStage { + _FinalStage name(@NotNull String name); + } + + public interface _FinalStage { + Team build(); + + _FinalStage adminIds(List adminIds); + + _FinalStage addAdminIds(Integer adminIds); + + _FinalStage addAllAdminIds(List adminIds); + + _FinalStage adminPriorityLevel(Optional adminPriorityLevel); + + _FinalStage adminPriorityLevel(AdminPriorityLevel adminPriorityLevel); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, NameStage, _FinalStage { + private String id; + + private String name; + + 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) { + id(other.getId()); + name(other.getName()); + adminIds(other.getAdminIds()); + adminPriorityLevel(other.getAdminPriorityLevel()); + return this; + } + + /** + *

The id of the team

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

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"); + return this; + } + + @java.lang.Override + public _FinalStage adminPriorityLevel(AdminPriorityLevel adminPriorityLevel) { + this.adminPriorityLevel = Optional.ofNullable(adminPriorityLevel); + return this; + } + + @java.lang.Override + @JsonSetter(value = "admin_priority_level", nulls = Nulls.SKIP) + public _FinalStage adminPriorityLevel(Optional adminPriorityLevel) { + this.adminPriorityLevel = adminPriorityLevel; + 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 addAllAdminIds(List adminIds) { + this.adminIds.addAll(adminIds); + 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "admin_ids", nulls = Nulls.SKIP) + public _FinalStage adminIds(List adminIds) { + this.adminIds.clear(); + this.adminIds.addAll(adminIds); + return this; + } + + @java.lang.Override + public Team build() { + return new Team(id, name, adminIds, adminPriorityLevel, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/tickets/AsyncTicketsClient.java b/src/main/java/com/intercom/api/resources/tickets/AsyncTicketsClient.java new file mode 100644 index 00000000..ab079c5d --- /dev/null +++ b/src/main/java/com/intercom/api/resources/tickets/AsyncTicketsClient.java @@ -0,0 +1,526 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.tickets; + +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.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.core.pagination.SyncPagingIterable; +import com.intercom.api.errors.BadRequestError; +import com.intercom.api.errors.NotFoundError; +import com.intercom.api.errors.UnauthorizedError; +import com.intercom.api.resources.tickets.requests.CreateTicketRequest; +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.Ticket; +import com.intercom.api.types.CursorPages; +import com.intercom.api.types.Error; +import com.intercom.api.types.SearchRequest; +import com.intercom.api.types.StartingAfterPaging; +import com.intercom.api.types.TicketList; +import com.intercom.api.types.TicketReply; +import java.io.IOException; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; +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 AsyncTicketsClient { + protected final ClientOptions clientOptions; + + public AsyncTicketsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can reply to a ticket with a message from an admin or on behalf of a contact, or with a note for admins. + */ + public CompletableFuture reply(ReplyToTicketRequest request) { + return reply(request, null); + } + + /** + * You can reply to a ticket with a message from an admin or on behalf of a contact, or with a note for admins. + */ + public CompletableFuture reply(ReplyToTicketRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("tickets") + .addPathSegment(request.getTicketId()) + .addPathSegments("reply") + .build(); + RequestBody body; + try { + 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("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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TicketReply.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + 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))); + 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 ticket. + */ + public CompletableFuture create(CreateTicketRequest request) { + return create(request, null); + } + + /** + * You can create a new ticket. + */ + public CompletableFuture create(CreateTicketRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("tickets") + .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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Ticket.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + 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))); + 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) { + return get(request, null); + } + + /** + * You can fetch the details of a single ticket. + */ + public CompletableFuture get(FindTicketRequest 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("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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Ticket.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + 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))); + 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 a ticket. + */ + public CompletableFuture update(UpdateTicketRequest request) { + return update(request, null); + } + + /** + * You can update a ticket. + */ + public CompletableFuture update(UpdateTicketRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("tickets") + .addPathSegment(request.getTicketId()) + .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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Ticket.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + 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))); + 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 tickets by the value of their attributes in order to fetch exactly which ones you want. + *

To search for tickets, you send a POST request to https://api.intercom.io/tickets/search.

+ *

This will accept a query object in the body which will define your filters. + * {% admonition type="warning" name="Optimizing search queries" %} + * Search queries can be complex, so optimizing them can help the performance of your search. + * Use the AND and OR operators to combine multiple filters to get the exact results you need and utilize + * pagination to limit the number of results returned. The default is 20 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ *

Nesting & Limitations

+ *

You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). + * There are some limitations to the amount of multiples there can be:

+ *
    + *
  • There's a limit of max 2 nested filters
  • + *
  • There's a limit of max 15 filters for each AND or OR group
  • + *
+ *

Accepted Fields

+ *

Most keys listed as part of the Ticket model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as created_at accepts a date, the value cannot be a string such as "foobar").

+ *

| Field | Type | + * | :---------------------------------------- | :--------------------------------------------------------------------------------------- | + * | id | String | + * | created_at | Date (UNIX timestamp) | + * | updated_at | Date (UNIX timestamp) | + * | default_title | String | + * | default_description | String | + * | category | String | + * | ticket_type_id | String | + * | contact_ids | String | + * | teammate_ids | String | + * | admin_assignee_id | String | + * | team_assignee_id | String | + * | open | Boolean | + * | state | String | + * | snoozed_until | Date (UNIX timestamp) | + * | ticket_attribute.{id} | String or Boolean or Date (UNIX timestamp) or Float or Integer |

+ *

Accepted Operators

+ *

{% admonition type="info" name="Searching based on created_at" %} + * You may use the <= or >= operators to search by created_at. + * {% /admonition %}

+ *

The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string ("="). The operator has to be compatible with the field's type (eg. you cannot search with > for a given string value as it's only compatible for integer's and dates).

+ *

| Operator | Valid Types | Description | + * | :------- | :----------------------------- | :----------------------------------------------------------- | + * | = | All | Equals | + * | != | All | Doesn't Equal | + * | IN | All | In Shortcut for OR queries Values most be in Array | + * | NIN | All | Not In Shortcut for OR ! queries Values must be in Array | + * | > | Integer Date (UNIX Timestamp) | Greater (or equal) than | + * | < | Integer Date (UNIX Timestamp) | Lower (or equal) than | + * | ~ | String | Contains | + * | !~ | String | Doesn't Contain | + * | ^ | String | Starts With | + * | $ | String | Ends With |

+ */ + public CompletableFuture> search(SearchRequest request) { + return search(request, null); + } + + /** + * You can search for multiple tickets by the value of their attributes in order to fetch exactly which ones you want. + *

To search for tickets, you send a POST request to https://api.intercom.io/tickets/search.

+ *

This will accept a query object in the body which will define your filters. + * {% admonition type="warning" name="Optimizing search queries" %} + * Search queries can be complex, so optimizing them can help the performance of your search. + * Use the AND and OR operators to combine multiple filters to get the exact results you need and utilize + * pagination to limit the number of results returned. The default is 20 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ *

Nesting & Limitations

+ *

You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). + * There are some limitations to the amount of multiples there can be:

+ *
    + *
  • There's a limit of max 2 nested filters
  • + *
  • There's a limit of max 15 filters for each AND or OR group
  • + *
+ *

Accepted Fields

+ *

Most keys listed as part of the Ticket model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as created_at accepts a date, the value cannot be a string such as "foobar").

+ *

| Field | Type | + * | :---------------------------------------- | :--------------------------------------------------------------------------------------- | + * | id | String | + * | created_at | Date (UNIX timestamp) | + * | updated_at | Date (UNIX timestamp) | + * | default_title | String | + * | default_description | String | + * | category | String | + * | ticket_type_id | String | + * | contact_ids | String | + * | teammate_ids | String | + * | admin_assignee_id | String | + * | team_assignee_id | String | + * | open | Boolean | + * | state | String | + * | snoozed_until | Date (UNIX timestamp) | + * | ticket_attribute.{id} | String or Boolean or Date (UNIX timestamp) or Float or Integer |

+ *

Accepted Operators

+ *

{% admonition type="info" name="Searching based on created_at" %} + * You may use the <= or >= operators to search by created_at. + * {% /admonition %}

+ *

The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string ("="). The operator has to be compatible with the field's type (eg. you cannot search with > for a given string value as it's only compatible for integer's and dates).

+ *

| Operator | Valid Types | Description | + * | :------- | :----------------------------- | :----------------------------------------------------------- | + * | = | All | Equals | + * | != | All | Doesn't Equal | + * | IN | All | In Shortcut for OR queries Values most be in Array | + * | NIN | All | Not In Shortcut for OR ! queries Values must be in Array | + * | > | Integer Date (UNIX Timestamp) | Greater (or equal) than | + * | < | Integer Date (UNIX Timestamp) | Lower (or equal) than | + * | ~ | String | Contains | + * | !~ | String | Doesn't Contain | + * | ^ | String | Starts With | + * | $ | String | Ends With |

+ */ + public CompletableFuture> search(SearchRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("tickets/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()) { + TicketList parsedResponse = + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TicketList.class); + Optional startingAfter = parsedResponse + .getPages() + .flatMap(CursorPages::getNext) + .flatMap(StartingAfterPaging::getStartingAfter); + Optional pagination = request.getPagination() + .map(pagination_ -> StartingAfterPaging.builder() + .from(pagination_) + .startingAfter(startingAfter) + .build()); + SearchRequest nextRequest = SearchRequest.builder() + .from(request) + .pagination(pagination) + .build(); + List result = parsedResponse.getTickets(); + future.complete(new SyncPagingIterable(startingAfter.isPresent(), result, () -> { + try { + return search(nextRequest, requestOptions).get(); + } catch (InterruptedException | ExecutionException e) { + throw new RuntimeException(e); + } + })); + 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))); + 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/tickets/TicketsClient.java b/src/main/java/com/intercom/api/resources/tickets/TicketsClient.java new file mode 100644 index 00000000..a1e6ce3a --- /dev/null +++ b/src/main/java/com/intercom/api/resources/tickets/TicketsClient.java @@ -0,0 +1,440 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.tickets; + +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.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.core.pagination.SyncPagingIterable; +import com.intercom.api.errors.BadRequestError; +import com.intercom.api.errors.NotFoundError; +import com.intercom.api.errors.UnauthorizedError; +import com.intercom.api.resources.tickets.requests.CreateTicketRequest; +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.Ticket; +import com.intercom.api.types.CursorPages; +import com.intercom.api.types.Error; +import com.intercom.api.types.SearchRequest; +import com.intercom.api.types.StartingAfterPaging; +import com.intercom.api.types.TicketList; +import com.intercom.api.types.TicketReply; +import java.io.IOException; +import java.util.List; +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 TicketsClient { + protected final ClientOptions clientOptions; + + public TicketsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can reply to a ticket with a message from an admin or on behalf of a contact, or with a note for admins. + */ + public TicketReply reply(ReplyToTicketRequest request) { + return reply(request, null); + } + + /** + * You can reply to a ticket with a message from an admin or on behalf of a contact, or with a note for admins. + */ + public TicketReply reply(ReplyToTicketRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("tickets") + .addPathSegment(request.getTicketId()) + .addPathSegments("reply") + .build(); + RequestBody body; + try { + 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("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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TicketReply.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can create a new ticket. + */ + public Ticket create(CreateTicketRequest request) { + return create(request, null); + } + + /** + * You can create a new ticket. + */ + public Ticket create(CreateTicketRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("tickets") + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Ticket.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can fetch the details of a single ticket. + */ + public Ticket get(FindTicketRequest request) { + return get(request, null); + } + + /** + * You can fetch the details of a single ticket. + */ + public Ticket get(FindTicketRequest 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("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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Ticket.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can update a ticket. + */ + public Ticket update(UpdateTicketRequest request) { + return update(request, null); + } + + /** + * You can update a ticket. + */ + public Ticket update(UpdateTicketRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("tickets") + .addPathSegment(request.getTicketId()) + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Ticket.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can search for multiple tickets by the value of their attributes in order to fetch exactly which ones you want. + *

To search for tickets, you send a POST request to https://api.intercom.io/tickets/search.

+ *

This will accept a query object in the body which will define your filters. + * {% admonition type="warning" name="Optimizing search queries" %} + * Search queries can be complex, so optimizing them can help the performance of your search. + * Use the AND and OR operators to combine multiple filters to get the exact results you need and utilize + * pagination to limit the number of results returned. The default is 20 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ *

Nesting & Limitations

+ *

You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). + * There are some limitations to the amount of multiples there can be:

+ *
    + *
  • There's a limit of max 2 nested filters
  • + *
  • There's a limit of max 15 filters for each AND or OR group
  • + *
+ *

Accepted Fields

+ *

Most keys listed as part of the Ticket model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as created_at accepts a date, the value cannot be a string such as "foobar").

+ *

| Field | Type | + * | :---------------------------------------- | :--------------------------------------------------------------------------------------- | + * | id | String | + * | created_at | Date (UNIX timestamp) | + * | updated_at | Date (UNIX timestamp) | + * | default_title | String | + * | default_description | String | + * | category | String | + * | ticket_type_id | String | + * | contact_ids | String | + * | teammate_ids | String | + * | admin_assignee_id | String | + * | team_assignee_id | String | + * | open | Boolean | + * | state | String | + * | snoozed_until | Date (UNIX timestamp) | + * | ticket_attribute.{id} | String or Boolean or Date (UNIX timestamp) or Float or Integer |

+ *

Accepted Operators

+ *

{% admonition type="info" name="Searching based on created_at" %} + * You may use the <= or >= operators to search by created_at. + * {% /admonition %}

+ *

The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string ("="). The operator has to be compatible with the field's type (eg. you cannot search with > for a given string value as it's only compatible for integer's and dates).

+ *

| Operator | Valid Types | Description | + * | :------- | :----------------------------- | :----------------------------------------------------------- | + * | = | All | Equals | + * | != | All | Doesn't Equal | + * | IN | All | In Shortcut for OR queries Values most be in Array | + * | NIN | All | Not In Shortcut for OR ! queries Values must be in Array | + * | > | Integer Date (UNIX Timestamp) | Greater (or equal) than | + * | < | Integer Date (UNIX Timestamp) | Lower (or equal) than | + * | ~ | String | Contains | + * | !~ | String | Doesn't Contain | + * | ^ | String | Starts With | + * | $ | String | Ends With |

+ */ + public SyncPagingIterable search(SearchRequest request) { + return search(request, null); + } + + /** + * You can search for multiple tickets by the value of their attributes in order to fetch exactly which ones you want. + *

To search for tickets, you send a POST request to https://api.intercom.io/tickets/search.

+ *

This will accept a query object in the body which will define your filters. + * {% admonition type="warning" name="Optimizing search queries" %} + * Search queries can be complex, so optimizing them can help the performance of your search. + * Use the AND and OR operators to combine multiple filters to get the exact results you need and utilize + * pagination to limit the number of results returned. The default is 20 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ *

Nesting & Limitations

+ *

You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). + * There are some limitations to the amount of multiples there can be:

+ *
    + *
  • There's a limit of max 2 nested filters
  • + *
  • There's a limit of max 15 filters for each AND or OR group
  • + *
+ *

Accepted Fields

+ *

Most keys listed as part of the Ticket model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as created_at accepts a date, the value cannot be a string such as "foobar").

+ *

| Field | Type | + * | :---------------------------------------- | :--------------------------------------------------------------------------------------- | + * | id | String | + * | created_at | Date (UNIX timestamp) | + * | updated_at | Date (UNIX timestamp) | + * | default_title | String | + * | default_description | String | + * | category | String | + * | ticket_type_id | String | + * | contact_ids | String | + * | teammate_ids | String | + * | admin_assignee_id | String | + * | team_assignee_id | String | + * | open | Boolean | + * | state | String | + * | snoozed_until | Date (UNIX timestamp) | + * | ticket_attribute.{id} | String or Boolean or Date (UNIX timestamp) or Float or Integer |

+ *

Accepted Operators

+ *

{% admonition type="info" name="Searching based on created_at" %} + * You may use the <= or >= operators to search by created_at. + * {% /admonition %}

+ *

The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string ("="). The operator has to be compatible with the field's type (eg. you cannot search with > for a given string value as it's only compatible for integer's and dates).

+ *

| Operator | Valid Types | Description | + * | :------- | :----------------------------- | :----------------------------------------------------------- | + * | = | All | Equals | + * | != | All | Doesn't Equal | + * | IN | All | In Shortcut for OR queries Values most be in Array | + * | NIN | All | Not In Shortcut for OR ! queries Values must be in Array | + * | > | Integer Date (UNIX Timestamp) | Greater (or equal) than | + * | < | Integer Date (UNIX Timestamp) | Lower (or equal) than | + * | ~ | String | Contains | + * | !~ | String | Doesn't Contain | + * | ^ | String | Starts With | + * | $ | String | Ends With |

+ */ + public SyncPagingIterable search(SearchRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("tickets/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()) { + TicketList parsedResponse = + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TicketList.class); + Optional startingAfter = parsedResponse + .getPages() + .flatMap(CursorPages::getNext) + .flatMap(StartingAfterPaging::getStartingAfter); + Optional pagination = request.getPagination() + .map(pagination_ -> StartingAfterPaging.builder() + .from(pagination_) + .startingAfter(startingAfter) + .build()); + SearchRequest nextRequest = SearchRequest.builder() + .from(request) + .pagination(pagination) + .build(); + List result = parsedResponse.getTickets(); + return new SyncPagingIterable( + startingAfter.isPresent(), result, () -> search(nextRequest, requestOptions)); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} 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 00000000..1ff1dd17 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/tickets/requests/CreateTicketRequest.java @@ -0,0 +1,747 @@ +/** + * 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.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 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 { + private final String ticketTypeId; + + private final List contacts; + + private final Optional companyId; + + private final Optional createdAt; + + private final Optional> ticketAttributes; + + private final Map additionalProperties; + + private CreateTicketRequest( + String ticketTypeId, + List contacts, + Optional companyId, + Optional createdAt, + Optional> ticketAttributes, + Map additionalProperties) { + this.ticketTypeId = ticketTypeId; + this.contacts = contacts; + this.companyId = companyId; + this.createdAt = createdAt; + this.ticketAttributes = ticketAttributes; + 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 company that the ticket is associated with. The ID that you set upon company creation. + */ + @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("ticket_attributes") + public Optional> getTicketAttributes() { + return ticketAttributes; + } + + @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) + && companyId.equals(other.companyId) + && createdAt.equals(other.createdAt) + && ticketAttributes.equals(other.ticketAttributes); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.ticketTypeId, this.contacts, this.companyId, this.createdAt, this.ticketAttributes); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TicketTypeIdStage builder() { + return new Builder(); + } + + public interface TicketTypeIdStage { + _FinalStage ticketTypeId(@NotNull String ticketTypeId); + + Builder from(CreateTicketRequest other); + } + + public interface _FinalStage { + CreateTicketRequest build(); + + _FinalStage contacts(List contacts); + + _FinalStage addContacts(ContactsItem contacts); + + _FinalStage addAllContacts(List contacts); + + _FinalStage companyId(Optional companyId); + + _FinalStage companyId(String companyId); + + _FinalStage createdAt(Optional createdAt); + + _FinalStage createdAt(Integer createdAt); + + _FinalStage ticketAttributes(Optional> ticketAttributes); + + _FinalStage ticketAttributes(Map ticketAttributes); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements TicketTypeIdStage, _FinalStage { + private String ticketTypeId; + + private Optional> ticketAttributes = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + private Optional companyId = 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()); + companyId(other.getCompanyId()); + createdAt(other.getCreatedAt()); + ticketAttributes(other.getTicketAttributes()); + return this; + } + + /** + *

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; + } + + @java.lang.Override + public _FinalStage ticketAttributes(Map ticketAttributes) { + this.ticketAttributes = Optional.ofNullable(ticketAttributes); + return this; + } + + @java.lang.Override + @JsonSetter(value = "ticket_attributes", nulls = Nulls.SKIP) + public _FinalStage ticketAttributes(Optional> ticketAttributes) { + this.ticketAttributes = ticketAttributes; + 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; + } + + @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 ID that you set upon company creation.

+ * @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; + } + + @java.lang.Override + @JsonSetter(value = "company_id", nulls = Nulls.SKIP) + public _FinalStage companyId(Optional companyId) { + this.companyId = companyId; + 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; + } + + @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, companyId, createdAt, ticketAttributes, additionalProperties); + } + } + + @JsonDeserialize(using = TicketAttributesValue.Deserializer.class) + public static final class TicketAttributesValue { + private final Object value; + + private final int type; + + private TicketAttributesValue(Object value, int type) { + this.value = value; + this.type = type; + } + + @JsonValue + public Object get() { + return this.value; + } + + public T visit(Visitor visitor) { + if (this.type == 0) { + return visitor.visit((Optional) this.value); + } else if (this.type == 1) { + return visitor.visit((double) this.value); + } else if (this.type == 2) { + return visitor.visit((boolean) this.value); + } else if (this.type == 3) { + 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 TicketAttributesValue && equalTo((TicketAttributesValue) other); + } + + private boolean equalTo(TicketAttributesValue 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 TicketAttributesValue of(Optional value) { + return new TicketAttributesValue(value, 0); + } + + public static TicketAttributesValue of(double value) { + return new TicketAttributesValue(value, 1); + } + + public static TicketAttributesValue of(boolean value) { + return new TicketAttributesValue(value, 2); + } + + public static TicketAttributesValue of(List value) { + return new TicketAttributesValue(value, 3); + } + + public interface Visitor { + T visit(Optional value); + + T visit(double value); + + T visit(boolean value); + + T visit(List value); + } + + static final class Deserializer extends StdDeserializer { + Deserializer() { + super(TicketAttributesValue.class); + } + + @java.lang.Override + public TicketAttributesValue deserialize(JsonParser p, DeserializationContext context) throws IOException { + Object value = p.readValueAs(Object.class); + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, new TypeReference>() {})); + } catch (IllegalArgumentException e) { + } + if (value instanceof Double) { + return of((Double) value); + } + if (value instanceof Boolean) { + return of((Boolean) value); + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, new TypeReference>() {})); + } catch (IllegalArgumentException e) { + } + throw new JsonParseException(p, "Failed to deserialize"); + } + } + } + + @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; + } + + 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 = 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 { + _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.

+ * @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 { + _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.

+ * @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 = 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 { + _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.

+ * @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); + } + } + } + } +} diff --git a/src/main/java/com/intercom/api/resources/tickets/requests/FindTicketRequest.java b/src/main/java/com/intercom/api/resources/tickets/requests/FindTicketRequest.java new file mode 100644 index 00000000..23933159 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/tickets/requests/FindTicketRequest.java @@ -0,0 +1,109 @@ +/** + * 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 = FindTicketRequest.Builder.class) +public final class FindTicketRequest { + private final String ticketId; + + private final Map additionalProperties; + + private FindTicketRequest(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 FindTicketRequest && equalTo((FindTicketRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(FindTicketRequest 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 { + _FinalStage ticketId(@NotNull String ticketId); + + Builder from(FindTicketRequest other); + } + + public interface _FinalStage { + FindTicketRequest 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(FindTicketRequest other) { + ticketId(other.getTicketId()); + return this; + } + + /** + *

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 FindTicketRequest build() { + return new FindTicketRequest(ticketId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/tickets/requests/ReplyToTicketRequest.java b/src/main/java/com/intercom/api/resources/tickets/requests/ReplyToTicketRequest.java new file mode 100644 index 00000000..704faf36 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/tickets/requests/ReplyToTicketRequest.java @@ -0,0 +1,126 @@ +/** + * 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 com.intercom.api.resources.tickets.types.TicketsReplyRequestBody; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ReplyToTicketRequest.Builder.class) +public final class ReplyToTicketRequest { + private final String ticketId; + + private final TicketsReplyRequestBody body; + + private final Map additionalProperties; + + private ReplyToTicketRequest( + String ticketId, TicketsReplyRequestBody body, Map additionalProperties) { + this.ticketId = ticketId; + this.body = body; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("ticket_id") + public String getTicketId() { + return ticketId; + } + + @JsonProperty("body") + public TicketsReplyRequestBody getBody() { + return body; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ReplyToTicketRequest && equalTo((ReplyToTicketRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ReplyToTicketRequest other) { + return ticketId.equals(other.ticketId) && body.equals(other.body); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.ticketId, this.body); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TicketIdStage builder() { + return new Builder(); + } + + public interface TicketIdStage { + BodyStage ticketId(@NotNull String ticketId); + + Builder from(ReplyToTicketRequest other); + } + + public interface BodyStage { + _FinalStage body(@NotNull TicketsReplyRequestBody body); + } + + public interface _FinalStage { + ReplyToTicketRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements TicketIdStage, BodyStage, _FinalStage { + private String ticketId; + + private TicketsReplyRequestBody body; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ReplyToTicketRequest other) { + ticketId(other.getTicketId()); + body(other.getBody()); + return this; + } + + @java.lang.Override + @JsonSetter("ticket_id") + public BodyStage ticketId(@NotNull String ticketId) { + this.ticketId = Objects.requireNonNull(ticketId, "ticketId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("body") + public _FinalStage body(@NotNull TicketsReplyRequestBody body) { + this.body = Objects.requireNonNull(body, "body must not be null"); + return this; + } + + @java.lang.Override + public ReplyToTicketRequest build() { + return new ReplyToTicketRequest(ticketId, body, 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 new file mode 100644 index 00000000..4f4f1a86 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/tickets/requests/UpdateTicketRequest.java @@ -0,0 +1,529 @@ +/** + * 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.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 = UpdateTicketRequest.Builder.class) +public final class UpdateTicketRequest { + private final String ticketId; + + private final Optional> ticketAttributes; + + private final Optional state; + + private final Optional open; + + private final Optional isShared; + + private final Optional snoozedUntil; + + private final Optional assignment; + + private final Map additionalProperties; + + private UpdateTicketRequest( + String ticketId, + Optional> ticketAttributes, + Optional state, + Optional open, + Optional isShared, + Optional snoozedUntil, + Optional assignment, + Map additionalProperties) { + this.ticketId = ticketId; + this.ticketAttributes = ticketAttributes; + this.state = state; + this.open = open; + this.isShared = isShared; + this.snoozedUntil = snoozedUntil; + this.assignment = assignment; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the ticket which is given by Intercom + */ + @JsonProperty("ticket_id") + public String getTicketId() { + return ticketId; + } + + /** + * @return The attributes set on the ticket. + */ + @JsonProperty("ticket_attributes") + public Optional> getTicketAttributes() { + return ticketAttributes; + } + + /** + * @return The state of the ticket. + */ + @JsonProperty("state") + public Optional getState() { + return state; + } + + /** + * @return Specify if a ticket is open. Set to false to close a ticket. Closing a ticket will also unsnooze it. + */ + @JsonProperty("open") + public Optional getOpen() { + return open; + } + + /** + * @return Specify whether the ticket is visible to users. + */ + @JsonProperty("is_shared") + public Optional getIsShared() { + return isShared; + } + + /** + * @return The time you want the ticket to reopen. + */ + @JsonProperty("snoozed_until") + public Optional getSnoozedUntil() { + return snoozedUntil; + } + + @JsonProperty("assignment") + public Optional getAssignment() { + return assignment; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UpdateTicketRequest && equalTo((UpdateTicketRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UpdateTicketRequest other) { + return ticketId.equals(other.ticketId) + && ticketAttributes.equals(other.ticketAttributes) + && state.equals(other.state) + && open.equals(other.open) + && isShared.equals(other.isShared) + && snoozedUntil.equals(other.snoozedUntil) + && assignment.equals(other.assignment); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.ticketId, + this.ticketAttributes, + this.state, + this.open, + this.isShared, + this.snoozedUntil, + this.assignment); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TicketIdStage builder() { + return new Builder(); + } + + public interface TicketIdStage { + _FinalStage ticketId(@NotNull String ticketId); + + Builder from(UpdateTicketRequest other); + } + + public interface _FinalStage { + UpdateTicketRequest build(); + + _FinalStage ticketAttributes(Optional> ticketAttributes); + + _FinalStage ticketAttributes(Map ticketAttributes); + + _FinalStage state(Optional state); + + _FinalStage state(State state); + + _FinalStage open(Optional open); + + _FinalStage open(Boolean open); + + _FinalStage isShared(Optional isShared); + + _FinalStage isShared(Boolean isShared); + + _FinalStage snoozedUntil(Optional snoozedUntil); + + _FinalStage snoozedUntil(Integer snoozedUntil); + + _FinalStage assignment(Optional assignment); + + _FinalStage assignment(Assignment assignment); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements TicketIdStage, _FinalStage { + private String ticketId; + + private Optional assignment = Optional.empty(); + + private Optional snoozedUntil = Optional.empty(); + + private Optional isShared = Optional.empty(); + + private Optional open = Optional.empty(); + + private Optional state = Optional.empty(); + + private Optional> ticketAttributes = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(UpdateTicketRequest other) { + ticketId(other.getTicketId()); + ticketAttributes(other.getTicketAttributes()); + state(other.getState()); + open(other.getOpen()); + isShared(other.getIsShared()); + snoozedUntil(other.getSnoozedUntil()); + assignment(other.getAssignment()); + return this; + } + + /** + *

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 _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 you want the ticket to reopen.

+ * @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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "snoozed_until", nulls = Nulls.SKIP) + public _FinalStage snoozedUntil(Optional snoozedUntil) { + this.snoozedUntil = snoozedUntil; + return this; + } + + /** + *

Specify whether the ticket is visible to users.

+ * @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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "is_shared", nulls = Nulls.SKIP) + public _FinalStage isShared(Optional isShared) { + this.isShared = isShared; + return this; + } + + /** + *

Specify if a ticket is open. Set to false to close a ticket. Closing a ticket will also unsnooze it.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage open(Boolean open) { + this.open = Optional.ofNullable(open); + return this; + } + + @java.lang.Override + @JsonSetter(value = "open", nulls = Nulls.SKIP) + public _FinalStage open(Optional open) { + this.open = open; + return this; + } + + /** + *

The state of the ticket.

+ * @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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "state", nulls = Nulls.SKIP) + public _FinalStage state(Optional state) { + this.state = state; + return this; + } + + /** + *

The attributes set on the ticket.

+ * @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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "ticket_attributes", nulls = Nulls.SKIP) + public _FinalStage ticketAttributes(Optional> ticketAttributes) { + this.ticketAttributes = ticketAttributes; + return this; + } + + @java.lang.Override + public UpdateTicketRequest build() { + return new UpdateTicketRequest( + ticketId, ticketAttributes, state, open, isShared, snoozedUntil, assignment, additionalProperties); + } + } + + public 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. + */ + @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 + 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); + } + + @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; + } + + @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; + } + + @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); + } + } + } +} 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 new file mode 100644 index 00000000..c494b98e --- /dev/null +++ b/src/main/java/com/intercom/api/resources/tickets/types/Ticket.java @@ -0,0 +1,1047 @@ +/** + * 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.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.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.FileAttribute; +import com.intercom.api.types.LinkedObjectList; +import com.intercom.api.types.TicketParts; +import java.io.IOException; +import java.util.HashMap; +import java.util.LinkedHashMap; +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 = Ticket.Builder.class) +public final class Ticket { + private final String id; + + private final String ticketId; + + private final Category category; + + private final Map ticketAttributes; + + private final TicketState ticketState; + + private final TicketType ticketType; + + private final TicketContacts contacts; + + private final Optional adminAssigneeId; + + private final Optional teamAssigneeId; + + private final Optional createdAt; + + private final Optional updatedAt; + + private final Optional open; + + private final Optional snoozedUntil; + + private final Optional linkedObjects; + + private final Optional ticketParts; + + 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 adminAssigneeId, + Optional teamAssigneeId, + Optional createdAt, + Optional updatedAt, + Optional open, + Optional snoozedUntil, + Optional linkedObjects, + Optional ticketParts, + Optional isShared, + Optional ticketStateInternalLabel, + Optional ticketStateExternalLabel, + Map additionalProperties) { + this.id = id; + this.ticketId = ticketId; + this.category = category; + this.ticketAttributes = ticketAttributes; + this.ticketState = ticketState; + this.ticketType = ticketType; + this.contacts = contacts; + this.adminAssigneeId = adminAssigneeId; + this.teamAssigneeId = teamAssigneeId; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.open = open; + this.snoozedUntil = snoozedUntil; + this.linkedObjects = linkedObjects; + this.ticketParts = ticketParts; + this.isShared = isShared; + this.ticketStateInternalLabel = ticketStateInternalLabel; + this.ticketStateExternalLabel = ticketStateExternalLabel; + this.additionalProperties = additionalProperties; + } + + /** + * @return Always ticket + */ + @JsonProperty("type") + public String getType() { + return "ticket"; + } + + /** + * @return The unique identifier for the ticket which is given by Intercom. + */ + @JsonProperty("id") + public String getId() { + return id; + } + + /** + * @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() { + return ticketId; + } + + /** + * @return Category of the Ticket. + */ + @JsonProperty("category") + public Category getCategory() { + return category; + } + + @JsonProperty("ticket_attributes") + public Map getTicketAttributes() { + return ticketAttributes; + } + + /** + * @return The state the ticket is currently in + */ + @JsonProperty("ticket_state") + public TicketState getTicketState() { + return ticketState; + } + + @JsonProperty("ticket_type") + public TicketType getTicketType() { + return ticketType; + } + + @JsonProperty("contacts") + public TicketContacts getContacts() { + return contacts; + } + + /** + * @return The id representing the admin assigned to the ticket. + */ + @JsonProperty("admin_assignee_id") + public Optional getAdminAssigneeId() { + return adminAssigneeId; + } + + /** + * @return The id representing the team assigned to the ticket. + */ + @JsonProperty("team_assignee_id") + public Optional getTeamAssigneeId() { + return teamAssigneeId; + } + + /** + * @return The time the ticket was created as a UTC Unix timestamp. + */ + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + /** + * @return The last time the ticket was updated as a UTC Unix timestamp. + */ + @JsonProperty("updated_at") + public Optional getUpdatedAt() { + return updatedAt; + } + + /** + * @return Whether or not the ticket is open. If false, the ticket is closed. + */ + @JsonProperty("open") + public Optional getOpen() { + return open; + } + + /** + * @return The time the ticket will be snoozed until as a UTC Unix timestamp. If null, the ticket is not currently snoozed. + */ + @JsonProperty("snoozed_until") + public Optional getSnoozedUntil() { + return snoozedUntil; + } + + @JsonProperty("linked_objects") + public Optional getLinkedObjects() { + return linkedObjects; + } + + @JsonProperty("ticket_parts") + public Optional getTicketParts() { + return ticketParts; + } + + /** + * @return Whether or not the ticket is shared with the customer. + */ + @JsonProperty("is_shared") + 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; + return other instanceof Ticket && equalTo((Ticket) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Ticket other) { + return id.equals(other.id) + && ticketId.equals(other.ticketId) + && category.equals(other.category) + && ticketAttributes.equals(other.ticketAttributes) + && ticketState.equals(other.ticketState) + && ticketType.equals(other.ticketType) + && contacts.equals(other.contacts) + && adminAssigneeId.equals(other.adminAssigneeId) + && teamAssigneeId.equals(other.teamAssigneeId) + && createdAt.equals(other.createdAt) + && updatedAt.equals(other.updatedAt) + && open.equals(other.open) + && snoozedUntil.equals(other.snoozedUntil) + && linkedObjects.equals(other.linkedObjects) + && ticketParts.equals(other.ticketParts) + && isShared.equals(other.isShared) + && ticketStateInternalLabel.equals(other.ticketStateInternalLabel) + && ticketStateExternalLabel.equals(other.ticketStateExternalLabel); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.id, + this.ticketId, + this.category, + this.ticketAttributes, + this.ticketState, + this.ticketType, + this.contacts, + this.adminAssigneeId, + this.teamAssigneeId, + this.createdAt, + this.updatedAt, + this.open, + this.snoozedUntil, + this.linkedObjects, + this.ticketParts, + this.isShared, + this.ticketStateInternalLabel, + this.ticketStateExternalLabel); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + TicketIdStage id(@NotNull String id); + + Builder from(Ticket other); + } + + public interface TicketIdStage { + CategoryStage ticketId(@NotNull String ticketId); + } + + public interface CategoryStage { + TicketStateStage category(@NotNull Category category); + } + + public interface TicketStateStage { + 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, TicketAttributesValue value); + + _FinalStage adminAssigneeId(Optional adminAssigneeId); + + _FinalStage adminAssigneeId(String adminAssigneeId); + + _FinalStage teamAssigneeId(Optional teamAssigneeId); + + _FinalStage teamAssigneeId(String teamAssigneeId); + + _FinalStage createdAt(Optional createdAt); + + _FinalStage createdAt(Integer createdAt); + + _FinalStage updatedAt(Optional updatedAt); + + _FinalStage updatedAt(Integer updatedAt); + + _FinalStage open(Optional open); + + _FinalStage open(Boolean open); + + _FinalStage snoozedUntil(Optional snoozedUntil); + + _FinalStage snoozedUntil(Integer snoozedUntil); + + _FinalStage linkedObjects(Optional linkedObjects); + + _FinalStage linkedObjects(LinkedObjectList linkedObjects); + + _FinalStage ticketParts(Optional ticketParts); + + _FinalStage ticketParts(TicketParts ticketParts); + + _FinalStage isShared(Optional isShared); + + _FinalStage isShared(Boolean isShared); + + _FinalStage ticketStateInternalLabel(Optional ticketStateInternalLabel); + + _FinalStage ticketStateInternalLabel(String ticketStateInternalLabel); + + _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; + + private String ticketId; + + private Category category; + + private TicketState ticketState; + + private TicketType ticketType; + + private TicketContacts contacts; + + private Optional ticketStateExternalLabel = Optional.empty(); + + private Optional ticketStateInternalLabel = Optional.empty(); + + private Optional isShared = Optional.empty(); + + private Optional ticketParts = Optional.empty(); + + private Optional linkedObjects = Optional.empty(); + + private Optional snoozedUntil = Optional.empty(); + + private Optional open = Optional.empty(); + + private Optional updatedAt = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + private Optional teamAssigneeId = Optional.empty(); + + private Optional adminAssigneeId = Optional.empty(); + + private Map ticketAttributes = new LinkedHashMap<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(Ticket other) { + id(other.getId()); + ticketId(other.getTicketId()); + category(other.getCategory()); + ticketAttributes(other.getTicketAttributes()); + ticketState(other.getTicketState()); + ticketType(other.getTicketType()); + contacts(other.getContacts()); + adminAssigneeId(other.getAdminAssigneeId()); + teamAssigneeId(other.getTeamAssigneeId()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + open(other.getOpen()); + snoozedUntil(other.getSnoozedUntil()); + 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.

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

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"); + return this; + } + + /** + *

Category of the Ticket.

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

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"); + return this; + } + + @java.lang.Override + @JsonSetter("ticket_type") + public ContactsStage ticketType(@NotNull TicketType ticketType) { + this.ticketType = Objects.requireNonNull(ticketType, "ticketType must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("contacts") + public _FinalStage contacts(@NotNull TicketContacts contacts) { + this.contacts = Objects.requireNonNull(contacts, "contacts must not be null"); + 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. + */ + @java.lang.Override + public _FinalStage ticketStateExternalLabel(String ticketStateExternalLabel) { + this.ticketStateExternalLabel = Optional.ofNullable(ticketStateExternalLabel); + return this; + } + + @java.lang.Override + @JsonSetter(value = "ticket_state_external_label", nulls = Nulls.SKIP) + public _FinalStage ticketStateExternalLabel(Optional ticketStateExternalLabel) { + this.ticketStateExternalLabel = ticketStateExternalLabel; + 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "ticket_state_internal_label", nulls = Nulls.SKIP) + public _FinalStage ticketStateInternalLabel(Optional ticketStateInternalLabel) { + this.ticketStateInternalLabel = ticketStateInternalLabel; + 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "is_shared", nulls = Nulls.SKIP) + public _FinalStage isShared(Optional isShared) { + this.isShared = isShared; + return this; + } + + @java.lang.Override + public _FinalStage ticketParts(TicketParts ticketParts) { + this.ticketParts = Optional.ofNullable(ticketParts); + return this; + } + + @java.lang.Override + @JsonSetter(value = "ticket_parts", nulls = Nulls.SKIP) + public _FinalStage ticketParts(Optional ticketParts) { + this.ticketParts = ticketParts; + return this; + } + + @java.lang.Override + public _FinalStage linkedObjects(LinkedObjectList linkedObjects) { + this.linkedObjects = Optional.ofNullable(linkedObjects); + return this; + } + + @java.lang.Override + @JsonSetter(value = "linked_objects", nulls = Nulls.SKIP) + public _FinalStage linkedObjects(Optional linkedObjects) { + this.linkedObjects = linkedObjects; + 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. + */ + @java.lang.Override + public _FinalStage snoozedUntil(Integer snoozedUntil) { + this.snoozedUntil = Optional.ofNullable(snoozedUntil); + return this; + } + + @java.lang.Override + @JsonSetter(value = "snoozed_until", nulls = Nulls.SKIP) + public _FinalStage snoozedUntil(Optional snoozedUntil) { + this.snoozedUntil = snoozedUntil; + 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. + */ + @java.lang.Override + public _FinalStage open(Boolean open) { + this.open = Optional.ofNullable(open); + return this; + } + + @java.lang.Override + @JsonSetter(value = "open", nulls = Nulls.SKIP) + public _FinalStage open(Optional open) { + this.open = open; + 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. + */ + @java.lang.Override + public _FinalStage updatedAt(Integer updatedAt) { + this.updatedAt = Optional.ofNullable(updatedAt); + return this; + } + + @java.lang.Override + @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) + public _FinalStage 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public _FinalStage createdAt(Optional createdAt) { + this.createdAt = createdAt; + 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "team_assignee_id", nulls = Nulls.SKIP) + public _FinalStage teamAssigneeId(Optional teamAssigneeId) { + this.teamAssigneeId = teamAssigneeId; + 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "admin_assignee_id", nulls = Nulls.SKIP) + public _FinalStage adminAssigneeId(Optional adminAssigneeId) { + this.adminAssigneeId = adminAssigneeId; + return this; + } + + @java.lang.Override + public _FinalStage ticketAttributes(String key, TicketAttributesValue value) { + this.ticketAttributes.put(key, value); + return this; + } + + @java.lang.Override + public _FinalStage putAllTicketAttributes(Map ticketAttributes) { + this.ticketAttributes.putAll(ticketAttributes); + return this; + } + + @java.lang.Override + @JsonSetter(value = "ticket_attributes", nulls = Nulls.SKIP) + public _FinalStage ticketAttributes(Map ticketAttributes) { + this.ticketAttributes.clear(); + this.ticketAttributes.putAll(ticketAttributes); + return this; + } + + @java.lang.Override + public Ticket build() { + return new Ticket( + id, + ticketId, + category, + ticketAttributes, + ticketState, + ticketType, + contacts, + adminAssigneeId, + teamAssigneeId, + createdAt, + updatedAt, + open, + snoozedUntil, + linkedObjects, + ticketParts, + isShared, + ticketStateInternalLabel, + ticketStateExternalLabel, + additionalProperties); + } + } + + public 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 final class Category { + public static final Category BACK_OFFICE = new Category(Value.BACK_OFFICE, "Back-office"); + + public static final Category CUSTOMER = new Category(Value.CUSTOMER, "Customer"); + + public static final Category TRACKER = new Category(Value.TRACKER, "Tracker"); + + private final Value value; + + private final String string; + + Category(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 Category && this.string.equals(((Category) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case BACK_OFFICE: + return visitor.visitBackOffice(); + case CUSTOMER: + return visitor.visitCustomer(); + case TRACKER: + return visitor.visitTracker(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static Category valueOf(String value) { + switch (value) { + case "Back-office": + return BACK_OFFICE; + case "Customer": + return CUSTOMER; + case "Tracker": + return TRACKER; + default: + return new Category(Value.UNKNOWN, value); + } + } + + public enum Value { + CUSTOMER, + + BACK_OFFICE, + + TRACKER, + + UNKNOWN + } + + public interface Visitor { + T visitCustomer(); + + T visitBackOffice(); + + T visitTracker(); + + T visitUnknown(String unknownType); + } + } + + @JsonDeserialize(using = TicketAttributesValue.Deserializer.class) + public static final class TicketAttributesValue { + private final Object value; + + private final int type; + + private TicketAttributesValue(Object value, int type) { + this.value = value; + this.type = type; + } + + @JsonValue + public Object get() { + return this.value; + } + + public T visit(Visitor visitor) { + if (this.type == 0) { + return visitor.visit((Optional) this.value); + } else if (this.type == 1) { + return visitor.visit((double) this.value); + } else if (this.type == 2) { + return visitor.visit((boolean) this.value); + } else if (this.type == 3) { + return visitor.visit((List) this.value); + } else if (this.type == 4) { + return visitor.visit((FileAttribute) 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 TicketAttributesValue && equalTo((TicketAttributesValue) other); + } + + private boolean equalTo(TicketAttributesValue 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 TicketAttributesValue of(Optional value) { + return new TicketAttributesValue(value, 0); + } + + public static TicketAttributesValue of(double value) { + return new TicketAttributesValue(value, 1); + } + + public static TicketAttributesValue of(boolean value) { + return new TicketAttributesValue(value, 2); + } + + public static TicketAttributesValue of(List value) { + return new TicketAttributesValue(value, 3); + } + + public static TicketAttributesValue of(FileAttribute value) { + return new TicketAttributesValue(value, 4); + } + + public interface Visitor { + T visit(Optional value); + + T visit(double value); + + T visit(boolean value); + + T visit(List value); + + T visit(FileAttribute value); + } + + static final class Deserializer extends StdDeserializer { + Deserializer() { + super(TicketAttributesValue.class); + } + + @java.lang.Override + public TicketAttributesValue deserialize(JsonParser p, DeserializationContext context) throws IOException { + Object value = p.readValueAs(Object.class); + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, new TypeReference>() {})); + } catch (IllegalArgumentException e) { + } + if (value instanceof Double) { + return of((Double) value); + } + if (value instanceof Boolean) { + return of((Boolean) value); + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, new TypeReference>() {})); + } catch (IllegalArgumentException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, FileAttribute.class)); + } catch (IllegalArgumentException e) { + } + throw new JsonParseException(p, "Failed to deserialize"); + } + } + } +} 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 new file mode 100644 index 00000000..925d6171 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/tickets/types/TicketContacts.java @@ -0,0 +1,114 @@ +/** + * 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 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; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = TicketContacts.Builder.class) +public final class TicketContacts { + private final List contacts; + + private final Map additionalProperties; + + private TicketContacts(List contacts, Map additionalProperties) { + this.contacts = contacts; + this.additionalProperties = additionalProperties; + } + + /** + * @return always contact.list + */ + @JsonProperty("type") + public String getType() { + return "contact.list"; + } + + /** + * @return The list of contacts affected by this ticket. + */ + @JsonProperty("contacts") + public List getContacts() { + return contacts; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof TicketContacts && equalTo((TicketContacts) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(TicketContacts other) { + return contacts.equals(other.contacts); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.contacts); + } + + @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 contacts = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(TicketContacts other) { + contacts(other.getContacts()); + return this; + } + + @JsonSetter(value = "contacts", nulls = Nulls.SKIP) + public Builder contacts(List contacts) { + this.contacts.clear(); + this.contacts.addAll(contacts); + return this; + } + + public Builder addContacts(ContactReference contacts) { + this.contacts.add(contacts); + return this; + } + + public Builder addAllContacts(List contacts) { + this.contacts.addAll(contacts); + return this; + } + + public TicketContacts build() { + return new TicketContacts(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 new file mode 100644 index 00000000..43c56291 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/tickets/types/TicketPart.java @@ -0,0 +1,729 @@ +/** + * 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.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 com.intercom.api.types.PartAttachment; +import com.intercom.api.types.Reference; +import com.intercom.api.types.TicketPartAuthor; +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 = TicketPart.Builder.class) +public final class TicketPart { + private final String id; + + private final String partType; + + private final Optional body; + + private final Optional previousTicketState; + + private final TicketState ticketState; + + private final int createdAt; + + private final Optional updatedAt; + + private final Optional assignedTo; + + private final Optional author; + + private final Optional> attachments; + + private final Optional externalId; + + private final Optional redacted; + + private final Map additionalProperties; + + private TicketPart( + String id, + String partType, + Optional body, + Optional previousTicketState, + TicketState ticketState, + int createdAt, + Optional updatedAt, + Optional assignedTo, + Optional author, + Optional> attachments, + Optional externalId, + Optional redacted, + Map additionalProperties) { + this.id = id; + this.partType = partType; + this.body = body; + this.previousTicketState = previousTicketState; + this.ticketState = ticketState; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.assignedTo = assignedTo; + this.author = author; + this.attachments = attachments; + this.externalId = externalId; + this.redacted = redacted; + this.additionalProperties = additionalProperties; + } + + /** + * @return Always ticket_part + */ + @JsonProperty("type") + public String getType() { + return "ticket_part"; + } + + /** + * @return The id representing the ticket part. + */ + @JsonProperty("id") + public String getId() { + return id; + } + + /** + * @return The type of ticket part. + */ + @JsonProperty("part_type") + public String getPartType() { + return partType; + } + + /** + * @return The message body, which may contain HTML. + */ + @JsonProperty("body") + public Optional getBody() { + return body; + } + + /** + * @return The previous state of the ticket. + */ + @JsonProperty("previous_ticket_state") + public Optional getPreviousTicketState() { + return previousTicketState; + } + + /** + * @return The state of the ticket. + */ + @JsonProperty("ticket_state") + public TicketState getTicketState() { + return ticketState; + } + + /** + * @return The time the ticket part was created. + */ + @JsonProperty("created_at") + public int getCreatedAt() { + return createdAt; + } + + /** + * @return The last time the ticket part was updated. + */ + @JsonProperty("updated_at") + public Optional getUpdatedAt() { + return updatedAt; + } + + /** + * @return The id of the admin that was assigned the ticket by this ticket_part (null if there has been no change in assignment.) + */ + @JsonProperty("assigned_to") + public Optional getAssignedTo() { + return assignedTo; + } + + @JsonProperty("author") + public Optional getAuthor() { + return author; + } + + /** + * @return A list of attachments for the part. + */ + @JsonProperty("attachments") + public Optional> getAttachments() { + return attachments; + } + + /** + * @return The external id of the ticket part + */ + @JsonProperty("external_id") + public Optional getExternalId() { + return externalId; + } + + /** + * @return Whether or not the ticket part has been redacted. + */ + @JsonProperty("redacted") + public Optional getRedacted() { + return redacted; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof TicketPart && equalTo((TicketPart) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(TicketPart other) { + return id.equals(other.id) + && partType.equals(other.partType) + && body.equals(other.body) + && previousTicketState.equals(other.previousTicketState) + && ticketState.equals(other.ticketState) + && createdAt == 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); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.id, + this.partType, + this.body, + this.previousTicketState, + this.ticketState, + this.createdAt, + this.updatedAt, + this.assignedTo, + this.author, + this.attachments, + this.externalId, + this.redacted); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + PartTypeStage id(@NotNull String id); + + Builder from(TicketPart other); + } + + public interface PartTypeStage { + TicketStateStage partType(@NotNull String partType); + } + + public interface TicketStateStage { + CreatedAtStage ticketState(@NotNull TicketState ticketState); + } + + public interface CreatedAtStage { + _FinalStage createdAt(int createdAt); + } + + public interface _FinalStage { + TicketPart build(); + + _FinalStage body(Optional body); + + _FinalStage body(String body); + + _FinalStage previousTicketState(Optional previousTicketState); + + _FinalStage previousTicketState(PreviousTicketState previousTicketState); + + _FinalStage updatedAt(Optional updatedAt); + + _FinalStage updatedAt(Integer updatedAt); + + _FinalStage assignedTo(Optional assignedTo); + + _FinalStage assignedTo(Reference assignedTo); + + _FinalStage author(Optional author); + + _FinalStage author(TicketPartAuthor author); + + _FinalStage attachments(Optional> attachments); + + _FinalStage attachments(List attachments); + + _FinalStage externalId(Optional externalId); + + _FinalStage externalId(String externalId); + + _FinalStage redacted(Optional redacted); + + _FinalStage redacted(Boolean redacted); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, PartTypeStage, TicketStateStage, CreatedAtStage, _FinalStage { + private String id; + + private String partType; + + private TicketState ticketState; + + private int createdAt; + + private Optional redacted = Optional.empty(); + + private Optional externalId = Optional.empty(); + + private Optional> attachments = Optional.empty(); + + private Optional author = Optional.empty(); + + private Optional assignedTo = Optional.empty(); + + private Optional updatedAt = Optional.empty(); + + private Optional previousTicketState = Optional.empty(); + + private Optional body = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(TicketPart other) { + id(other.getId()); + partType(other.getPartType()); + body(other.getBody()); + previousTicketState(other.getPreviousTicketState()); + ticketState(other.getTicketState()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + assignedTo(other.getAssignedTo()); + author(other.getAuthor()); + attachments(other.getAttachments()); + externalId(other.getExternalId()); + redacted(other.getRedacted()); + return this; + } + + /** + *

The id representing the ticket part.

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

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"); + return this; + } + + /** + *

The state of the ticket.

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

The time the ticket part was created.

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

Whether or not the ticket part has been redacted.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage redacted(Boolean redacted) { + this.redacted = Optional.ofNullable(redacted); + return this; + } + + @java.lang.Override + @JsonSetter(value = "redacted", nulls = Nulls.SKIP) + public _FinalStage redacted(Optional redacted) { + this.redacted = redacted; + return this; + } + + /** + *

The external id of the ticket part

+ * @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; + } + + @java.lang.Override + @JsonSetter(value = "external_id", nulls = Nulls.SKIP) + public _FinalStage externalId(Optional externalId) { + this.externalId = externalId; + return this; + } + + /** + *

A list of attachments for the part.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage attachments(List attachments) { + this.attachments = Optional.ofNullable(attachments); + return this; + } + + @java.lang.Override + @JsonSetter(value = "attachments", nulls = Nulls.SKIP) + public _FinalStage attachments(Optional> attachments) { + this.attachments = attachments; + return this; + } + + @java.lang.Override + public _FinalStage author(TicketPartAuthor author) { + this.author = Optional.ofNullable(author); + return this; + } + + @java.lang.Override + @JsonSetter(value = "author", nulls = Nulls.SKIP) + public _FinalStage 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "assigned_to", nulls = Nulls.SKIP) + public _FinalStage assignedTo(Optional assignedTo) { + this.assignedTo = assignedTo; + 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) + public _FinalStage updatedAt(Optional updatedAt) { + this.updatedAt = updatedAt; + 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "previous_ticket_state", nulls = Nulls.SKIP) + public _FinalStage previousTicketState(Optional previousTicketState) { + this.previousTicketState = previousTicketState; + return this; + } + + /** + *

The message body, which may contain HTML.

+ * @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; + } + + @java.lang.Override + @JsonSetter(value = "body", nulls = Nulls.SKIP) + public _FinalStage body(Optional body) { + this.body = body; + return this; + } + + @java.lang.Override + public TicketPart build() { + return new TicketPart( + id, + partType, + body, + previousTicketState, + ticketState, + createdAt, + updatedAt, + assignedTo, + author, + attachments, + externalId, + redacted, + additionalProperties); + } + } + + public final class PreviousTicketState { + public static final PreviousTicketState IN_PROGRESS = new PreviousTicketState(Value.IN_PROGRESS, "in_progress"); + + public static final PreviousTicketState SUBMITTED = new PreviousTicketState(Value.SUBMITTED, "submitted"); + + public static final PreviousTicketState RESOLVED = new PreviousTicketState(Value.RESOLVED, "resolved"); + + public static final PreviousTicketState WAITING_ON_CUSTOMER = + new PreviousTicketState(Value.WAITING_ON_CUSTOMER, "waiting_on_customer"); + + private final Value value; + + private final String string; + + PreviousTicketState(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 PreviousTicketState + && this.string.equals(((PreviousTicketState) 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 PreviousTicketState 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 PreviousTicketState(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 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); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/tickets/types/TicketType.java b/src/main/java/com/intercom/api/resources/tickets/types/TicketType.java new file mode 100644 index 00000000..ca345f98 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/tickets/types/TicketType.java @@ -0,0 +1,519 @@ +/** + * 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.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 com.intercom.api.types.TicketTypeAttributeList; +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 = TicketType.Builder.class) +public final class TicketType { + private final String id; + + private final Category category; + + private final String name; + + private final String description; + + private final String icon; + + private final String workspaceId; + + private final TicketTypeAttributeList ticketTypeAttributes; + + private final boolean archived; + + private final int createdAt; + + private final Optional updatedAt; + + private final Map additionalProperties; + + private TicketType( + String id, + Category category, + String name, + String description, + String icon, + String workspaceId, + TicketTypeAttributeList ticketTypeAttributes, + boolean archived, + int createdAt, + Optional updatedAt, + Map additionalProperties) { + this.id = id; + this.category = category; + this.name = name; + this.description = description; + this.icon = icon; + this.workspaceId = workspaceId; + this.ticketTypeAttributes = ticketTypeAttributes; + this.archived = archived; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.additionalProperties = additionalProperties; + } + + /** + * @return String representing the object's type. Always has the value ticket_type. + */ + @JsonProperty("type") + public String getType() { + return "ticket_type"; + } + + /** + * @return The id representing the ticket type. + */ + @JsonProperty("id") + public String getId() { + return id; + } + + /** + * @return Category of the Ticket Type. + */ + @JsonProperty("category") + public Category getCategory() { + return category; + } + + /** + * @return The name of the ticket type + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * @return The description of the ticket type + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * @return The icon of the ticket type + */ + @JsonProperty("icon") + public String getIcon() { + return icon; + } + + /** + * @return The id of the workspace that the ticket type belongs to. + */ + @JsonProperty("workspace_id") + public String getWorkspaceId() { + return workspaceId; + } + + @JsonProperty("ticket_type_attributes") + public TicketTypeAttributeList getTicketTypeAttributes() { + return ticketTypeAttributes; + } + + /** + * @return Whether the ticket type is archived or not. + */ + @JsonProperty("archived") + public boolean getArchived() { + return archived; + } + + /** + * @return The date and time the ticket type was created. + */ + @JsonProperty("created_at") + public int getCreatedAt() { + return createdAt; + } + + /** + * @return The date and time the ticket type was last updated. + */ + @JsonProperty("updated_at") + public Optional getUpdatedAt() { + return updatedAt; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof TicketType && equalTo((TicketType) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(TicketType other) { + return id.equals(other.id) + && category.equals(other.category) + && name.equals(other.name) + && description.equals(other.description) + && icon.equals(other.icon) + && workspaceId.equals(other.workspaceId) + && ticketTypeAttributes.equals(other.ticketTypeAttributes) + && archived == other.archived + && createdAt == other.createdAt + && updatedAt.equals(other.updatedAt); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.id, + this.category, + this.name, + this.description, + this.icon, + this.workspaceId, + this.ticketTypeAttributes, + this.archived, + this.createdAt, + this.updatedAt); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + CategoryStage id(@NotNull String id); + + Builder from(TicketType other); + } + + public interface CategoryStage { + NameStage category(@NotNull Category category); + } + + public interface NameStage { + DescriptionStage name(@NotNull String name); + } + + public interface DescriptionStage { + IconStage description(@NotNull String description); + } + + public interface IconStage { + WorkspaceIdStage icon(@NotNull String icon); + } + + public interface WorkspaceIdStage { + TicketTypeAttributesStage workspaceId(@NotNull String workspaceId); + } + + public interface TicketTypeAttributesStage { + ArchivedStage ticketTypeAttributes(@NotNull TicketTypeAttributeList ticketTypeAttributes); + } + + public interface ArchivedStage { + CreatedAtStage archived(boolean archived); + } + + public interface CreatedAtStage { + _FinalStage createdAt(int createdAt); + } + + public interface _FinalStage { + TicketType build(); + + _FinalStage updatedAt(Optional updatedAt); + + _FinalStage updatedAt(Integer updatedAt); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements IdStage, + CategoryStage, + NameStage, + DescriptionStage, + IconStage, + WorkspaceIdStage, + TicketTypeAttributesStage, + ArchivedStage, + CreatedAtStage, + _FinalStage { + private String id; + + private Category category; + + private String name; + + private String description; + + private String icon; + + private String workspaceId; + + private TicketTypeAttributeList ticketTypeAttributes; + + private boolean archived; + + private int createdAt; + + private Optional updatedAt = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(TicketType other) { + id(other.getId()); + category(other.getCategory()); + name(other.getName()); + description(other.getDescription()); + icon(other.getIcon()); + workspaceId(other.getWorkspaceId()); + ticketTypeAttributes(other.getTicketTypeAttributes()); + archived(other.getArchived()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + return this; + } + + /** + *

The id representing the ticket type.

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

Category of the Ticket Type.

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

The name of the ticket type

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

The description of the ticket type

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

The icon of the ticket type

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

The id of the workspace that the ticket type belongs to.

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

Whether the ticket type is archived or not.

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

The date and time the ticket type was created.

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

The date and time the ticket type 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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) + public _FinalStage updatedAt(Optional updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + @java.lang.Override + public TicketType build() { + return new TicketType( + id, + category, + name, + description, + icon, + workspaceId, + ticketTypeAttributes, + archived, + createdAt, + updatedAt, + additionalProperties); + } + } + + public final class Category { + public static final Category BACK_OFFICE = new Category(Value.BACK_OFFICE, "Back-office"); + + public static final Category CUSTOMER = new Category(Value.CUSTOMER, "Customer"); + + public static final Category TRACKER = new Category(Value.TRACKER, "Tracker"); + + private final Value value; + + private final String string; + + Category(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 Category && this.string.equals(((Category) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case BACK_OFFICE: + return visitor.visitBackOffice(); + case CUSTOMER: + return visitor.visitCustomer(); + case TRACKER: + return visitor.visitTracker(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static Category valueOf(String value) { + switch (value) { + case "Back-office": + return BACK_OFFICE; + case "Customer": + return CUSTOMER; + case "Tracker": + return TRACKER; + default: + return new Category(Value.UNKNOWN, value); + } + } + + public enum Value { + CUSTOMER, + + BACK_OFFICE, + + TRACKER, + + UNKNOWN + } + + public interface Visitor { + T visitCustomer(); + + T visitBackOffice(); + + T visitTracker(); + + T visitUnknown(String unknownType); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/tickets/types/TicketsReplyRequestBody.java b/src/main/java/com/intercom/api/resources/tickets/types/TicketsReplyRequestBody.java new file mode 100644 index 00000000..c2d23787 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/tickets/types/TicketsReplyRequestBody.java @@ -0,0 +1,96 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.tickets.types; + +import com.fasterxml.jackson.annotation.JsonValue; +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.AdminReplyTicketRequest; +import com.intercom.api.types.ContactReplyTicketRequest; +import java.io.IOException; +import java.util.Objects; + +@JsonDeserialize(using = TicketsReplyRequestBody.Deserializer.class) +public final class TicketsReplyRequestBody { + private final Object value; + + private final int type; + + private TicketsReplyRequestBody(Object value, int type) { + this.value = value; + this.type = type; + } + + @JsonValue + public Object get() { + return this.value; + } + + public T visit(Visitor visitor) { + if (this.type == 0) { + return visitor.visit((ContactReplyTicketRequest) this.value); + } else if (this.type == 1) { + return visitor.visit((AdminReplyTicketRequest) 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 TicketsReplyRequestBody && equalTo((TicketsReplyRequestBody) other); + } + + private boolean equalTo(TicketsReplyRequestBody 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 TicketsReplyRequestBody of(ContactReplyTicketRequest value) { + return new TicketsReplyRequestBody(value, 0); + } + + public static TicketsReplyRequestBody of(AdminReplyTicketRequest value) { + return new TicketsReplyRequestBody(value, 1); + } + + public interface Visitor { + T visit(ContactReplyTicketRequest value); + + T visit(AdminReplyTicketRequest value); + } + + static final class Deserializer extends StdDeserializer { + Deserializer() { + super(TicketsReplyRequestBody.class); + } + + @java.lang.Override + public TicketsReplyRequestBody deserialize(JsonParser p, DeserializationContext context) throws IOException { + Object value = p.readValueAs(Object.class); + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, ContactReplyTicketRequest.class)); + } catch (IllegalArgumentException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, AdminReplyTicketRequest.class)); + } catch (IllegalArgumentException e) { + } + throw new JsonParseException(p, "Failed to deserialize"); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/tickettypes/AsyncTicketTypesClient.java b/src/main/java/com/intercom/api/resources/tickettypes/AsyncTicketTypesClient.java new file mode 100644 index 00000000..6560422d --- /dev/null +++ b/src/main/java/com/intercom/api/resources/tickettypes/AsyncTicketTypesClient.java @@ -0,0 +1,336 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.tickettypes; + +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.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.core.Suppliers; +import com.intercom.api.errors.UnauthorizedError; +import com.intercom.api.resources.tickets.types.TicketType; +import com.intercom.api.resources.tickettypes.attributes.AsyncAttributesClient; +import com.intercom.api.resources.tickettypes.requests.CreateTicketTypeRequest; +import com.intercom.api.resources.tickettypes.requests.FindTicketTypeRequest; +import com.intercom.api.resources.tickettypes.requests.UpdateTicketTypeRequest; +import com.intercom.api.types.Error; +import com.intercom.api.types.TicketTypeList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import java.util.function.Supplier; +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 AsyncTicketTypesClient { + protected final ClientOptions clientOptions; + + protected final Supplier attributesClient; + + public AsyncTicketTypesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.attributesClient = Suppliers.memoize(() -> new AsyncAttributesClient(clientOptions)); + } + + /** + * You can get a list of all ticket types for a workspace. + */ + public CompletableFuture list() { + return list(null); + } + + /** + * You can get a list of all ticket types for a workspace. + */ + public CompletableFuture list(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticket_types") + .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( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TicketTypeList.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + 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))); + 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 ticket type. + *
+ *

📘 Creating ticket types.

+ *

Every ticket type will be created with two default attributes: default_title and default_description. + * For the icon propery, use an emoji from Twemoji Cheatsheet

+ *
+ */ + public CompletableFuture create(CreateTicketTypeRequest request) { + return create(request, null); + } + + /** + * You can create a new ticket type. + *
+ *

📘 Creating ticket types.

+ *

Every ticket type will be created with two default attributes: default_title and default_description. + * For the icon propery, use an emoji from Twemoji Cheatsheet

+ *
+ */ + public CompletableFuture create(CreateTicketTypeRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticket_types") + .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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TicketType.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + 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))); + 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 type. + */ + public CompletableFuture get(FindTicketTypeRequest request) { + return get(request, null); + } + + /** + * You can fetch the details of a single ticket type. + */ + public CompletableFuture get(FindTicketTypeRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticket_types") + .addPathSegment(request.getTicketTypeId()) + .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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TicketType.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + 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))); + 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 a ticket type. + *
+ *

📘 Updating a ticket type.

+ *

For the icon propery, use an emoji from Twemoji Cheatsheet

+ *
+ */ + public CompletableFuture update(UpdateTicketTypeRequest request) { + return update(request, null); + } + + /** + * You can update a ticket type. + *
+ *

📘 Updating a ticket type.

+ *

For the icon propery, use an emoji from Twemoji Cheatsheet

+ *
+ */ + public CompletableFuture update(UpdateTicketTypeRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticket_types") + .addPathSegment(request.getTicketTypeId()) + .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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TicketType.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + 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))); + 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 AsyncAttributesClient attributes() { + return this.attributesClient.get(); + } +} diff --git a/src/main/java/com/intercom/api/resources/tickettypes/TicketTypesClient.java b/src/main/java/com/intercom/api/resources/tickettypes/TicketTypesClient.java new file mode 100644 index 00000000..f8e12275 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/tickettypes/TicketTypesClient.java @@ -0,0 +1,271 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.tickettypes; + +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.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.core.Suppliers; +import com.intercom.api.errors.UnauthorizedError; +import com.intercom.api.resources.tickets.types.TicketType; +import com.intercom.api.resources.tickettypes.attributes.AttributesClient; +import com.intercom.api.resources.tickettypes.requests.CreateTicketTypeRequest; +import com.intercom.api.resources.tickettypes.requests.FindTicketTypeRequest; +import com.intercom.api.resources.tickettypes.requests.UpdateTicketTypeRequest; +import com.intercom.api.types.Error; +import com.intercom.api.types.TicketTypeList; +import java.io.IOException; +import java.util.function.Supplier; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class TicketTypesClient { + protected final ClientOptions clientOptions; + + protected final Supplier attributesClient; + + public TicketTypesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.attributesClient = Suppliers.memoize(() -> new AttributesClient(clientOptions)); + } + + /** + * You can get a list of all ticket types for a workspace. + */ + public TicketTypeList list() { + return list(null); + } + + /** + * You can get a list of all ticket types for a workspace. + */ + public TicketTypeList list(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticket_types") + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TicketTypeList.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can create a new ticket type. + *
+ *

📘 Creating ticket types.

+ *

Every ticket type will be created with two default attributes: default_title and default_description. + * For the icon propery, use an emoji from Twemoji Cheatsheet

+ *
+ */ + public TicketType create(CreateTicketTypeRequest request) { + return create(request, null); + } + + /** + * You can create a new ticket type. + *
+ *

📘 Creating ticket types.

+ *

Every ticket type will be created with two default attributes: default_title and default_description. + * For the icon propery, use an emoji from Twemoji Cheatsheet

+ *
+ */ + public TicketType create(CreateTicketTypeRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticket_types") + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TicketType.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can fetch the details of a single ticket type. + */ + public TicketType get(FindTicketTypeRequest request) { + return get(request, null); + } + + /** + * You can fetch the details of a single ticket type. + */ + public TicketType get(FindTicketTypeRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticket_types") + .addPathSegment(request.getTicketTypeId()) + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TicketType.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can update a ticket type. + *
+ *

📘 Updating a ticket type.

+ *

For the icon propery, use an emoji from Twemoji Cheatsheet

+ *
+ */ + public TicketType update(UpdateTicketTypeRequest request) { + return update(request, null); + } + + /** + * You can update a ticket type. + *
+ *

📘 Updating a ticket type.

+ *

For the icon propery, use an emoji from Twemoji Cheatsheet

+ *
+ */ + public TicketType update(UpdateTicketTypeRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticket_types") + .addPathSegment(request.getTicketTypeId()) + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TicketType.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + public AttributesClient attributes() { + return this.attributesClient.get(); + } +} diff --git a/src/main/java/com/intercom/api/resources/tickettypes/attributes/AsyncAttributesClient.java b/src/main/java/com/intercom/api/resources/tickettypes/attributes/AsyncAttributesClient.java new file mode 100644 index 00000000..c5b09d00 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/tickettypes/attributes/AsyncAttributesClient.java @@ -0,0 +1,186 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.tickettypes.attributes; + +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.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.errors.UnauthorizedError; +import com.intercom.api.resources.tickettypes.attributes.requests.CreateTicketTypeAttributeRequest; +import com.intercom.api.resources.tickettypes.attributes.requests.UpdateTicketTypeAttributeRequest; +import com.intercom.api.types.Error; +import com.intercom.api.types.TicketTypeAttribute; +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 AsyncAttributesClient { + protected final ClientOptions clientOptions; + + public AsyncAttributesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can create a new attribute for a ticket type. + */ + public CompletableFuture create(CreateTicketTypeAttributeRequest request) { + return create(request, null); + } + + /** + * You can create a new attribute for a ticket type. + */ + public CompletableFuture create( + CreateTicketTypeAttributeRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticket_types") + .addPathSegment(request.getTicketTypeId()) + .addPathSegments("attributes") + .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( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TicketTypeAttribute.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + 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))); + 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 attribute for a ticket type. + */ + public CompletableFuture update(UpdateTicketTypeAttributeRequest request) { + return update(request, null); + } + + /** + * You can update an existing attribute for a ticket type. + */ + public CompletableFuture update( + UpdateTicketTypeAttributeRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticket_types") + .addPathSegment(request.getTicketTypeId()) + .addPathSegments("attributes") + .addPathSegment(request.getAttributeId()) + .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( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TicketTypeAttribute.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + 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))); + 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/tickettypes/attributes/AttributesClient.java b/src/main/java/com/intercom/api/resources/tickettypes/attributes/AttributesClient.java new file mode 100644 index 00000000..44e226f8 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/tickettypes/attributes/AttributesClient.java @@ -0,0 +1,148 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.tickettypes.attributes; + +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.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.errors.UnauthorizedError; +import com.intercom.api.resources.tickettypes.attributes.requests.CreateTicketTypeAttributeRequest; +import com.intercom.api.resources.tickettypes.attributes.requests.UpdateTicketTypeAttributeRequest; +import com.intercom.api.types.Error; +import com.intercom.api.types.TicketTypeAttribute; +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 AttributesClient { + protected final ClientOptions clientOptions; + + public AttributesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can create a new attribute for a ticket type. + */ + public TicketTypeAttribute create(CreateTicketTypeAttributeRequest request) { + return create(request, null); + } + + /** + * You can create a new attribute for a ticket type. + */ + public TicketTypeAttribute create(CreateTicketTypeAttributeRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticket_types") + .addPathSegment(request.getTicketTypeId()) + .addPathSegments("attributes") + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TicketTypeAttribute.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can update an existing attribute for a ticket type. + */ + public TicketTypeAttribute update(UpdateTicketTypeAttributeRequest request) { + return update(request, null); + } + + /** + * You can update an existing attribute for a ticket type. + */ + public TicketTypeAttribute update(UpdateTicketTypeAttributeRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticket_types") + .addPathSegment(request.getTicketTypeId()) + .addPathSegments("attributes") + .addPathSegment(request.getAttributeId()) + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TicketTypeAttribute.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/tickettypes/attributes/requests/CreateTicketTypeAttributeRequest.java b/src/main/java/com/intercom/api/resources/tickettypes/attributes/requests/CreateTicketTypeAttributeRequest.java new file mode 100644 index 00000000..956faa4f --- /dev/null +++ b/src/main/java/com/intercom/api/resources/tickettypes/attributes/requests/CreateTicketTypeAttributeRequest.java @@ -0,0 +1,616 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.tickettypes.attributes.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 = CreateTicketTypeAttributeRequest.Builder.class) +public final class CreateTicketTypeAttributeRequest { + private final String ticketTypeId; + + private final String name; + + private final String description; + + private final DataType dataType; + + private final Optional requiredToCreate; + + private final Optional requiredToCreateForContacts; + + private final Optional visibleOnCreate; + + private final Optional visibleToContacts; + + private final Optional multiline; + + private final Optional listItems; + + private final Optional allowMultipleValues; + + private final Map additionalProperties; + + private CreateTicketTypeAttributeRequest( + String ticketTypeId, + String name, + String description, + DataType dataType, + Optional requiredToCreate, + Optional requiredToCreateForContacts, + Optional visibleOnCreate, + Optional visibleToContacts, + Optional multiline, + Optional listItems, + Optional allowMultipleValues, + Map additionalProperties) { + this.ticketTypeId = ticketTypeId; + this.name = name; + this.description = description; + this.dataType = dataType; + this.requiredToCreate = requiredToCreate; + this.requiredToCreateForContacts = requiredToCreateForContacts; + this.visibleOnCreate = visibleOnCreate; + this.visibleToContacts = visibleToContacts; + this.multiline = multiline; + this.listItems = listItems; + this.allowMultipleValues = allowMultipleValues; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the ticket type which is given by Intercom. + */ + @JsonProperty("ticket_type_id") + public String getTicketTypeId() { + return ticketTypeId; + } + + /** + * @return The name of the ticket type attribute + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * @return The description of the attribute presented to the teammate or contact + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * @return The data type of the attribute + */ + @JsonProperty("data_type") + public DataType getDataType() { + return dataType; + } + + /** + * @return Whether the attribute is required to be filled in when teammates are creating the ticket in Inbox. + */ + @JsonProperty("required_to_create") + public Optional getRequiredToCreate() { + return requiredToCreate; + } + + /** + * @return Whether the attribute is required to be filled in when contacts are creating the ticket in Messenger. + */ + @JsonProperty("required_to_create_for_contacts") + public Optional getRequiredToCreateForContacts() { + return requiredToCreateForContacts; + } + + /** + * @return Whether the attribute is visible to teammates when creating a ticket in Inbox. + */ + @JsonProperty("visible_on_create") + public Optional getVisibleOnCreate() { + return visibleOnCreate; + } + + /** + * @return Whether the attribute is visible to contacts when creating a ticket in Messenger. + */ + @JsonProperty("visible_to_contacts") + public Optional getVisibleToContacts() { + return visibleToContacts; + } + + /** + * @return Whether the attribute allows multiple lines of text (only applicable to string attributes) + */ + @JsonProperty("multiline") + public Optional getMultiline() { + return multiline; + } + + /** + * @return A comma delimited list of items for the attribute value (only applicable to list attributes) + */ + @JsonProperty("list_items") + public Optional getListItems() { + return listItems; + } + + /** + * @return Whether the attribute allows multiple files to be attached to it (only applicable to file attributes) + */ + @JsonProperty("allow_multiple_values") + public Optional getAllowMultipleValues() { + return allowMultipleValues; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreateTicketTypeAttributeRequest && equalTo((CreateTicketTypeAttributeRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreateTicketTypeAttributeRequest other) { + return ticketTypeId.equals(other.ticketTypeId) + && name.equals(other.name) + && description.equals(other.description) + && dataType.equals(other.dataType) + && requiredToCreate.equals(other.requiredToCreate) + && requiredToCreateForContacts.equals(other.requiredToCreateForContacts) + && visibleOnCreate.equals(other.visibleOnCreate) + && visibleToContacts.equals(other.visibleToContacts) + && multiline.equals(other.multiline) + && listItems.equals(other.listItems) + && allowMultipleValues.equals(other.allowMultipleValues); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.ticketTypeId, + this.name, + this.description, + this.dataType, + this.requiredToCreate, + this.requiredToCreateForContacts, + this.visibleOnCreate, + this.visibleToContacts, + this.multiline, + this.listItems, + this.allowMultipleValues); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TicketTypeIdStage builder() { + return new Builder(); + } + + public interface TicketTypeIdStage { + NameStage ticketTypeId(@NotNull String ticketTypeId); + + Builder from(CreateTicketTypeAttributeRequest other); + } + + public interface NameStage { + DescriptionStage name(@NotNull String name); + } + + public interface DescriptionStage { + DataTypeStage description(@NotNull String description); + } + + public interface DataTypeStage { + _FinalStage dataType(@NotNull DataType dataType); + } + + public interface _FinalStage { + CreateTicketTypeAttributeRequest build(); + + _FinalStage requiredToCreate(Optional requiredToCreate); + + _FinalStage requiredToCreate(Boolean requiredToCreate); + + _FinalStage requiredToCreateForContacts(Optional requiredToCreateForContacts); + + _FinalStage requiredToCreateForContacts(Boolean requiredToCreateForContacts); + + _FinalStage visibleOnCreate(Optional visibleOnCreate); + + _FinalStage visibleOnCreate(Boolean visibleOnCreate); + + _FinalStage visibleToContacts(Optional visibleToContacts); + + _FinalStage visibleToContacts(Boolean visibleToContacts); + + _FinalStage multiline(Optional multiline); + + _FinalStage multiline(Boolean multiline); + + _FinalStage listItems(Optional listItems); + + _FinalStage listItems(String listItems); + + _FinalStage allowMultipleValues(Optional allowMultipleValues); + + _FinalStage allowMultipleValues(Boolean allowMultipleValues); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements TicketTypeIdStage, NameStage, DescriptionStage, DataTypeStage, _FinalStage { + private String ticketTypeId; + + private String name; + + private String description; + + private DataType dataType; + + private Optional allowMultipleValues = Optional.empty(); + + private Optional listItems = Optional.empty(); + + private Optional multiline = Optional.empty(); + + private Optional visibleToContacts = Optional.empty(); + + private Optional visibleOnCreate = Optional.empty(); + + private Optional requiredToCreateForContacts = Optional.empty(); + + private Optional requiredToCreate = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CreateTicketTypeAttributeRequest other) { + ticketTypeId(other.getTicketTypeId()); + name(other.getName()); + description(other.getDescription()); + dataType(other.getDataType()); + requiredToCreate(other.getRequiredToCreate()); + requiredToCreateForContacts(other.getRequiredToCreateForContacts()); + visibleOnCreate(other.getVisibleOnCreate()); + visibleToContacts(other.getVisibleToContacts()); + multiline(other.getMultiline()); + listItems(other.getListItems()); + allowMultipleValues(other.getAllowMultipleValues()); + return this; + } + + /** + *

The unique identifier for the ticket type which is given by Intercom.

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

The name of the ticket type attribute

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

The description of the attribute presented to the teammate or contact

+ * @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

+ * @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; + } + + /** + *

Whether the attribute allows multiple files to be attached to it (only applicable to file attributes)

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage allowMultipleValues(Boolean allowMultipleValues) { + this.allowMultipleValues = Optional.ofNullable(allowMultipleValues); + return this; + } + + @java.lang.Override + @JsonSetter(value = "allow_multiple_values", nulls = Nulls.SKIP) + public _FinalStage allowMultipleValues(Optional allowMultipleValues) { + this.allowMultipleValues = allowMultipleValues; + return this; + } + + /** + *

A comma delimited list of items for the attribute value (only applicable to list attributes)

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage listItems(String listItems) { + this.listItems = Optional.ofNullable(listItems); + return this; + } + + @java.lang.Override + @JsonSetter(value = "list_items", nulls = Nulls.SKIP) + public _FinalStage listItems(Optional listItems) { + this.listItems = listItems; + return this; + } + + /** + *

Whether the attribute allows multiple lines of text (only applicable to string attributes)

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage multiline(Boolean multiline) { + this.multiline = Optional.ofNullable(multiline); + return this; + } + + @java.lang.Override + @JsonSetter(value = "multiline", nulls = Nulls.SKIP) + public _FinalStage multiline(Optional multiline) { + this.multiline = multiline; + return this; + } + + /** + *

Whether the attribute is visible to contacts when creating a ticket in Messenger.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage visibleToContacts(Boolean visibleToContacts) { + this.visibleToContacts = Optional.ofNullable(visibleToContacts); + return this; + } + + @java.lang.Override + @JsonSetter(value = "visible_to_contacts", nulls = Nulls.SKIP) + public _FinalStage visibleToContacts(Optional visibleToContacts) { + this.visibleToContacts = visibleToContacts; + return this; + } + + /** + *

Whether the attribute is visible to teammates when creating a ticket in Inbox.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage visibleOnCreate(Boolean visibleOnCreate) { + this.visibleOnCreate = Optional.ofNullable(visibleOnCreate); + return this; + } + + @java.lang.Override + @JsonSetter(value = "visible_on_create", nulls = Nulls.SKIP) + public _FinalStage visibleOnCreate(Optional visibleOnCreate) { + this.visibleOnCreate = visibleOnCreate; + return this; + } + + /** + *

Whether the attribute is required to be filled in when contacts are creating the ticket in Messenger.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage requiredToCreateForContacts(Boolean requiredToCreateForContacts) { + this.requiredToCreateForContacts = Optional.ofNullable(requiredToCreateForContacts); + return this; + } + + @java.lang.Override + @JsonSetter(value = "required_to_create_for_contacts", nulls = Nulls.SKIP) + public _FinalStage requiredToCreateForContacts(Optional requiredToCreateForContacts) { + this.requiredToCreateForContacts = requiredToCreateForContacts; + return this; + } + + /** + *

Whether the attribute is required to be filled in when teammates are creating the ticket in Inbox.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage requiredToCreate(Boolean requiredToCreate) { + this.requiredToCreate = Optional.ofNullable(requiredToCreate); + return this; + } + + @java.lang.Override + @JsonSetter(value = "required_to_create", nulls = Nulls.SKIP) + public _FinalStage requiredToCreate(Optional requiredToCreate) { + this.requiredToCreate = requiredToCreate; + return this; + } + + @java.lang.Override + public CreateTicketTypeAttributeRequest build() { + return new CreateTicketTypeAttributeRequest( + ticketTypeId, + name, + description, + dataType, + requiredToCreate, + requiredToCreateForContacts, + visibleOnCreate, + visibleToContacts, + multiline, + listItems, + allowMultipleValues, + additionalProperties); + } + } + + public final class DataType { + public static final DataType STRING = new DataType(Value.STRING, "string"); + + public static final DataType DECIMAL = new DataType(Value.DECIMAL, "decimal"); + + public static final DataType LIST = new DataType(Value.LIST, "list"); + + 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 FILES = new DataType(Value.FILES, "files"); + + 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 DECIMAL: + return visitor.visitDecimal(); + case LIST: + return visitor.visitList(); + case INTEGER: + return visitor.visitInteger(); + case DATETIME: + return visitor.visitDatetime(); + case BOOLEAN: + return visitor.visitBoolean(); + case FILES: + return visitor.visitFiles(); + 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 "decimal": + return DECIMAL; + case "list": + return LIST; + case "integer": + return INTEGER; + case "datetime": + return DATETIME; + case "boolean": + return BOOLEAN; + case "files": + return FILES; + default: + return new DataType(Value.UNKNOWN, value); + } + } + + public enum Value { + STRING, + + LIST, + + INTEGER, + + DECIMAL, + + BOOLEAN, + + DATETIME, + + FILES, + + UNKNOWN + } + + public interface Visitor { + T visitString(); + + T visitList(); + + T visitInteger(); + + T visitDecimal(); + + T visitBoolean(); + + T visitDatetime(); + + T visitFiles(); + + T visitUnknown(String unknownType); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/tickettypes/attributes/requests/UpdateTicketTypeAttributeRequest.java b/src/main/java/com/intercom/api/resources/tickettypes/attributes/requests/UpdateTicketTypeAttributeRequest.java new file mode 100644 index 00000000..ccff1750 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/tickettypes/attributes/requests/UpdateTicketTypeAttributeRequest.java @@ -0,0 +1,539 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.tickettypes.attributes.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 = UpdateTicketTypeAttributeRequest.Builder.class) +public final class UpdateTicketTypeAttributeRequest { + private final String ticketTypeId; + + private final String attributeId; + + private final Optional name; + + private final Optional description; + + private final Optional requiredToCreate; + + private final Optional requiredToCreateForContacts; + + private final Optional visibleOnCreate; + + private final Optional visibleToContacts; + + private final Optional multiline; + + private final Optional listItems; + + private final Optional allowMultipleValues; + + private final Optional archived; + + private final Map additionalProperties; + + private UpdateTicketTypeAttributeRequest( + String ticketTypeId, + String attributeId, + Optional name, + Optional description, + Optional requiredToCreate, + Optional requiredToCreateForContacts, + Optional visibleOnCreate, + Optional visibleToContacts, + Optional multiline, + Optional listItems, + Optional allowMultipleValues, + Optional archived, + Map additionalProperties) { + this.ticketTypeId = ticketTypeId; + this.attributeId = attributeId; + this.name = name; + this.description = description; + this.requiredToCreate = requiredToCreate; + this.requiredToCreateForContacts = requiredToCreateForContacts; + this.visibleOnCreate = visibleOnCreate; + this.visibleToContacts = visibleToContacts; + this.multiline = multiline; + this.listItems = listItems; + this.allowMultipleValues = allowMultipleValues; + this.archived = archived; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the ticket type which is given by Intercom. + */ + @JsonProperty("ticket_type_id") + public String getTicketTypeId() { + return ticketTypeId; + } + + /** + * @return The unique identifier for the ticket type attribute which is given by Intercom. + */ + @JsonProperty("attribute_id") + public String getAttributeId() { + return attributeId; + } + + /** + * @return The name of the ticket type attribute + */ + @JsonProperty("name") + public Optional getName() { + return name; + } + + /** + * @return The description of the attribute presented to the teammate or contact + */ + @JsonProperty("description") + public Optional getDescription() { + return description; + } + + /** + * @return Whether the attribute is required to be filled in when teammates are creating the ticket in Inbox. + */ + @JsonProperty("required_to_create") + public Optional getRequiredToCreate() { + return requiredToCreate; + } + + /** + * @return Whether the attribute is required to be filled in when contacts are creating the ticket in Messenger. + */ + @JsonProperty("required_to_create_for_contacts") + public Optional getRequiredToCreateForContacts() { + return requiredToCreateForContacts; + } + + /** + * @return Whether the attribute is visible to teammates when creating a ticket in Inbox. + */ + @JsonProperty("visible_on_create") + public Optional getVisibleOnCreate() { + return visibleOnCreate; + } + + /** + * @return Whether the attribute is visible to contacts when creating a ticket in Messenger. + */ + @JsonProperty("visible_to_contacts") + public Optional getVisibleToContacts() { + return visibleToContacts; + } + + /** + * @return Whether the attribute allows multiple lines of text (only applicable to string attributes) + */ + @JsonProperty("multiline") + public Optional getMultiline() { + return multiline; + } + + /** + * @return A comma delimited list of items for the attribute value (only applicable to list attributes) + */ + @JsonProperty("list_items") + public Optional getListItems() { + return listItems; + } + + /** + * @return Whether the attribute allows multiple files to be attached to it (only applicable to file attributes) + */ + @JsonProperty("allow_multiple_values") + public Optional getAllowMultipleValues() { + return allowMultipleValues; + } + + /** + * @return Whether the attribute should be archived and not shown during creation of the ticket (it will still be present on previously created tickets) + */ + @JsonProperty("archived") + public Optional getArchived() { + return archived; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UpdateTicketTypeAttributeRequest && equalTo((UpdateTicketTypeAttributeRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UpdateTicketTypeAttributeRequest other) { + return ticketTypeId.equals(other.ticketTypeId) + && attributeId.equals(other.attributeId) + && name.equals(other.name) + && description.equals(other.description) + && requiredToCreate.equals(other.requiredToCreate) + && requiredToCreateForContacts.equals(other.requiredToCreateForContacts) + && visibleOnCreate.equals(other.visibleOnCreate) + && visibleToContacts.equals(other.visibleToContacts) + && multiline.equals(other.multiline) + && listItems.equals(other.listItems) + && allowMultipleValues.equals(other.allowMultipleValues) + && archived.equals(other.archived); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.ticketTypeId, + this.attributeId, + this.name, + this.description, + this.requiredToCreate, + this.requiredToCreateForContacts, + this.visibleOnCreate, + this.visibleToContacts, + this.multiline, + this.listItems, + this.allowMultipleValues, + this.archived); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TicketTypeIdStage builder() { + return new Builder(); + } + + public interface TicketTypeIdStage { + AttributeIdStage ticketTypeId(@NotNull String ticketTypeId); + + Builder from(UpdateTicketTypeAttributeRequest other); + } + + public interface AttributeIdStage { + _FinalStage attributeId(@NotNull String attributeId); + } + + public interface _FinalStage { + UpdateTicketTypeAttributeRequest build(); + + _FinalStage name(Optional name); + + _FinalStage name(String name); + + _FinalStage description(Optional description); + + _FinalStage description(String description); + + _FinalStage requiredToCreate(Optional requiredToCreate); + + _FinalStage requiredToCreate(Boolean requiredToCreate); + + _FinalStage requiredToCreateForContacts(Optional requiredToCreateForContacts); + + _FinalStage requiredToCreateForContacts(Boolean requiredToCreateForContacts); + + _FinalStage visibleOnCreate(Optional visibleOnCreate); + + _FinalStage visibleOnCreate(Boolean visibleOnCreate); + + _FinalStage visibleToContacts(Optional visibleToContacts); + + _FinalStage visibleToContacts(Boolean visibleToContacts); + + _FinalStage multiline(Optional multiline); + + _FinalStage multiline(Boolean multiline); + + _FinalStage listItems(Optional listItems); + + _FinalStage listItems(String listItems); + + _FinalStage allowMultipleValues(Optional allowMultipleValues); + + _FinalStage allowMultipleValues(Boolean allowMultipleValues); + + _FinalStage archived(Optional archived); + + _FinalStage archived(Boolean archived); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements TicketTypeIdStage, AttributeIdStage, _FinalStage { + private String ticketTypeId; + + private String attributeId; + + private Optional archived = Optional.empty(); + + private Optional allowMultipleValues = Optional.empty(); + + private Optional listItems = Optional.empty(); + + private Optional multiline = Optional.empty(); + + private Optional visibleToContacts = Optional.empty(); + + private Optional visibleOnCreate = Optional.empty(); + + private Optional requiredToCreateForContacts = Optional.empty(); + + private Optional requiredToCreate = Optional.empty(); + + private Optional description = Optional.empty(); + + private Optional name = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(UpdateTicketTypeAttributeRequest other) { + ticketTypeId(other.getTicketTypeId()); + attributeId(other.getAttributeId()); + name(other.getName()); + description(other.getDescription()); + requiredToCreate(other.getRequiredToCreate()); + requiredToCreateForContacts(other.getRequiredToCreateForContacts()); + visibleOnCreate(other.getVisibleOnCreate()); + visibleToContacts(other.getVisibleToContacts()); + multiline(other.getMultiline()); + listItems(other.getListItems()); + allowMultipleValues(other.getAllowMultipleValues()); + archived(other.getArchived()); + return this; + } + + /** + *

The unique identifier for the ticket type which is given by Intercom.

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

The unique identifier for the ticket type attribute which is given by Intercom.

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

Whether the attribute should be archived and not shown during creation of the ticket (it will still be present on previously created tickets)

+ * @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; + } + + @java.lang.Override + @JsonSetter(value = "archived", nulls = Nulls.SKIP) + public _FinalStage archived(Optional archived) { + this.archived = archived; + return this; + } + + /** + *

Whether the attribute allows multiple files to be attached to it (only applicable to file attributes)

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage allowMultipleValues(Boolean allowMultipleValues) { + this.allowMultipleValues = Optional.ofNullable(allowMultipleValues); + return this; + } + + @java.lang.Override + @JsonSetter(value = "allow_multiple_values", nulls = Nulls.SKIP) + public _FinalStage allowMultipleValues(Optional allowMultipleValues) { + this.allowMultipleValues = allowMultipleValues; + return this; + } + + /** + *

A comma delimited list of items for the attribute value (only applicable to list attributes)

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage listItems(String listItems) { + this.listItems = Optional.ofNullable(listItems); + return this; + } + + @java.lang.Override + @JsonSetter(value = "list_items", nulls = Nulls.SKIP) + public _FinalStage listItems(Optional listItems) { + this.listItems = listItems; + return this; + } + + /** + *

Whether the attribute allows multiple lines of text (only applicable to string attributes)

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage multiline(Boolean multiline) { + this.multiline = Optional.ofNullable(multiline); + return this; + } + + @java.lang.Override + @JsonSetter(value = "multiline", nulls = Nulls.SKIP) + public _FinalStage multiline(Optional multiline) { + this.multiline = multiline; + return this; + } + + /** + *

Whether the attribute is visible to contacts when creating a ticket in Messenger.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage visibleToContacts(Boolean visibleToContacts) { + this.visibleToContacts = Optional.ofNullable(visibleToContacts); + return this; + } + + @java.lang.Override + @JsonSetter(value = "visible_to_contacts", nulls = Nulls.SKIP) + public _FinalStage visibleToContacts(Optional visibleToContacts) { + this.visibleToContacts = visibleToContacts; + return this; + } + + /** + *

Whether the attribute is visible to teammates when creating a ticket in Inbox.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage visibleOnCreate(Boolean visibleOnCreate) { + this.visibleOnCreate = Optional.ofNullable(visibleOnCreate); + return this; + } + + @java.lang.Override + @JsonSetter(value = "visible_on_create", nulls = Nulls.SKIP) + public _FinalStage visibleOnCreate(Optional visibleOnCreate) { + this.visibleOnCreate = visibleOnCreate; + return this; + } + + /** + *

Whether the attribute is required to be filled in when contacts are creating the ticket in Messenger.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage requiredToCreateForContacts(Boolean requiredToCreateForContacts) { + this.requiredToCreateForContacts = Optional.ofNullable(requiredToCreateForContacts); + return this; + } + + @java.lang.Override + @JsonSetter(value = "required_to_create_for_contacts", nulls = Nulls.SKIP) + public _FinalStage requiredToCreateForContacts(Optional requiredToCreateForContacts) { + this.requiredToCreateForContacts = requiredToCreateForContacts; + return this; + } + + /** + *

Whether the attribute is required to be filled in when teammates are creating the ticket in Inbox.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage requiredToCreate(Boolean requiredToCreate) { + this.requiredToCreate = Optional.ofNullable(requiredToCreate); + return this; + } + + @java.lang.Override + @JsonSetter(value = "required_to_create", nulls = Nulls.SKIP) + public _FinalStage requiredToCreate(Optional requiredToCreate) { + this.requiredToCreate = requiredToCreate; + return this; + } + + /** + *

The description of the attribute presented to the teammate or contact

+ * @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; + } + + @java.lang.Override + @JsonSetter(value = "description", nulls = Nulls.SKIP) + public _FinalStage description(Optional description) { + this.description = description; + return this; + } + + /** + *

The name of the ticket type attribute

+ * @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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public _FinalStage name(Optional name) { + this.name = name; + return this; + } + + @java.lang.Override + public UpdateTicketTypeAttributeRequest build() { + return new UpdateTicketTypeAttributeRequest( + ticketTypeId, + attributeId, + name, + description, + requiredToCreate, + requiredToCreateForContacts, + visibleOnCreate, + visibleToContacts, + multiline, + listItems, + allowMultipleValues, + archived, + additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/tickettypes/requests/CreateTicketTypeRequest.java b/src/main/java/com/intercom/api/resources/tickettypes/requests/CreateTicketTypeRequest.java new file mode 100644 index 00000000..a7b5e85a --- /dev/null +++ b/src/main/java/com/intercom/api/resources/tickettypes/requests/CreateTicketTypeRequest.java @@ -0,0 +1,348 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.tickettypes.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 = CreateTicketTypeRequest.Builder.class) +public final class CreateTicketTypeRequest { + private final String name; + + private final Optional description; + + private final Optional category; + + private final Optional icon; + + private final Optional isInternal; + + private final Map additionalProperties; + + private CreateTicketTypeRequest( + String name, + Optional description, + Optional category, + Optional icon, + Optional isInternal, + Map additionalProperties) { + this.name = name; + this.description = description; + this.category = category; + this.icon = icon; + this.isInternal = isInternal; + this.additionalProperties = additionalProperties; + } + + /** + * @return The name of the ticket type. + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * @return The description of the ticket type. + */ + @JsonProperty("description") + public Optional getDescription() { + return description; + } + + /** + * @return Category of the Ticket Type. + */ + @JsonProperty("category") + public Optional getCategory() { + return category; + } + + /** + * @return The icon of the ticket type. + */ + @JsonProperty("icon") + public Optional getIcon() { + return icon; + } + + /** + * @return Whether the tickets associated with this ticket type are intended for internal use only or will be shared with customers. This is currently a limited attribute. + */ + @JsonProperty("is_internal") + public Optional getIsInternal() { + return isInternal; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreateTicketTypeRequest && equalTo((CreateTicketTypeRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreateTicketTypeRequest other) { + return name.equals(other.name) + && description.equals(other.description) + && category.equals(other.category) + && icon.equals(other.icon) + && isInternal.equals(other.isInternal); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.name, this.description, this.category, this.icon, this.isInternal); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static NameStage builder() { + return new Builder(); + } + + public interface NameStage { + _FinalStage name(@NotNull String name); + + Builder from(CreateTicketTypeRequest other); + } + + public interface _FinalStage { + CreateTicketTypeRequest build(); + + _FinalStage description(Optional description); + + _FinalStage description(String description); + + _FinalStage category(Optional category); + + _FinalStage category(Category category); + + _FinalStage icon(Optional icon); + + _FinalStage icon(String icon); + + _FinalStage isInternal(Optional isInternal); + + _FinalStage isInternal(Boolean isInternal); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements NameStage, _FinalStage { + private String name; + + private Optional isInternal = Optional.empty(); + + private Optional icon = Optional.empty(); + + private Optional category = Optional.empty(); + + private Optional description = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CreateTicketTypeRequest other) { + name(other.getName()); + description(other.getDescription()); + category(other.getCategory()); + icon(other.getIcon()); + isInternal(other.getIsInternal()); + return this; + } + + /** + *

The name of the ticket type.

+ * @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"); + return this; + } + + /** + *

Whether the tickets associated with this ticket type are intended for internal use only or will be shared with customers. This is currently a limited attribute.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage isInternal(Boolean isInternal) { + this.isInternal = Optional.ofNullable(isInternal); + return this; + } + + @java.lang.Override + @JsonSetter(value = "is_internal", nulls = Nulls.SKIP) + public _FinalStage isInternal(Optional isInternal) { + this.isInternal = isInternal; + return this; + } + + /** + *

The icon of the ticket type.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage icon(String icon) { + this.icon = Optional.ofNullable(icon); + return this; + } + + @java.lang.Override + @JsonSetter(value = "icon", nulls = Nulls.SKIP) + public _FinalStage icon(Optional icon) { + this.icon = icon; + return this; + } + + /** + *

Category of the Ticket Type.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage category(Category category) { + this.category = Optional.ofNullable(category); + return this; + } + + @java.lang.Override + @JsonSetter(value = "category", nulls = Nulls.SKIP) + public _FinalStage category(Optional category) { + this.category = category; + return this; + } + + /** + *

The description of the ticket type.

+ * @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; + } + + @java.lang.Override + @JsonSetter(value = "description", nulls = Nulls.SKIP) + public _FinalStage description(Optional description) { + this.description = description; + return this; + } + + @java.lang.Override + public CreateTicketTypeRequest build() { + return new CreateTicketTypeRequest(name, description, category, icon, isInternal, additionalProperties); + } + } + + public final class Category { + public static final Category BACK_OFFICE = new Category(Value.BACK_OFFICE, "Back-office"); + + public static final Category CUSTOMER = new Category(Value.CUSTOMER, "Customer"); + + public static final Category TRACKER = new Category(Value.TRACKER, "Tracker"); + + private final Value value; + + private final String string; + + Category(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 Category && this.string.equals(((Category) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case BACK_OFFICE: + return visitor.visitBackOffice(); + case CUSTOMER: + return visitor.visitCustomer(); + case TRACKER: + return visitor.visitTracker(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static Category valueOf(String value) { + switch (value) { + case "Back-office": + return BACK_OFFICE; + case "Customer": + return CUSTOMER; + case "Tracker": + return TRACKER; + default: + return new Category(Value.UNKNOWN, value); + } + } + + public enum Value { + CUSTOMER, + + BACK_OFFICE, + + TRACKER, + + UNKNOWN + } + + public interface Visitor { + T visitCustomer(); + + T visitBackOffice(); + + T visitTracker(); + + T visitUnknown(String unknownType); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/tickettypes/requests/FindTicketTypeRequest.java b/src/main/java/com/intercom/api/resources/tickettypes/requests/FindTicketTypeRequest.java new file mode 100644 index 00000000..4551ea72 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/tickettypes/requests/FindTicketTypeRequest.java @@ -0,0 +1,109 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.tickettypes.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 = FindTicketTypeRequest.Builder.class) +public final class FindTicketTypeRequest { + private final String ticketTypeId; + + private final Map additionalProperties; + + private FindTicketTypeRequest(String ticketTypeId, Map additionalProperties) { + this.ticketTypeId = ticketTypeId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the ticket type which is given by Intercom. + */ + @JsonProperty("ticket_type_id") + public String getTicketTypeId() { + return ticketTypeId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof FindTicketTypeRequest && equalTo((FindTicketTypeRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(FindTicketTypeRequest other) { + return ticketTypeId.equals(other.ticketTypeId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.ticketTypeId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TicketTypeIdStage builder() { + return new Builder(); + } + + public interface TicketTypeIdStage { + _FinalStage ticketTypeId(@NotNull String ticketTypeId); + + Builder from(FindTicketTypeRequest other); + } + + public interface _FinalStage { + FindTicketTypeRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements TicketTypeIdStage, _FinalStage { + private String ticketTypeId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(FindTicketTypeRequest other) { + ticketTypeId(other.getTicketTypeId()); + return this; + } + + /** + *

The unique identifier for the ticket type which is given by Intercom.

+ * @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; + } + + @java.lang.Override + public FindTicketTypeRequest build() { + return new FindTicketTypeRequest(ticketTypeId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/tickettypes/requests/UpdateTicketTypeRequest.java b/src/main/java/com/intercom/api/resources/tickettypes/requests/UpdateTicketTypeRequest.java new file mode 100644 index 00000000..9a634e1a --- /dev/null +++ b/src/main/java/com/intercom/api/resources/tickettypes/requests/UpdateTicketTypeRequest.java @@ -0,0 +1,430 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.tickettypes.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 = UpdateTicketTypeRequest.Builder.class) +public final class UpdateTicketTypeRequest { + private final String ticketTypeId; + + private final Optional name; + + private final Optional description; + + private final Optional category; + + private final Optional icon; + + private final Optional archived; + + private final Optional isInternal; + + private final Map additionalProperties; + + private UpdateTicketTypeRequest( + String ticketTypeId, + Optional name, + Optional description, + Optional category, + Optional icon, + Optional archived, + Optional isInternal, + Map additionalProperties) { + this.ticketTypeId = ticketTypeId; + this.name = name; + this.description = description; + this.category = category; + this.icon = icon; + this.archived = archived; + this.isInternal = isInternal; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the ticket type which is given by Intercom. + */ + @JsonProperty("ticket_type_id") + public String getTicketTypeId() { + return ticketTypeId; + } + + /** + * @return The name of the ticket type. + */ + @JsonProperty("name") + public Optional getName() { + return name; + } + + /** + * @return The description of the ticket type. + */ + @JsonProperty("description") + public Optional getDescription() { + return description; + } + + /** + * @return Category of the Ticket Type. + */ + @JsonProperty("category") + public Optional getCategory() { + return category; + } + + /** + * @return The icon of the ticket type. + */ + @JsonProperty("icon") + public Optional getIcon() { + return icon; + } + + /** + * @return The archived status of the ticket type. + */ + @JsonProperty("archived") + public Optional getArchived() { + return archived; + } + + /** + * @return Whether the tickets associated with this ticket type are intended for internal use only or will be shared with customers. This is currently a limited attribute. + */ + @JsonProperty("is_internal") + public Optional getIsInternal() { + return isInternal; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UpdateTicketTypeRequest && equalTo((UpdateTicketTypeRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UpdateTicketTypeRequest other) { + return ticketTypeId.equals(other.ticketTypeId) + && name.equals(other.name) + && description.equals(other.description) + && category.equals(other.category) + && icon.equals(other.icon) + && archived.equals(other.archived) + && isInternal.equals(other.isInternal); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.ticketTypeId, + this.name, + this.description, + this.category, + this.icon, + this.archived, + this.isInternal); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TicketTypeIdStage builder() { + return new Builder(); + } + + public interface TicketTypeIdStage { + _FinalStage ticketTypeId(@NotNull String ticketTypeId); + + Builder from(UpdateTicketTypeRequest other); + } + + public interface _FinalStage { + UpdateTicketTypeRequest build(); + + _FinalStage name(Optional name); + + _FinalStage name(String name); + + _FinalStage description(Optional description); + + _FinalStage description(String description); + + _FinalStage category(Optional category); + + _FinalStage category(Category category); + + _FinalStage icon(Optional icon); + + _FinalStage icon(String icon); + + _FinalStage archived(Optional archived); + + _FinalStage archived(Boolean archived); + + _FinalStage isInternal(Optional isInternal); + + _FinalStage isInternal(Boolean isInternal); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements TicketTypeIdStage, _FinalStage { + private String ticketTypeId; + + private Optional isInternal = Optional.empty(); + + private Optional archived = Optional.empty(); + + private Optional icon = Optional.empty(); + + private Optional category = Optional.empty(); + + private Optional description = Optional.empty(); + + private Optional name = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(UpdateTicketTypeRequest other) { + ticketTypeId(other.getTicketTypeId()); + name(other.getName()); + description(other.getDescription()); + category(other.getCategory()); + icon(other.getIcon()); + archived(other.getArchived()); + isInternal(other.getIsInternal()); + return this; + } + + /** + *

The unique identifier for the ticket type which is given by Intercom.

+ * @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; + } + + /** + *

Whether the tickets associated with this ticket type are intended for internal use only or will be shared with customers. This is currently a limited attribute.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage isInternal(Boolean isInternal) { + this.isInternal = Optional.ofNullable(isInternal); + return this; + } + + @java.lang.Override + @JsonSetter(value = "is_internal", nulls = Nulls.SKIP) + public _FinalStage isInternal(Optional isInternal) { + this.isInternal = isInternal; + return this; + } + + /** + *

The archived status of the ticket type.

+ * @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; + } + + @java.lang.Override + @JsonSetter(value = "archived", nulls = Nulls.SKIP) + public _FinalStage archived(Optional archived) { + this.archived = archived; + return this; + } + + /** + *

The icon of the ticket type.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage icon(String icon) { + this.icon = Optional.ofNullable(icon); + return this; + } + + @java.lang.Override + @JsonSetter(value = "icon", nulls = Nulls.SKIP) + public _FinalStage icon(Optional icon) { + this.icon = icon; + return this; + } + + /** + *

Category of the Ticket Type.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage category(Category category) { + this.category = Optional.ofNullable(category); + return this; + } + + @java.lang.Override + @JsonSetter(value = "category", nulls = Nulls.SKIP) + public _FinalStage category(Optional category) { + this.category = category; + return this; + } + + /** + *

The description of the ticket type.

+ * @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; + } + + @java.lang.Override + @JsonSetter(value = "description", nulls = Nulls.SKIP) + public _FinalStage description(Optional description) { + this.description = description; + return this; + } + + /** + *

The name of the ticket type.

+ * @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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public _FinalStage name(Optional name) { + this.name = name; + return this; + } + + @java.lang.Override + public UpdateTicketTypeRequest build() { + return new UpdateTicketTypeRequest( + ticketTypeId, name, description, category, icon, archived, isInternal, additionalProperties); + } + } + + public final class Category { + public static final Category BACK_OFFICE = new Category(Value.BACK_OFFICE, "Back-office"); + + public static final Category CUSTOMER = new Category(Value.CUSTOMER, "Customer"); + + public static final Category TRACKER = new Category(Value.TRACKER, "Tracker"); + + private final Value value; + + private final String string; + + Category(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 Category && this.string.equals(((Category) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case BACK_OFFICE: + return visitor.visitBackOffice(); + case CUSTOMER: + return visitor.visitCustomer(); + case TRACKER: + return visitor.visitTracker(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static Category valueOf(String value) { + switch (value) { + case "Back-office": + return BACK_OFFICE; + case "Customer": + return CUSTOMER; + case "Tracker": + return TRACKER; + default: + return new Category(Value.UNKNOWN, value); + } + } + + public enum Value { + CUSTOMER, + + BACK_OFFICE, + + TRACKER, + + UNKNOWN + } + + public interface Visitor { + T visitCustomer(); + + T visitBackOffice(); + + T visitTracker(); + + T visitUnknown(String unknownType); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/visitors/AsyncVisitorsClient.java b/src/main/java/com/intercom/api/resources/visitors/AsyncVisitorsClient.java new file mode 100644 index 00000000..8a01b0a3 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/visitors/AsyncVisitorsClient.java @@ -0,0 +1,267 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.visitors; + +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.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.contacts.types.Contact; +import com.intercom.api.resources.visitors.requests.FindVisitorRequest; +import com.intercom.api.resources.visitors.requests.MergeVisitorToContactRequest; +import com.intercom.api.types.Error; +import com.intercom.api.types.UpdateVisitorRequest; +import com.intercom.api.types.Visitor; +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 AsyncVisitorsClient { + protected final ClientOptions clientOptions; + + public AsyncVisitorsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can fetch the details of a single visitor. + */ + public CompletableFuture find(FindVisitorRequest request) { + return find(request, null); + } + + /** + * You can fetch the details of a single visitor. + */ + public CompletableFuture find(FindVisitorRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("visitors"); + QueryStringMapper.addQueryParameter(httpUrl, "user_id", request.getUserId(), 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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Visitor.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + 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))); + 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 PUT request to /visitors will result in an update of an existing Visitor. + *

Option 1. You can update a visitor by passing in the user_id of the visitor in the Request body.

+ *

Option 2. You can update a visitor by passing in the id of the visitor in the Request body.

+ */ + public CompletableFuture update(UpdateVisitorRequest request) { + return update(request, null); + } + + /** + * Sending a PUT request to /visitors will result in an update of an existing Visitor. + *

Option 1. You can update a visitor by passing in the user_id of the visitor in the Request body.

+ *

Option 2. You can update a visitor by passing in the id of the visitor in the Request body.

+ */ + public CompletableFuture update(UpdateVisitorRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("visitors") + .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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Visitor.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class))); + 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))); + 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 merge a Visitor to a Contact of role type lead or user. + *
+ *

📘 What happens upon a visitor being converted?

+ *

If the User exists, then the Visitor will be merged into it, the Visitor deleted and the User returned. If the User does not exist, the Visitor will be converted to a User, with the User identifiers replacing it's Visitor identifiers.

+ *
+ */ + public CompletableFuture mergeToContact(MergeVisitorToContactRequest request) { + return mergeToContact(request, null); + } + + /** + * You can merge a Visitor to a Contact of role type lead or user. + *
+ *

📘 What happens upon a visitor being converted?

+ *

If the User exists, then the Visitor will be merged into it, the Visitor deleted and the User returned. If the User does not exist, the Visitor will be converted to a User, with the User identifiers replacing it's Visitor identifiers.

+ *
+ */ + public CompletableFuture mergeToContact( + MergeVisitorToContactRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("visitors/convert") + .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(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Contact.class)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class))); + 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))); + 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/visitors/VisitorsClient.java b/src/main/java/com/intercom/api/resources/visitors/VisitorsClient.java new file mode 100644 index 00000000..924e23b0 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/visitors/VisitorsClient.java @@ -0,0 +1,215 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.visitors; + +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.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.contacts.types.Contact; +import com.intercom.api.resources.visitors.requests.FindVisitorRequest; +import com.intercom.api.resources.visitors.requests.MergeVisitorToContactRequest; +import com.intercom.api.types.Error; +import com.intercom.api.types.UpdateVisitorRequest; +import com.intercom.api.types.Visitor; +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 VisitorsClient { + protected final ClientOptions clientOptions; + + public VisitorsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can fetch the details of a single visitor. + */ + public Visitor find(FindVisitorRequest request) { + return find(request, null); + } + + /** + * You can fetch the details of a single visitor. + */ + public Visitor find(FindVisitorRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("visitors"); + QueryStringMapper.addQueryParameter(httpUrl, "user_id", request.getUserId(), 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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Visitor.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * Sending a PUT request to /visitors will result in an update of an existing Visitor. + *

Option 1. You can update a visitor by passing in the user_id of the visitor in the Request body.

+ *

Option 2. You can update a visitor by passing in the id of the visitor in the Request body.

+ */ + public Visitor update(UpdateVisitorRequest request) { + return update(request, null); + } + + /** + * Sending a PUT request to /visitors will result in an update of an existing Visitor. + *

Option 1. You can update a visitor by passing in the user_id of the visitor in the Request body.

+ *

Option 2. You can update a visitor by passing in the id of the visitor in the Request body.

+ */ + public Visitor update(UpdateVisitorRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("visitors") + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Visitor.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + case 404: + throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can merge a Visitor to a Contact of role type lead or user. + *
+ *

📘 What happens upon a visitor being converted?

+ *

If the User exists, then the Visitor will be merged into it, the Visitor deleted and the User returned. If the User does not exist, the Visitor will be converted to a User, with the User identifiers replacing it's Visitor identifiers.

+ *
+ */ + public Contact mergeToContact(MergeVisitorToContactRequest request) { + return mergeToContact(request, null); + } + + /** + * You can merge a Visitor to a Contact of role type lead or user. + *
+ *

📘 What happens upon a visitor being converted?

+ *

If the User exists, then the Visitor will be merged into it, the Visitor deleted and the User returned. If the User does not exist, the Visitor will be converted to a User, with the User identifiers replacing it's Visitor identifiers.

+ *
+ */ + public Contact mergeToContact(MergeVisitorToContactRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("visitors/convert") + .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 ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Contact.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class)); + } + } 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)); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/visitors/requests/FindVisitorRequest.java b/src/main/java/com/intercom/api/resources/visitors/requests/FindVisitorRequest.java new file mode 100644 index 00000000..6d48dd33 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/visitors/requests/FindVisitorRequest.java @@ -0,0 +1,109 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.visitors.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 = FindVisitorRequest.Builder.class) +public final class FindVisitorRequest { + private final String userId; + + private final Map additionalProperties; + + private FindVisitorRequest(String userId, Map additionalProperties) { + this.userId = userId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The user_id of the Visitor you want to retrieve. + */ + @JsonProperty("user_id") + public String getUserId() { + return userId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof FindVisitorRequest && equalTo((FindVisitorRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(FindVisitorRequest other) { + return userId.equals(other.userId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.userId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static UserIdStage builder() { + return new Builder(); + } + + public interface UserIdStage { + _FinalStage userId(@NotNull String userId); + + Builder from(FindVisitorRequest other); + } + + public interface _FinalStage { + FindVisitorRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements UserIdStage, _FinalStage { + private String userId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(FindVisitorRequest other) { + userId(other.getUserId()); + return this; + } + + /** + *

The user_id of the Visitor you want to retrieve.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("user_id") + public _FinalStage userId(@NotNull String userId) { + this.userId = Objects.requireNonNull(userId, "userId must not be null"); + return this; + } + + @java.lang.Override + public FindVisitorRequest build() { + return new FindVisitorRequest(userId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/visitors/requests/MergeVisitorToContactRequest.java b/src/main/java/com/intercom/api/resources/visitors/requests/MergeVisitorToContactRequest.java new file mode 100644 index 00000000..81c0bd41 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/visitors/requests/MergeVisitorToContactRequest.java @@ -0,0 +1,878 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.visitors.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 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 = MergeVisitorToContactRequest.Builder.class) +public final class MergeVisitorToContactRequest { + private final String type; + + private final User user; + + private final Visitor visitor; + + private final Map additionalProperties; + + private MergeVisitorToContactRequest( + String type, User user, Visitor visitor, Map additionalProperties) { + this.type = type; + this.user = user; + this.visitor = visitor; + this.additionalProperties = additionalProperties; + } + + /** + * @return Represents the role of the Contact model. Accepts lead or user. + */ + @JsonProperty("type") + public String getType() { + return type; + } + + /** + * @return The unique identifiers retained after converting or merging. + */ + @JsonProperty("user") + public User getUser() { + return user; + } + + /** + * @return The unique identifiers to convert a single Visitor. + */ + @JsonProperty("visitor") + public Visitor getVisitor() { + return visitor; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof MergeVisitorToContactRequest && equalTo((MergeVisitorToContactRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(MergeVisitorToContactRequest other) { + return type.equals(other.type) && user.equals(other.user) && visitor.equals(other.visitor); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.user, this.visitor); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TypeStage builder() { + return new Builder(); + } + + public interface TypeStage { + UserStage type(@NotNull String type); + + Builder from(MergeVisitorToContactRequest other); + } + + public interface UserStage { + VisitorStage user(@NotNull User user); + } + + public interface VisitorStage { + _FinalStage visitor(@NotNull Visitor visitor); + } + + public interface _FinalStage { + MergeVisitorToContactRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements TypeStage, UserStage, VisitorStage, _FinalStage { + private String type; + + private User user; + + private Visitor visitor; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(MergeVisitorToContactRequest other) { + type(other.getType()); + user(other.getUser()); + visitor(other.getVisitor()); + return this; + } + + /** + *

Represents the role of the Contact model. Accepts lead or user.

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

The unique identifiers retained after converting or merging.

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

The unique identifiers to convert a single Visitor.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("visitor") + public _FinalStage visitor(@NotNull Visitor visitor) { + this.visitor = Objects.requireNonNull(visitor, "visitor must not be null"); + return this; + } + + @java.lang.Override + public MergeVisitorToContactRequest build() { + return new MergeVisitorToContactRequest(type, user, visitor, additionalProperties); + } + } + + @JsonDeserialize(using = User.Deserializer.class) + public static final class User { + private final Object value; + + private final int type; + + private User(Object value, int type) { + this.value = value; + this.type = type; + } + + @JsonValue + public Object get() { + return this.value; + } + + public T visit(Visitor visitor) { + if (this.type == 0) { + return visitor.visit((UserWithId) this.value); + } else if (this.type == 1) { + return visitor.visit((UserWithUserId) 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 User && equalTo((User) other); + } + + private boolean equalTo(User 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 User of(UserWithId value) { + return new User(value, 0); + } + + public static User of(UserWithUserId value) { + return new User(value, 1); + } + + public interface Visitor { + T visit(UserWithId value); + + T visit(UserWithUserId value); + } + + static final class Deserializer extends StdDeserializer { + Deserializer() { + super(User.class); + } + + @java.lang.Override + public User deserialize(JsonParser p, DeserializationContext context) throws IOException { + Object value = p.readValueAs(Object.class); + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, UserWithId.class)); + } catch (IllegalArgumentException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, UserWithUserId.class)); + } catch (IllegalArgumentException e) { + } + throw new JsonParseException(p, "Failed to deserialize"); + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = UserWithId.Builder.class) + public static final class UserWithId { + private final String id; + + private final Optional email; + + private final Map additionalProperties; + + private UserWithId(String id, Optional email, Map additionalProperties) { + this.id = id; + this.email = email; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the contact which is given by Intercom. + */ + @JsonProperty("id") + public String getId() { + return id; + } + + /** + * @return The contact's email, retained by default if one is present. + */ + @JsonProperty("email") + public Optional getEmail() { + return email; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UserWithId && equalTo((UserWithId) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UserWithId other) { + return id.equals(other.id) && email.equals(other.email); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id, this.email); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + _FinalStage id(@NotNull String id); + + Builder from(UserWithId other); + } + + public interface _FinalStage { + UserWithId build(); + + _FinalStage email(Optional email); + + _FinalStage email(String email); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, _FinalStage { + private String id; + + private Optional email = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(UserWithId other) { + id(other.getId()); + email(other.getEmail()); + return this; + } + + /** + *

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 _FinalStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + /** + *

The contact's email, retained by default if one is present.

+ * @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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "email", nulls = Nulls.SKIP) + public _FinalStage email(Optional email) { + this.email = email; + return this; + } + + @java.lang.Override + public UserWithId build() { + return new UserWithId(id, email, additionalProperties); + } + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = UserWithUserId.Builder.class) + public static final class UserWithUserId { + private final String userId; + + private final Optional email; + + private final Map additionalProperties; + + private UserWithUserId(String userId, Optional email, Map additionalProperties) { + this.userId = userId; + this.email = email; + this.additionalProperties = additionalProperties; + } + + /** + * @return A unique identifier for the contact which is given to Intercom. + */ + @JsonProperty("user_id") + public String getUserId() { + return userId; + } + + /** + * @return The contact's email, retained by default if one is present. + */ + @JsonProperty("email") + public Optional getEmail() { + return email; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UserWithUserId && equalTo((UserWithUserId) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UserWithUserId other) { + return userId.equals(other.userId) && email.equals(other.email); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.userId, this.email); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static UserIdStage builder() { + return new Builder(); + } + + public interface UserIdStage { + _FinalStage userId(@NotNull String userId); + + Builder from(UserWithUserId other); + } + + public interface _FinalStage { + UserWithUserId build(); + + _FinalStage email(Optional email); + + _FinalStage email(String email); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements UserIdStage, _FinalStage { + private String userId; + + private Optional email = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(UserWithUserId other) { + userId(other.getUserId()); + email(other.getEmail()); + return this; + } + + /** + *

A unique identifier for the contact which is given to Intercom.

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

The contact's email, retained by default if one is present.

+ * @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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "email", nulls = Nulls.SKIP) + public _FinalStage email(Optional email) { + this.email = email; + return this; + } + + @java.lang.Override + public UserWithUserId build() { + return new UserWithUserId(userId, email, additionalProperties); + } + } + } + } + + @JsonDeserialize(using = Visitor.Deserializer.class) + public static final class Visitor { + private final Object value; + + private final int type; + + private Visitor(Object value, int type) { + this.value = value; + this.type = type; + } + + @JsonValue + public Object get() { + return this.value; + } + + public T visit(Visitor_ visitor) { + if (this.type == 0) { + return visitor.visit((VisitorWithId) this.value); + } else if (this.type == 1) { + return visitor.visit((VisitorWithUserId) this.value); + } else if (this.type == 2) { + return visitor.visit((VisitorWithEmail) 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 Visitor && equalTo((Visitor) other); + } + + private boolean equalTo(Visitor 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 Visitor of(VisitorWithId value) { + return new Visitor(value, 0); + } + + public static Visitor of(VisitorWithUserId value) { + return new Visitor(value, 1); + } + + public static Visitor of(VisitorWithEmail value) { + return new Visitor(value, 2); + } + + public interface Visitor_ { + T visit(VisitorWithId value); + + T visit(VisitorWithUserId value); + + T visit(VisitorWithEmail value); + } + + static final class Deserializer extends StdDeserializer { + Deserializer() { + super(Visitor.class); + } + + @java.lang.Override + public Visitor deserialize(JsonParser p, DeserializationContext context) throws IOException { + Object value = p.readValueAs(Object.class); + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, VisitorWithId.class)); + } catch (IllegalArgumentException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, VisitorWithUserId.class)); + } catch (IllegalArgumentException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, VisitorWithEmail.class)); + } catch (IllegalArgumentException e) { + } + throw new JsonParseException(p, "Failed to deserialize"); + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = VisitorWithEmail.Builder.class) + public static final class VisitorWithEmail { + private final String email; + + private final Map additionalProperties; + + private VisitorWithEmail(String email, Map additionalProperties) { + this.email = email; + this.additionalProperties = additionalProperties; + } + + /** + * @return The visitor's email. + */ + @JsonProperty("email") + public String getEmail() { + return email; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof VisitorWithEmail && equalTo((VisitorWithEmail) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(VisitorWithEmail 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 { + _FinalStage email(@NotNull String email); + + Builder from(VisitorWithEmail other); + } + + public interface _FinalStage { + VisitorWithEmail 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(VisitorWithEmail other) { + email(other.getEmail()); + return this; + } + + /** + *

The visitor's email.

+ * @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 VisitorWithEmail build() { + return new VisitorWithEmail(email, additionalProperties); + } + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = VisitorWithId.Builder.class) + public static final class VisitorWithId { + private final String id; + + private final Map additionalProperties; + + private VisitorWithId(String id, Map additionalProperties) { + this.id = id; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the contact which is 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 VisitorWithId && equalTo((VisitorWithId) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(VisitorWithId 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 { + _FinalStage id(@NotNull String id); + + Builder from(VisitorWithId other); + } + + public interface _FinalStage { + VisitorWithId 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(VisitorWithId other) { + id(other.getId()); + return this; + } + + /** + *

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 _FinalStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + public VisitorWithId build() { + return new VisitorWithId(id, additionalProperties); + } + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = VisitorWithUserId.Builder.class) + public static final class VisitorWithUserId { + private final String userId; + + private final Map additionalProperties; + + private VisitorWithUserId(String userId, Map additionalProperties) { + this.userId = userId; + this.additionalProperties = additionalProperties; + } + + /** + * @return A unique identifier for the contact which is given to Intercom. + */ + @JsonProperty("user_id") + public String getUserId() { + return userId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof VisitorWithUserId && equalTo((VisitorWithUserId) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(VisitorWithUserId other) { + return userId.equals(other.userId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.userId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static UserIdStage builder() { + return new Builder(); + } + + public interface UserIdStage { + _FinalStage userId(@NotNull String userId); + + Builder from(VisitorWithUserId other); + } + + public interface _FinalStage { + VisitorWithUserId build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements UserIdStage, _FinalStage { + private String userId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(VisitorWithUserId other) { + userId(other.getUserId()); + return this; + } + + /** + *

A unique identifier for the contact which is given to Intercom.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("user_id") + public _FinalStage userId(@NotNull String userId) { + this.userId = Objects.requireNonNull(userId, "userId must not be null"); + return this; + } + + @java.lang.Override + public VisitorWithUserId build() { + return new VisitorWithUserId(userId, additionalProperties); + } + } + } + } +} diff --git a/src/main/java/com/intercom/api/types/ActionComponent.java b/src/main/java/com/intercom/api/types/ActionComponent.java new file mode 100644 index 00000000..f4e21444 --- /dev/null +++ b/src/main/java/com/intercom/api/types/ActionComponent.java @@ -0,0 +1,263 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonUnwrapped; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; +import java.util.Optional; + +public final class ActionComponent { + private final Value value; + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + private ActionComponent(Value value) { + this.value = value; + } + + public T visit(Visitor visitor) { + return value.visit(visitor); + } + + public static ActionComponent sheet(SheetActionComponent value) { + return new ActionComponent(new SheetValue(value)); + } + + public static ActionComponent url(UrlActionComponent value) { + return new ActionComponent(new UrlValue(value)); + } + + public static ActionComponent submit(SubmitActionComponent value) { + return new ActionComponent(new SubmitValue(value)); + } + + public boolean isSheet() { + return value instanceof SheetValue; + } + + public boolean isUrl() { + return value instanceof UrlValue; + } + + public boolean isSubmit() { + return value instanceof SubmitValue; + } + + public boolean _isUnknown() { + return value instanceof _UnknownValue; + } + + public Optional getSheet() { + if (isSheet()) { + return Optional.of(((SheetValue) value).value); + } + return Optional.empty(); + } + + public Optional getUrl() { + if (isUrl()) { + return Optional.of(((UrlValue) value).value); + } + return Optional.empty(); + } + + public Optional getSubmit() { + if (isSubmit()) { + return Optional.of(((SubmitValue) value).value); + } + return Optional.empty(); + } + + public Optional _getUnknown() { + if (_isUnknown()) { + return Optional.of(((_UnknownValue) value).value); + } + return Optional.empty(); + } + + @JsonValue + private Value getValue() { + return this.value; + } + + public interface Visitor { + T visitSheet(SheetActionComponent sheet); + + T visitUrl(UrlActionComponent url); + + T visitSubmit(SubmitActionComponent submit); + + T _visitUnknown(Object unknownType); + } + + @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type", visible = true, defaultImpl = _UnknownValue.class) + @JsonSubTypes({ + @JsonSubTypes.Type(SheetValue.class), + @JsonSubTypes.Type(UrlValue.class), + @JsonSubTypes.Type(SubmitValue.class) + }) + @JsonIgnoreProperties(ignoreUnknown = true) + private interface Value { + T visit(Visitor visitor); + } + + @JsonTypeName("sheet") + @JsonIgnoreProperties("type") + private static final class SheetValue implements Value { + @JsonUnwrapped + private SheetActionComponent value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private SheetValue() {} + + private SheetValue(SheetActionComponent value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitSheet(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof SheetValue && equalTo((SheetValue) other); + } + + private boolean equalTo(SheetValue other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "ActionComponent{" + "value: " + value + "}"; + } + } + + @JsonTypeName("url") + @JsonIgnoreProperties("type") + private static final class UrlValue implements Value { + @JsonUnwrapped + private UrlActionComponent value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private UrlValue() {} + + private UrlValue(UrlActionComponent value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitUrl(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UrlValue && equalTo((UrlValue) other); + } + + private boolean equalTo(UrlValue other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "ActionComponent{" + "value: " + value + "}"; + } + } + + @JsonTypeName("submit") + @JsonIgnoreProperties("type") + private static final class SubmitValue implements Value { + @JsonUnwrapped + private SubmitActionComponent value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private SubmitValue() {} + + private SubmitValue(SubmitActionComponent value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitSubmit(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof SubmitValue && equalTo((SubmitValue) other); + } + + private boolean equalTo(SubmitValue other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "ActionComponent{" + "value: " + value + "}"; + } + } + + @JsonIgnoreProperties("type") + private static final class _UnknownValue implements Value { + private String type; + + @JsonValue + private Object value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private _UnknownValue(@JsonProperty("value") Object value) {} + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor._visitUnknown(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof _UnknownValue && equalTo((_UnknownValue) other); + } + + private boolean equalTo(_UnknownValue other) { + return type.equals(other.type) && value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.value); + } + + @java.lang.Override + public String toString() { + return "ActionComponent{" + "type: " + type + ", value: " + value + "}"; + } + } +} diff --git a/src/main/java/com/intercom/api/types/ActivityLog.java b/src/main/java/com/intercom/api/types/ActivityLog.java new file mode 100644 index 00000000..6157c8ad --- /dev/null +++ b/src/main/java/com/intercom/api/types/ActivityLog.java @@ -0,0 +1,1217 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.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 = ActivityLog.Builder.class) +public final class ActivityLog { + private final String id; + + private final PerformedBy performedBy; + + private final Optional metadata; + + private final Optional createdAt; + + private final ActivityType activityType; + + private final Optional activityDescription; + + private final Map additionalProperties; + + private ActivityLog( + String id, + PerformedBy performedBy, + Optional metadata, + Optional createdAt, + ActivityType activityType, + Optional activityDescription, + Map additionalProperties) { + this.id = id; + this.performedBy = performedBy; + this.metadata = metadata; + this.createdAt = createdAt; + this.activityType = activityType; + this.activityDescription = activityDescription; + this.additionalProperties = additionalProperties; + } + + /** + * @return The id representing the activity. + */ + @JsonProperty("id") + public String getId() { + return id; + } + + /** + * @return Details about the Admin involved in the activity. + */ + @JsonProperty("performed_by") + public PerformedBy getPerformedBy() { + return performedBy; + } + + @JsonProperty("metadata") + public Optional getMetadata() { + return metadata; + } + + /** + * @return The time the activity was created. + */ + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + @JsonProperty("activity_type") + public ActivityType getActivityType() { + return activityType; + } + + /** + * @return A sentence or two describing the activity. + */ + @JsonProperty("activity_description") + public Optional getActivityDescription() { + return activityDescription; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ActivityLog && equalTo((ActivityLog) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ActivityLog other) { + return id.equals(other.id) + && performedBy.equals(other.performedBy) + && metadata.equals(other.metadata) + && createdAt.equals(other.createdAt) + && activityType.equals(other.activityType) + && activityDescription.equals(other.activityDescription); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.id, this.performedBy, this.metadata, this.createdAt, this.activityType, this.activityDescription); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + PerformedByStage id(@NotNull String id); + + Builder from(ActivityLog other); + } + + public interface PerformedByStage { + ActivityTypeStage performedBy(@NotNull PerformedBy performedBy); + } + + public interface ActivityTypeStage { + _FinalStage activityType(@NotNull ActivityType activityType); + } + + public interface _FinalStage { + ActivityLog build(); + + _FinalStage metadata(Optional metadata); + + _FinalStage metadata(ActivityLogMetadata metadata); + + _FinalStage createdAt(Optional createdAt); + + _FinalStage createdAt(Integer createdAt); + + _FinalStage activityDescription(Optional activityDescription); + + _FinalStage activityDescription(String activityDescription); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, PerformedByStage, ActivityTypeStage, _FinalStage { + private String id; + + private PerformedBy performedBy; + + private ActivityType activityType; + + private Optional activityDescription = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + private Optional metadata = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ActivityLog other) { + id(other.getId()); + performedBy(other.getPerformedBy()); + metadata(other.getMetadata()); + createdAt(other.getCreatedAt()); + activityType(other.getActivityType()); + activityDescription(other.getActivityDescription()); + return this; + } + + /** + *

The id representing the activity.

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

Details about the Admin involved in the activity.

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

A sentence or two describing the activity.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage activityDescription(String activityDescription) { + this.activityDescription = Optional.ofNullable(activityDescription); + return this; + } + + @java.lang.Override + @JsonSetter(value = "activity_description", nulls = Nulls.SKIP) + public _FinalStage activityDescription(Optional activityDescription) { + this.activityDescription = activityDescription; + return this; + } + + /** + *

The time the activity was created.

+ * @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; + } + + @java.lang.Override + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public _FinalStage createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + @java.lang.Override + public _FinalStage metadata(ActivityLogMetadata metadata) { + this.metadata = Optional.ofNullable(metadata); + return this; + } + + @java.lang.Override + @JsonSetter(value = "metadata", nulls = Nulls.SKIP) + public _FinalStage metadata(Optional metadata) { + this.metadata = metadata; + return this; + } + + @java.lang.Override + public ActivityLog build() { + return new ActivityLog( + id, performedBy, metadata, createdAt, activityType, activityDescription, additionalProperties); + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = PerformedBy.Builder.class) + public static final class PerformedBy { + private final Optional type; + + private final Optional id; + + private final Optional email; + + private final Optional ip; + + private final Map additionalProperties; + + private PerformedBy( + Optional type, + Optional id, + Optional email, + Optional ip, + Map additionalProperties) { + this.type = type; + this.id = id; + this.email = email; + this.ip = ip; + this.additionalProperties = additionalProperties; + } + + /** + * @return String representing the object's type. Always has the value admin. + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return The id representing the admin. + */ + @JsonProperty("id") + public Optional getId() { + return id; + } + + /** + * @return The email of the admin. + */ + @JsonProperty("email") + public Optional getEmail() { + return email; + } + + /** + * @return The IP address of the admin. + */ + @JsonProperty("ip") + public Optional getIp() { + return ip; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof PerformedBy && equalTo((PerformedBy) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(PerformedBy other) { + return type.equals(other.type) && id.equals(other.id) && email.equals(other.email) && ip.equals(other.ip); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.id, this.email, this.ip); + } + + @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 email = Optional.empty(); + + private Optional ip = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(PerformedBy other) { + type(other.getType()); + id(other.getId()); + email(other.getEmail()); + ip(other.getIp()); + 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 = "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 = "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; + } + + @JsonSetter(value = "ip", nulls = Nulls.SKIP) + public Builder ip(Optional ip) { + this.ip = ip; + return this; + } + + public Builder ip(String ip) { + this.ip = Optional.ofNullable(ip); + return this; + } + + public PerformedBy build() { + return new PerformedBy(type, id, email, ip, additionalProperties); + } + } + } + + public final class ActivityType { + public static final ActivityType CAMPAIGN_DELETION = + new ActivityType(Value.CAMPAIGN_DELETION, "campaign_deletion"); + + public static final ActivityType ADMIN_LOGOUT = new ActivityType(Value.ADMIN_LOGOUT, "admin_logout"); + + public static final ActivityType TEMPORARY_EXPECTATION_CHANGE = + new ActivityType(Value.TEMPORARY_EXPECTATION_CHANGE, "temporary_expectation_change"); + + public static final ActivityType ADMIN_IMPERSONATION_END = + new ActivityType(Value.ADMIN_IMPERSONATION_END, "admin_impersonation_end"); + + public static final ActivityType APP_OUTBOUND_ADDRESS_CHANGE = + new ActivityType(Value.APP_OUTBOUND_ADDRESS_CHANGE, "app_outbound_address_change"); + + public static final ActivityType SEAT_CHANGE = new ActivityType(Value.SEAT_CHANGE, "seat_change"); + + public static final ActivityType SEARCH_BROWSE_REQUIRED_CHANGE = + new ActivityType(Value.SEARCH_BROWSE_REQUIRED_CHANGE, "search_browse_required_change"); + + public static final ActivityType SECURITY_SETTINGS_CHANGE = + new ActivityType(Value.SECURITY_SETTINGS_CHANGE, "security_settings_change"); + + public static final ActivityType APP_TEAM_CREATION = + new ActivityType(Value.APP_TEAM_CREATION, "app_team_creation"); + + public static final ActivityType APP_PACKAGE_UNINSTALLATION = + new ActivityType(Value.APP_PACKAGE_UNINSTALLATION, "app_package_uninstallation"); + + public static final ActivityType CONVERSATION_TOPIC_CHANGE = + new ActivityType(Value.CONVERSATION_TOPIC_CHANGE, "conversation_topic_change"); + + public static final ActivityType ADMIN_ASSIGNMENT_LIMIT_CHANGE = + new ActivityType(Value.ADMIN_ASSIGNMENT_LIMIT_CHANGE, "admin_assignment_limit_change"); + + public static final ActivityType CAMPAIGN_STATE_CHANGE = + new ActivityType(Value.CAMPAIGN_STATE_CHANGE, "campaign_state_change"); + + public static final ActivityType ADMIN_AWAY_MODE_CHANGE = + new ActivityType(Value.ADMIN_AWAY_MODE_CHANGE, "admin_away_mode_change"); + + public static final ActivityType CONVERSATION_PART_DELETION = + new ActivityType(Value.CONVERSATION_PART_DELETION, "conversation_part_deletion"); + + public static final ActivityType APP_WEBHOOK_DELETION = + new ActivityType(Value.APP_WEBHOOK_DELETION, "app_webhook_deletion"); + + public static final ActivityType SEARCH_BROWSE_ENABLED_CHANGE = + new ActivityType(Value.SEARCH_BROWSE_ENABLED_CHANGE, "search_browse_enabled_change"); + + public static final ActivityType MESSENGER_SEARCH_REQUIRED_CHANGE = + new ActivityType(Value.MESSENGER_SEARCH_REQUIRED_CHANGE, "messenger_search_required_change"); + + public static final ActivityType ADMIN_DEPROVISIONED = + new ActivityType(Value.ADMIN_DEPROVISIONED, "admin_deprovisioned"); + + public static final ActivityType APP_AUTHENTICATION_METHOD_CHANGE = + new ActivityType(Value.APP_AUTHENTICATION_METHOD_CHANGE, "app_authentication_method_change"); + + public static final ActivityType RULESET_CREATION = + new ActivityType(Value.RULESET_CREATION, "ruleset_creation"); + + public static final ActivityType ADMIN_DELETION = new ActivityType(Value.ADMIN_DELETION, "admin_deletion"); + + public static final ActivityType APP_PACKAGE_INSTALLATION = + new ActivityType(Value.APP_PACKAGE_INSTALLATION, "app_package_installation"); + + public static final ActivityType ROLE_CREATION = new ActivityType(Value.ROLE_CREATION, "role_creation"); + + public static final ActivityType APP_ADMIN_JOIN = new ActivityType(Value.APP_ADMIN_JOIN, "app_admin_join"); + + public static final ActivityType APP_DATA_EXPORT = new ActivityType(Value.APP_DATA_EXPORT, "app_data_export"); + + public static final ActivityType ADMIN_LOGIN_FAILURE = + new ActivityType(Value.ADMIN_LOGIN_FAILURE, "admin_login_failure"); + + public static final ActivityType APP_TEAM_DELETION = + new ActivityType(Value.APP_TEAM_DELETION, "app_team_deletion"); + + public static final ActivityType MESSENGER_LOOK_AND_FEEL_CHANGE = + new ActivityType(Value.MESSENGER_LOOK_AND_FEEL_CHANGE, "messenger_look_and_feel_change"); + + public static final ActivityType SEAT_REVOKE = new ActivityType(Value.SEAT_REVOKE, "seat_revoke"); + + public static final ActivityType RULESET_ACTIVATION_TITLE_PREVIEW = + new ActivityType(Value.RULESET_ACTIVATION_TITLE_PREVIEW, "ruleset_activation_title_preview"); + + public static final ActivityType MESSAGE_DELETION = + new ActivityType(Value.MESSAGE_DELETION, "message_deletion"); + + public static final ActivityType MESSENGER_SPACES_CHANGE = + new ActivityType(Value.MESSENGER_SPACES_CHANGE, "messenger_spaces_change"); + + public static final ActivityType APP_NAME_CHANGE = new ActivityType(Value.APP_NAME_CHANGE, "app_name_change"); + + public static final ActivityType APP_WEBHOOK_CREATION = + new ActivityType(Value.APP_WEBHOOK_CREATION, "app_webhook_creation"); + + public static final ActivityType APP_GOOGLE_SSO_DOMAIN_CHANGE = + new ActivityType(Value.APP_GOOGLE_SSO_DOMAIN_CHANGE, "app_google_sso_domain_change"); + + public static final ActivityType CONVERSATION_TOPIC_CREATION = + new ActivityType(Value.CONVERSATION_TOPIC_CREATION, "conversation_topic_creation"); + + public static final ActivityType HELP_CENTER_SETTINGS_CHANGE = + new ActivityType(Value.HELP_CENTER_SETTINGS_CHANGE, "help_center_settings_change"); + + public static final ActivityType ROLE_DELETION = new ActivityType(Value.ROLE_DELETION, "role_deletion"); + + public static final ActivityType APP_PACKAGE_TOKEN_REGENERATION = + new ActivityType(Value.APP_PACKAGE_TOKEN_REGENERATION, "app_package_token_regeneration"); + + public static final ActivityType APP_TIMEZONE_CHANGE = + new ActivityType(Value.APP_TIMEZONE_CHANGE, "app_timezone_change"); + + public static final ActivityType ROLE_CHANGE = new ActivityType(Value.ROLE_CHANGE, "role_change"); + + public static final ActivityType ADMIN_IMPERSONATION_START = + new ActivityType(Value.ADMIN_IMPERSONATION_START, "admin_impersonation_start"); + + public static final ActivityType BULK_DELETE = new ActivityType(Value.BULK_DELETE, "bulk_delete"); + + public static final ActivityType ADMIN_INVITE_DELETION = + new ActivityType(Value.ADMIN_INVITE_DELETION, "admin_invite_deletion"); + + public static final ActivityType ADMIN_PASSWORD_RESET_REQUEST = + new ActivityType(Value.ADMIN_PASSWORD_RESET_REQUEST, "admin_password_reset_request"); + + public static final ActivityType APP_DATA_DELETION = + new ActivityType(Value.APP_DATA_DELETION, "app_data_deletion"); + + public static final ActivityType APP_IDENTITY_VERIFICATION_CHANGE = + new ActivityType(Value.APP_IDENTITY_VERIFICATION_CHANGE, "app_identity_verification_change"); + + public static final ActivityType CONVERSATION_TOPIC_DELETION = + new ActivityType(Value.CONVERSATION_TOPIC_DELETION, "conversation_topic_deletion"); + + public static final ActivityType ADMIN_PASSWORD_RESET_SUCCESS = + new ActivityType(Value.ADMIN_PASSWORD_RESET_SUCCESS, "admin_password_reset_success"); + + public static final ActivityType OFFICE_HOURS_CHANGE = + new ActivityType(Value.OFFICE_HOURS_CHANGE, "office_hours_change"); + + public static final ActivityType ADMIN_UNAUTHORIZED_SIGN_IN_METHOD = + new ActivityType(Value.ADMIN_UNAUTHORIZED_SIGN_IN_METHOD, "admin_unauthorized_sign_in_method"); + + public static final ActivityType BULK_EXPORT = new ActivityType(Value.BULK_EXPORT, "bulk_export"); + + public static final ActivityType WELCOME_MESSAGE_CHANGE = + new ActivityType(Value.WELCOME_MESSAGE_CHANGE, "welcome_message_change"); + + public static final ActivityType ADMIN_PROVISIONED = + new ActivityType(Value.ADMIN_PROVISIONED, "admin_provisioned"); + + public static final ActivityType UPFRONT_EMAIL_COLLECTION_CHANGE = + new ActivityType(Value.UPFRONT_EMAIL_COLLECTION_CHANGE, "upfront_email_collection_change"); + + public static final ActivityType ARTICLES_IN_MESSENGER_ENABLED_CHANGE = + new ActivityType(Value.ARTICLES_IN_MESSENGER_ENABLED_CHANGE, "articles_in_messenger_enabled_change"); + + public static final ActivityType ADMIN_LOGIN_SUCCESS = + new ActivityType(Value.ADMIN_LOGIN_SUCCESS, "admin_login_success"); + + public static final ActivityType ADMIN_TWO_FACTOR_AUTH_CHANGE = + new ActivityType(Value.ADMIN_TWO_FACTOR_AUTH_CHANGE, "admin_two_factor_auth_change"); + + public static final ActivityType APP_TEAM_MEMBERSHIP_MODIFICATION = + new ActivityType(Value.APP_TEAM_MEMBERSHIP_MODIFICATION, "app_team_membership_modification"); + + public static final ActivityType ADMIN_PERMISSION_CHANGE = + new ActivityType(Value.ADMIN_PERMISSION_CHANGE, "admin_permission_change"); + + public static final ActivityType INBOUND_CONVERSATIONS_CHANGE = + new ActivityType(Value.INBOUND_CONVERSATIONS_CHANGE, "inbound_conversations_change"); + + public static final ActivityType MESSAGE_STATE_CHANGE = + new ActivityType(Value.MESSAGE_STATE_CHANGE, "message_state_change"); + + public static final ActivityType ADMIN_INVITE_CREATION = + new ActivityType(Value.ADMIN_INVITE_CREATION, "admin_invite_creation"); + + public static final ActivityType INBOX_ACCESS_CHANGE = + new ActivityType(Value.INBOX_ACCESS_CHANGE, "inbox_access_change"); + + public static final ActivityType ADMIN_INVITE_CHANGE = + new ActivityType(Value.ADMIN_INVITE_CHANGE, "admin_invite_change"); + + public static final ActivityType RULESET_DELETION = + new ActivityType(Value.RULESET_DELETION, "ruleset_deletion"); + + private final Value value; + + private final String string; + + ActivityType(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 ActivityType && this.string.equals(((ActivityType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case CAMPAIGN_DELETION: + return visitor.visitCampaignDeletion(); + case ADMIN_LOGOUT: + return visitor.visitAdminLogout(); + case TEMPORARY_EXPECTATION_CHANGE: + return visitor.visitTemporaryExpectationChange(); + case ADMIN_IMPERSONATION_END: + return visitor.visitAdminImpersonationEnd(); + case APP_OUTBOUND_ADDRESS_CHANGE: + return visitor.visitAppOutboundAddressChange(); + case SEAT_CHANGE: + return visitor.visitSeatChange(); + case SEARCH_BROWSE_REQUIRED_CHANGE: + return visitor.visitSearchBrowseRequiredChange(); + case SECURITY_SETTINGS_CHANGE: + return visitor.visitSecuritySettingsChange(); + case APP_TEAM_CREATION: + return visitor.visitAppTeamCreation(); + case APP_PACKAGE_UNINSTALLATION: + return visitor.visitAppPackageUninstallation(); + case CONVERSATION_TOPIC_CHANGE: + return visitor.visitConversationTopicChange(); + case ADMIN_ASSIGNMENT_LIMIT_CHANGE: + return visitor.visitAdminAssignmentLimitChange(); + case CAMPAIGN_STATE_CHANGE: + return visitor.visitCampaignStateChange(); + case ADMIN_AWAY_MODE_CHANGE: + return visitor.visitAdminAwayModeChange(); + case CONVERSATION_PART_DELETION: + return visitor.visitConversationPartDeletion(); + case APP_WEBHOOK_DELETION: + return visitor.visitAppWebhookDeletion(); + case SEARCH_BROWSE_ENABLED_CHANGE: + return visitor.visitSearchBrowseEnabledChange(); + case MESSENGER_SEARCH_REQUIRED_CHANGE: + return visitor.visitMessengerSearchRequiredChange(); + case ADMIN_DEPROVISIONED: + return visitor.visitAdminDeprovisioned(); + case APP_AUTHENTICATION_METHOD_CHANGE: + return visitor.visitAppAuthenticationMethodChange(); + case RULESET_CREATION: + return visitor.visitRulesetCreation(); + case ADMIN_DELETION: + return visitor.visitAdminDeletion(); + case APP_PACKAGE_INSTALLATION: + return visitor.visitAppPackageInstallation(); + case ROLE_CREATION: + return visitor.visitRoleCreation(); + case APP_ADMIN_JOIN: + return visitor.visitAppAdminJoin(); + case APP_DATA_EXPORT: + return visitor.visitAppDataExport(); + case ADMIN_LOGIN_FAILURE: + return visitor.visitAdminLoginFailure(); + case APP_TEAM_DELETION: + return visitor.visitAppTeamDeletion(); + case MESSENGER_LOOK_AND_FEEL_CHANGE: + return visitor.visitMessengerLookAndFeelChange(); + case SEAT_REVOKE: + return visitor.visitSeatRevoke(); + case RULESET_ACTIVATION_TITLE_PREVIEW: + return visitor.visitRulesetActivationTitlePreview(); + case MESSAGE_DELETION: + return visitor.visitMessageDeletion(); + case MESSENGER_SPACES_CHANGE: + return visitor.visitMessengerSpacesChange(); + case APP_NAME_CHANGE: + return visitor.visitAppNameChange(); + case APP_WEBHOOK_CREATION: + return visitor.visitAppWebhookCreation(); + case APP_GOOGLE_SSO_DOMAIN_CHANGE: + return visitor.visitAppGoogleSsoDomainChange(); + case CONVERSATION_TOPIC_CREATION: + return visitor.visitConversationTopicCreation(); + case HELP_CENTER_SETTINGS_CHANGE: + return visitor.visitHelpCenterSettingsChange(); + case ROLE_DELETION: + return visitor.visitRoleDeletion(); + case APP_PACKAGE_TOKEN_REGENERATION: + return visitor.visitAppPackageTokenRegeneration(); + case APP_TIMEZONE_CHANGE: + return visitor.visitAppTimezoneChange(); + case ROLE_CHANGE: + return visitor.visitRoleChange(); + case ADMIN_IMPERSONATION_START: + return visitor.visitAdminImpersonationStart(); + case BULK_DELETE: + return visitor.visitBulkDelete(); + case ADMIN_INVITE_DELETION: + return visitor.visitAdminInviteDeletion(); + case ADMIN_PASSWORD_RESET_REQUEST: + return visitor.visitAdminPasswordResetRequest(); + case APP_DATA_DELETION: + return visitor.visitAppDataDeletion(); + case APP_IDENTITY_VERIFICATION_CHANGE: + return visitor.visitAppIdentityVerificationChange(); + case CONVERSATION_TOPIC_DELETION: + return visitor.visitConversationTopicDeletion(); + case ADMIN_PASSWORD_RESET_SUCCESS: + return visitor.visitAdminPasswordResetSuccess(); + case OFFICE_HOURS_CHANGE: + return visitor.visitOfficeHoursChange(); + case ADMIN_UNAUTHORIZED_SIGN_IN_METHOD: + return visitor.visitAdminUnauthorizedSignInMethod(); + case BULK_EXPORT: + return visitor.visitBulkExport(); + case WELCOME_MESSAGE_CHANGE: + return visitor.visitWelcomeMessageChange(); + case ADMIN_PROVISIONED: + return visitor.visitAdminProvisioned(); + case UPFRONT_EMAIL_COLLECTION_CHANGE: + return visitor.visitUpfrontEmailCollectionChange(); + case ARTICLES_IN_MESSENGER_ENABLED_CHANGE: + return visitor.visitArticlesInMessengerEnabledChange(); + case ADMIN_LOGIN_SUCCESS: + return visitor.visitAdminLoginSuccess(); + case ADMIN_TWO_FACTOR_AUTH_CHANGE: + return visitor.visitAdminTwoFactorAuthChange(); + case APP_TEAM_MEMBERSHIP_MODIFICATION: + return visitor.visitAppTeamMembershipModification(); + case ADMIN_PERMISSION_CHANGE: + return visitor.visitAdminPermissionChange(); + case INBOUND_CONVERSATIONS_CHANGE: + return visitor.visitInboundConversationsChange(); + case MESSAGE_STATE_CHANGE: + return visitor.visitMessageStateChange(); + case ADMIN_INVITE_CREATION: + return visitor.visitAdminInviteCreation(); + case INBOX_ACCESS_CHANGE: + return visitor.visitInboxAccessChange(); + case ADMIN_INVITE_CHANGE: + return visitor.visitAdminInviteChange(); + case RULESET_DELETION: + return visitor.visitRulesetDeletion(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static ActivityType valueOf(String value) { + switch (value) { + case "campaign_deletion": + return CAMPAIGN_DELETION; + case "admin_logout": + return ADMIN_LOGOUT; + case "temporary_expectation_change": + return TEMPORARY_EXPECTATION_CHANGE; + case "admin_impersonation_end": + return ADMIN_IMPERSONATION_END; + case "app_outbound_address_change": + return APP_OUTBOUND_ADDRESS_CHANGE; + case "seat_change": + return SEAT_CHANGE; + case "search_browse_required_change": + return SEARCH_BROWSE_REQUIRED_CHANGE; + case "security_settings_change": + return SECURITY_SETTINGS_CHANGE; + case "app_team_creation": + return APP_TEAM_CREATION; + case "app_package_uninstallation": + return APP_PACKAGE_UNINSTALLATION; + case "conversation_topic_change": + return CONVERSATION_TOPIC_CHANGE; + case "admin_assignment_limit_change": + return ADMIN_ASSIGNMENT_LIMIT_CHANGE; + case "campaign_state_change": + return CAMPAIGN_STATE_CHANGE; + case "admin_away_mode_change": + return ADMIN_AWAY_MODE_CHANGE; + case "conversation_part_deletion": + return CONVERSATION_PART_DELETION; + case "app_webhook_deletion": + return APP_WEBHOOK_DELETION; + case "search_browse_enabled_change": + return SEARCH_BROWSE_ENABLED_CHANGE; + case "messenger_search_required_change": + return MESSENGER_SEARCH_REQUIRED_CHANGE; + case "admin_deprovisioned": + return ADMIN_DEPROVISIONED; + case "app_authentication_method_change": + return APP_AUTHENTICATION_METHOD_CHANGE; + case "ruleset_creation": + return RULESET_CREATION; + case "admin_deletion": + return ADMIN_DELETION; + case "app_package_installation": + return APP_PACKAGE_INSTALLATION; + case "role_creation": + return ROLE_CREATION; + case "app_admin_join": + return APP_ADMIN_JOIN; + case "app_data_export": + return APP_DATA_EXPORT; + case "admin_login_failure": + return ADMIN_LOGIN_FAILURE; + case "app_team_deletion": + return APP_TEAM_DELETION; + case "messenger_look_and_feel_change": + return MESSENGER_LOOK_AND_FEEL_CHANGE; + case "seat_revoke": + return SEAT_REVOKE; + case "ruleset_activation_title_preview": + return RULESET_ACTIVATION_TITLE_PREVIEW; + case "message_deletion": + return MESSAGE_DELETION; + case "messenger_spaces_change": + return MESSENGER_SPACES_CHANGE; + case "app_name_change": + return APP_NAME_CHANGE; + case "app_webhook_creation": + return APP_WEBHOOK_CREATION; + case "app_google_sso_domain_change": + return APP_GOOGLE_SSO_DOMAIN_CHANGE; + case "conversation_topic_creation": + return CONVERSATION_TOPIC_CREATION; + case "help_center_settings_change": + return HELP_CENTER_SETTINGS_CHANGE; + case "role_deletion": + return ROLE_DELETION; + case "app_package_token_regeneration": + return APP_PACKAGE_TOKEN_REGENERATION; + case "app_timezone_change": + return APP_TIMEZONE_CHANGE; + case "role_change": + return ROLE_CHANGE; + case "admin_impersonation_start": + return ADMIN_IMPERSONATION_START; + case "bulk_delete": + return BULK_DELETE; + case "admin_invite_deletion": + return ADMIN_INVITE_DELETION; + case "admin_password_reset_request": + return ADMIN_PASSWORD_RESET_REQUEST; + case "app_data_deletion": + return APP_DATA_DELETION; + case "app_identity_verification_change": + return APP_IDENTITY_VERIFICATION_CHANGE; + case "conversation_topic_deletion": + return CONVERSATION_TOPIC_DELETION; + case "admin_password_reset_success": + return ADMIN_PASSWORD_RESET_SUCCESS; + case "office_hours_change": + return OFFICE_HOURS_CHANGE; + case "admin_unauthorized_sign_in_method": + return ADMIN_UNAUTHORIZED_SIGN_IN_METHOD; + case "bulk_export": + return BULK_EXPORT; + case "welcome_message_change": + return WELCOME_MESSAGE_CHANGE; + case "admin_provisioned": + return ADMIN_PROVISIONED; + case "upfront_email_collection_change": + return UPFRONT_EMAIL_COLLECTION_CHANGE; + case "articles_in_messenger_enabled_change": + return ARTICLES_IN_MESSENGER_ENABLED_CHANGE; + case "admin_login_success": + return ADMIN_LOGIN_SUCCESS; + case "admin_two_factor_auth_change": + return ADMIN_TWO_FACTOR_AUTH_CHANGE; + case "app_team_membership_modification": + return APP_TEAM_MEMBERSHIP_MODIFICATION; + case "admin_permission_change": + return ADMIN_PERMISSION_CHANGE; + case "inbound_conversations_change": + return INBOUND_CONVERSATIONS_CHANGE; + case "message_state_change": + return MESSAGE_STATE_CHANGE; + case "admin_invite_creation": + return ADMIN_INVITE_CREATION; + case "inbox_access_change": + return INBOX_ACCESS_CHANGE; + case "admin_invite_change": + return ADMIN_INVITE_CHANGE; + case "ruleset_deletion": + return RULESET_DELETION; + default: + return new ActivityType(Value.UNKNOWN, value); + } + } + + public enum Value { + ADMIN_ASSIGNMENT_LIMIT_CHANGE, + + ADMIN_AWAY_MODE_CHANGE, + + ADMIN_DELETION, + + ADMIN_DEPROVISIONED, + + ADMIN_IMPERSONATION_END, + + ADMIN_IMPERSONATION_START, + + ADMIN_INVITE_CHANGE, + + ADMIN_INVITE_CREATION, + + ADMIN_INVITE_DELETION, + + ADMIN_LOGIN_FAILURE, + + ADMIN_LOGIN_SUCCESS, + + ADMIN_LOGOUT, + + ADMIN_PASSWORD_RESET_REQUEST, + + ADMIN_PASSWORD_RESET_SUCCESS, + + ADMIN_PERMISSION_CHANGE, + + ADMIN_PROVISIONED, + + ADMIN_TWO_FACTOR_AUTH_CHANGE, + + ADMIN_UNAUTHORIZED_SIGN_IN_METHOD, + + APP_ADMIN_JOIN, + + APP_AUTHENTICATION_METHOD_CHANGE, + + APP_DATA_DELETION, + + APP_DATA_EXPORT, + + APP_GOOGLE_SSO_DOMAIN_CHANGE, + + APP_IDENTITY_VERIFICATION_CHANGE, + + APP_NAME_CHANGE, + + APP_OUTBOUND_ADDRESS_CHANGE, + + APP_PACKAGE_INSTALLATION, + + APP_PACKAGE_TOKEN_REGENERATION, + + APP_PACKAGE_UNINSTALLATION, + + APP_TEAM_CREATION, + + APP_TEAM_DELETION, + + APP_TEAM_MEMBERSHIP_MODIFICATION, + + APP_TIMEZONE_CHANGE, + + APP_WEBHOOK_CREATION, + + APP_WEBHOOK_DELETION, + + ARTICLES_IN_MESSENGER_ENABLED_CHANGE, + + BULK_DELETE, + + BULK_EXPORT, + + CAMPAIGN_DELETION, + + CAMPAIGN_STATE_CHANGE, + + CONVERSATION_PART_DELETION, + + CONVERSATION_TOPIC_CHANGE, + + CONVERSATION_TOPIC_CREATION, + + CONVERSATION_TOPIC_DELETION, + + HELP_CENTER_SETTINGS_CHANGE, + + INBOUND_CONVERSATIONS_CHANGE, + + INBOX_ACCESS_CHANGE, + + MESSAGE_DELETION, + + MESSAGE_STATE_CHANGE, + + MESSENGER_LOOK_AND_FEEL_CHANGE, + + MESSENGER_SEARCH_REQUIRED_CHANGE, + + MESSENGER_SPACES_CHANGE, + + OFFICE_HOURS_CHANGE, + + ROLE_CHANGE, + + ROLE_CREATION, + + ROLE_DELETION, + + RULESET_ACTIVATION_TITLE_PREVIEW, + + RULESET_CREATION, + + RULESET_DELETION, + + SEARCH_BROWSE_ENABLED_CHANGE, + + SEARCH_BROWSE_REQUIRED_CHANGE, + + SEAT_CHANGE, + + SEAT_REVOKE, + + SECURITY_SETTINGS_CHANGE, + + TEMPORARY_EXPECTATION_CHANGE, + + UPFRONT_EMAIL_COLLECTION_CHANGE, + + WELCOME_MESSAGE_CHANGE, + + UNKNOWN + } + + public interface Visitor { + T visitAdminAssignmentLimitChange(); + + T visitAdminAwayModeChange(); + + T visitAdminDeletion(); + + T visitAdminDeprovisioned(); + + T visitAdminImpersonationEnd(); + + T visitAdminImpersonationStart(); + + T visitAdminInviteChange(); + + T visitAdminInviteCreation(); + + T visitAdminInviteDeletion(); + + T visitAdminLoginFailure(); + + T visitAdminLoginSuccess(); + + T visitAdminLogout(); + + T visitAdminPasswordResetRequest(); + + T visitAdminPasswordResetSuccess(); + + T visitAdminPermissionChange(); + + T visitAdminProvisioned(); + + T visitAdminTwoFactorAuthChange(); + + T visitAdminUnauthorizedSignInMethod(); + + T visitAppAdminJoin(); + + T visitAppAuthenticationMethodChange(); + + T visitAppDataDeletion(); + + T visitAppDataExport(); + + T visitAppGoogleSsoDomainChange(); + + T visitAppIdentityVerificationChange(); + + T visitAppNameChange(); + + T visitAppOutboundAddressChange(); + + T visitAppPackageInstallation(); + + T visitAppPackageTokenRegeneration(); + + T visitAppPackageUninstallation(); + + T visitAppTeamCreation(); + + T visitAppTeamDeletion(); + + T visitAppTeamMembershipModification(); + + T visitAppTimezoneChange(); + + T visitAppWebhookCreation(); + + T visitAppWebhookDeletion(); + + T visitArticlesInMessengerEnabledChange(); + + T visitBulkDelete(); + + T visitBulkExport(); + + T visitCampaignDeletion(); + + T visitCampaignStateChange(); + + T visitConversationPartDeletion(); + + T visitConversationTopicChange(); + + T visitConversationTopicCreation(); + + T visitConversationTopicDeletion(); + + T visitHelpCenterSettingsChange(); + + T visitInboundConversationsChange(); + + T visitInboxAccessChange(); + + T visitMessageDeletion(); + + T visitMessageStateChange(); + + T visitMessengerLookAndFeelChange(); + + T visitMessengerSearchRequiredChange(); + + T visitMessengerSpacesChange(); + + T visitOfficeHoursChange(); + + T visitRoleChange(); + + T visitRoleCreation(); + + T visitRoleDeletion(); + + T visitRulesetActivationTitlePreview(); + + T visitRulesetCreation(); + + T visitRulesetDeletion(); + + T visitSearchBrowseEnabledChange(); + + T visitSearchBrowseRequiredChange(); + + T visitSeatChange(); + + T visitSeatRevoke(); + + T visitSecuritySettingsChange(); + + T visitTemporaryExpectationChange(); + + T visitUpfrontEmailCollectionChange(); + + T visitWelcomeMessageChange(); + + T visitUnknown(String unknownType); + } + } +} diff --git a/src/main/java/com/intercom/api/types/ActivityLogList.java b/src/main/java/com/intercom/api/types/ActivityLogList.java new file mode 100644 index 00000000..4df6d846 --- /dev/null +++ b/src/main/java/com/intercom/api/types/ActivityLogList.java @@ -0,0 +1,137 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.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.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 = ActivityLogList.Builder.class) +public final class ActivityLogList { + private final Optional pages; + + private final List activityLogs; + + private final Map additionalProperties; + + private ActivityLogList( + Optional pages, List activityLogs, Map additionalProperties) { + this.pages = pages; + this.activityLogs = activityLogs; + this.additionalProperties = additionalProperties; + } + + /** + * @return String representing the object's type. Always has the value activity_log.list. + */ + @JsonProperty("type") + public String getType() { + return "activity_log.list"; + } + + @JsonProperty("pages") + public Optional getPages() { + return pages; + } + + /** + * @return An array of activity logs + */ + @JsonProperty("activity_logs") + public List getActivityLogs() { + return activityLogs; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ActivityLogList && equalTo((ActivityLogList) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ActivityLogList other) { + return pages.equals(other.pages) && activityLogs.equals(other.activityLogs); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.pages, this.activityLogs); + } + + @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 pages = Optional.empty(); + + private List activityLogs = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ActivityLogList other) { + pages(other.getPages()); + activityLogs(other.getActivityLogs()); + 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; + } + + @JsonSetter(value = "activity_logs", nulls = Nulls.SKIP) + public Builder activityLogs(List activityLogs) { + this.activityLogs.clear(); + this.activityLogs.addAll(activityLogs); + return this; + } + + public Builder addActivityLogs(ActivityLog activityLogs) { + this.activityLogs.add(activityLogs); + return this; + } + + public Builder addAllActivityLogs(List activityLogs) { + this.activityLogs.addAll(activityLogs); + return this; + } + + public ActivityLogList build() { + return new ActivityLogList(pages, activityLogs, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/types/ActivityLogMetadata.java b/src/main/java/com/intercom/api/types/ActivityLogMetadata.java new file mode 100644 index 00000000..da09df55 --- /dev/null +++ b/src/main/java/com/intercom/api/types/ActivityLogMetadata.java @@ -0,0 +1,335 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.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 = ActivityLogMetadata.Builder.class) +public final class ActivityLogMetadata { + private final Optional signInMethod; + + private final Optional externalId; + + private final Optional awayMode; + + private final Optional awayStatusReason; + + private final Optional reassignConversations; + + private final Optional source; + + private final Optional autoChanged; + + private final Optional updateBy; + + private final Optional updateByName; + + private final Map additionalProperties; + + private ActivityLogMetadata( + Optional signInMethod, + Optional externalId, + Optional awayMode, + Optional awayStatusReason, + Optional reassignConversations, + Optional source, + Optional autoChanged, + Optional updateBy, + Optional updateByName, + Map additionalProperties) { + this.signInMethod = signInMethod; + this.externalId = externalId; + this.awayMode = awayMode; + this.awayStatusReason = awayStatusReason; + this.reassignConversations = reassignConversations; + this.source = source; + this.autoChanged = autoChanged; + this.updateBy = updateBy; + this.updateByName = updateByName; + this.additionalProperties = additionalProperties; + } + + /** + * @return The way the admin signed in. + */ + @JsonProperty("sign_in_method") + public Optional getSignInMethod() { + return signInMethod; + } + + /** + * @return The unique identifier for the contact which is provided by the Client. + */ + @JsonProperty("external_id") + public Optional getExternalId() { + return externalId; + } + + /** + * @return The away mode status which is set to true when away and false when returned. + */ + @JsonProperty("away_mode") + public Optional getAwayMode() { + return awayMode; + } + + /** + * @return The reason the Admin is away. + */ + @JsonProperty("away_status_reason") + public Optional getAwayStatusReason() { + return awayStatusReason; + } + + /** + * @return Indicates if conversations should be reassigned while an Admin is away. + */ + @JsonProperty("reassign_conversations") + public Optional getReassignConversations() { + return reassignConversations; + } + + /** + * @return The action that initiated the status change. + */ + @JsonProperty("source") + public Optional getSource() { + return source; + } + + /** + * @return Indicates if the status was changed automatically or manually. + */ + @JsonProperty("auto_changed") + public Optional getAutoChanged() { + return autoChanged; + } + + /** + * @return The ID of the Admin who initiated the activity. + */ + @JsonProperty("update_by") + public Optional getUpdateBy() { + return updateBy; + } + + /** + * @return The name of the Admin who initiated the activity. + */ + @JsonProperty("update_by_name") + public Optional getUpdateByName() { + return updateByName; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ActivityLogMetadata && equalTo((ActivityLogMetadata) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ActivityLogMetadata other) { + return signInMethod.equals(other.signInMethod) + && externalId.equals(other.externalId) + && awayMode.equals(other.awayMode) + && awayStatusReason.equals(other.awayStatusReason) + && reassignConversations.equals(other.reassignConversations) + && source.equals(other.source) + && autoChanged.equals(other.autoChanged) + && updateBy.equals(other.updateBy) + && updateByName.equals(other.updateByName); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.signInMethod, + this.externalId, + this.awayMode, + this.awayStatusReason, + this.reassignConversations, + this.source, + this.autoChanged, + this.updateBy, + this.updateByName); + } + + @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 signInMethod = Optional.empty(); + + private Optional externalId = Optional.empty(); + + private Optional awayMode = Optional.empty(); + + private Optional awayStatusReason = Optional.empty(); + + private Optional reassignConversations = Optional.empty(); + + private Optional source = Optional.empty(); + + private Optional autoChanged = Optional.empty(); + + private Optional updateBy = Optional.empty(); + + private Optional updateByName = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ActivityLogMetadata other) { + signInMethod(other.getSignInMethod()); + externalId(other.getExternalId()); + awayMode(other.getAwayMode()); + awayStatusReason(other.getAwayStatusReason()); + reassignConversations(other.getReassignConversations()); + source(other.getSource()); + autoChanged(other.getAutoChanged()); + updateBy(other.getUpdateBy()); + updateByName(other.getUpdateByName()); + return this; + } + + @JsonSetter(value = "sign_in_method", nulls = Nulls.SKIP) + public Builder signInMethod(Optional signInMethod) { + this.signInMethod = signInMethod; + return this; + } + + public Builder signInMethod(String signInMethod) { + this.signInMethod = Optional.ofNullable(signInMethod); + return this; + } + + @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; + } + + @JsonSetter(value = "away_mode", nulls = Nulls.SKIP) + public Builder awayMode(Optional awayMode) { + this.awayMode = awayMode; + return this; + } + + public Builder awayMode(Boolean awayMode) { + this.awayMode = Optional.ofNullable(awayMode); + return this; + } + + @JsonSetter(value = "away_status_reason", nulls = Nulls.SKIP) + public Builder awayStatusReason(Optional awayStatusReason) { + this.awayStatusReason = awayStatusReason; + return this; + } + + public Builder awayStatusReason(String awayStatusReason) { + this.awayStatusReason = Optional.ofNullable(awayStatusReason); + return this; + } + + @JsonSetter(value = "reassign_conversations", nulls = Nulls.SKIP) + public Builder reassignConversations(Optional reassignConversations) { + this.reassignConversations = reassignConversations; + return this; + } + + public Builder reassignConversations(Boolean reassignConversations) { + this.reassignConversations = Optional.ofNullable(reassignConversations); + return this; + } + + @JsonSetter(value = "source", nulls = Nulls.SKIP) + public Builder source(Optional source) { + this.source = source; + return this; + } + + public Builder source(String source) { + this.source = Optional.ofNullable(source); + return this; + } + + @JsonSetter(value = "auto_changed", nulls = Nulls.SKIP) + public Builder autoChanged(Optional autoChanged) { + this.autoChanged = autoChanged; + return this; + } + + public Builder autoChanged(String autoChanged) { + this.autoChanged = Optional.ofNullable(autoChanged); + return this; + } + + @JsonSetter(value = "update_by", nulls = Nulls.SKIP) + public Builder updateBy(Optional updateBy) { + this.updateBy = updateBy; + return this; + } + + public Builder updateBy(Integer updateBy) { + this.updateBy = Optional.ofNullable(updateBy); + return this; + } + + @JsonSetter(value = "update_by_name", nulls = Nulls.SKIP) + public Builder updateByName(Optional updateByName) { + this.updateByName = updateByName; + return this; + } + + public Builder updateByName(String updateByName) { + this.updateByName = Optional.ofNullable(updateByName); + return this; + } + + public ActivityLogMetadata build() { + return new ActivityLogMetadata( + signInMethod, + externalId, + awayMode, + awayStatusReason, + reassignConversations, + source, + autoChanged, + updateBy, + updateByName, + additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/types/AddressableList.java b/src/main/java/com/intercom/api/types/AddressableList.java new file mode 100644 index 00000000..0b8252fd --- /dev/null +++ b/src/main/java/com/intercom/api/types/AddressableList.java @@ -0,0 +1,167 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.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.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 = AddressableList.Builder.class) +public final class AddressableList { + private final String type; + + private final String id; + + private final String url; + + private final Map additionalProperties; + + private AddressableList(String type, String id, String url, Map additionalProperties) { + this.type = type; + this.id = id; + this.url = url; + this.additionalProperties = additionalProperties; + } + + /** + * @return The addressable object type + */ + @JsonProperty("type") + public String getType() { + return type; + } + + /** + * @return The id of the addressable object + */ + @JsonProperty("id") + public String getId() { + return id; + } + + /** + * @return Url to get more company resources for this contact + */ + @JsonProperty("url") + public String getUrl() { + return url; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AddressableList && equalTo((AddressableList) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(AddressableList other) { + return type.equals(other.type) && id.equals(other.id) && url.equals(other.url); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.id, this.url); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TypeStage builder() { + return new Builder(); + } + + public interface TypeStage { + IdStage type(@NotNull String type); + + Builder from(AddressableList other); + } + + public interface IdStage { + UrlStage id(@NotNull String id); + } + + public interface UrlStage { + _FinalStage url(@NotNull String url); + } + + public interface _FinalStage { + AddressableList build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements TypeStage, IdStage, UrlStage, _FinalStage { + private String type; + + private String id; + + private String url; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(AddressableList other) { + type(other.getType()); + id(other.getId()); + url(other.getUrl()); + return this; + } + + /** + *

The addressable object type

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

The id of the addressable object

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

Url to get more company resources for this contact

+ * @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; + } + + @java.lang.Override + public AddressableList build() { + return new AddressableList(type, id, url, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/types/AdminList.java b/src/main/java/com/intercom/api/types/AdminList.java new file mode 100644 index 00000000..4d1b01c7 --- /dev/null +++ b/src/main/java/com/intercom/api/types/AdminList.java @@ -0,0 +1,114 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.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.resources.admins.types.Admin; +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 = AdminList.Builder.class) +public final class AdminList { + private final List admins; + + private final Map additionalProperties; + + private AdminList(List admins, Map additionalProperties) { + this.admins = admins; + this.additionalProperties = additionalProperties; + } + + /** + * @return String representing the object's type. Always has the value admin.list. + */ + @JsonProperty("type") + public String getType() { + return "admin.list"; + } + + /** + * @return A list of admins associated with a given workspace. + */ + @JsonProperty("admins") + public List getAdmins() { + return admins; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AdminList && equalTo((AdminList) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(AdminList other) { + return admins.equals(other.admins); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.admins); + } + + @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 admins = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(AdminList other) { + admins(other.getAdmins()); + return this; + } + + @JsonSetter(value = "admins", nulls = Nulls.SKIP) + public Builder admins(List admins) { + this.admins.clear(); + this.admins.addAll(admins); + return this; + } + + public Builder addAdmins(Admin admins) { + this.admins.add(admins); + return this; + } + + public Builder addAllAdmins(List admins) { + this.admins.addAll(admins); + return this; + } + + public AdminList build() { + return new AdminList(admins, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/types/AdminPriorityLevel.java b/src/main/java/com/intercom/api/types/AdminPriorityLevel.java new file mode 100644 index 00000000..6efbf530 --- /dev/null +++ b/src/main/java/com/intercom/api/types/AdminPriorityLevel.java @@ -0,0 +1,127 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.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 = AdminPriorityLevel.Builder.class) +public final class AdminPriorityLevel { + private final Optional> primaryAdminIds; + + private final Optional> secondaryAdminIds; + + private final Map additionalProperties; + + private AdminPriorityLevel( + Optional> primaryAdminIds, + Optional> secondaryAdminIds, + Map additionalProperties) { + this.primaryAdminIds = primaryAdminIds; + this.secondaryAdminIds = secondaryAdminIds; + this.additionalProperties = additionalProperties; + } + + /** + * @return The primary admin ids for the team + */ + @JsonProperty("primary_admin_ids") + public Optional> getPrimaryAdminIds() { + return primaryAdminIds; + } + + /** + * @return The secondary admin ids for the team + */ + @JsonProperty("secondary_admin_ids") + public Optional> getSecondaryAdminIds() { + return secondaryAdminIds; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AdminPriorityLevel && equalTo((AdminPriorityLevel) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(AdminPriorityLevel other) { + return primaryAdminIds.equals(other.primaryAdminIds) && secondaryAdminIds.equals(other.secondaryAdminIds); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.primaryAdminIds, this.secondaryAdminIds); + } + + @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> primaryAdminIds = Optional.empty(); + + private Optional> secondaryAdminIds = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(AdminPriorityLevel other) { + primaryAdminIds(other.getPrimaryAdminIds()); + secondaryAdminIds(other.getSecondaryAdminIds()); + return this; + } + + @JsonSetter(value = "primary_admin_ids", nulls = Nulls.SKIP) + public Builder primaryAdminIds(Optional> primaryAdminIds) { + this.primaryAdminIds = primaryAdminIds; + return this; + } + + public Builder primaryAdminIds(List primaryAdminIds) { + this.primaryAdminIds = Optional.ofNullable(primaryAdminIds); + return this; + } + + @JsonSetter(value = "secondary_admin_ids", nulls = Nulls.SKIP) + public Builder secondaryAdminIds(Optional> secondaryAdminIds) { + this.secondaryAdminIds = secondaryAdminIds; + return this; + } + + public Builder secondaryAdminIds(List secondaryAdminIds) { + this.secondaryAdminIds = Optional.ofNullable(secondaryAdminIds); + return this; + } + + public AdminPriorityLevel build() { + return new AdminPriorityLevel(primaryAdminIds, secondaryAdminIds, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/types/AdminReplyConversationRequest.java b/src/main/java/com/intercom/api/types/AdminReplyConversationRequest.java new file mode 100644 index 00000000..cd73ece1 --- /dev/null +++ b/src/main/java/com/intercom/api/types/AdminReplyConversationRequest.java @@ -0,0 +1,371 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.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.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 = AdminReplyConversationRequest.Builder.class) +public final class AdminReplyConversationRequest { + private final MessageType messageType; + + private final Optional body; + + private final String adminId; + + private final Optional createdAt; + + private final Optional> attachmentUrls; + + private final Optional> attachmentFiles; + + private final Map additionalProperties; + + private AdminReplyConversationRequest( + MessageType messageType, + Optional body, + String adminId, + Optional createdAt, + Optional> attachmentUrls, + Optional> attachmentFiles, + Map additionalProperties) { + this.messageType = messageType; + this.body = body; + this.adminId = adminId; + this.createdAt = createdAt; + this.attachmentUrls = attachmentUrls; + this.attachmentFiles = attachmentFiles; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("message_type") + public MessageType getMessageType() { + return messageType; + } + + @JsonProperty("type") + public String getType() { + return "admin"; + } + + /** + * @return The text body of the reply. Notes accept some HTML formatting. Must be present for comment and note message types. + */ + @JsonProperty("body") + public Optional getBody() { + return body; + } + + /** + * @return The id of the admin who is authoring the comment. + */ + @JsonProperty("admin_id") + public String getAdminId() { + return adminId; + } + + /** + * @return The time the reply was created. If not provided, the current time will be used. + */ + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + /** + * @return A list of image URLs that will be added as attachments. You can include up to 10 URLs. + */ + @JsonProperty("attachment_urls") + public Optional> getAttachmentUrls() { + return attachmentUrls; + } + + /** + * @return A list of files that will be added as attachments. You can include up to 10 files + */ + @JsonProperty("attachment_files") + public Optional> getAttachmentFiles() { + return attachmentFiles; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AdminReplyConversationRequest && equalTo((AdminReplyConversationRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(AdminReplyConversationRequest other) { + return messageType.equals(other.messageType) + && body.equals(other.body) + && adminId.equals(other.adminId) + && createdAt.equals(other.createdAt) + && attachmentUrls.equals(other.attachmentUrls) + && attachmentFiles.equals(other.attachmentFiles); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.messageType, this.body, this.adminId, this.createdAt, this.attachmentUrls, this.attachmentFiles); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static MessageTypeStage builder() { + return new Builder(); + } + + public interface MessageTypeStage { + AdminIdStage messageType(@NotNull MessageType messageType); + + Builder from(AdminReplyConversationRequest other); + } + + public interface AdminIdStage { + _FinalStage adminId(@NotNull String adminId); + } + + public interface _FinalStage { + AdminReplyConversationRequest build(); + + _FinalStage body(Optional body); + + _FinalStage body(String body); + + _FinalStage createdAt(Optional createdAt); + + _FinalStage createdAt(Integer createdAt); + + _FinalStage attachmentUrls(Optional> attachmentUrls); + + _FinalStage attachmentUrls(List attachmentUrls); + + _FinalStage attachmentFiles(Optional> attachmentFiles); + + _FinalStage attachmentFiles(List attachmentFiles); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements MessageTypeStage, AdminIdStage, _FinalStage { + private MessageType messageType; + + private String adminId; + + private Optional> attachmentFiles = Optional.empty(); + + private Optional> attachmentUrls = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + private Optional body = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(AdminReplyConversationRequest other) { + messageType(other.getMessageType()); + body(other.getBody()); + adminId(other.getAdminId()); + createdAt(other.getCreatedAt()); + attachmentUrls(other.getAttachmentUrls()); + attachmentFiles(other.getAttachmentFiles()); + return this; + } + + @java.lang.Override + @JsonSetter("message_type") + public AdminIdStage messageType(@NotNull MessageType messageType) { + this.messageType = Objects.requireNonNull(messageType, "messageType must not be null"); + return this; + } + + /** + *

The id of the admin who is authoring the comment.

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

A list of files that will be added as attachments. You can include up to 10 files

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage attachmentFiles(List attachmentFiles) { + this.attachmentFiles = Optional.ofNullable(attachmentFiles); + return this; + } + + @java.lang.Override + @JsonSetter(value = "attachment_files", nulls = Nulls.SKIP) + public _FinalStage attachmentFiles(Optional> attachmentFiles) { + this.attachmentFiles = attachmentFiles; + return this; + } + + /** + *

A list of image URLs that will be added as attachments. You can include up to 10 URLs.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage attachmentUrls(List attachmentUrls) { + this.attachmentUrls = Optional.ofNullable(attachmentUrls); + return this; + } + + @java.lang.Override + @JsonSetter(value = "attachment_urls", nulls = Nulls.SKIP) + public _FinalStage attachmentUrls(Optional> attachmentUrls) { + this.attachmentUrls = attachmentUrls; + return this; + } + + /** + *

The time the reply 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; + } + + @java.lang.Override + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public _FinalStage createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + /** + *

The text body of the reply. Notes accept some HTML formatting. Must be present for comment and note message types.

+ * @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; + } + + @java.lang.Override + @JsonSetter(value = "body", nulls = Nulls.SKIP) + public _FinalStage body(Optional body) { + this.body = body; + return this; + } + + @java.lang.Override + public AdminReplyConversationRequest build() { + return new AdminReplyConversationRequest( + messageType, body, adminId, createdAt, attachmentUrls, attachmentFiles, additionalProperties); + } + } + + public final class MessageType { + public static final MessageType NOTE = new MessageType(Value.NOTE, "note"); + + public static final MessageType COMMENT = new MessageType(Value.COMMENT, "comment"); + + private final Value value; + + private final String string; + + MessageType(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 MessageType && this.string.equals(((MessageType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case NOTE: + return visitor.visitNote(); + case COMMENT: + return visitor.visitComment(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static MessageType valueOf(String value) { + switch (value) { + case "note": + return NOTE; + case "comment": + return COMMENT; + default: + return new MessageType(Value.UNKNOWN, value); + } + } + + public enum Value { + COMMENT, + + NOTE, + + UNKNOWN + } + + public interface Visitor { + T visitComment(); + + T visitNote(); + + T visitUnknown(String unknownType); + } + } +} diff --git a/src/main/java/com/intercom/api/types/AdminReplyTicketRequest.java b/src/main/java/com/intercom/api/types/AdminReplyTicketRequest.java new file mode 100644 index 00000000..992e99cc --- /dev/null +++ b/src/main/java/com/intercom/api/types/AdminReplyTicketRequest.java @@ -0,0 +1,502 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.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.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 = AdminReplyTicketRequest.Builder.class) +public final class AdminReplyTicketRequest { + private final MessageType messageType; + + private final Optional body; + + private final String adminId; + + private final Optional createdAt; + + private final Optional> replyOptions; + + private final Optional> attachmentUrls; + + private final Map additionalProperties; + + private AdminReplyTicketRequest( + MessageType messageType, + Optional body, + String adminId, + Optional createdAt, + Optional> replyOptions, + Optional> attachmentUrls, + Map additionalProperties) { + this.messageType = messageType; + this.body = body; + this.adminId = adminId; + this.createdAt = createdAt; + this.replyOptions = replyOptions; + this.attachmentUrls = attachmentUrls; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("message_type") + public MessageType getMessageType() { + return messageType; + } + + @JsonProperty("type") + public String getType() { + return "admin"; + } + + /** + * @return The text body of the reply. Notes accept some HTML formatting. Must be present for comment and note message types. + */ + @JsonProperty("body") + public Optional getBody() { + return body; + } + + /** + * @return The id of the admin who is authoring the comment. + */ + @JsonProperty("admin_id") + public String getAdminId() { + return adminId; + } + + /** + * @return The time the reply was created. If not provided, the current time will be used. + */ + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + /** + * @return The quick reply options to display. Must be present for quick_reply message types. + */ + @JsonProperty("reply_options") + public Optional> getReplyOptions() { + return replyOptions; + } + + /** + * @return A list of image URLs that will be added as attachments. You can include up to 10 URLs. + */ + @JsonProperty("attachment_urls") + public Optional> getAttachmentUrls() { + return attachmentUrls; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AdminReplyTicketRequest && equalTo((AdminReplyTicketRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(AdminReplyTicketRequest other) { + return messageType.equals(other.messageType) + && body.equals(other.body) + && adminId.equals(other.adminId) + && createdAt.equals(other.createdAt) + && replyOptions.equals(other.replyOptions) + && attachmentUrls.equals(other.attachmentUrls); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.messageType, this.body, this.adminId, this.createdAt, this.replyOptions, this.attachmentUrls); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static MessageTypeStage builder() { + return new Builder(); + } + + public interface MessageTypeStage { + AdminIdStage messageType(@NotNull MessageType messageType); + + Builder from(AdminReplyTicketRequest other); + } + + public interface AdminIdStage { + _FinalStage adminId(@NotNull String adminId); + } + + public interface _FinalStage { + AdminReplyTicketRequest build(); + + _FinalStage body(Optional body); + + _FinalStage body(String body); + + _FinalStage createdAt(Optional createdAt); + + _FinalStage createdAt(Integer createdAt); + + _FinalStage replyOptions(Optional> replyOptions); + + _FinalStage replyOptions(List replyOptions); + + _FinalStage attachmentUrls(Optional> attachmentUrls); + + _FinalStage attachmentUrls(List attachmentUrls); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements MessageTypeStage, AdminIdStage, _FinalStage { + private MessageType messageType; + + private String adminId; + + private Optional> attachmentUrls = Optional.empty(); + + private Optional> replyOptions = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + private Optional body = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(AdminReplyTicketRequest other) { + messageType(other.getMessageType()); + body(other.getBody()); + adminId(other.getAdminId()); + createdAt(other.getCreatedAt()); + replyOptions(other.getReplyOptions()); + attachmentUrls(other.getAttachmentUrls()); + return this; + } + + @java.lang.Override + @JsonSetter("message_type") + public AdminIdStage messageType(@NotNull MessageType messageType) { + this.messageType = Objects.requireNonNull(messageType, "messageType must not be null"); + return this; + } + + /** + *

The id of the admin who is authoring the comment.

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

A list of image URLs that will be added as attachments. You can include up to 10 URLs.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage attachmentUrls(List attachmentUrls) { + this.attachmentUrls = Optional.ofNullable(attachmentUrls); + return this; + } + + @java.lang.Override + @JsonSetter(value = "attachment_urls", nulls = Nulls.SKIP) + public _FinalStage attachmentUrls(Optional> attachmentUrls) { + this.attachmentUrls = attachmentUrls; + return this; + } + + /** + *

The quick reply options to display. Must be present for quick_reply message types.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage replyOptions(List replyOptions) { + this.replyOptions = Optional.ofNullable(replyOptions); + return this; + } + + @java.lang.Override + @JsonSetter(value = "reply_options", nulls = Nulls.SKIP) + public _FinalStage replyOptions(Optional> replyOptions) { + this.replyOptions = replyOptions; + return this; + } + + /** + *

The time the reply 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; + } + + @java.lang.Override + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public _FinalStage createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + /** + *

The text body of the reply. Notes accept some HTML formatting. Must be present for comment and note message types.

+ * @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; + } + + @java.lang.Override + @JsonSetter(value = "body", nulls = Nulls.SKIP) + public _FinalStage body(Optional body) { + this.body = body; + return this; + } + + @java.lang.Override + public AdminReplyTicketRequest build() { + return new AdminReplyTicketRequest( + messageType, body, adminId, createdAt, replyOptions, attachmentUrls, additionalProperties); + } + } + + public final class MessageType { + public static final MessageType NOTE = new MessageType(Value.NOTE, "note"); + + public static final MessageType QUICK_REPLY = new MessageType(Value.QUICK_REPLY, "quick_reply"); + + public static final MessageType COMMENT = new MessageType(Value.COMMENT, "comment"); + + private final Value value; + + private final String string; + + MessageType(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 MessageType && this.string.equals(((MessageType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case NOTE: + return visitor.visitNote(); + case QUICK_REPLY: + return visitor.visitQuickReply(); + case COMMENT: + return visitor.visitComment(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static MessageType valueOf(String value) { + switch (value) { + case "note": + return NOTE; + case "quick_reply": + return QUICK_REPLY; + case "comment": + return COMMENT; + default: + return new MessageType(Value.UNKNOWN, value); + } + } + + public enum Value { + COMMENT, + + NOTE, + + QUICK_REPLY, + + UNKNOWN + } + + public interface Visitor { + T visitComment(); + + T visitNote(); + + T visitQuickReply(); + + T visitUnknown(String unknownType); + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = ReplyOptionsItem.Builder.class) + public static final class ReplyOptionsItem { + private final String text; + + private final String uuid; + + private final Map additionalProperties; + + private ReplyOptionsItem(String text, String uuid, Map additionalProperties) { + this.text = text; + this.uuid = uuid; + this.additionalProperties = additionalProperties; + } + + /** + * @return The text to display in this quick reply option. + */ + @JsonProperty("text") + public String getText() { + return text; + } + + /** + * @return A unique identifier for this quick reply option. This value will be available within the metadata of the comment ticket part that is created when a user clicks on this reply option. + */ + @JsonProperty("uuid") + public String getUuid() { + return uuid; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ReplyOptionsItem && equalTo((ReplyOptionsItem) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ReplyOptionsItem other) { + return text.equals(other.text) && uuid.equals(other.uuid); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.text, this.uuid); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TextStage builder() { + return new Builder(); + } + + public interface TextStage { + UuidStage text(@NotNull String text); + + Builder from(ReplyOptionsItem other); + } + + public interface UuidStage { + _FinalStage uuid(@NotNull String uuid); + } + + public interface _FinalStage { + ReplyOptionsItem build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements TextStage, UuidStage, _FinalStage { + private String text; + + private String uuid; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ReplyOptionsItem other) { + text(other.getText()); + uuid(other.getUuid()); + return this; + } + + /** + *

The text to display in this quick reply option.

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

A unique identifier for this quick reply option. This value will be available within the metadata of the comment ticket part that is created when a user clicks on this reply option.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("uuid") + public _FinalStage uuid(@NotNull String uuid) { + this.uuid = Objects.requireNonNull(uuid, "uuid must not be null"); + return this; + } + + @java.lang.Override + public ReplyOptionsItem build() { + return new ReplyOptionsItem(text, uuid, additionalProperties); + } + } + } +} diff --git a/src/main/java/com/intercom/api/types/AdminWithApp.java b/src/main/java/com/intercom/api/types/AdminWithApp.java new file mode 100644 index 00000000..ed2a98ac --- /dev/null +++ b/src/main/java/com/intercom/api/types/AdminWithApp.java @@ -0,0 +1,606 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.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.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 = AdminWithApp.Builder.class) +public final class AdminWithApp { + private final String id; + + private final String name; + + private final String email; + + private final String jobTitle; + + private final boolean awayModeEnabled; + + private final boolean awayModeReassign; + + private final boolean hasInboxSeat; + + private final List teamIds; + + private final Optional avatar; + + private final Optional emailVerified; + + private final Optional app; + + private final Map additionalProperties; + + private AdminWithApp( + String id, + String name, + String email, + String jobTitle, + boolean awayModeEnabled, + boolean awayModeReassign, + boolean hasInboxSeat, + List teamIds, + Optional avatar, + Optional emailVerified, + Optional app, + Map additionalProperties) { + this.id = id; + this.name = name; + this.email = email; + this.jobTitle = jobTitle; + this.awayModeEnabled = awayModeEnabled; + this.awayModeReassign = awayModeReassign; + this.hasInboxSeat = hasInboxSeat; + this.teamIds = teamIds; + this.avatar = avatar; + this.emailVerified = emailVerified; + this.app = app; + this.additionalProperties = additionalProperties; + } + + /** + * @return String representing the object's type. Always has the value admin. + */ + @JsonProperty("type") + public String getType() { + return "admin"; + } + + /** + * @return The id representing the admin. + */ + @JsonProperty("id") + public String getId() { + return id; + } + + /** + * @return The name of the admin. + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * @return The email of the admin. + */ + @JsonProperty("email") + public String getEmail() { + return email; + } + + /** + * @return The job title of the admin. + */ + @JsonProperty("job_title") + public String getJobTitle() { + return jobTitle; + } + + /** + * @return Identifies if this admin is currently set in away mode. + */ + @JsonProperty("away_mode_enabled") + public boolean getAwayModeEnabled() { + return awayModeEnabled; + } + + /** + * @return Identifies if this admin is set to automatically reassign new conversations to the apps default inbox. + */ + @JsonProperty("away_mode_reassign") + public boolean getAwayModeReassign() { + return awayModeReassign; + } + + /** + * @return Identifies if this admin has a paid inbox seat to restrict/allow features that require them. + */ + @JsonProperty("has_inbox_seat") + public boolean getHasInboxSeat() { + return hasInboxSeat; + } + + /** + * @return This is a list of ids of the teams that this admin is part of. + */ + @JsonProperty("team_ids") + public List getTeamIds() { + return teamIds; + } + + /** + * @return This object represents the avatar associated with the admin. + */ + @JsonProperty("avatar") + public Optional getAvatar() { + return avatar; + } + + /** + * @return Identifies if this admin's email is verified. + */ + @JsonProperty("email_verified") + public Optional getEmailVerified() { + return emailVerified; + } + + /** + * @return App that the admin belongs to. + */ + @JsonProperty("app") + public Optional getApp() { + return app; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AdminWithApp && equalTo((AdminWithApp) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(AdminWithApp other) { + return id.equals(other.id) + && name.equals(other.name) + && email.equals(other.email) + && jobTitle.equals(other.jobTitle) + && awayModeEnabled == other.awayModeEnabled + && awayModeReassign == other.awayModeReassign + && hasInboxSeat == other.hasInboxSeat + && teamIds.equals(other.teamIds) + && avatar.equals(other.avatar) + && emailVerified.equals(other.emailVerified) + && app.equals(other.app); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.id, + this.name, + this.email, + this.jobTitle, + this.awayModeEnabled, + this.awayModeReassign, + this.hasInboxSeat, + this.teamIds, + this.avatar, + this.emailVerified, + this.app); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + NameStage id(@NotNull String id); + + Builder from(AdminWithApp other); + } + + public interface NameStage { + EmailStage name(@NotNull String name); + } + + public interface EmailStage { + JobTitleStage email(@NotNull String email); + } + + public interface JobTitleStage { + AwayModeEnabledStage jobTitle(@NotNull String jobTitle); + } + + public interface AwayModeEnabledStage { + AwayModeReassignStage awayModeEnabled(boolean awayModeEnabled); + } + + public interface AwayModeReassignStage { + HasInboxSeatStage awayModeReassign(boolean awayModeReassign); + } + + public interface HasInboxSeatStage { + _FinalStage hasInboxSeat(boolean hasInboxSeat); + } + + public interface _FinalStage { + AdminWithApp build(); + + _FinalStage teamIds(List teamIds); + + _FinalStage addTeamIds(Integer teamIds); + + _FinalStage addAllTeamIds(List teamIds); + + _FinalStage avatar(Optional avatar); + + _FinalStage avatar(Avatar avatar); + + _FinalStage emailVerified(Optional emailVerified); + + _FinalStage emailVerified(Boolean emailVerified); + + _FinalStage app(Optional app); + + _FinalStage app(App app); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements IdStage, + NameStage, + EmailStage, + JobTitleStage, + AwayModeEnabledStage, + AwayModeReassignStage, + HasInboxSeatStage, + _FinalStage { + private String id; + + private String name; + + private String email; + + private String jobTitle; + + private boolean awayModeEnabled; + + private boolean awayModeReassign; + + private boolean hasInboxSeat; + + private Optional app = Optional.empty(); + + private Optional emailVerified = Optional.empty(); + + private Optional avatar = Optional.empty(); + + private List teamIds = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(AdminWithApp other) { + id(other.getId()); + name(other.getName()); + email(other.getEmail()); + jobTitle(other.getJobTitle()); + awayModeEnabled(other.getAwayModeEnabled()); + awayModeReassign(other.getAwayModeReassign()); + hasInboxSeat(other.getHasInboxSeat()); + teamIds(other.getTeamIds()); + avatar(other.getAvatar()); + emailVerified(other.getEmailVerified()); + app(other.getApp()); + return this; + } + + /** + *

The id representing the admin.

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

The name of the admin.

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

The email of the admin.

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

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.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("away_mode_enabled") + public AwayModeReassignStage awayModeEnabled(boolean awayModeEnabled) { + this.awayModeEnabled = awayModeEnabled; + return this; + } + + /** + *

Identifies if this admin is set to automatically reassign new conversations to the apps default inbox.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("away_mode_reassign") + public HasInboxSeatStage awayModeReassign(boolean awayModeReassign) { + this.awayModeReassign = awayModeReassign; + return this; + } + + /** + *

Identifies if this admin has a paid inbox seat to restrict/allow features that require them.

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

App that the admin belongs to.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage app(App app) { + this.app = Optional.ofNullable(app); + return this; + } + + @java.lang.Override + @JsonSetter(value = "app", nulls = Nulls.SKIP) + public _FinalStage app(Optional app) { + this.app = app; + return this; + } + + /** + *

Identifies if this admin's email is verified.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage emailVerified(Boolean emailVerified) { + this.emailVerified = Optional.ofNullable(emailVerified); + return this; + } + + @java.lang.Override + @JsonSetter(value = "email_verified", nulls = Nulls.SKIP) + public _FinalStage emailVerified(Optional emailVerified) { + this.emailVerified = emailVerified; + return this; + } + + /** + *

This object represents the avatar associated with the admin.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage avatar(Avatar avatar) { + this.avatar = Optional.ofNullable(avatar); + return this; + } + + @java.lang.Override + @JsonSetter(value = "avatar", nulls = Nulls.SKIP) + public _FinalStage avatar(Optional avatar) { + this.avatar = avatar; + return this; + } + + /** + *

This is a list of ids of the teams that this admin is part of.

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

This is a list of ids of the teams that this admin is part of.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage addTeamIds(Integer teamIds) { + this.teamIds.add(teamIds); + return this; + } + + @java.lang.Override + @JsonSetter(value = "team_ids", nulls = Nulls.SKIP) + public _FinalStage teamIds(List teamIds) { + this.teamIds.clear(); + this.teamIds.addAll(teamIds); + return this; + } + + @java.lang.Override + public AdminWithApp build() { + return new AdminWithApp( + id, + name, + email, + jobTitle, + awayModeEnabled, + awayModeReassign, + hasInboxSeat, + teamIds, + avatar, + emailVerified, + app, + additionalProperties); + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = Avatar.Builder.class) + public static final class Avatar { + private final Optional type; + + private final Optional imageUrl; + + private final Map additionalProperties; + + private Avatar(Optional type, Optional imageUrl, Map additionalProperties) { + this.type = type; + this.imageUrl = imageUrl; + this.additionalProperties = additionalProperties; + } + + /** + * @return This is a string that identifies the type of the object. It will always have the value avatar. + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return This object represents the avatar associated with the admin. + */ + @JsonProperty("image_url") + public Optional 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 type.equals(other.type) && imageUrl.equals(other.imageUrl); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.imageUrl); + } + + @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 imageUrl = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(Avatar other) { + type(other.getType()); + imageUrl(other.getImageUrl()); + 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 = "image_url", nulls = Nulls.SKIP) + public Builder imageUrl(Optional imageUrl) { + this.imageUrl = imageUrl; + return this; + } + + public Builder imageUrl(String imageUrl) { + this.imageUrl = Optional.ofNullable(imageUrl); + return this; + } + + public Avatar build() { + return new Avatar(type, imageUrl, additionalProperties); + } + } + } +} diff --git a/src/main/java/com/intercom/api/types/App.java b/src/main/java/com/intercom/api/types/App.java new file mode 100644 index 00000000..1e9162bc --- /dev/null +++ b/src/main/java/com/intercom/api/types/App.java @@ -0,0 +1,311 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.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.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 = App.Builder.class) +public final class App { + private final String type; + + private final String idCode; + + private final String name; + + private final String region; + + private final String timezone; + + private final int createdAt; + + private final boolean identityVerification; + + private final Map additionalProperties; + + private App( + String type, + String idCode, + String name, + String region, + String timezone, + int createdAt, + boolean identityVerification, + Map additionalProperties) { + this.type = type; + this.idCode = idCode; + this.name = name; + this.region = region; + this.timezone = timezone; + this.createdAt = createdAt; + this.identityVerification = identityVerification; + this.additionalProperties = additionalProperties; + } + + /** + * @return + */ + @JsonProperty("type") + public String getType() { + return type; + } + + /** + * @return The id of the app. + */ + @JsonProperty("id_code") + public String getIdCode() { + return idCode; + } + + /** + * @return The name of the app. + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * @return The Intercom region the app is located in. + */ + @JsonProperty("region") + public String getRegion() { + return region; + } + + /** + * @return The timezone of the region where the app is located. + */ + @JsonProperty("timezone") + public String getTimezone() { + return timezone; + } + + /** + * @return When the app was created. + */ + @JsonProperty("created_at") + public int getCreatedAt() { + return createdAt; + } + + /** + * @return Whether or not the app uses identity verification. + */ + @JsonProperty("identity_verification") + public boolean getIdentityVerification() { + return identityVerification; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof App && equalTo((App) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(App other) { + return type.equals(other.type) + && idCode.equals(other.idCode) + && name.equals(other.name) + && region.equals(other.region) + && timezone.equals(other.timezone) + && createdAt == other.createdAt + && identityVerification == other.identityVerification; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.type, + this.idCode, + this.name, + this.region, + this.timezone, + this.createdAt, + this.identityVerification); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TypeStage builder() { + return new Builder(); + } + + public interface TypeStage { + IdCodeStage type(@NotNull String type); + + Builder from(App other); + } + + public interface IdCodeStage { + NameStage idCode(@NotNull String idCode); + } + + public interface NameStage { + RegionStage name(@NotNull String name); + } + + public interface RegionStage { + TimezoneStage region(@NotNull String region); + } + + public interface TimezoneStage { + CreatedAtStage timezone(@NotNull String timezone); + } + + public interface CreatedAtStage { + IdentityVerificationStage createdAt(int createdAt); + } + + public interface IdentityVerificationStage { + _FinalStage identityVerification(boolean identityVerification); + } + + public interface _FinalStage { + App build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements TypeStage, + IdCodeStage, + NameStage, + RegionStage, + TimezoneStage, + CreatedAtStage, + IdentityVerificationStage, + _FinalStage { + private String type; + + private String idCode; + + private String name; + + private String region; + + private String timezone; + + private int createdAt; + + private boolean identityVerification; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(App other) { + type(other.getType()); + idCode(other.getIdCode()); + name(other.getName()); + region(other.getRegion()); + timezone(other.getTimezone()); + createdAt(other.getCreatedAt()); + identityVerification(other.getIdentityVerification()); + return this; + } + + /** + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("type") + public IdCodeStage type(@NotNull String type) { + this.type = Objects.requireNonNull(type, "type must not be null"); + return this; + } + + /** + *

The id of the app.

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

The name of the app.

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

The Intercom region the app is located in.

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

The timezone of the region where the app is located.

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

When the app was created.

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

Whether or not the app uses identity verification.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("identity_verification") + public _FinalStage identityVerification(boolean identityVerification) { + this.identityVerification = identityVerification; + return this; + } + + @java.lang.Override + public App build() { + return new App(type, idCode, name, region, timezone, createdAt, identityVerification, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/types/ArticleContent.java b/src/main/java/com/intercom/api/types/ArticleContent.java new file mode 100644 index 00000000..e3c26347 --- /dev/null +++ b/src/main/java/com/intercom/api/types/ArticleContent.java @@ -0,0 +1,443 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.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 = ArticleContent.Builder.class) +public final class ArticleContent { + private final String title; + + private final String description; + + private final String body; + + private final int authorId; + + private final State state; + + private final Optional createdAt; + + private final Optional updatedAt; + + private final Optional url; + + private final Map additionalProperties; + + private ArticleContent( + String title, + String description, + String body, + int authorId, + State state, + Optional createdAt, + Optional updatedAt, + Optional url, + Map additionalProperties) { + this.title = title; + this.description = description; + this.body = body; + this.authorId = authorId; + this.state = state; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.url = url; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of object - article_content . + */ + @JsonProperty("type") + public String getType() { + return "article_content"; + } + + /** + * @return The title of the article. + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * @return The description of the article. + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * @return The body of the article. + */ + @JsonProperty("body") + public String getBody() { + return body; + } + + /** + * @return The ID of the author of the article. + */ + @JsonProperty("author_id") + public int getAuthorId() { + return authorId; + } + + /** + * @return Whether the article is published or is a draft . + */ + @JsonProperty("state") + public State getState() { + return state; + } + + /** + * @return The time when the article was created (seconds). + */ + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + /** + * @return The time when the article was last updated (seconds). + */ + @JsonProperty("updated_at") + public Optional getUpdatedAt() { + return updatedAt; + } + + /** + * @return The URL of the article. + */ + @JsonProperty("url") + public Optional getUrl() { + return url; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ArticleContent && equalTo((ArticleContent) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ArticleContent other) { + return title.equals(other.title) + && description.equals(other.description) + && body.equals(other.body) + && authorId == other.authorId + && state.equals(other.state) + && createdAt.equals(other.createdAt) + && updatedAt.equals(other.updatedAt) + && url.equals(other.url); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.title, + this.description, + this.body, + this.authorId, + this.state, + this.createdAt, + this.updatedAt, + this.url); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TitleStage builder() { + return new Builder(); + } + + public interface TitleStage { + DescriptionStage title(@NotNull String title); + + Builder from(ArticleContent other); + } + + public interface DescriptionStage { + BodyStage description(@NotNull String description); + } + + public interface BodyStage { + AuthorIdStage body(@NotNull String body); + } + + public interface AuthorIdStage { + StateStage authorId(int authorId); + } + + public interface StateStage { + _FinalStage state(@NotNull State state); + } + + public interface _FinalStage { + ArticleContent build(); + + _FinalStage createdAt(Optional createdAt); + + _FinalStage createdAt(Integer createdAt); + + _FinalStage updatedAt(Optional updatedAt); + + _FinalStage updatedAt(Integer updatedAt); + + _FinalStage url(Optional url); + + _FinalStage url(String url); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements TitleStage, DescriptionStage, BodyStage, AuthorIdStage, StateStage, _FinalStage { + private String title; + + private String description; + + private String body; + + private int authorId; + + private State state; + + private Optional url = Optional.empty(); + + private Optional updatedAt = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ArticleContent other) { + title(other.getTitle()); + description(other.getDescription()); + body(other.getBody()); + authorId(other.getAuthorId()); + state(other.getState()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + url(other.getUrl()); + return this; + } + + /** + *

The title of the article.

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

The description of the article.

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

The body of the article.

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

Whether the article is published or is a draft .

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

The URL of the article.

+ * @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; + } + + @java.lang.Override + @JsonSetter(value = "url", nulls = Nulls.SKIP) + public _FinalStage url(Optional url) { + this.url = url; + return this; + } + + /** + *

The time when the article was last updated (seconds).

+ * @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); + return this; + } + + @java.lang.Override + @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) + public _FinalStage updatedAt(Optional updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + /** + *

The time when the article was created (seconds).

+ * @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; + } + + @java.lang.Override + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public _FinalStage createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + @java.lang.Override + public ArticleContent build() { + return new ArticleContent( + title, description, body, authorId, state, createdAt, updatedAt, url, additionalProperties); + } + } + + public final class State { + public static final State PUBLISHED = new State(Value.PUBLISHED, "published"); + + public static final State DRAFT = new State(Value.DRAFT, "draft"); + + 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 PUBLISHED: + return visitor.visitPublished(); + case DRAFT: + return visitor.visitDraft(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static State valueOf(String value) { + switch (value) { + case "published": + return PUBLISHED; + case "draft": + return DRAFT; + default: + return new State(Value.UNKNOWN, value); + } + } + + public enum Value { + PUBLISHED, + + DRAFT, + + UNKNOWN + } + + public interface Visitor { + T visitPublished(); + + T visitDraft(); + + T visitUnknown(String unknownType); + } + } +} diff --git a/src/main/java/com/intercom/api/types/ArticleList.java b/src/main/java/com/intercom/api/types/ArticleList.java new file mode 100644 index 00000000..36443ff9 --- /dev/null +++ b/src/main/java/com/intercom/api/types/ArticleList.java @@ -0,0 +1,201 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.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.resources.articles.types.ArticleListItem; +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 = ArticleList.Builder.class) +public final class ArticleList { + private final Optional pages; + + private final int totalCount; + + private final List data; + + private final Map additionalProperties; + + private ArticleList( + Optional pages, + int totalCount, + List data, + Map additionalProperties) { + this.pages = pages; + this.totalCount = totalCount; + this.data = data; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of the object - list. + */ + @JsonProperty("type") + public String getType() { + return "list"; + } + + @JsonProperty("pages") + public Optional getPages() { + return pages; + } + + /** + * @return A count of the total number of articles. + */ + @JsonProperty("total_count") + public int getTotalCount() { + return totalCount; + } + + /** + * @return An array of Article objects + */ + @JsonProperty("data") + public List getData() { + return data; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ArticleList && equalTo((ArticleList) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ArticleList other) { + return pages.equals(other.pages) && totalCount == other.totalCount && data.equals(other.data); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.pages, this.totalCount, this.data); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TotalCountStage builder() { + return new Builder(); + } + + public interface TotalCountStage { + _FinalStage totalCount(int totalCount); + + Builder from(ArticleList other); + } + + public interface _FinalStage { + ArticleList build(); + + _FinalStage pages(Optional pages); + + _FinalStage pages(Object pages); + + _FinalStage data(List data); + + _FinalStage addData(ArticleListItem data); + + _FinalStage addAllData(List data); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements TotalCountStage, _FinalStage { + private int totalCount; + + private List data = new ArrayList<>(); + + private Optional pages = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ArticleList other) { + pages(other.getPages()); + totalCount(other.getTotalCount()); + data(other.getData()); + return this; + } + + /** + *

A count of the total number of articles.

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

An array of Article objects

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

An array of Article objects

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage addData(ArticleListItem data) { + this.data.add(data); + return this; + } + + @java.lang.Override + @JsonSetter(value = "data", nulls = Nulls.SKIP) + public _FinalStage data(List data) { + this.data.clear(); + this.data.addAll(data); + return this; + } + + @java.lang.Override + public _FinalStage pages(Object pages) { + this.pages = Optional.ofNullable(pages); + return this; + } + + @java.lang.Override + @JsonSetter(value = "pages", nulls = Nulls.SKIP) + public _FinalStage pages(Optional pages) { + this.pages = pages; + return this; + } + + @java.lang.Override + public ArticleList build() { + return new ArticleList(pages, totalCount, data, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/types/ArticleStatistics.java b/src/main/java/com/intercom/api/types/ArticleStatistics.java new file mode 100644 index 00000000..50ed66f0 --- /dev/null +++ b/src/main/java/com/intercom/api/types/ArticleStatistics.java @@ -0,0 +1,293 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.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.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 = ArticleStatistics.Builder.class) +public final class ArticleStatistics { + private final int views; + + private final int conversions; + + private final int reactions; + + private final float happyReactionPercentage; + + private final float neutralReactionPercentage; + + private final float sadReactionPercentage; + + private final Map additionalProperties; + + private ArticleStatistics( + int views, + int conversions, + int reactions, + float happyReactionPercentage, + float neutralReactionPercentage, + float sadReactionPercentage, + Map additionalProperties) { + this.views = views; + this.conversions = conversions; + this.reactions = reactions; + this.happyReactionPercentage = happyReactionPercentage; + this.neutralReactionPercentage = neutralReactionPercentage; + this.sadReactionPercentage = sadReactionPercentage; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of object - article_statistics. + */ + @JsonProperty("type") + public String getType() { + return "article_statistics"; + } + + /** + * @return The number of total views the article has received. + */ + @JsonProperty("views") + public int getViews() { + return views; + } + + /** + * @return The number of conversations started from the article. + */ + @JsonProperty("conversions") + public int getConversions() { + return conversions; + } + + /** + * @return The number of total reactions the article has received. + */ + @JsonProperty("reactions") + public int getReactions() { + return reactions; + } + + /** + * @return The percentage of happy reactions the article has received against other types of reaction. + */ + @JsonProperty("happy_reaction_percentage") + public float getHappyReactionPercentage() { + return happyReactionPercentage; + } + + /** + * @return The percentage of neutral reactions the article has received against other types of reaction. + */ + @JsonProperty("neutral_reaction_percentage") + public float getNeutralReactionPercentage() { + return neutralReactionPercentage; + } + + /** + * @return The percentage of sad reactions the article has received against other types of reaction. + */ + @JsonProperty("sad_reaction_percentage") + public float getSadReactionPercentage() { + return sadReactionPercentage; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ArticleStatistics && equalTo((ArticleStatistics) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ArticleStatistics other) { + return views == other.views + && conversions == other.conversions + && reactions == other.reactions + && happyReactionPercentage == other.happyReactionPercentage + && neutralReactionPercentage == other.neutralReactionPercentage + && sadReactionPercentage == other.sadReactionPercentage; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.views, + this.conversions, + this.reactions, + this.happyReactionPercentage, + this.neutralReactionPercentage, + this.sadReactionPercentage); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ViewsStage builder() { + return new Builder(); + } + + public interface ViewsStage { + ConversionsStage views(int views); + + Builder from(ArticleStatistics other); + } + + public interface ConversionsStage { + ReactionsStage conversions(int conversions); + } + + public interface ReactionsStage { + HappyReactionPercentageStage reactions(int reactions); + } + + public interface HappyReactionPercentageStage { + NeutralReactionPercentageStage happyReactionPercentage(float happyReactionPercentage); + } + + public interface NeutralReactionPercentageStage { + SadReactionPercentageStage neutralReactionPercentage(float neutralReactionPercentage); + } + + public interface SadReactionPercentageStage { + _FinalStage sadReactionPercentage(float sadReactionPercentage); + } + + public interface _FinalStage { + ArticleStatistics build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements ViewsStage, + ConversionsStage, + ReactionsStage, + HappyReactionPercentageStage, + NeutralReactionPercentageStage, + SadReactionPercentageStage, + _FinalStage { + private int views; + + private int conversions; + + private int reactions; + + private float happyReactionPercentage; + + private float neutralReactionPercentage; + + private float sadReactionPercentage; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ArticleStatistics other) { + views(other.getViews()); + conversions(other.getConversions()); + reactions(other.getReactions()); + happyReactionPercentage(other.getHappyReactionPercentage()); + neutralReactionPercentage(other.getNeutralReactionPercentage()); + sadReactionPercentage(other.getSadReactionPercentage()); + return this; + } + + /** + *

The number of total views the article has received.

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

The number of conversations started from the article.

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

The number of total reactions the article has received.

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

The percentage of happy reactions the article has received against other types of reaction.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("happy_reaction_percentage") + public NeutralReactionPercentageStage happyReactionPercentage(float happyReactionPercentage) { + this.happyReactionPercentage = happyReactionPercentage; + return this; + } + + /** + *

The percentage of neutral reactions the article has received against other types of reaction.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("neutral_reaction_percentage") + public SadReactionPercentageStage neutralReactionPercentage(float neutralReactionPercentage) { + this.neutralReactionPercentage = neutralReactionPercentage; + return this; + } + + /** + *

The percentage of sad reactions the article has received against other types of reaction.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("sad_reaction_percentage") + public _FinalStage sadReactionPercentage(float sadReactionPercentage) { + this.sadReactionPercentage = sadReactionPercentage; + return this; + } + + @java.lang.Override + public ArticleStatistics build() { + return new ArticleStatistics( + views, + conversions, + reactions, + happyReactionPercentage, + neutralReactionPercentage, + sadReactionPercentage, + additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/types/ArticleTranslatedContent.java b/src/main/java/com/intercom/api/types/ArticleTranslatedContent.java new file mode 100644 index 00000000..02828b20 --- /dev/null +++ b/src/main/java/com/intercom/api/types/ArticleTranslatedContent.java @@ -0,0 +1,1142 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.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 = ArticleTranslatedContent.Builder.class) +public final class ArticleTranslatedContent { + private final Optional type; + + private final Optional ar; + + private final Optional bg; + + private final Optional bs; + + private final Optional ca; + + private final Optional cs; + + private final Optional da; + + private final Optional de; + + private final Optional el; + + private final Optional en; + + private final Optional es; + + private final Optional et; + + private final Optional fi; + + private final Optional fr; + + private final Optional he; + + private final Optional hr; + + private final Optional hu; + + private final Optional id; + + private final Optional it; + + private final Optional ja; + + private final Optional ko; + + private final Optional lt; + + private final Optional lv; + + private final Optional mn; + + private final Optional nb; + + private final Optional nl; + + private final Optional pl; + + private final Optional pt; + + private final Optional ro; + + private final Optional ru; + + private final Optional sl; + + private final Optional sr; + + private final Optional sv; + + private final Optional tr; + + private final Optional vi; + + private final Optional ptBr; + + private final Optional zhCn; + + private final Optional zhTw; + + private final Map additionalProperties; + + private ArticleTranslatedContent( + Optional type, + Optional ar, + Optional bg, + Optional bs, + Optional ca, + Optional cs, + Optional da, + Optional de, + Optional el, + Optional en, + Optional es, + Optional et, + Optional fi, + Optional fr, + Optional he, + Optional hr, + Optional hu, + Optional id, + Optional it, + Optional ja, + Optional ko, + Optional lt, + Optional lv, + Optional mn, + Optional nb, + Optional nl, + Optional pl, + Optional pt, + Optional ro, + Optional ru, + Optional sl, + Optional sr, + Optional sv, + Optional tr, + Optional vi, + Optional ptBr, + Optional zhCn, + Optional zhTw, + Map additionalProperties) { + this.type = type; + this.ar = ar; + this.bg = bg; + this.bs = bs; + this.ca = ca; + this.cs = cs; + this.da = da; + this.de = de; + this.el = el; + this.en = en; + this.es = es; + this.et = et; + this.fi = fi; + this.fr = fr; + this.he = he; + this.hr = hr; + this.hu = hu; + this.id = id; + this.it = it; + this.ja = ja; + this.ko = ko; + this.lt = lt; + this.lv = lv; + this.mn = mn; + this.nb = nb; + this.nl = nl; + this.pl = pl; + this.pt = pt; + this.ro = ro; + this.ru = ru; + this.sl = sl; + this.sr = sr; + this.sv = sv; + this.tr = tr; + this.vi = vi; + this.ptBr = ptBr; + this.zhCn = zhCn; + this.zhTw = zhTw; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of object - article_translated_content. + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return The content of the article in Arabic + */ + @JsonProperty("ar") + public Optional getAr() { + return ar; + } + + /** + * @return The content of the article in Bulgarian + */ + @JsonProperty("bg") + public Optional getBg() { + return bg; + } + + /** + * @return The content of the article in Bosnian + */ + @JsonProperty("bs") + public Optional getBs() { + return bs; + } + + /** + * @return The content of the article in Catalan + */ + @JsonProperty("ca") + public Optional getCa() { + return ca; + } + + /** + * @return The content of the article in Czech + */ + @JsonProperty("cs") + public Optional getCs() { + return cs; + } + + /** + * @return The content of the article in Danish + */ + @JsonProperty("da") + public Optional getDa() { + return da; + } + + /** + * @return The content of the article in German + */ + @JsonProperty("de") + public Optional getDe() { + return de; + } + + /** + * @return The content of the article in Greek + */ + @JsonProperty("el") + public Optional getEl() { + return el; + } + + /** + * @return The content of the article in English + */ + @JsonProperty("en") + public Optional getEn() { + return en; + } + + /** + * @return The content of the article in Spanish + */ + @JsonProperty("es") + public Optional getEs() { + return es; + } + + /** + * @return The content of the article in Estonian + */ + @JsonProperty("et") + public Optional getEt() { + return et; + } + + /** + * @return The content of the article in Finnish + */ + @JsonProperty("fi") + public Optional getFi() { + return fi; + } + + /** + * @return The content of the article in French + */ + @JsonProperty("fr") + public Optional getFr() { + return fr; + } + + /** + * @return The content of the article in Hebrew + */ + @JsonProperty("he") + public Optional getHe() { + return he; + } + + /** + * @return The content of the article in Croatian + */ + @JsonProperty("hr") + public Optional getHr() { + return hr; + } + + /** + * @return The content of the article in Hungarian + */ + @JsonProperty("hu") + public Optional getHu() { + return hu; + } + + /** + * @return The content of the article in Indonesian + */ + @JsonProperty("id") + public Optional getId() { + return id; + } + + /** + * @return The content of the article in Italian + */ + @JsonProperty("it") + public Optional getIt() { + return it; + } + + /** + * @return The content of the article in Japanese + */ + @JsonProperty("ja") + public Optional getJa() { + return ja; + } + + /** + * @return The content of the article in Korean + */ + @JsonProperty("ko") + public Optional getKo() { + return ko; + } + + /** + * @return The content of the article in Lithuanian + */ + @JsonProperty("lt") + public Optional getLt() { + return lt; + } + + /** + * @return The content of the article in Latvian + */ + @JsonProperty("lv") + public Optional getLv() { + return lv; + } + + /** + * @return The content of the article in Mongolian + */ + @JsonProperty("mn") + public Optional getMn() { + return mn; + } + + /** + * @return The content of the article in Norwegian + */ + @JsonProperty("nb") + public Optional getNb() { + return nb; + } + + /** + * @return The content of the article in Dutch + */ + @JsonProperty("nl") + public Optional getNl() { + return nl; + } + + /** + * @return The content of the article in Polish + */ + @JsonProperty("pl") + public Optional getPl() { + return pl; + } + + /** + * @return The content of the article in Portuguese (Portugal) + */ + @JsonProperty("pt") + public Optional getPt() { + return pt; + } + + /** + * @return The content of the article in Romanian + */ + @JsonProperty("ro") + public Optional getRo() { + return ro; + } + + /** + * @return The content of the article in Russian + */ + @JsonProperty("ru") + public Optional getRu() { + return ru; + } + + /** + * @return The content of the article in Slovenian + */ + @JsonProperty("sl") + public Optional getSl() { + return sl; + } + + /** + * @return The content of the article in Serbian + */ + @JsonProperty("sr") + public Optional getSr() { + return sr; + } + + /** + * @return The content of the article in Swedish + */ + @JsonProperty("sv") + public Optional getSv() { + return sv; + } + + /** + * @return The content of the article in Turkish + */ + @JsonProperty("tr") + public Optional getTr() { + return tr; + } + + /** + * @return The content of the article in Vietnamese + */ + @JsonProperty("vi") + public Optional getVi() { + return vi; + } + + /** + * @return The content of the article in Portuguese (Brazil) + */ + @JsonProperty("pt-BR") + public Optional getPtBr() { + return ptBr; + } + + /** + * @return The content of the article in Chinese (China) + */ + @JsonProperty("zh-CN") + public Optional getZhCn() { + return zhCn; + } + + /** + * @return The content of the article in Chinese (Taiwan) + */ + @JsonProperty("zh-TW") + public Optional getZhTw() { + return zhTw; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ArticleTranslatedContent && equalTo((ArticleTranslatedContent) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ArticleTranslatedContent other) { + return type.equals(other.type) + && ar.equals(other.ar) + && bg.equals(other.bg) + && bs.equals(other.bs) + && ca.equals(other.ca) + && cs.equals(other.cs) + && da.equals(other.da) + && de.equals(other.de) + && el.equals(other.el) + && en.equals(other.en) + && es.equals(other.es) + && et.equals(other.et) + && fi.equals(other.fi) + && fr.equals(other.fr) + && he.equals(other.he) + && hr.equals(other.hr) + && hu.equals(other.hu) + && id.equals(other.id) + && it.equals(other.it) + && ja.equals(other.ja) + && ko.equals(other.ko) + && lt.equals(other.lt) + && lv.equals(other.lv) + && mn.equals(other.mn) + && nb.equals(other.nb) + && nl.equals(other.nl) + && pl.equals(other.pl) + && pt.equals(other.pt) + && ro.equals(other.ro) + && ru.equals(other.ru) + && sl.equals(other.sl) + && sr.equals(other.sr) + && sv.equals(other.sv) + && tr.equals(other.tr) + && vi.equals(other.vi) + && ptBr.equals(other.ptBr) + && zhCn.equals(other.zhCn) + && zhTw.equals(other.zhTw); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.type, this.ar, this.bg, this.bs, this.ca, this.cs, this.da, this.de, this.el, this.en, this.es, + this.et, this.fi, this.fr, this.he, this.hr, this.hu, this.id, this.it, this.ja, this.ko, this.lt, + this.lv, this.mn, this.nb, this.nl, this.pl, this.pt, this.ro, this.ru, this.sl, this.sr, this.sv, + this.tr, this.vi, this.ptBr, this.zhCn, this.zhTw); + } + + @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 ar = Optional.empty(); + + private Optional bg = Optional.empty(); + + private Optional bs = Optional.empty(); + + private Optional ca = Optional.empty(); + + private Optional cs = Optional.empty(); + + private Optional da = Optional.empty(); + + private Optional de = Optional.empty(); + + private Optional el = Optional.empty(); + + private Optional en = Optional.empty(); + + private Optional es = Optional.empty(); + + private Optional et = Optional.empty(); + + private Optional fi = Optional.empty(); + + private Optional fr = Optional.empty(); + + private Optional he = Optional.empty(); + + private Optional hr = Optional.empty(); + + private Optional hu = Optional.empty(); + + private Optional id = Optional.empty(); + + private Optional it = Optional.empty(); + + private Optional ja = Optional.empty(); + + private Optional ko = Optional.empty(); + + private Optional lt = Optional.empty(); + + private Optional lv = Optional.empty(); + + private Optional mn = Optional.empty(); + + private Optional nb = Optional.empty(); + + private Optional nl = Optional.empty(); + + private Optional pl = Optional.empty(); + + private Optional pt = Optional.empty(); + + private Optional ro = Optional.empty(); + + private Optional ru = Optional.empty(); + + private Optional sl = Optional.empty(); + + private Optional sr = Optional.empty(); + + private Optional sv = Optional.empty(); + + private Optional tr = Optional.empty(); + + private Optional vi = Optional.empty(); + + private Optional ptBr = Optional.empty(); + + private Optional zhCn = Optional.empty(); + + private Optional zhTw = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ArticleTranslatedContent other) { + type(other.getType()); + ar(other.getAr()); + bg(other.getBg()); + bs(other.getBs()); + ca(other.getCa()); + cs(other.getCs()); + da(other.getDa()); + de(other.getDe()); + el(other.getEl()); + en(other.getEn()); + es(other.getEs()); + et(other.getEt()); + fi(other.getFi()); + fr(other.getFr()); + he(other.getHe()); + hr(other.getHr()); + hu(other.getHu()); + id(other.getId()); + it(other.getIt()); + ja(other.getJa()); + ko(other.getKo()); + lt(other.getLt()); + lv(other.getLv()); + mn(other.getMn()); + nb(other.getNb()); + nl(other.getNl()); + pl(other.getPl()); + pt(other.getPt()); + ro(other.getRo()); + ru(other.getRu()); + sl(other.getSl()); + sr(other.getSr()); + sv(other.getSv()); + tr(other.getTr()); + vi(other.getVi()); + ptBr(other.getPtBr()); + zhCn(other.getZhCn()); + zhTw(other.getZhTw()); + 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 = "ar", nulls = Nulls.SKIP) + public Builder ar(Optional ar) { + this.ar = ar; + return this; + } + + public Builder ar(ArticleContent ar) { + this.ar = Optional.ofNullable(ar); + return this; + } + + @JsonSetter(value = "bg", nulls = Nulls.SKIP) + public Builder bg(Optional bg) { + this.bg = bg; + return this; + } + + public Builder bg(ArticleContent bg) { + this.bg = Optional.ofNullable(bg); + return this; + } + + @JsonSetter(value = "bs", nulls = Nulls.SKIP) + public Builder bs(Optional bs) { + this.bs = bs; + return this; + } + + public Builder bs(ArticleContent bs) { + this.bs = Optional.ofNullable(bs); + return this; + } + + @JsonSetter(value = "ca", nulls = Nulls.SKIP) + public Builder ca(Optional ca) { + this.ca = ca; + return this; + } + + public Builder ca(ArticleContent ca) { + this.ca = Optional.ofNullable(ca); + return this; + } + + @JsonSetter(value = "cs", nulls = Nulls.SKIP) + public Builder cs(Optional cs) { + this.cs = cs; + return this; + } + + public Builder cs(ArticleContent cs) { + this.cs = Optional.ofNullable(cs); + return this; + } + + @JsonSetter(value = "da", nulls = Nulls.SKIP) + public Builder da(Optional da) { + this.da = da; + return this; + } + + public Builder da(ArticleContent da) { + this.da = Optional.ofNullable(da); + return this; + } + + @JsonSetter(value = "de", nulls = Nulls.SKIP) + public Builder de(Optional de) { + this.de = de; + return this; + } + + public Builder de(ArticleContent de) { + this.de = Optional.ofNullable(de); + return this; + } + + @JsonSetter(value = "el", nulls = Nulls.SKIP) + public Builder el(Optional el) { + this.el = el; + return this; + } + + public Builder el(ArticleContent el) { + this.el = Optional.ofNullable(el); + return this; + } + + @JsonSetter(value = "en", nulls = Nulls.SKIP) + public Builder en(Optional en) { + this.en = en; + return this; + } + + public Builder en(ArticleContent en) { + this.en = Optional.ofNullable(en); + return this; + } + + @JsonSetter(value = "es", nulls = Nulls.SKIP) + public Builder es(Optional es) { + this.es = es; + return this; + } + + public Builder es(ArticleContent es) { + this.es = Optional.ofNullable(es); + return this; + } + + @JsonSetter(value = "et", nulls = Nulls.SKIP) + public Builder et(Optional et) { + this.et = et; + return this; + } + + public Builder et(ArticleContent et) { + this.et = Optional.ofNullable(et); + return this; + } + + @JsonSetter(value = "fi", nulls = Nulls.SKIP) + public Builder fi(Optional fi) { + this.fi = fi; + return this; + } + + public Builder fi(ArticleContent fi) { + this.fi = Optional.ofNullable(fi); + return this; + } + + @JsonSetter(value = "fr", nulls = Nulls.SKIP) + public Builder fr(Optional fr) { + this.fr = fr; + return this; + } + + public Builder fr(ArticleContent fr) { + this.fr = Optional.ofNullable(fr); + return this; + } + + @JsonSetter(value = "he", nulls = Nulls.SKIP) + public Builder he(Optional he) { + this.he = he; + return this; + } + + public Builder he(ArticleContent he) { + this.he = Optional.ofNullable(he); + return this; + } + + @JsonSetter(value = "hr", nulls = Nulls.SKIP) + public Builder hr(Optional hr) { + this.hr = hr; + return this; + } + + public Builder hr(ArticleContent hr) { + this.hr = Optional.ofNullable(hr); + return this; + } + + @JsonSetter(value = "hu", nulls = Nulls.SKIP) + public Builder hu(Optional hu) { + this.hu = hu; + return this; + } + + public Builder hu(ArticleContent hu) { + this.hu = Optional.ofNullable(hu); + return this; + } + + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(ArticleContent id) { + this.id = Optional.ofNullable(id); + return this; + } + + @JsonSetter(value = "it", nulls = Nulls.SKIP) + public Builder it(Optional it) { + this.it = it; + return this; + } + + public Builder it(ArticleContent it) { + this.it = Optional.ofNullable(it); + return this; + } + + @JsonSetter(value = "ja", nulls = Nulls.SKIP) + public Builder ja(Optional ja) { + this.ja = ja; + return this; + } + + public Builder ja(ArticleContent ja) { + this.ja = Optional.ofNullable(ja); + return this; + } + + @JsonSetter(value = "ko", nulls = Nulls.SKIP) + public Builder ko(Optional ko) { + this.ko = ko; + return this; + } + + public Builder ko(ArticleContent ko) { + this.ko = Optional.ofNullable(ko); + return this; + } + + @JsonSetter(value = "lt", nulls = Nulls.SKIP) + public Builder lt(Optional lt) { + this.lt = lt; + return this; + } + + public Builder lt(ArticleContent lt) { + this.lt = Optional.ofNullable(lt); + return this; + } + + @JsonSetter(value = "lv", nulls = Nulls.SKIP) + public Builder lv(Optional lv) { + this.lv = lv; + return this; + } + + public Builder lv(ArticleContent lv) { + this.lv = Optional.ofNullable(lv); + return this; + } + + @JsonSetter(value = "mn", nulls = Nulls.SKIP) + public Builder mn(Optional mn) { + this.mn = mn; + return this; + } + + public Builder mn(ArticleContent mn) { + this.mn = Optional.ofNullable(mn); + return this; + } + + @JsonSetter(value = "nb", nulls = Nulls.SKIP) + public Builder nb(Optional nb) { + this.nb = nb; + return this; + } + + public Builder nb(ArticleContent nb) { + this.nb = Optional.ofNullable(nb); + return this; + } + + @JsonSetter(value = "nl", nulls = Nulls.SKIP) + public Builder nl(Optional nl) { + this.nl = nl; + return this; + } + + public Builder nl(ArticleContent nl) { + this.nl = Optional.ofNullable(nl); + return this; + } + + @JsonSetter(value = "pl", nulls = Nulls.SKIP) + public Builder pl(Optional pl) { + this.pl = pl; + return this; + } + + public Builder pl(ArticleContent pl) { + this.pl = Optional.ofNullable(pl); + return this; + } + + @JsonSetter(value = "pt", nulls = Nulls.SKIP) + public Builder pt(Optional pt) { + this.pt = pt; + return this; + } + + public Builder pt(ArticleContent pt) { + this.pt = Optional.ofNullable(pt); + return this; + } + + @JsonSetter(value = "ro", nulls = Nulls.SKIP) + public Builder ro(Optional ro) { + this.ro = ro; + return this; + } + + public Builder ro(ArticleContent ro) { + this.ro = Optional.ofNullable(ro); + return this; + } + + @JsonSetter(value = "ru", nulls = Nulls.SKIP) + public Builder ru(Optional ru) { + this.ru = ru; + return this; + } + + public Builder ru(ArticleContent ru) { + this.ru = Optional.ofNullable(ru); + return this; + } + + @JsonSetter(value = "sl", nulls = Nulls.SKIP) + public Builder sl(Optional sl) { + this.sl = sl; + return this; + } + + public Builder sl(ArticleContent sl) { + this.sl = Optional.ofNullable(sl); + return this; + } + + @JsonSetter(value = "sr", nulls = Nulls.SKIP) + public Builder sr(Optional sr) { + this.sr = sr; + return this; + } + + public Builder sr(ArticleContent sr) { + this.sr = Optional.ofNullable(sr); + return this; + } + + @JsonSetter(value = "sv", nulls = Nulls.SKIP) + public Builder sv(Optional sv) { + this.sv = sv; + return this; + } + + public Builder sv(ArticleContent sv) { + this.sv = Optional.ofNullable(sv); + return this; + } + + @JsonSetter(value = "tr", nulls = Nulls.SKIP) + public Builder tr(Optional tr) { + this.tr = tr; + return this; + } + + public Builder tr(ArticleContent tr) { + this.tr = Optional.ofNullable(tr); + return this; + } + + @JsonSetter(value = "vi", nulls = Nulls.SKIP) + public Builder vi(Optional vi) { + this.vi = vi; + return this; + } + + public Builder vi(ArticleContent vi) { + this.vi = Optional.ofNullable(vi); + return this; + } + + @JsonSetter(value = "pt-BR", nulls = Nulls.SKIP) + public Builder ptBr(Optional ptBr) { + this.ptBr = ptBr; + return this; + } + + public Builder ptBr(ArticleContent ptBr) { + this.ptBr = Optional.ofNullable(ptBr); + return this; + } + + @JsonSetter(value = "zh-CN", nulls = Nulls.SKIP) + public Builder zhCn(Optional zhCn) { + this.zhCn = zhCn; + return this; + } + + public Builder zhCn(ArticleContent zhCn) { + this.zhCn = Optional.ofNullable(zhCn); + return this; + } + + @JsonSetter(value = "zh-TW", nulls = Nulls.SKIP) + public Builder zhTw(Optional zhTw) { + this.zhTw = zhTw; + return this; + } + + public Builder zhTw(ArticleContent zhTw) { + this.zhTw = Optional.ofNullable(zhTw); + return this; + } + + public ArticleTranslatedContent build() { + return new ArticleTranslatedContent( + type, + ar, + bg, + bs, + ca, + cs, + da, + de, + el, + en, + es, + et, + fi, + fr, + he, + hr, + hu, + id, + it, + ja, + ko, + lt, + lv, + mn, + nb, + nl, + pl, + pt, + ro, + ru, + sl, + sr, + sv, + tr, + vi, + ptBr, + zhCn, + zhTw, + additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/types/AssignConversationRequest.java b/src/main/java/com/intercom/api/types/AssignConversationRequest.java new file mode 100644 index 00000000..0b0c01cf --- /dev/null +++ b/src/main/java/com/intercom/api/types/AssignConversationRequest.java @@ -0,0 +1,282 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.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 = AssignConversationRequest.Builder.class) +public final class AssignConversationRequest { + private final Type type; + + private final String adminId; + + private final String assigneeId; + + private final Optional body; + + private final Map additionalProperties; + + private AssignConversationRequest( + Type type, + String adminId, + String assigneeId, + Optional body, + Map additionalProperties) { + this.type = type; + this.adminId = adminId; + this.assigneeId = assigneeId; + this.body = body; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("type") + public Type getType() { + return type; + } + + /** + * @return The id of the admin who is performing the action. + */ + @JsonProperty("admin_id") + public String getAdminId() { + return adminId; + } + + /** + * @return The id of the admin or team which will be assigned the conversation. A conversation can be assigned both an admin and a team.\nSet 0 if you want this assign to no admin or team (ie. Unassigned). + */ + @JsonProperty("assignee_id") + public String getAssigneeId() { + return assigneeId; + } + + /** + * @return Optionally you can send a response in the conversation when it is assigned. + */ + @JsonProperty("body") + public Optional getBody() { + return body; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AssignConversationRequest && equalTo((AssignConversationRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(AssignConversationRequest other) { + return type.equals(other.type) + && adminId.equals(other.adminId) + && assigneeId.equals(other.assigneeId) + && body.equals(other.body); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.adminId, this.assigneeId, this.body); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TypeStage builder() { + return new Builder(); + } + + public interface TypeStage { + AdminIdStage type(@NotNull Type type); + + Builder from(AssignConversationRequest other); + } + + public interface AdminIdStage { + AssigneeIdStage adminId(@NotNull String adminId); + } + + public interface AssigneeIdStage { + _FinalStage assigneeId(@NotNull String assigneeId); + } + + public interface _FinalStage { + AssignConversationRequest build(); + + _FinalStage body(Optional body); + + _FinalStage body(String body); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements TypeStage, AdminIdStage, AssigneeIdStage, _FinalStage { + private Type type; + + private String adminId; + + private String assigneeId; + + private Optional body = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(AssignConversationRequest other) { + type(other.getType()); + adminId(other.getAdminId()); + assigneeId(other.getAssigneeId()); + body(other.getBody()); + return this; + } + + @java.lang.Override + @JsonSetter("type") + public AdminIdStage type(@NotNull Type type) { + this.type = Objects.requireNonNull(type, "type must not be null"); + return this; + } + + /** + *

The id of the admin who is performing the action.

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

The id of the admin or team which will be assigned the conversation. A conversation can be assigned both an admin and a team.\nSet 0 if you want this assign to no admin or team (ie. Unassigned).

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

Optionally you can send a response in the conversation when it is assigned.

+ * @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; + } + + @java.lang.Override + @JsonSetter(value = "body", nulls = Nulls.SKIP) + public _FinalStage body(Optional body) { + this.body = body; + return this; + } + + @java.lang.Override + public AssignConversationRequest build() { + return new AssignConversationRequest(type, adminId, assigneeId, body, additionalProperties); + } + } + + public final class Type { + public static final Type ADMIN = new Type(Value.ADMIN, "admin"); + + public static final Type TEAM = new Type(Value.TEAM, "team"); + + private final Value value; + + private final String string; + + Type(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 Type && this.string.equals(((Type) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case ADMIN: + return visitor.visitAdmin(); + case TEAM: + return visitor.visitTeam(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static Type valueOf(String value) { + switch (value) { + case "admin": + return ADMIN; + case "team": + return TEAM; + default: + return new Type(Value.UNKNOWN, value); + } + } + + public enum Value { + ADMIN, + + TEAM, + + UNKNOWN + } + + public interface Visitor { + T visitAdmin(); + + T visitTeam(); + + T visitUnknown(String unknownType); + } + } +} diff --git a/src/main/java/com/intercom/api/types/ButtonComponent.java b/src/main/java/com/intercom/api/types/ButtonComponent.java new file mode 100644 index 00000000..22f54587 --- /dev/null +++ b/src/main/java/com/intercom/api/types/ButtonComponent.java @@ -0,0 +1,336 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.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 = ButtonComponent.Builder.class) +public final class ButtonComponent { + private final String id; + + private final String label; + + private final ActionComponent action; + + private final Optional