From ef113381934f10b8176a73c064d4c79c00438859 Mon Sep 17 00:00:00 2001 From: "fern-api[bot]" <115122769+fern-api[bot]@users.noreply.github.com> Date: Fri, 5 Dec 2025 22:32:11 +0000 Subject: [PATCH] SDK regeneration --- .fern/metadata.json | 20 + .github/workflows/ci.yml | 4 +- README.md | 23 +- reference.md | 21225 ++++++++++++++++ src/Admins/AdminsClient.php | 23 +- .../Requests/ConfigureAwayAdminRequest.php | 39 +- src/Admins/Requests/FindAdminRequest.php | 14 +- src/Admins/Types/Admin.php | 33 +- src/AiAgent/Types/AiAgent.php | 84 +- src/AiAgent/Types/AiAgentLastAnswerType.php | 9 + src/AiAgent/Types/AiAgentResolutionState.php | 11 + src/AiContent/AiContentClient.php | 609 + .../CreateContentImportSourceRequest.php | 94 + .../Requests/CreateExternalPageRequest.php | 218 + .../DeleteContentImportSourceRequest.php | 41 + .../Requests/DeleteExternalPageRequest.php | 41 + .../GetContentImportSourceRequest.php | 41 + .../Requests/GetExternalPageRequest.php | 41 + .../UpdateContentImportSourceRequest.php | 119 + .../Requests/UpdateExternalPageRequest.php | 217 + src/AiContent/Types/ContentImportSource.php | 229 + .../Types/ContentImportSourceStatus.php | 9 + .../Types/ContentImportSourceSyncBehavior.php | 10 + .../Types/ContentImportSourcesList.php | 131 + ...CreateContentImportSourceRequestStatus.php | 9 + src/AiContent/Types/ExternalPage.php | 379 + src/AiContent/Types/ExternalPagesList.php | 131 + ...UpdateContentImportSourceRequestStatus.php | 9 + ...ContentImportSourceRequestSyncBehavior.php | 10 + src/AiContentSource/Types/ContentSource.php | 66 +- src/Articles/ArticlesClient.php | 16 +- .../Requests/DeleteArticleRequest.php | 14 +- src/Articles/Requests/FindArticleRequest.php | 14 +- .../Requests/UpdateArticleRequest.php | 33 +- .../Types/ArticleSearchHighlights.php | 50 +- ...Response.php => ArticleSearchResponse.php} | 52 +- ...Data.php => ArticleSearchResponseData.php} | 2 +- .../Types/UpdateArticleRequestBodyState.php | 9 - .../Types/UpdateArticleRequestState.php | 2 +- .../AwayStatusReasonsClient.php | 107 + src/Calls/CallsClient.php | 337 + src/Calls/Requests/ListCallsRequest.php | 65 + .../ListCallsWithTranscriptsRequest.php | 44 + .../Requests/ShowCallRecordingRequest.php | 41 + src/Calls/Requests/ShowCallRequest.php | 41 + .../Requests/ShowCallTranscriptRequest.php | 41 + src/Calls/Traits/Call.php | 530 + src/Calls/Types/Call.php | 566 + .../ListCallsWithTranscriptsResponse.php | 77 + ...stCallsWithTranscriptsResponseDataItem.php | 134 + src/Companies/CompaniesClient.php | 28 +- .../Requests/ListAttachedContactsRequest.php | 48 - .../Requests/UpdateCompanyRequest.php | 25 + src/Companies/Types/Company.php | 25 + src/Companies/Types/CompanyPlan.php | 8 +- src/Contacts/ContactsClient.php | 152 +- .../Requests/ArchiveContactRequest.php | 2 +- src/Contacts/Requests/BlockContactRequest.php | 41 + .../Requests/DeleteContactRequest.php | 2 +- src/Contacts/Requests/FindContactRequest.php | 2 +- .../Requests/MergeContactsRequest.php | 34 +- .../ShowContactByExternalIdRequest.php | 41 + .../Requests/UnarchiveContactRequest.php | 2 +- src/Contacts/Traits/Contact.php | 1098 + src/Contacts/Types/Contact.php | 189 +- src/Contacts/Types/ContactsCreateResponse.php | 149 + src/Contacts/Types/ContactsFindResponse.php | 149 + .../Types/ContactsMergeLeadInUserResponse.php | 149 + src/Contacts/Types/ContactsUpdateResponse.php | 149 + .../Types/ShowContactByExternalIdResponse.php | 149 + src/Conversations/ConversationsClient.php | 178 +- .../ConvertConversationToTicketRequest.php | 14 +- .../Requests/DeleteConversationRequest.php | 41 + .../Requests/FindConversationRequest.php | 24 + .../Requests/UpdateConversationRequest.php | 83 +- src/Conversations/Types/Conversation.php | 220 +- src/Core/Client/RawClient.php | 3 + src/Core/Client/RetryMiddleware.php | 81 +- src/Core/Json/JsonDeserializer.php | 4 +- src/Core/Json/JsonSerializer.php | 7 +- .../CustomChannelEventsClient.php | 284 + .../NotifyAttributeCollectedRequest.php | 54 + .../Requests/NotifyNewMessageRequest.php | 53 + .../NotifyQuickReplySelectedRequest.php | 53 + .../CustomObjectInstancesClient.php | 349 + ...ateOrUpdateCustomObjectInstanceRequest.php | 144 + ...stomObjectInstancesByExternalIdRequest.php | 65 + ...DeleteCustomObjectInstancesByIdRequest.php | 65 + ...stomObjectInstancesByExternalIdRequest.php | 65 + .../GetCustomObjectInstancesByIdRequest.php | 65 + .../Types/CustomObjectInstance.php | 230 + src/DataAttributes/DataAttributesClient.php | 18 +- .../Requests/CreateDataAttributeRequest.php | 171 - .../Requests/UpdateDataAttributeRequest.php | 126 +- .../Types/CreateDataAttributeRequestModel.php | 9 - src/DataExport/DataExportClient.php | 127 +- .../DownloadReportingDataExportRequest.php | 89 + .../Requests/ExportReportingDataRequest.php | 89 + src/DataExport/Types/DataExport.php | 66 +- .../DataExportExportReportingDataResponse.php | 126 + src/Events/EventsClient.php | 4 +- src/Export/ExportClient.php | 160 + .../PostExportReportingDataEnqueueRequest.php | 119 + ...ExportReportingDataGetDatasetsResponse.php | 77 + ...portingDataGetDatasetsResponseDataItem.php | 152 + ...atasetsResponseDataItemAttributesItem.php} | 31 +- ...PostExportReportingDataEnqueueResponse.php | 126 + src/HelpCenter/Types/HelpCenter.php | 148 +- src/HelpCenter/Types/HelpCenterList.php | 34 +- .../Collections/CollectionsClient.php | 2 +- .../Requests/DeleteCollectionRequest.php | 14 +- .../Requests/FindCollectionRequest.php | 14 +- .../Requests/UpdateCollectionRequest.php | 14 +- src/HelpCenters/HelpCentersClient.php | 2 +- .../Requests/FindHelpCenterRequest.php | 14 +- src/IntercomClient.php | 80 +- .../InternalArticlesClient.php | 396 + .../Requests/DeleteInternalArticleRequest.php | 41 + .../RetrieveInternalArticleRequest.php | 41 + .../SearchInternalArticlesRequest.php | 41 + .../UpdateInternalArticleRequestBody.php | 142 + .../Types/InternalArticleListItem.php | 254 + .../Types/InternalArticleSearchResponse.php | 130 + .../InternalArticleSearchResponseData.php | 55 + src/Jobs/JobsClient.php | 108 + src/Jobs/Requests/JobsStatusRequest.php | 41 + src/Jobs/Types/Jobs.php | 204 + src/Jobs/Types/JobsStatus.php | 10 + src/Messages/MessagesClient.php | 6 +- src/Messages/Types/Message.php | 32 +- src/News/Feeds/FeedsClient.php | 17 +- src/News/Items/ItemsClient.php | 10 +- .../Items/Requests/DeleteNewsItemRequest.php | 14 +- .../Items/Requests/FindNewsItemRequest.php | 14 +- .../Items/Requests/UpdateNewsItemRequest.php | 14 +- src/News/NewsClient.php | 2 +- src/News/Types/NewsItem.php | 130 +- src/News/Types/Newsfeed.php | 66 +- src/News/Types/NewsfeedAssignment.php | 34 +- src/Notes/NotesClient.php | 2 +- src/Notes/Requests/FindNoteRequest.php | 14 +- src/Notes/Types/Note.php | 82 +- src/Notes/Types/NoteContact.php | 8 +- .../PhoneCallRedirectsClient.php | 13 +- src/Segments/SegmentsClient.php | 2 +- src/Segments/Types/Segment.php | 82 +- .../SubscriptionTypesClient.php | 2 +- .../Types/SubscriptionType.php | 114 +- .../Requests/UntagConversationRequest.php | 2 +- src/Tags/TagsClient.php | 3 +- src/Tags/Types/TagBasic.php | 104 + src/Teams/TeamsClient.php | 2 +- src/Teams/Types/Team.php | 116 +- src/TicketStates/TicketStatesClient.php | 106 + .../Attributes/AttributesClient.php | 16 +- .../Requests/UpdateTicketTypeRequest.php | 10 +- src/TicketTypes/TicketTypesClient.php | 27 +- .../Types/UpdateTicketTypeRequestCategory.php | 2 +- src/Tickets/Requests/CreateTicketRequest.php | 66 + src/Tickets/Requests/DeleteTicketRequest.php | 41 + .../Requests/EnqueueCreateTicketRequest.php | 66 + src/Tickets/Requests/UpdateTicketRequest.php | 96 +- src/Tickets/TicketsClient.php | 166 +- src/Tickets/Types/DeleteTicketResponse.php | 104 + src/Tickets/Types/Ticket.php | 180 +- src/Tickets/Types/TicketContacts.php | 34 +- src/Tickets/Types/TicketPart.php | 132 +- .../Types/TicketPartUpdatedAttributeData.php | 79 + ...cketPartUpdatedAttributeDataAttribute.php} | 64 +- .../TicketPartUpdatedAttributeDataValue.php | 133 + src/Tickets/Types/TicketState.php | 154 + ...icketState.php => TicketStateCategory.php} | 2 +- src/Tickets/Types/TicketStateDetailed.php | 204 + ...te.php => TicketStateDetailedCategory.php} | 3 +- .../Types/TicketStateDetailedTicketTypes.php | 81 + src/Tickets/Types/TicketType.php | 187 +- src/Tickets/Types/TicketTypeTicketStates.php | 81 + .../Types/UpdateTicketRequestAssignment.php | 76 - src/Traits/ContactReference.php | 84 + src/Traits/ContactReplyBaseRequest.php | 25 + src/Traits/CreateTicketRequestBody.php | 184 + src/Traits/CustomChannelBaseEvent.php | 83 + src/Traits/ListItem.php | 205 - src/Traits/QuickReplyOption.php | 58 + src/Types/ActivityLog.php | 50 +- src/Types/ActivityLogActivityType.php | 28 +- src/Types/ActivityLogList.php | 37 +- src/Types/ActivityLogMetadata.php | 228 + src/Types/ActivityLogMetadataTeam.php | 79 + src/Types/ActivityLogPerformedBy.php | 8 +- src/Types/AddressableList.php | 50 +- src/Types/AdminList.php | 37 +- src/Types/AdminReplyConversationRequest.php | 25 + ...minReplyConversationRequestMessageType.php | 1 + src/Types/AdminWithApp.php | 146 +- src/Types/AdminWithAppAvatar.php | 8 +- src/Types/App.php | 114 +- src/Types/ArticleContent.php | 98 +- src/Types/ArticleList.php | 50 +- src/Types/AwayStatusReason.php | 226 + src/Types/ButtonComponent.php | 157 - src/Types/ButtonComponentStyle.php | 10 - ...natedNewsItemResponse.php => CallList.php} | 80 +- src/Types/CanvasObject.php | 110 - src/Types/CheckboxComponent.php | 184 - src/Types/CheckboxComponentSaveState.php | 10 - src/Types/CheckboxOption.php | 129 - src/Types/CollectionList.php | 50 +- src/Types/CompanyAttachedContacts.php | 50 +- src/Types/CompanyAttachedSegments.php | 34 +- src/Types/CompanyData.php | 104 + src/Types/CompanyList.php | 59 +- src/Types/CompanyScroll.php | 34 +- src/Types/Component.php | 703 - src/Types/ConfigureRequestComponentId.php | 203 - src/Types/ConfigureRequestZero.php | 102 - src/Types/ConfigureResponseCanvas.php | 51 - src/Types/ContactArchived.php | 96 +- src/Types/ContactAttachedCompanies.php | 50 +- src/Types/ContactBlocked.php | 63 + src/Types/ContactCompanies.php | 87 +- src/Types/ContactDeleted.php | 96 +- src/Types/ContactList.php | 50 +- src/Types/ContactLocation.php | 18 +- src/Types/ContactNotes.php | 66 +- src/Types/ContactReference.php | 34 +- src/Types/ContactReplyBaseRequest.php | 25 + ...ontactReplyBaseRequestReplyOptionsItem.php | 76 + src/Types/ContactReplyEmailRequest.php | 2 + .../ContactReplyIntercomUserIdRequest.php | 2 + src/Types/ContactReplyTicketEmailRequest.php | 2 + ...ontactReplyTicketIntercomUserIdRequest.php | 2 + src/Types/ContactReplyTicketUserIdRequest.php | 2 + src/Types/ContactReplyUserIdRequest.php | 2 + src/Types/ContactSegments.php | 34 +- src/Types/ContactSocialProfiles.php | 18 +- src/Types/ContactSubscriptionTypes.php | 66 +- src/Types/ContactTags.php | 66 +- src/Types/ContactUnarchived.php | 96 +- src/Types/ContentObject.php | 57 - src/Types/ContentSourcesList.php | 50 +- src/Types/Context.php | 181 - src/Types/ContextLocation.php | 11 - src/Types/ConversationAttachmentFiles.php | 50 +- .../ConversationAttributeUpdatedByAdmin.php | 79 + ...sationAttributeUpdatedByAdminAttribute.php | 51 + ...nversationAttributeUpdatedByAdminValue.php | 51 + ...ConversationAttributeUpdatedByWorkflow.php | 104 + ...ionAttributeUpdatedByWorkflowAttribute.php | 51 + ...rsationAttributeUpdatedByWorkflowValue.php | 51 + ...tionAttributeUpdatedByWorkflowWorkflow.php | 51 + src/Types/ConversationContacts.php | 34 +- src/Types/ConversationDeleted.php | 104 + src/Types/ConversationFirstContactReply.php | 34 +- ...ationResponse.php => ConversationList.php} | 52 +- src/Types/ConversationPart.php | 290 +- src/Types/ConversationPartAuthor.php | 116 +- src/Types/ConversationPartMetadata.php | 80 + ...ationPartMetadataQuickReplyOptionsItem.php | 59 + src/Types/ConversationPartState.php | 10 + src/Types/ConversationParts.php | 50 +- src/Types/ConversationRating.php | 107 +- src/Types/ConversationResponseTime.php | 104 + src/Types/ConversationSource.php | 100 +- src/Types/ConversationStatistics.php | 119 +- .../CreateArticleRequest.php | 16 +- .../Types/CreateArticleRequestParentType.php | 2 +- .../Types/CreateArticleRequestState.php | 2 +- src/Types/CreateDataAttributeRequestOne.php | 51 + ...CreateDataAttributeRequestOneDataType.php} | 4 +- .../CreateDataAttributeRequestOptions.php | 77 + ...DataAttributeRequestOptionsOptionsItem.php | 51 + src/Types/CreateInternalArticleRequest.php | 129 + .../CreateOrUpdateCompanyRequest.php | 13 +- .../CreatePhoneSwitchRequest.php} | 47 +- src/Types/CreateTicketRequestAssignment.php | 76 + ...equest.php => CreateTicketRequestBody.php} | 57 +- .../CreateTicketTypeRequest.php | 15 +- .../Types/CreateTicketTypeRequestCategory.php | 2 +- src/Types/CurrentCanvas.php | 54 - src/Types/CursorPages.php | 18 +- src/Types/CustomActionFinished.php | 54 + src/Types/CustomActionFinishedAction.php | 76 + .../CustomActionFinishedActionResult.php | 9 + src/Types/CustomActionStarted.php | 54 + src/Types/CustomActionStartedAction.php | 51 + .../CustomChannelAttribute.php} | 31 +- src/Types/CustomChannelBaseEvent.php | 101 + src/Types/CustomChannelContact.php | 126 + src/Types/CustomChannelContactType.php | 9 + .../CustomChannelNotificationResponse.php | 126 + src/Types/CustomObjectInstanceDeleted.php | 104 + src/Types/CustomObjectInstanceList.php | 82 + src/Types/DataAttributeList.php | 34 +- src/Types/DataEventList.php | 34 +- src/Types/DataEventSummary.php | 11 +- src/Types/DataEventSummaryItem.php | 66 +- src/Types/DataExportCsv.php | 130 +- src/Types/DataTableComponent.php | 55 - src/Types/DataTableItem.php | 104 - src/Types/DeletedArticleObject.php | 50 +- src/Types/DeletedCollectionObject.php | 50 +- src/Types/DeletedCompanyObject.php | 50 +- src/Types/DeletedInternalArticleObject.php | 104 + src/Types/DeletedObject.php | 50 +- src/Types/DropdownComponent.php | 182 - src/Types/DropdownComponentSaveState.php | 10 - src/Types/DropdownOption.php | 129 - src/Types/EmailAddressHeader.php | 104 + src/Types/EmailMessageMetadata.php | 80 + src/Types/Event.php | 54 - src/Types/FileAttribute.php | 114 +- src/Types/GroupContent.php | 50 +- src/Types/GroupTranslatedContent.php | 18 +- src/Types/ImageComponent.php | 232 - src/Types/ImageComponentAlign.php | 11 - src/Types/InitializeRequest.php | 208 - src/Types/InitializeResponse.php | 54 - src/Types/InputComponent.php | 207 - src/Types/InputComponentSaveState.php | 10 - src/Types/InternalArticleList.php | 131 + src/Types/LinkedObject.php | 42 +- .../LinkedObjectCategory.php} | 4 +- src/Types/LinkedObjectList.php | 66 +- src/Types/ListComponent.php | 97 - src/Types/ListItem.php | 229 - src/Types/ListItemWithImage.php | 120 - src/Types/ListItemWithoutImage.php | 120 - src/Types/LiveCanvasRequest.php | 157 - src/Types/LiveCanvasResponse.php | 54 - src/Types/MultipleFilterSearchRequest.php | 41 +- src/Types/NotFoundErrorBody.php | 102 + src/Types/NotFoundErrorBodyErrorsItem.php | 76 + src/Types/NoteList.php | 50 +- src/Types/OperatorWorkflowEvent.php | 79 + src/Types/OperatorWorkflowEventEvent.php | 76 + src/Types/OperatorWorkflowEventWorkflow.php | 51 + src/Types/PagesLink.php | 66 +- src/Types/PaginatedResponse.php | 130 + ...nent.php => PaginatedResponseDataItem.php} | 139 +- src/Types/PaginatedResponseType.php | 9 + src/Types/PartAttachment.php | 114 +- src/Types/PhoneSwitch.php | 34 +- src/Types/QuickReplyOption.php | 76 + src/Types/Recipient.php | 79 + src/Types/RecipientType.php | 9 + src/Types/Reference.php | 18 +- src/Types/ResultsResponse.php | 55 - src/Types/SegmentList.php | 34 +- src/Types/SheetActionComponent.php | 56 - src/Types/SingleFilterSearchRequest.php | 26 +- .../SingleFilterSearchRequestOperator.php | 2 +- src/Types/SingleSelectComponent.php | 210 - src/Types/SingleSelectComponentSaveState.php | 10 - src/Types/SingleSelectOption.php | 129 - src/Types/SlaApplied.php | 50 +- src/Types/SocialProfile.php | 50 +- src/Types/SpacerComponentSize.php | 12 - src/Types/StartingAfterPaging.php | 18 +- src/Types/SubmitActionComponent.php | 19 - src/Types/SubmitRequest.php | 283 - src/Types/SubmitResponse.php | 113 - src/Types/SubscriptionTypeList.php | 34 +- src/Types/TagList.php | 34 +- src/Types/Tags.php | 34 +- src/Types/TeamList.php | 34 +- src/Types/TextAreaComponent.php | 181 - src/Types/TextComponent.php | 154 - src/Types/TextComponentAlign.php | 10 - src/Types/TextComponentStyle.php | 11 - src/Types/TicketList.php | 53 +- src/Types/TicketPartAuthor.php | 50 +- src/Types/TicketParts.php | 50 +- src/Types/TicketReply.php | 66 +- src/Types/TicketStateList.php | 82 + src/Types/TicketTypeAttribute.php | 258 +- src/Types/TicketTypeAttributeList.php | 37 +- src/Types/TicketTypeList.php | 41 +- src/Types/Translation.php | 50 +- .../UntagCompanyRequestCompaniesItem.php | 50 +- src/Types/UpdateArticleRequestBody.php | 51 + .../UpdateArticleRequestBodyParentType.php | 2 +- src/Types/UpdateCompanyRequestBody.php | 205 + .../UpdateDataAttributeRequestOptions.php | 52 + ...DataAttributeRequestOptionsOptionsItem.php | 51 + src/Types/UrlActionComponent.php | 54 - src/Types/Visitor.php | 130 +- src/Types/VisitorDeletedObject.php | 50 +- src/Types/WhatsappMessageStatusList.php | 152 + .../WhatsappMessageStatusListEventsItem.php | 226 + ...tsappMessageStatusListEventsItemStatus.php | 11 + src/Types/WhatsappMessageStatusListPages.php | 126 + .../WhatsappMessageStatusListPagesNext.php | 54 + src/Unstable/Admins/AdminsClient.php | 2 +- src/Unstable/AiAgent/Types/AiAgent.php | 66 +- .../AiAgent/Types/AiAgentLastAnswerType.php | 9 + .../AiAgent/Types/AiAgentResolutionState.php | 11 + src/Unstable/AiContent/AiContentClient.php | 2 +- src/Unstable/Articles/ArticlesClient.php | 2 +- .../AwayStatusReasonsClient.php | 2 +- src/Unstable/Brands/BrandsClient.php | 164 + .../Brands/Requests/RetrieveBrandRequest.php | 41 + src/Unstable/Brands/Types/Brand.php | 229 + src/Unstable/Brands/Types/BrandList.php | 80 + src/Unstable/Calls/CallsClient.php | 572 + ...CollectFinVoiceCallByExternalIdRequest.php | 41 + .../CollectFinVoiceCallByIdRequest.php | 41 + ...ollectFinVoiceCallByPhoneNumberRequest.php | 41 + .../Calls/Requests/ListCallsRequest.php | 65 + .../ListCallsWithTranscriptsRequest.php | 44 + .../Requests/ShowCallRecordingRequest.php | 41 + .../Calls/Requests/ShowCallRequest.php | 41 + .../Requests/ShowCallTranscriptRequest.php | 41 + src/Unstable/Calls/Traits/Call.php | 530 + src/Unstable/Calls/Types/Call.php | 566 + .../ListCallsWithTranscriptsResponse.php | 77 + ...stCallsWithTranscriptsResponseDataItem.php | 134 + src/Unstable/Companies/CompaniesClient.php | 2 +- src/Unstable/Companies/Types/Company.php | 25 + src/Unstable/Companies/Types/CompanyNotes.php | 81 + src/Unstable/Contacts/ContactsClient.php | 2 +- .../Conversations/ConversationsClient.php | 10 +- .../Requests/RetrieveConversationRequest.php | 26 +- .../Requests/UpdateConversationRequest.php | 2 +- .../CustomChannelEventsClient.php | 2 +- .../CustomObjectInstancesClient.php | 2 +- .../DataAttributes/DataAttributesClient.php | 9 +- .../Requests/CreateDataAttributeRequest.php | 171 - .../Requests/UpdateDataAttributeRequest.php | 98 +- .../Types/CreateDataAttributeRequestModel.php | 9 - src/Unstable/DataEvents/DataEventsClient.php | 4 +- src/Unstable/DataExport/DataExportClient.php | 2 +- src/Unstable/Emails/EmailsClient.php | 163 + .../Emails/Requests/RetrieveEmailRequest.php | 41 + src/Unstable/Emails/Types/EmailList.php | 80 + src/Unstable/Emails/Types/EmailSetting.php | 279 + src/Unstable/Export/ExportClient.php | 2 +- src/Unstable/HelpCenter/HelpCenterClient.php | 2 +- src/Unstable/HelpCenter/Types/HelpCenter.php | 50 + .../InternalArticlesClient.php | 396 + .../Requests/DeleteInternalArticleRequest.php | 41 + .../RetrieveInternalArticleRequest.php | 41 + .../SearchInternalArticlesRequest.php | 41 + .../UpdateInternalArticleRequestBody.php | 142 + .../Types/InternalArticleListItem.php | 254 + .../Types/InternalArticleSearchResponse.php | 130 + .../InternalArticleSearchResponseData.php | 55 + src/Unstable/Jobs/JobsClient.php | 2 +- src/Unstable/Macros/MacrosClient.php | 2 +- src/Unstable/Messages/MessagesClient.php | 4 +- src/Unstable/News/NewsClient.php | 2 +- src/Unstable/News/Types/NewsItem.php | 25 + src/Unstable/News/Types/Newsfeed.php | 25 + src/Unstable/Notes/NotesClient.php | 60 +- .../Requests/ListCompanyNotesRequest.php | 41 + src/Unstable/Notes/Types/CompanyNote.php | 180 + .../Notes/Types/CompanyNoteCompany.php} | 42 +- src/Unstable/Segments/SegmentsClient.php | 2 +- .../SubscriptionTypesClient.php | 2 +- src/Unstable/Switch_/SwitchClient.php | 2 +- src/Unstable/Tags/TagsClient.php | 3 +- src/Unstable/Teams/TeamsClient.php | 2 +- .../TicketStates/TicketStatesClient.php | 2 +- .../TicketTypeAttributesClient.php | 2 +- .../TicketTypes/TicketTypesClient.php | 2 +- src/Unstable/Tickets/TicketsClient.php | 6 +- .../Types/ActivityLogActivityType.php | 3 +- src/Unstable/Types/ActivityLogMetadata.php | 50 + src/Unstable/Types/AiCallResponse.php | 280 + src/Unstable/Types/ArticleContent.php | 8 +- .../Types/ArticleTranslatedContent.php | 8 +- .../Types/CallList.php} | 82 +- src/Unstable/Types/ConversationRating.php | 25 + src/Unstable/Types/ConversationStatistics.php | 25 + ...questBody.php => CreateArticleRequest.php} | 60 +- .../Types/CreateArticleRequestState.php | 9 + .../Types/CreateDataAttributeRequestOne.php | 51 + ...CreateDataAttributeRequestOneDataType.php} | 4 +- .../CreateDataAttributeRequestOptions.php | 77 + ...DataAttributeRequestOptionsOptionsItem.php | 51 + .../Types/CreateInternalArticleRequest.php | 129 + .../Types/CreateOrUpdateCompanyRequest.php | 255 + .../Types/CreatePhoneSwitchRequest.php | 102 + ...stBody.php => CreateTicketTypeRequest.php} | 57 +- .../Types/CreateTicketTypeRequestCategory.php | 10 + .../Types/DeletedInternalArticleObject.php | 104 + src/Unstable/Types/EmailMessageMetadata.php | 25 + src/Unstable/Types/GroupContent.php | 8 +- src/Unstable/Types/GroupTranslatedContent.php | 8 +- src/Unstable/Types/IntercomVersion.php | 25 - src/Unstable/Types/InternalArticleList.php | 131 + src/Unstable/Types/LinkedObject.php | 8 +- src/Unstable/Types/LinkedObjectCategory.php | 10 + src/Unstable/Types/NoteList.php | 2 +- .../Types/RegisterFinVoiceCallRequest.php | 130 + .../RegisterFinVoiceCallRequestSource.php | 10 + .../UpdateDataAttributeRequestOptions.php | 52 + ...DataAttributeRequestOptionsOptionsItem.php | 51 + src/Unstable/UnstableClient.php | 42 +- src/Unstable/Visitors/VisitorsClient.php | 2 +- src/Visitors/VisitorsClient.php | 16 +- tests/Core/Client/RawClientTest.php | 227 + tests/Core/Json/ExhaustiveTest.php | 2 +- tests/Core/Json/UnionArrayTest.php | 2 +- 504 files changed, 50270 insertions(+), 10299 deletions(-) create mode 100644 .fern/metadata.json create mode 100644 reference.md create mode 100644 src/AiAgent/Types/AiAgentLastAnswerType.php create mode 100644 src/AiAgent/Types/AiAgentResolutionState.php create mode 100644 src/AiContent/AiContentClient.php create mode 100644 src/AiContent/Requests/CreateContentImportSourceRequest.php create mode 100644 src/AiContent/Requests/CreateExternalPageRequest.php create mode 100644 src/AiContent/Requests/DeleteContentImportSourceRequest.php create mode 100644 src/AiContent/Requests/DeleteExternalPageRequest.php create mode 100644 src/AiContent/Requests/GetContentImportSourceRequest.php create mode 100644 src/AiContent/Requests/GetExternalPageRequest.php create mode 100644 src/AiContent/Requests/UpdateContentImportSourceRequest.php create mode 100644 src/AiContent/Requests/UpdateExternalPageRequest.php create mode 100644 src/AiContent/Types/ContentImportSource.php create mode 100644 src/AiContent/Types/ContentImportSourceStatus.php create mode 100644 src/AiContent/Types/ContentImportSourceSyncBehavior.php create mode 100644 src/AiContent/Types/ContentImportSourcesList.php create mode 100644 src/AiContent/Types/CreateContentImportSourceRequestStatus.php create mode 100644 src/AiContent/Types/ExternalPage.php create mode 100644 src/AiContent/Types/ExternalPagesList.php create mode 100644 src/AiContent/Types/UpdateContentImportSourceRequestStatus.php create mode 100644 src/AiContent/Types/UpdateContentImportSourceRequestSyncBehavior.php rename src/Articles/Types/{SearchArticlesResponse.php => ArticleSearchResponse.php} (56%) rename src/Articles/Types/{SearchArticlesResponseData.php => ArticleSearchResponseData.php} (96%) delete mode 100644 src/Articles/Types/UpdateArticleRequestBodyState.php rename src/{Unstable => Articles}/Types/UpdateArticleRequestState.php (76%) create mode 100644 src/AwayStatusReasons/AwayStatusReasonsClient.php create mode 100644 src/Calls/CallsClient.php create mode 100644 src/Calls/Requests/ListCallsRequest.php create mode 100644 src/Calls/Requests/ListCallsWithTranscriptsRequest.php create mode 100644 src/Calls/Requests/ShowCallRecordingRequest.php create mode 100644 src/Calls/Requests/ShowCallRequest.php create mode 100644 src/Calls/Requests/ShowCallTranscriptRequest.php create mode 100644 src/Calls/Traits/Call.php create mode 100644 src/Calls/Types/Call.php create mode 100644 src/Calls/Types/ListCallsWithTranscriptsResponse.php create mode 100644 src/Calls/Types/ListCallsWithTranscriptsResponseDataItem.php create mode 100644 src/Contacts/Requests/BlockContactRequest.php create mode 100644 src/Contacts/Requests/ShowContactByExternalIdRequest.php create mode 100644 src/Contacts/Traits/Contact.php create mode 100644 src/Contacts/Types/ContactsCreateResponse.php create mode 100644 src/Contacts/Types/ContactsFindResponse.php create mode 100644 src/Contacts/Types/ContactsMergeLeadInUserResponse.php create mode 100644 src/Contacts/Types/ContactsUpdateResponse.php create mode 100644 src/Contacts/Types/ShowContactByExternalIdResponse.php create mode 100644 src/Conversations/Requests/DeleteConversationRequest.php create mode 100644 src/CustomChannelEvents/CustomChannelEventsClient.php create mode 100644 src/CustomChannelEvents/Requests/NotifyAttributeCollectedRequest.php create mode 100644 src/CustomChannelEvents/Requests/NotifyNewMessageRequest.php create mode 100644 src/CustomChannelEvents/Requests/NotifyQuickReplySelectedRequest.php create mode 100644 src/CustomObjectInstances/CustomObjectInstancesClient.php create mode 100644 src/CustomObjectInstances/Requests/CreateOrUpdateCustomObjectInstanceRequest.php create mode 100644 src/CustomObjectInstances/Requests/DeleteCustomObjectInstancesByExternalIdRequest.php create mode 100644 src/CustomObjectInstances/Requests/DeleteCustomObjectInstancesByIdRequest.php create mode 100644 src/CustomObjectInstances/Requests/GetCustomObjectInstancesByExternalIdRequest.php create mode 100644 src/CustomObjectInstances/Requests/GetCustomObjectInstancesByIdRequest.php create mode 100644 src/CustomObjectInstances/Types/CustomObjectInstance.php delete mode 100644 src/DataAttributes/Requests/CreateDataAttributeRequest.php delete mode 100644 src/DataAttributes/Types/CreateDataAttributeRequestModel.php create mode 100644 src/DataExport/Requests/DownloadReportingDataExportRequest.php create mode 100644 src/DataExport/Requests/ExportReportingDataRequest.php create mode 100644 src/DataExport/Types/DataExportExportReportingDataResponse.php create mode 100644 src/Export/ExportClient.php create mode 100644 src/Export/Requests/PostExportReportingDataEnqueueRequest.php create mode 100644 src/Export/Types/GetExportReportingDataGetDatasetsResponse.php create mode 100644 src/Export/Types/GetExportReportingDataGetDatasetsResponseDataItem.php rename src/{Types/SpacerComponent.php => Export/Types/GetExportReportingDataGetDatasetsResponseDataItemAttributesItem.php} (54%) create mode 100644 src/Export/Types/PostExportReportingDataEnqueueResponse.php create mode 100644 src/InternalArticles/InternalArticlesClient.php create mode 100644 src/InternalArticles/Requests/DeleteInternalArticleRequest.php create mode 100644 src/InternalArticles/Requests/RetrieveInternalArticleRequest.php create mode 100644 src/InternalArticles/Requests/SearchInternalArticlesRequest.php create mode 100644 src/InternalArticles/Requests/UpdateInternalArticleRequestBody.php create mode 100644 src/InternalArticles/Types/InternalArticleListItem.php create mode 100644 src/InternalArticles/Types/InternalArticleSearchResponse.php create mode 100644 src/InternalArticles/Types/InternalArticleSearchResponseData.php create mode 100644 src/Jobs/JobsClient.php create mode 100644 src/Jobs/Requests/JobsStatusRequest.php create mode 100644 src/Jobs/Types/Jobs.php create mode 100644 src/Jobs/Types/JobsStatus.php create mode 100644 src/Tags/Types/TagBasic.php create mode 100644 src/TicketStates/TicketStatesClient.php rename src/{Unstable => TicketTypes}/Types/UpdateTicketTypeRequestCategory.php (80%) create mode 100644 src/Tickets/Requests/CreateTicketRequest.php create mode 100644 src/Tickets/Requests/DeleteTicketRequest.php create mode 100644 src/Tickets/Requests/EnqueueCreateTicketRequest.php create mode 100644 src/Tickets/Types/DeleteTicketResponse.php create mode 100644 src/Tickets/Types/TicketPartUpdatedAttributeData.php rename src/{Types/ContactCompany.php => Tickets/Types/TicketPartUpdatedAttributeDataAttribute.php} (62%) create mode 100644 src/Tickets/Types/TicketPartUpdatedAttributeDataValue.php create mode 100644 src/Tickets/Types/TicketState.php rename src/Tickets/Types/{TicketTicketState.php => TicketStateCategory.php} (85%) create mode 100644 src/Tickets/Types/TicketStateDetailed.php rename src/Tickets/Types/{UpdateTicketRequestState.php => TicketStateDetailedCategory.php} (69%) create mode 100644 src/Tickets/Types/TicketStateDetailedTicketTypes.php create mode 100644 src/Tickets/Types/TicketTypeTicketStates.php delete mode 100644 src/Tickets/Types/UpdateTicketRequestAssignment.php create mode 100644 src/Traits/ContactReference.php create mode 100644 src/Traits/CreateTicketRequestBody.php create mode 100644 src/Traits/CustomChannelBaseEvent.php delete mode 100644 src/Traits/ListItem.php create mode 100644 src/Traits/QuickReplyOption.php create mode 100644 src/Types/ActivityLogMetadataTeam.php create mode 100644 src/Types/AwayStatusReason.php delete mode 100644 src/Types/ButtonComponent.php delete mode 100644 src/Types/ButtonComponentStyle.php rename src/Types/{PaginatedNewsItemResponse.php => CallList.php} (55%) delete mode 100644 src/Types/CanvasObject.php delete mode 100644 src/Types/CheckboxComponent.php delete mode 100644 src/Types/CheckboxComponentSaveState.php delete mode 100644 src/Types/CheckboxOption.php create mode 100644 src/Types/CompanyData.php delete mode 100644 src/Types/Component.php delete mode 100644 src/Types/ConfigureRequestComponentId.php delete mode 100644 src/Types/ConfigureRequestZero.php delete mode 100644 src/Types/ConfigureResponseCanvas.php create mode 100644 src/Types/ContactBlocked.php create mode 100644 src/Types/ContactReplyBaseRequestReplyOptionsItem.php delete mode 100644 src/Types/ContentObject.php delete mode 100644 src/Types/Context.php delete mode 100644 src/Types/ContextLocation.php create mode 100644 src/Types/ConversationAttributeUpdatedByAdmin.php create mode 100644 src/Types/ConversationAttributeUpdatedByAdminAttribute.php create mode 100644 src/Types/ConversationAttributeUpdatedByAdminValue.php create mode 100644 src/Types/ConversationAttributeUpdatedByWorkflow.php create mode 100644 src/Types/ConversationAttributeUpdatedByWorkflowAttribute.php create mode 100644 src/Types/ConversationAttributeUpdatedByWorkflowValue.php create mode 100644 src/Types/ConversationAttributeUpdatedByWorkflowWorkflow.php create mode 100644 src/Types/ConversationDeleted.php rename src/Types/{PaginatedConversationResponse.php => ConversationList.php} (59%) create mode 100644 src/Types/ConversationPartMetadata.php create mode 100644 src/Types/ConversationPartMetadataQuickReplyOptionsItem.php create mode 100644 src/Types/ConversationPartState.php create mode 100644 src/Types/ConversationResponseTime.php rename src/{Articles/Requests => Types}/CreateArticleRequest.php (96%) rename src/{Articles => }/Types/CreateArticleRequestParentType.php (77%) rename src/{Articles => }/Types/CreateArticleRequestState.php (76%) create mode 100644 src/Types/CreateDataAttributeRequestOne.php rename src/{DataAttributes/Types/CreateDataAttributeRequestDataType.php => Types/CreateDataAttributeRequestOneDataType.php} (67%) create mode 100644 src/Types/CreateDataAttributeRequestOptions.php create mode 100644 src/Types/CreateDataAttributeRequestOptionsOptionsItem.php create mode 100644 src/Types/CreateInternalArticleRequest.php rename src/{Companies/Requests => Types}/CreateOrUpdateCompanyRequest.php (96%) rename src/{PhoneCallRedirects/Requests/CreatePhoneCallRedirectRequest.php => Types/CreatePhoneSwitchRequest.php} (58%) create mode 100644 src/Types/CreateTicketRequestAssignment.php rename src/Types/{CreateTicketRequest.php => CreateTicketRequestBody.php} (68%) rename src/{TicketTypes/Requests => Types}/CreateTicketTypeRequest.php (90%) rename src/{TicketTypes => }/Types/CreateTicketTypeRequestCategory.php (80%) delete mode 100644 src/Types/CurrentCanvas.php create mode 100644 src/Types/CustomActionFinished.php create mode 100644 src/Types/CustomActionFinishedAction.php create mode 100644 src/Types/CustomActionFinishedActionResult.php create mode 100644 src/Types/CustomActionStarted.php create mode 100644 src/Types/CustomActionStartedAction.php rename src/{DataAttributes/Types/UpdateDataAttributeRequestOptionsItem.php => Types/CustomChannelAttribute.php} (55%) create mode 100644 src/Types/CustomChannelBaseEvent.php create mode 100644 src/Types/CustomChannelContact.php create mode 100644 src/Types/CustomChannelContactType.php create mode 100644 src/Types/CustomChannelNotificationResponse.php create mode 100644 src/Types/CustomObjectInstanceDeleted.php create mode 100644 src/Types/CustomObjectInstanceList.php delete mode 100644 src/Types/DataTableComponent.php delete mode 100644 src/Types/DataTableItem.php create mode 100644 src/Types/DeletedInternalArticleObject.php delete mode 100644 src/Types/DropdownComponent.php delete mode 100644 src/Types/DropdownComponentSaveState.php delete mode 100644 src/Types/DropdownOption.php create mode 100644 src/Types/EmailAddressHeader.php create mode 100644 src/Types/EmailMessageMetadata.php delete mode 100644 src/Types/Event.php delete mode 100644 src/Types/ImageComponent.php delete mode 100644 src/Types/ImageComponentAlign.php delete mode 100644 src/Types/InitializeRequest.php delete mode 100644 src/Types/InitializeResponse.php delete mode 100644 src/Types/InputComponent.php delete mode 100644 src/Types/InputComponentSaveState.php create mode 100644 src/Types/InternalArticleList.php rename src/{TicketTypes/Types/UpdateTicketTypeRequestBodyCategory.php => Types/LinkedObjectCategory.php} (56%) delete mode 100644 src/Types/ListComponent.php delete mode 100644 src/Types/ListItem.php delete mode 100644 src/Types/ListItemWithImage.php delete mode 100644 src/Types/ListItemWithoutImage.php delete mode 100644 src/Types/LiveCanvasRequest.php delete mode 100644 src/Types/LiveCanvasResponse.php create mode 100644 src/Types/NotFoundErrorBody.php create mode 100644 src/Types/NotFoundErrorBodyErrorsItem.php create mode 100644 src/Types/OperatorWorkflowEvent.php create mode 100644 src/Types/OperatorWorkflowEventEvent.php create mode 100644 src/Types/OperatorWorkflowEventWorkflow.php create mode 100644 src/Types/PaginatedResponse.php rename src/Types/{ActionComponent.php => PaginatedResponseDataItem.php} (52%) create mode 100644 src/Types/PaginatedResponseType.php create mode 100644 src/Types/QuickReplyOption.php create mode 100644 src/Types/Recipient.php create mode 100644 src/Types/RecipientType.php delete mode 100644 src/Types/ResultsResponse.php delete mode 100644 src/Types/SheetActionComponent.php delete mode 100644 src/Types/SingleSelectComponent.php delete mode 100644 src/Types/SingleSelectComponentSaveState.php delete mode 100644 src/Types/SingleSelectOption.php delete mode 100644 src/Types/SpacerComponentSize.php delete mode 100644 src/Types/SubmitActionComponent.php delete mode 100644 src/Types/SubmitRequest.php delete mode 100644 src/Types/SubmitResponse.php delete mode 100644 src/Types/TextAreaComponent.php delete mode 100644 src/Types/TextComponent.php delete mode 100644 src/Types/TextComponentAlign.php delete mode 100644 src/Types/TextComponentStyle.php create mode 100644 src/Types/TicketStateList.php create mode 100644 src/Types/UpdateArticleRequestBody.php rename src/{Articles => }/Types/UpdateArticleRequestBodyParentType.php (78%) create mode 100644 src/Types/UpdateCompanyRequestBody.php create mode 100644 src/Types/UpdateDataAttributeRequestOptions.php create mode 100644 src/Types/UpdateDataAttributeRequestOptionsOptionsItem.php delete mode 100644 src/Types/UrlActionComponent.php create mode 100644 src/Types/WhatsappMessageStatusList.php create mode 100644 src/Types/WhatsappMessageStatusListEventsItem.php create mode 100644 src/Types/WhatsappMessageStatusListEventsItemStatus.php create mode 100644 src/Types/WhatsappMessageStatusListPages.php create mode 100644 src/Types/WhatsappMessageStatusListPagesNext.php create mode 100644 src/Unstable/AiAgent/Types/AiAgentLastAnswerType.php create mode 100644 src/Unstable/AiAgent/Types/AiAgentResolutionState.php create mode 100644 src/Unstable/Brands/BrandsClient.php create mode 100644 src/Unstable/Brands/Requests/RetrieveBrandRequest.php create mode 100644 src/Unstable/Brands/Types/Brand.php create mode 100644 src/Unstable/Brands/Types/BrandList.php create mode 100644 src/Unstable/Calls/CallsClient.php create mode 100644 src/Unstable/Calls/Requests/CollectFinVoiceCallByExternalIdRequest.php create mode 100644 src/Unstable/Calls/Requests/CollectFinVoiceCallByIdRequest.php create mode 100644 src/Unstable/Calls/Requests/CollectFinVoiceCallByPhoneNumberRequest.php create mode 100644 src/Unstable/Calls/Requests/ListCallsRequest.php create mode 100644 src/Unstable/Calls/Requests/ListCallsWithTranscriptsRequest.php create mode 100644 src/Unstable/Calls/Requests/ShowCallRecordingRequest.php create mode 100644 src/Unstable/Calls/Requests/ShowCallRequest.php create mode 100644 src/Unstable/Calls/Requests/ShowCallTranscriptRequest.php create mode 100644 src/Unstable/Calls/Traits/Call.php create mode 100644 src/Unstable/Calls/Types/Call.php create mode 100644 src/Unstable/Calls/Types/ListCallsWithTranscriptsResponse.php create mode 100644 src/Unstable/Calls/Types/ListCallsWithTranscriptsResponseDataItem.php create mode 100644 src/Unstable/Companies/Types/CompanyNotes.php delete mode 100644 src/Unstable/DataAttributes/Requests/CreateDataAttributeRequest.php delete mode 100644 src/Unstable/DataAttributes/Types/CreateDataAttributeRequestModel.php create mode 100644 src/Unstable/Emails/EmailsClient.php create mode 100644 src/Unstable/Emails/Requests/RetrieveEmailRequest.php create mode 100644 src/Unstable/Emails/Types/EmailList.php create mode 100644 src/Unstable/Emails/Types/EmailSetting.php create mode 100644 src/Unstable/InternalArticles/InternalArticlesClient.php create mode 100644 src/Unstable/InternalArticles/Requests/DeleteInternalArticleRequest.php create mode 100644 src/Unstable/InternalArticles/Requests/RetrieveInternalArticleRequest.php create mode 100644 src/Unstable/InternalArticles/Requests/SearchInternalArticlesRequest.php create mode 100644 src/Unstable/InternalArticles/Requests/UpdateInternalArticleRequestBody.php create mode 100644 src/Unstable/InternalArticles/Types/InternalArticleListItem.php create mode 100644 src/Unstable/InternalArticles/Types/InternalArticleSearchResponse.php create mode 100644 src/Unstable/InternalArticles/Types/InternalArticleSearchResponseData.php create mode 100644 src/Unstable/Notes/Requests/ListCompanyNotesRequest.php create mode 100644 src/Unstable/Notes/Types/CompanyNote.php rename src/{Types/DividerComponent.php => Unstable/Notes/Types/CompanyNoteCompany.php} (55%) create mode 100644 src/Unstable/Types/AiCallResponse.php rename src/{Types/PaginatedNewsfeedResponse.php => Unstable/Types/CallList.php} (53%) rename src/Unstable/Types/{UpdateArticleRequestBody.php => CreateArticleRequest.php} (73%) create mode 100644 src/Unstable/Types/CreateArticleRequestState.php create mode 100644 src/Unstable/Types/CreateDataAttributeRequestOne.php rename src/Unstable/{DataAttributes/Types/CreateDataAttributeRequestDataType.php => Types/CreateDataAttributeRequestOneDataType.php} (65%) create mode 100644 src/Unstable/Types/CreateDataAttributeRequestOptions.php create mode 100644 src/Unstable/Types/CreateDataAttributeRequestOptionsOptionsItem.php create mode 100644 src/Unstable/Types/CreateInternalArticleRequest.php create mode 100644 src/Unstable/Types/CreateOrUpdateCompanyRequest.php create mode 100644 src/Unstable/Types/CreatePhoneSwitchRequest.php rename src/Unstable/Types/{UpdateTicketTypeRequestBody.php => CreateTicketTypeRequest.php} (66%) create mode 100644 src/Unstable/Types/CreateTicketTypeRequestCategory.php create mode 100644 src/Unstable/Types/DeletedInternalArticleObject.php delete mode 100644 src/Unstable/Types/IntercomVersion.php create mode 100644 src/Unstable/Types/InternalArticleList.php create mode 100644 src/Unstable/Types/LinkedObjectCategory.php create mode 100644 src/Unstable/Types/RegisterFinVoiceCallRequest.php create mode 100644 src/Unstable/Types/RegisterFinVoiceCallRequestSource.php create mode 100644 src/Unstable/Types/UpdateDataAttributeRequestOptions.php create mode 100644 src/Unstable/Types/UpdateDataAttributeRequestOptionsOptionsItem.php diff --git a/.fern/metadata.json b/.fern/metadata.json new file mode 100644 index 0000000..a9003b2 --- /dev/null +++ b/.fern/metadata.json @@ -0,0 +1,20 @@ +{ + "cliVersion": "3.0.2", + "generatorName": "fernapi/fern-php-sdk", + "generatorVersion": "1.25.0", + "generatorConfig": { + "namespace": "Intercom", + "clientName": "IntercomClient", + "packageName": "intercom/intercom-php", + "propertyAccess": "private", + "inlinePathParameters": true, + "composerJson": { + "description": "Intercom API client.", + "author": { + "name": "Intercom Platform Team", + "url": "https://www.intercom.com" + }, + "homepage": "https://developers.intercom.com/docs" + } + } +} \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 258bf33..ba5836a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,7 +27,7 @@ jobs: run: | composer analyze - unit-tests: + test: runs-on: ubuntu-latest steps: @@ -45,4 +45,4 @@ jobs: - name: Run Tests run: | - composer test \ No newline at end of file + composer test diff --git a/README.md b/README.md index 21e9f39..1db1a90 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,20 @@ The Intercom PHP library provides convenient access to the Intercom APIs from PHP. +## Table of Contents + +- [Requirements](#requirements) +- [Installation](#installation) +- [Usage](#usage) +- [Exception Handling](#exception-handling) +- [Pagination](#pagination) +- [Legacy Sdk](#legacy-sdk) +- [Advanced](#advanced) + - [Custom Client](#custom-client) + - [Retries](#retries) + - [Timeouts](#timeouts) +- [Contributing](#contributing) + ## Requirements This SDK requires PHP ^8.1. @@ -26,7 +40,6 @@ namespace Example; use Intercom\IntercomClient; use Intercom\AiContent\Requests\CreateContentImportSourceRequest; -use Intercom\AiContent\Types\CreateContentImportSourceRequestStatus; $client = new IntercomClient( token: '', @@ -34,8 +47,7 @@ $client = new IntercomClient( $client->aiContent->createContentImportSource( new CreateContentImportSourceRequest([ 'syncBehavior' => 'api', - 'status' => CreateContentImportSourceRequestStatus::Active->value, - 'url' => 'url', + 'url' => 'https://www.example.com', ]), ); @@ -87,6 +99,7 @@ foreach ($items->getPages() as $page) { } ``` + ## Legacy SDK While the new SDK has a lot of improvements, we at Intercom understand that it takes time to upgrade when there are breaking changes. @@ -156,7 +169,7 @@ A request is deemed retryable when any of the following HTTP status codes is ret Use the `maxRetries` request option to configure this behavior. ```php -$response = $client->articles->create( +$response = $client->aiContent->createContentImportSource( ..., options: [ 'maxRetries' => 0 // Override maxRetries at the request level @@ -169,7 +182,7 @@ $response = $client->articles->create( The SDK defaults to a 30 second timeout. Use the `timeout` option to configure this behavior. ```php -$response = $client->articles->create( +$response = $client->aiContent->createContentImportSource( ..., options: [ 'timeout' => 3.0 // Override timeout to 3 seconds diff --git a/reference.md b/reference.md new file mode 100644 index 0000000..462ca43 --- /dev/null +++ b/reference.md @@ -0,0 +1,21225 @@ +# Reference +## Admins +
$client->admins->identify() -> ?AdminWithApp +
+
+ +#### 📝 Description + +
+
+ +
+
+ + +You can view the currently authorised admin along with the embedded app object (a "workspace" in legacy terminology). + +> 🚧 Single Sign On +> +> If you are building a custom "Log in with Intercom" flow for your site, and you call the `/me` endpoint to identify the logged-in user, you should not accept any sign-ins from users with unverified email addresses as it poses a potential impersonation security risk. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->admins->identify(); +``` +
+
+
+
+ + +
+
+
+ +
$client->admins->away($request) -> ?Admin +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can set an Admin as away for the Inbox. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->admins->away( + new ConfigureAwayAdminRequest([ + 'adminId' => 1, + 'awayModeEnabled' => true, + 'awayModeReassign' => true, + 'awayStatusReasonId' => 12345, + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$adminId:** `int` — The unique identifier of a given admin + +
+
+ +
+
+ +**$awayModeEnabled:** `bool` — Set to "true" to change the status of the admin to away. + +
+
+ +
+
+ +**$awayModeReassign:** `bool` — Set to "true" to assign any new conversation replies to your default inbox. + +
+
+ +
+
+ +**$awayStatusReasonId:** `?int` — The unique identifier of the away status reason + +
+
+
+
+ + +
+
+
+ +
$client->admins->listAllActivityLogs($request) -> ActivityLogList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can get a log of activities by all admins in an app. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->admins->listAllActivityLogs( + new ListAllActivityLogsRequest([ + 'createdAtAfter' => '1677253093', + 'createdAtBefore' => '1677861493', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$createdAtAfter:** `string` — The start date that you request data for. It must be formatted as a UNIX timestamp. + +
+
+ +
+
+ +**$createdAtBefore:** `?string` — The end date that you request data for. It must be formatted as a UNIX timestamp. + +
+
+
+
+ + +
+
+
+ +
$client->admins->list() -> AdminList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of admins for a given workspace. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->admins->list(); +``` +
+
+
+
+ + +
+
+
+ +
$client->admins->find($request) -> ?Admin +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can retrieve the details of a single admin. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->admins->find( + new FindAdminRequest([ + 'adminId' => 1, + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$adminId:** `int` — The unique identifier of a given admin + +
+
+
+
+ + +
+
+
+ +## AI Content +
$client->aiContent->listContentImportSources() -> ContentImportSourcesList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can retrieve a list of all content import sources for a workspace. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->aiContent->listContentImportSources(); +``` +
+
+
+
+ + +
+
+
+ +
$client->aiContent->createContentImportSource($request) -> ContentImportSource +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a new content import source by sending a POST request to this endpoint. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->aiContent->createContentImportSource( + new CreateContentImportSourceRequest([ + 'syncBehavior' => 'api', + 'url' => 'https://www.example.com', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$syncBehavior:** `string` — If you intend to create or update External Pages via the API, this should be set to `api`. + +
+
+ +
+
+ +**$status:** `?string` — The status of the content import source. + +
+
+ +
+
+ +**$url:** `string` — The URL of the content import source. + +
+
+
+
+ + +
+
+
+ +
$client->aiContent->getContentImportSource($request) -> ContentImportSource +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->aiContent->getContentImportSource( + new GetContentImportSourceRequest([ + 'sourceId' => 'source_id', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$sourceId:** `string` — The unique identifier for the content import source which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
$client->aiContent->updateContentImportSource($request) -> ContentImportSource +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can update an existing content import source. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->aiContent->updateContentImportSource( + new UpdateContentImportSourceRequest([ + 'sourceId' => 'source_id', + 'syncBehavior' => UpdateContentImportSourceRequestSyncBehavior::Api->value, + 'url' => 'https://www.example.com', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$sourceId:** `string` — The unique identifier for the content import source which is given by Intercom. + +
+
+ +
+
+ +**$syncBehavior:** `string` — If you intend to create or update External Pages via the API, this should be set to `api`. You can not change the value to or from api. + +
+
+ +
+
+ +**$status:** `?string` — The status of the content import source. + +
+
+ +
+
+ +**$url:** `string` — The URL of the content import source. This may only be different from the existing value if the sync behavior is API. + +
+
+
+
+ + +
+
+
+ +
$client->aiContent->deleteContentImportSource($request) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can delete a content import source by making a DELETE request this endpoint. This will also delete all external pages that were imported from this source. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->aiContent->deleteContentImportSource( + new DeleteContentImportSourceRequest([ + 'sourceId' => 'source_id', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$sourceId:** `string` — The unique identifier for the content import source which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
$client->aiContent->listExternalPages() -> ExternalPagesList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can retrieve a list of all external pages for a workspace. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->aiContent->listExternalPages(); +``` +
+
+
+
+ + +
+
+
+ +
$client->aiContent->createExternalPage($request) -> ExternalPage +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a new external page by sending a POST request to this endpoint. If an external page already exists with the specified source_id and external_id, it will be updated instead. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->aiContent->createExternalPage( + new CreateExternalPageRequest([ + 'title' => 'Test', + 'html' => '

Test

', + 'url' => 'https://www.example.com', + 'locale' => 'en', + 'sourceId' => 44, + 'externalId' => 'abc1234', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$title:** `string` — The title of the external page. + +
+
+ +
+
+ +**$html:** `string` — The body of the external page in HTML. + +
+
+ +
+
+ +**$url:** `?string` — The URL of the external page. This will be used by Fin to link end users to the page it based its answer on. When a URL is not present, Fin will not reference the source. + +
+
+ +
+
+ +**$aiAgentAvailability:** `?bool` — Whether the external page should be used to answer questions by AI Agent. Will not default when updating an existing external page. + +
+
+ +
+
+ +**$aiCopilotAvailability:** `?bool` — Whether the external page should be used to answer questions by AI Copilot. Will not default when updating an existing external page. + +
+
+ +
+
+ +**$locale:** `string` — Always en + +
+
+ +
+
+ +**$sourceId:** `int` — The unique identifier for the source of the external page which was given by Intercom. Every external page must be associated with a Content Import Source which represents the place it comes from and from which it inherits a default audience (configured in the UI). For a new source, make a POST request to the Content Import Source endpoint and an ID for the source will be returned in the response. + +
+
+ +
+
+ +**$externalId:** `string` — The identifier for the external page which was given by the source. Must be unique for the source. + +
+
+
+
+ + +
+
+
+ +
$client->aiContent->getExternalPage($request) -> ExternalPage +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can retrieve an external page. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->aiContent->getExternalPage( + new GetExternalPageRequest([ + 'pageId' => 'page_id', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$pageId:** `string` — The unique identifier for the external page which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
$client->aiContent->updateExternalPage($request) -> ExternalPage +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can update an existing external page (if it was created via the API). +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->aiContent->updateExternalPage( + new UpdateExternalPageRequest([ + 'pageId' => 'page_id', + 'title' => 'Test', + 'html' => '

Test

', + 'url' => 'https://www.example.com', + 'locale' => 'en', + 'sourceId' => 47, + 'externalId' => '5678', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$pageId:** `string` — The unique identifier for the external page which is given by Intercom. + +
+
+ +
+
+ +**$title:** `string` — The title of the external page. + +
+
+ +
+
+ +**$html:** `string` — The body of the external page in HTML. + +
+
+ +
+
+ +**$url:** `string` — The URL of the external page. This will be used by Fin to link end users to the page it based its answer on. + +
+
+ +
+
+ +**$finAvailability:** `?bool` — Whether the external page should be used to answer questions by Fin. + +
+
+ +
+
+ +**$locale:** `string` — Always en + +
+
+ +
+
+ +**$sourceId:** `int` — The unique identifier for the source of the external page which was given by Intercom. Every external page must be associated with a Content Import Source which represents the place it comes from and from which it inherits a default audience (configured in the UI). For a new source, make a POST request to the Content Import Source endpoint and an ID for the source will be returned in the response. + +
+
+ +
+
+ +**$externalId:** `?string` — The identifier for the external page which was given by the source. Must be unique for the source. + +
+
+
+
+ + +
+
+
+ +
$client->aiContent->deleteExternalPage($request) -> ExternalPage +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Sending a DELETE request for an external page will remove it from the content library UI and from being used for AI answers. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->aiContent->deleteExternalPage( + new DeleteExternalPageRequest([ + 'pageId' => 'page_id', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$pageId:** `string` — The unique identifier for the external page which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +## Articles +
$client->articles->list($request) -> ArticleList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all articles by making a GET request to `https://api.intercom.io/articles`. + +> 📘 How are the articles sorted and ordered? +> +> Articles will be returned in descending order on the `updated_at` attribute. This means if you need to iterate through results then we'll show the most recently updated articles first. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->articles->list( + new ListArticlesRequest([]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$page:** `?int` — The page of results to fetch. Defaults to first page + +
+
+ +
+
+ +**$perPage:** `?int` — How many results to display per page. Defaults to 15 + +
+
+
+
+ + +
+
+
+ +
$client->articles->create($request) -> Article +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a new article by making a POST request to `https://api.intercom.io/articles`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->articles->create( + new CreateArticleRequest([ + 'title' => 'Thanks for everything', + 'description' => 'Description of the Article', + 'body' => 'Body of the Article', + 'authorId' => 991267497, + 'state' => CreateArticleRequestState::Published->value, + 'parentId' => 145, + 'parentType' => CreateArticleRequestParentType::Collection->value, + 'translatedContent' => new ArticleTranslatedContent([ + 'fr' => new ArticleContent([ + 'title' => 'Merci pour tout', + 'description' => "Description de l'article", + 'body' => "Corps de l'article", + 'authorId' => 991267497, + 'state' => ArticleContentState::Published->value, + ]), + ]), + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$request:** `?CreateArticleRequest` + +
+
+
+
+ + +
+
+
+ +
$client->articles->find($request) -> Article +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single article by making a GET request to `https://api.intercom.io/articles/`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->articles->find( + new FindArticleRequest([ + 'articleId' => 1, + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$articleId:** `int` — The unique identifier for the article which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
$client->articles->update($request) -> Article +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can update the details of a single article by making a PUT request to `https://api.intercom.io/articles/`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->articles->update( + new UpdateArticleRequest([ + 'articleId' => 1, + 'title' => 'Christmas is here!', + 'body' => '

New gifts in store for the jolly season

', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$articleId:** `int` — The unique identifier for the article which is given by Intercom. + +
+
+ +
+
+ +**$title:** `?string` — The title of the article.For multilingual articles, this will be the title of the default language's content. + +
+
+ +
+
+ +**$description:** `?string` — The description of the article. For multilingual articles, this will be the description of the default language's content. + +
+
+ +
+
+ +**$body:** `?string` — The content of the article. For multilingual articles, this will be the body of the default language's content. + +
+
+ +
+
+ +**$authorId:** `?int` — 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. + +
+
+ +
+
+ +**$state:** `?string` — 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. + +
+
+ +
+
+ +**$parentId:** `?string` — The id of the article's parent collection or section. An article without this field stands alone. + +
+
+ +
+
+ +**$parentType:** `?string` — The type of parent, which can either be a `collection` or `section`. + +
+
+ +
+
+ +**$translatedContent:** `?ArticleTranslatedContent` + +
+
+
+
+ + +
+
+
+ +
$client->articles->delete($request) -> DeletedArticleObject +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can delete a single article by making a DELETE request to `https://api.intercom.io/articles/`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->articles->delete( + new DeleteArticleRequest([ + 'articleId' => 1, + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$articleId:** `int` — The unique identifier for the article which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
$client->articles->search($request) -> ArticleSearchResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can search for articles by making a GET request to `https://api.intercom.io/articles/search`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->articles->search( + new SearchArticlesRequest([ + 'phrase' => 'Getting started', + 'state' => 'published', + 'helpCenterId' => 1, + 'highlight' => true, + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$phrase:** `?string` — The phrase within your articles to search for. + +
+
+ +
+
+ +**$state:** `?string` — The state of the Articles returned. One of `published`, `draft` or `all`. + +
+
+ +
+
+ +**$helpCenterId:** `?int` — The ID of the Help Center to search in. + +
+
+ +
+
+ +**$highlight:** `?bool` — Return a highlighted version of the matching content within your articles. Refer to the response schema for more details. + +
+
+
+
+ + +
+
+
+ +## Away Status Reasons +
$client->awayStatusReasons->listAwayStatusReasons() -> array +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Returns a list of all away status reasons configured for the workspace, including deleted ones. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->awayStatusReasons->listAwayStatusReasons(); +``` +
+
+
+
+ + +
+
+
+ +## Export +
$client->export->enqueueANewReportingDataExportJob($request) -> PostExportReportingDataEnqueueResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->export->enqueueANewReportingDataExportJob( + new PostExportReportingDataEnqueueRequest([ + 'datasetId' => 'conversation', + 'attributeIds' => [ + 'conversation_id', + 'conversation_started_at', + ], + 'startTime' => 1717490000, + 'endTime' => 1717510000, + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$datasetId:** `string` + +
+
+ +
+
+ +**$attributeIds:** `array` + +
+
+ +
+
+ +**$startTime:** `int` + +
+
+ +
+
+ +**$endTime:** `int` + +
+
+
+
+ + +
+
+
+ +
$client->export->listAvailableDatasetsAndAttributes() -> GetExportReportingDataGetDatasetsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->export->listAvailableDatasetsAndAttributes(); +``` +
+
+
+
+ + +
+
+
+ +## Data Export +
$client->dataExport->exportReportingData($request) -> DataExportExportReportingDataResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->dataExport->exportReportingData( + new ExportReportingDataRequest([ + 'jobIdentifier' => 'job_identifier', + 'appId' => 'app_id', + 'clientId' => 'client_id', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$jobIdentifier:** `string` — Unique identifier of the job. + +
+
+ +
+
+ +**$appId:** `string` — The Intercom defined code of the workspace the company is associated to. + +
+
+ +
+
+ +**$clientId:** `string` + +
+
+
+
+ + +
+
+
+ +
$client->dataExport->downloadReportingDataExport($request) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Download the data from a completed reporting data export job. + +> Octet header required +> +> You will have to specify the header Accept: `application/octet-stream` when hitting this endpoint. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->dataExport->downloadReportingDataExport( + new DownloadReportingDataExportRequest([ + 'jobIdentifier' => 'job_identifier', + 'appId' => 'app_id', + 'accept' => 'application/octet-stream', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$jobIdentifier:** `string` + +
+
+ +
+
+ +**$appId:** `string` + +
+
+ +
+
+ +**$accept:** `string` — Required header for downloading the export file + +
+
+
+
+ + +
+
+
+ +
$client->dataExport->create($request) -> DataExport +
+
+ +#### 📝 Description + +
+
+ +
+
+ +To create your export job, you need to send a `POST` request to the export endpoint `https://api.intercom.io/export/content/data`. + +The only parameters you need to provide are the range of dates that you want exported. + +>🚧 Limit of one active job +> +> You can only have one active job per workspace. You will receive a HTTP status code of 429 with the message Exceeded rate limit of 1 pending message data export jobs if you attempt to create a second concurrent job. + +>❗️ Updated_at not included +> +> It should be noted that the timeframe only includes messages sent during the time period and not messages that were only updated during this period. For example, if a message was updated yesterday but sent two days ago, you would need to set the created_at_after date before the message was sent to include that in your retrieval job. + +>📘 Date ranges are inclusive +> +> Requesting data for 2018-06-01 until 2018-06-30 will get all data for those days including those specified - e.g. 2018-06-01 00:00:00 until 2018-06-30 23:59:99. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->dataExport->create( + new CreateDataExportRequest([ + 'createdAtAfter' => 1734519776, + 'createdAtBefore' => 1734537776, + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$createdAtAfter:** `int` — The start date that you request data for. It must be formatted as a unix timestamp. + +
+
+ +
+
+ +**$createdAtBefore:** `int` — The end date that you request data for. It must be formatted as a unix timestamp. + +
+
+
+
+ + +
+
+
+ +
$client->dataExport->find($request) -> DataExport +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can view the status of your job by sending a `GET` request to the URL +`https://api.intercom.io/export/content/data/{job_identifier}` - the `{job_identifier}` is the value returned in the response when you first created the export job. More on it can be seen in the Export Job Model. + +> 🚧 Jobs expire after two days +> All jobs that have completed processing (and are thus available to download from the provided URL) will have an expiry limit of two days from when the export ob completed. After this, the data will no longer be available. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->dataExport->find( + new FindDataExportRequest([ + 'jobIdentifier' => 'job_identifier', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$jobIdentifier:** `string` — job_identifier + +
+
+
+
+ + +
+
+
+ +
$client->dataExport->cancel($request) -> DataExport +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can cancel your job +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->dataExport->cancel( + new CancelDataExportRequest([ + 'jobIdentifier' => 'job_identifier', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$jobIdentifier:** `string` — job_identifier + +
+
+
+
+ + +
+
+
+ +
$client->dataExport->download($request) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +When a job has a status of complete, and thus a filled download_url, you can download your data by hitting that provided URL, formatted like so: https://api.intercom.io/download/content/data/xyz1234. + +Your exported message data will be streamed continuously back down to you in a gzipped CSV format. + +> 📘 Octet header required +> +> You will have to specify the header Accept: `application/octet-stream` when hitting this endpoint. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->dataExport->download( + new DownloadDataExportRequest([ + 'jobIdentifier' => 'job_identifier', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$jobIdentifier:** `string` — job_identifier + +
+
+
+
+ + +
+
+
+ +## HelpCenters +
$client->helpCenters->find($request) -> HelpCenter +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single Help Center by making a GET request to `https://api.intercom.io/help_center/help_center/`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->helpCenters->find( + new FindHelpCenterRequest([ + 'helpCenterId' => 1, + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$helpCenterId:** `int` — The unique identifier for the collection which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
$client->helpCenters->list($request) -> HelpCenterList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can list all Help Centers by making a GET request to `https://api.intercom.io/help_center/help_centers`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->helpCenters->list( + new ListHelpCentersRequest([]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$page:** `?int` — The page of results to fetch. Defaults to first page + +
+
+ +
+
+ +**$perPage:** `?int` — How many results to display per page. Defaults to 15 + +
+
+
+
+ + +
+
+
+ +## Internal Articles +
$client->internalArticles->listInternalArticles() -> InternalArticleList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all internal articles by making a GET request to `https://api.intercom.io/internal_articles`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->internalArticles->listInternalArticles(); +``` +
+
+
+
+ + +
+
+
+ +
$client->internalArticles->createInternalArticle($request) -> InternalArticleListItem +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a new internal article by making a POST request to `https://api.intercom.io/internal_articles`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->internalArticles->createInternalArticle( + new CreateInternalArticleRequest([ + 'title' => 'Thanks for everything', + 'body' => 'Body of the Article', + 'authorId' => 991266252, + 'ownerId' => 991266252, + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$request:** `?CreateInternalArticleRequest` + +
+
+
+
+ + +
+
+
+ +
$client->internalArticles->retrieveInternalArticle($request) -> InternalArticleListItem +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single internal article by making a GET request to `https://api.intercom.io/internal_articles/`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->internalArticles->retrieveInternalArticle( + new RetrieveInternalArticleRequest([ + 'internalArticleId' => 1, + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$internalArticleId:** `int` — The unique identifier for the article which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
$client->internalArticles->updateInternalArticle($request) -> InternalArticleListItem +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can update the details of a single internal article by making a PUT request to `https://api.intercom.io/internal_articles/`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->internalArticles->updateInternalArticle( + new UpdateInternalArticleRequestBody([ + 'internalArticleId' => 1, + 'title' => 'Christmas is here!', + 'body' => '

New gifts in store for the jolly season

', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$internalArticleId:** `int` — The unique identifier for the internal article which is given by Intercom. + +
+
+ +
+
+ +**$title:** `?string` — The title of the article. + +
+
+ +
+
+ +**$body:** `?string` — The content of the article. + +
+
+ +
+
+ +**$authorId:** `?int` — The id of the author of the article. + +
+
+ +
+
+ +**$ownerId:** `?int` — The id of the author of the article. + +
+
+
+
+ + +
+
+
+ +
$client->internalArticles->deleteInternalArticle($request) -> DeletedInternalArticleObject +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can delete a single internal article by making a DELETE request to `https://api.intercom.io/internal_articles/`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->internalArticles->deleteInternalArticle( + new DeleteInternalArticleRequest([ + 'internalArticleId' => 1, + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$internalArticleId:** `int` — The unique identifier for the internal article which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
$client->internalArticles->searchInternalArticles($request) -> InternalArticleSearchResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can search for internal articles by making a GET request to `https://api.intercom.io/internal_articles/search`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->internalArticles->searchInternalArticles( + new SearchInternalArticlesRequest([ + 'folderId' => 'folder_id', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$folderId:** `?string` — The ID of the folder to search in. + +
+
+
+
+ + +
+
+
+ +## Companies +
$client->companies->retrieve($request) -> CompaniesRetrieveResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a single company by passing in `company_id` or `name`. + + `https://api.intercom.io/companies?name={name}` + + `https://api.intercom.io/companies?company_id={company_id}` + +You can fetch all companies and filter by `segment_id` or `tag_id` as a query parameter. + + `https://api.intercom.io/companies?tag_id={tag_id}` + + `https://api.intercom.io/companies?segment_id={segment_id}` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->companies->retrieve( + new RetrieveCompanyRequest([ + 'name' => 'my company', + 'companyId' => '12345', + 'tagId' => '678910', + 'segmentId' => '98765', + 'page' => 1, + 'perPage' => 1, + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$name:** `?string` — The `name` of the company to filter by. + +
+
+ +
+
+ +**$companyId:** `?string` — The `company_id` of the company to filter by. + +
+
+ +
+
+ +**$tagId:** `?string` — The `tag_id` of the company to filter by. + +
+
+ +
+
+ +**$segmentId:** `?string` — The `segment_id` of the company to filter by. + +
+
+ +
+
+ +**$page:** `?int` — The page of results to fetch. Defaults to first page + +
+
+ +
+
+ +**$perPage:** `?int` — How many results to display per page. Defaults to 15 + +
+
+
+
+ + +
+
+
+ +
$client->companies->createOrUpdate($request) -> Company +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create or update a company. + +Companies will be only visible in Intercom when there is at least one associated user. + +Companies are looked up via `company_id` in a `POST` request, if not found via `company_id`, the new company will be created, if found, that company will be updated. + +{% admonition type="warning" name="Using `company_id`" %} + You can set a unique `company_id` value when creating a company. However, it is not possible to update `company_id`. Be sure to set a unique value once upon creation of the company. +{% /admonition %} +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->companies->createOrUpdate( + new CreateOrUpdateCompanyRequest([ + 'name' => 'my company', + 'companyId' => 'company_remote_id', + 'remoteCreatedAt' => 1374138000, + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$request:** `?CreateOrUpdateCompanyRequest` + +
+
+
+
+ + +
+
+
+ +
$client->companies->find($request) -> Company +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a single company. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->companies->find( + new FindCompanyRequest([ + 'companyId' => '5f4d3c1c-7b1b-4d7d-a97e-6095715c6632', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$companyId:** `string` — The unique identifier for the company which is given by Intercom + +
+
+
+
+ + +
+
+
+ +
$client->companies->update($request) -> Company +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can update a single company using the Intercom provisioned `id`. + +{% admonition type="warning" name="Using `company_id`" %} + When updating a company it is not possible to update `company_id`. This can only be set once upon creation of the company. +{% /admonition %} +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->companies->update( + new UpdateCompanyRequest([ + 'companyId' => '5f4d3c1c-7b1b-4d7d-a97e-6095715c6632', + 'body' => new UpdateCompanyRequestBody([ + 'name' => 'my company', + 'website' => 'http://www.mycompany.com/', + ]), + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$companyId:** `string` — The unique identifier for the company which is given by Intercom + +
+
+ +
+
+ +**$request:** `?UpdateCompanyRequestBody` + +
+
+
+
+ + +
+
+
+ +
$client->companies->delete($request) -> DeletedCompanyObject +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can delete a single company. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->companies->delete( + new DeleteCompanyRequest([ + 'companyId' => '5f4d3c1c-7b1b-4d7d-a97e-6095715c6632', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$companyId:** `string` — The unique identifier for the company which is given by Intercom + +
+
+
+
+ + +
+
+
+ +
$client->companies->listAttachedContacts($request) -> CompanyAttachedContacts +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all contacts that belong to a company. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->companies->listAttachedContacts( + new ListAttachedContactsRequest([ + 'companyId' => '5f4d3c1c-7b1b-4d7d-a97e-6095715c6632', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$companyId:** `string` — The unique identifier for the company which is given by Intercom + +
+
+
+
+ + +
+
+
+ +
$client->companies->listAttachedSegments($request) -> CompanyAttachedSegments +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all segments that belong to a company. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->companies->listAttachedSegments( + new ListSegmentsAttachedToCompanyRequest([ + 'companyId' => '5f4d3c1c-7b1b-4d7d-a97e-6095715c6632', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$companyId:** `string` — The unique identifier for the company which is given by Intercom + +
+
+
+
+ + +
+
+
+ +
$client->companies->list($request) -> CompanyList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can list companies. The company list is sorted by the `last_request_at` field and by default is ordered descending, most recently requested first. + +Note that the API does not include companies who have no associated users in list responses. + +When using the Companies endpoint and the pages object to iterate through the returned companies, there is a limit of 10,000 Companies that can be returned. If you need to list or iterate on more than 10,000 Companies, please use the [Scroll API](https://developers.intercom.com/reference#iterating-over-all-companies). +{% admonition type="warning" name="Pagination" %} + You can use pagination to limit the number of results returned. The default is `20` results per page. + See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#pagination-for-list-apis) for more details on how to use the `starting_after` param. +{% /admonition %} +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->companies->list( + new ListCompaniesRequest([ + 'page' => 1, + 'perPage' => 1, + 'order' => 'desc', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$page:** `?int` — The page of results to fetch. Defaults to first page + +
+
+ +
+
+ +**$perPage:** `?int` — How many results to return per page. Defaults to 15 + +
+
+ +
+
+ +**$order:** `?string` — `asc` or `desc`. Return the companies in ascending or descending order. Defaults to desc + +
+
+
+
+ + +
+
+
+ +
$client->companies->scroll($request) -> ?CompanyScroll +
+
+ +#### 📝 Description + +
+
+ +
+
+ + The `list all companies` functionality does not work well for huge datasets, and can result in errors and performance problems when paging deeply. The Scroll API provides an efficient mechanism for iterating over all companies in a dataset. + +- Each app can only have 1 scroll open at a time. You'll get an error message if you try to have more than one open per app. +- If the scroll isn't used for 1 minute, it expires and calls with that scroll param will fail +- If the end of the scroll is reached, "companies" will be empty and the scroll parameter will expire + +{% admonition type="info" name="Scroll Parameter" %} + You can get the first page of companies by simply sending a GET request to the scroll endpoint. + For subsequent requests you will need to use the scroll parameter from the response. +{% /admonition %} +{% admonition type="danger" name="Scroll network timeouts" %} + Since scroll is often used on large datasets network errors such as timeouts can be encountered. When this occurs you will see a HTTP 500 error with the following message: + "Request failed due to an internal network error. Please restart the scroll operation." + If this happens, you will need to restart your scroll query: It is not possible to continue from a specific point when using scroll. +{% /admonition %} +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->companies->scroll( + new ScrollCompaniesRequest([ + 'scrollParam' => 'scroll_param', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$scrollParam:** `?string` — + +
+
+
+
+ + +
+
+
+ +
$client->companies->attachContact($request) -> Company +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can attach a company to a single contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->companies->attachContact( + new AttachContactToCompanyRequest([ + 'contactId' => 'contact_id', + 'companyId' => '6762f09a1bb69f9f2193bb34', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$contactId:** `string` — The unique identifier for the contact which is given by Intercom + +
+
+ +
+
+ +**$companyId:** `string` — The unique identifier for the company which is given by Intercom + +
+
+
+
+ + +
+
+
+ +
$client->companies->detachContact($request) -> Company +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can detach a company from a single contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->companies->detachContact( + new DetachContactFromCompanyRequest([ + 'contactId' => '58a430d35458202d41b1e65b', + 'companyId' => '58a430d35458202d41b1e65b', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$contactId:** `string` — The unique identifier for the contact which is given by Intercom + +
+
+ +
+
+ +**$companyId:** `string` — The unique identifier for the company which is given by Intercom + +
+
+
+
+ + +
+
+
+ +## Contacts +
$client->contacts->listAttachedCompanies($request) -> ContactAttachedCompanies +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of companies that are associated to a contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->contacts->listAttachedCompanies( + new ListAttachedCompaniesRequest([ + 'contactId' => '63a07ddf05a32042dffac965', + 'page' => 1, + 'perPage' => 1, + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$contactId:** `string` — The unique identifier for the contact which is given by Intercom + +
+
+ +
+
+ +**$page:** `?int` — The page of results to fetch. Defaults to first page + +
+
+ +
+
+ +**$perPage:** `?int` — How many results to display per page. Defaults to 15 + +
+
+
+
+ + +
+
+
+ +
$client->contacts->listAttachedSegments($request) -> ContactSegments +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of segments that are associated to a contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->contacts->listAttachedSegments( + new ListSegmentsAttachedToContactRequest([ + 'contactId' => '63a07ddf05a32042dffac965', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$contactId:** `string` — The unique identifier for the contact which is given by Intercom + +
+
+
+
+ + +
+
+
+ +
$client->contacts->listAttachedSubscriptions($request) -> SubscriptionTypeList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of subscription types that are attached to a contact. These can be subscriptions that a user has 'opted-in' to or has 'opted-out' from, depending on the subscription type. +This will return a list of Subscription Type objects that the contact is associated with. + +The data property will show a combined list of: + + 1.Opt-out subscription types that the user has opted-out from. + 2.Opt-in subscription types that the user has opted-in to receiving. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->contacts->listAttachedSubscriptions( + new ListAttachedSubscriptionsRequest([ + 'contactId' => '63a07ddf05a32042dffac965', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$contactId:** `string` — The unique identifier for the contact which is given by Intercom + +
+
+
+
+ + +
+
+
+ +
$client->contacts->attachSubscription($request) -> SubscriptionType +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can add a specific subscription to a contact. In Intercom, we have two different subscription types based on user consent - opt-out and opt-in: + + 1.Attaching a contact to an opt-out subscription type will opt that user out from receiving messages related to that subscription type. + + 2.Attaching a contact to an opt-in subscription type will opt that user in to receiving messages related to that subscription type. + +This will return a subscription type model for the subscription type that was added to the contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->contacts->attachSubscription( + new AttachSubscriptionToContactRequest([ + 'contactId' => '63a07ddf05a32042dffac965', + 'subscriptionId' => '37846', + 'consentType' => 'opt_in', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$contactId:** `string` — The unique identifier for the contact which is given by Intercom + +
+
+ +
+
+ +**$subscriptionId:** `string` — The unique identifier for the subscription which is given by Intercom + +
+
+ +
+
+ +**$consentType:** `string` — The consent_type of a subscription, opt_out or opt_in. + +
+
+
+
+ + +
+
+
+ +
$client->contacts->detachSubscription($request) -> SubscriptionType +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can remove a specific subscription from a contact. This will return a subscription type model for the subscription type that was removed from the contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->contacts->detachSubscription( + new DetachSubscriptionFromContactRequest([ + 'contactId' => '63a07ddf05a32042dffac965', + 'subscriptionId' => '37846', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$contactId:** `string` — The unique identifier for the contact which is given by Intercom + +
+
+ +
+
+ +**$subscriptionId:** `string` — The unique identifier for the subscription type which is given by Intercom + +
+
+
+
+ + +
+
+
+ +
$client->contacts->listAttachedTags($request) -> TagList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all tags that are attached to a specific contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->contacts->listAttachedTags( + new ListTagsAttachedToContactRequest([ + 'contactId' => '63a07ddf05a32042dffac965', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$contactId:** `string` — The unique identifier for the contact which is given by Intercom + +
+
+
+
+ + +
+
+
+ +
$client->contacts->find($request) -> ContactsFindResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->contacts->find( + new FindContactRequest([ + 'contactId' => '63a07ddf05a32042dffac965', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$contactId:** `string` — contact_id + +
+
+
+
+ + +
+
+
+ +
$client->contacts->update($request) -> ContactsUpdateResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can update an existing contact (ie. user or lead). + +{% admonition type="info" %} + This endpoint handles both **contact updates** and **custom object associations**. + + See _`update a contact with an association to a custom object instance`_ in the request/response examples to see the custom object association format. +{% /admonition %} +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->contacts->update( + new UpdateContactRequest([ + 'contactId' => '63a07ddf05a32042dffac965', + 'email' => 'joebloggs@intercom.io', + 'name' => 'joe bloggs', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$contactId:** `string` — id + +
+
+ +
+
+ +**$role:** `?string` — The role of the contact. + +
+
+ +
+
+ +**$externalId:** `?string` — A unique identifier for the contact which is given to Intercom + +
+
+ +
+
+ +**$email:** `?string` — The contacts email + +
+
+ +
+
+ +**$phone:** `?string` — The contacts phone + +
+
+ +
+
+ +**$name:** `?string` — The contacts name + +
+
+ +
+
+ +**$avatar:** `?string` — An image URL containing the avatar of a contact + +
+
+ +
+
+ +**$signedUpAt:** `?int` — The time specified for when a contact signed up + +
+
+ +
+
+ +**$lastSeenAt:** `?int` — The time when the contact was last seen (either where the Intercom Messenger was installed or when specified manually) + +
+
+ +
+
+ +**$ownerId:** `?int` — The id of an admin that has been assigned account ownership of the contact + +
+
+ +
+
+ +**$unsubscribedFromEmails:** `?bool` — Whether the contact is unsubscribed from emails + +
+
+ +
+
+ +**$customAttributes:** `?array` — The custom attributes which are set for the contact + +
+
+
+
+ + +
+
+
+ +
$client->contacts->delete($request) -> ContactDeleted +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can delete a single contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->contacts->delete( + new DeleteContactRequest([ + 'contactId' => 'contact_id', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$contactId:** `string` — contact_id + +
+
+
+
+ + +
+
+
+ +
$client->contacts->mergeLeadInUser($request) -> ContactsMergeLeadInUserResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can merge a contact with a `role` of `lead` into a contact with a `role` of `user`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->contacts->mergeLeadInUser( + new MergeContactsRequest([ + 'leadId' => '6762f0d51bb69f9f2193bb7f', + 'contactId' => '6762f0d51bb69f9f2193bb80', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$leadId:** `?string` — The unique identifier for the contact to merge away from. Must be a lead. + +
+
+ +
+
+ +**$contactId:** `?string` — The unique identifier for the contact to merge into. Must be a user. + +
+
+
+
+ + +
+
+
+ +
$client->contacts->search($request) -> ContactList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can search for multiple contacts by the value of their attributes in order to fetch exactly who you want. + +To search for contacts, you need to send a `POST` request to `https://api.intercom.io/contacts/search`. + +This will accept a query object in the body which will define your filters in order to search for contacts. + +{% admonition type="warning" name="Optimizing search queries" %} + Search queries can be complex, so optimizing them can help the performance of your search. + Use the `AND` and `OR` operators to combine multiple filters to get the exact results you need and utilize + pagination to limit the number of results returned. The default is `50` results per page. + See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#example-search-conversations-request) for more details on how to use the `starting_after` param. +{% /admonition %} +### Contact Creation Delay + +If a contact has recently been created, there is a possibility that it will not yet be available when searching. This means that it may not appear in the response. This delay can take a few minutes. If you need to be instantly notified it is recommended to use webhooks and iterate to see if they match your search filters. + +### Nesting & Limitations + +You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). +There are some limitations to the amount of multiple's there can be: +* There's a limit of max 2 nested filters +* There's a limit of max 15 filters for each AND or OR group + +### Searching for Timestamp Fields + +All timestamp fields (created_at, updated_at etc.) are indexed as Dates for Contact Search queries; Datetime queries are not currently supported. This means you can only query for timestamp fields by day - not hour, minute or second. +For example, if you search for all Contacts with a created_at value greater (>) than 1577869200 (the UNIX timestamp for January 1st, 2020 9:00 AM), that will be interpreted as 1577836800 (January 1st, 2020 12:00 AM). The search results will then include Contacts created from January 2nd, 2020 12:00 AM onwards. +If you'd like to get contacts created on January 1st, 2020 you should search with a created_at value equal (=) to 1577836800 (January 1st, 2020 12:00 AM). +This behaviour applies only to timestamps used in search queries. The search results will still contain the full UNIX timestamp and be sorted accordingly. + +### Accepted Fields + +Most key listed as part of the Contacts Model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as `created_at` accepts a date, the `value` cannot be a string such as `"foorbar"`). + +| Field | Type | +| ---------------------------------- | ------------------------------ | +| id | String | +| role | String
Accepts user or lead | +| name | String | +| avatar | String | +| owner_id | Integer | +| email | String | +| email_domain | String | +| phone | String | +| external_id | String | +| created_at | Date (UNIX Timestamp) | +| signed_up_at | Date (UNIX Timestamp) | +| updated_at | Date (UNIX Timestamp) | +| last_seen_at | Date (UNIX Timestamp) | +| last_contacted_at | Date (UNIX Timestamp) | +| last_replied_at | Date (UNIX Timestamp) | +| last_email_opened_at | Date (UNIX Timestamp) | +| last_email_clicked_at | Date (UNIX Timestamp) | +| language_override | String | +| browser | String | +| browser_language | String | +| os | String | +| location.country | String | +| location.region | String | +| location.city | String | +| unsubscribed_from_emails | Boolean | +| marked_email_as_spam | Boolean | +| has_hard_bounced | Boolean | +| ios_last_seen_at | Date (UNIX Timestamp) | +| ios_app_version | String | +| ios_device | String | +| ios_app_device | String | +| ios_os_version | String | +| ios_app_name | String | +| ios_sdk_version | String | +| android_last_seen_at | Date (UNIX Timestamp) | +| android_app_version | String | +| android_device | String | +| android_app_name | String | +| andoid_sdk_version | String | +| segment_id | String | +| tag_id | String | +| custom_attributes.{attribute_name} | String | + +### Accepted Operators + +{% admonition type="warning" name="Searching based on `created_at`" %} + You cannot use the `<=` or `>=` operators to search by `created_at`. +{% /admonition %} + +The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string (`"="`). The operator has to be compatible with the field's type (eg. you cannot search with `>` for a given string value as it's only compatible for integer's and dates). + +| Operator | Valid Types | Description | +| :------- | :------------------------------- | :--------------------------------------------------------------- | +| = | All | Equals | +| != | All | Doesn't Equal | +| IN | All | In
Shortcut for `OR` queries
Values must be in Array | +| NIN | All | Not In
Shortcut for `OR !` queries
Values must be in Array | +| > | Integer
Date (UNIX Timestamp) | Greater than | +| < | Integer
Date (UNIX Timestamp) | Lower than | +| ~ | String | Contains | +| !~ | String | Doesn't Contain | +| ^ | String | Starts With | +| $ | String | Ends With | +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->contacts->searchContacts( + new SearchRequest([ + 'query' => new SingleFilterSearchRequest([]), + 'pagination' => new StartingAfterPaging([ + 'perPage' => 5, + ]), + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$request:** `SearchRequest` + +
+
+
+
+ + +
+
+
+ +
$client->contacts->list($request) -> ContactList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all contacts (ie. users or leads) in your workspace. +{% admonition type="warning" name="Pagination" %} + You can use pagination to limit the number of results returned. The default is `50` results per page. + See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#pagination-for-list-apis) for more details on how to use the `starting_after` param. +{% /admonition %} +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->contacts->list( + new ListContactsRequest([]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$page:** `?int` — The page of results to fetch. Defaults to first page + +
+
+ +
+
+ +**$perPage:** `?int` — How many results to display per page. Defaults to 15 + +
+
+ +
+
+ +**$startingAfter:** `?string` — String used to get the next page of conversations. + +
+
+
+
+ + +
+
+
+ +
$client->contacts->create($request) -> ContactsCreateResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a new contact (ie. user or lead). +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->contacts->create( + new CreateContactRequestWithEmail([ + 'email' => 'joebloggs@intercom.io', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$request:** `CreateContactRequestWithEmail|CreateContactRequestWithExternalId|CreateContactRequestWithRole` + +
+
+
+
+ + +
+
+
+ +
$client->contacts->showContactByExternalId($request) -> ShowContactByExternalIdResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single contact by external ID. Note that this endpoint only supports users and not leads. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->contacts->showContactByExternalId( + new ShowContactByExternalIdRequest([ + 'externalId' => 'cdd29344-5e0c-4ef0-ac56-f9ba2979bc27', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$externalId:** `string` — The external ID of the user that you want to retrieve + +
+
+
+
+ + +
+
+
+ +
$client->contacts->archive($request) -> ContactArchived +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can archive a single contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->contacts->archive( + new ArchiveContactRequest([ + 'contactId' => '63a07ddf05a32042dffac965', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$contactId:** `string` — contact_id + +
+
+
+
+ + +
+
+
+ +
$client->contacts->unarchive($request) -> ContactUnarchived +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can unarchive a single contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->contacts->unarchive( + new UnarchiveContactRequest([ + 'contactId' => '63a07ddf05a32042dffac965', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$contactId:** `string` — contact_id + +
+
+
+
+ + +
+
+
+ +
$client->contacts->blockContact($request) -> ContactBlocked +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Block a single contact.
**Note:** conversations of the contact will also be archived during the process.
More details in [FAQ How do I block Inbox spam?](https://www.intercom.com/help/en/articles/8838656-inbox-faqs) +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->contacts->blockContact( + new BlockContactRequest([ + 'contactId' => '63a07ddf05a32042dffac965', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$contactId:** `string` — contact_id + +
+
+
+
+ + +
+
+
+ +## Notes +
$client->notes->list($request) -> NoteList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of notes that are associated to a contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->notes->list( + new ListContactNotesRequest([ + 'contactId' => 'contact_id', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$contactId:** `string` — The unique identifier of a contact. + +
+
+ +
+
+ +**$page:** `?int` — The page of results to fetch. Defaults to first page + +
+
+ +
+
+ +**$perPage:** `?int` — How many results to display per page. Defaults to 15 + +
+
+
+
+ + +
+
+
+ +
$client->notes->create($request) -> Note +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can add a note to a single contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->notes->create( + new CreateContactNoteRequest([ + 'contactId' => '123', + 'body' => 'Hello', + 'adminId' => '123', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$contactId:** `string` — The unique identifier of a given contact. + +
+
+ +
+
+ +**$body:** `string` — The text of the note. + +
+
+ +
+
+ +**$adminId:** `?string` — The unique identifier of a given admin. + +
+
+
+
+ + +
+
+
+ +
$client->notes->find($request) -> Note +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single note. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->notes->find( + new FindNoteRequest([ + 'noteId' => 1, + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$noteId:** `int` — The unique identifier of a given note + +
+
+
+
+ + +
+
+
+ +## Tags +
$client->tags->tagContact($request) -> Tag +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can tag a specific contact. This will return a tag object for the tag that was added to the contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->tags->tagContact( + new TagContactRequest([ + 'contactId' => '63a07ddf05a32042dffac965', + 'tagId' => '7522907', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$contactId:** `string` — The unique identifier for the contact which is given by Intercom + +
+
+ +
+
+ +**$tagId:** `string` — The unique identifier for the tag which is given by Intercom + +
+
+
+
+ + +
+
+
+ +
$client->tags->untagContact($request) -> Tag +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can remove tag from a specific contact. This will return a tag object for the tag that was removed from the contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->tags->untagContact( + new UntagContactRequest([ + 'contactId' => '63a07ddf05a32042dffac965', + 'tagId' => '7522907', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$contactId:** `string` — The unique identifier for the contact which is given by Intercom + +
+
+ +
+
+ +**$tagId:** `string` — The unique identifier for the tag which is given by Intercom + +
+
+
+
+ + +
+
+
+ +
$client->tags->tagConversation($request) -> Tag +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can tag a specific conversation. This will return a tag object for the tag that was added to the conversation. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->tags->tagConversation( + new TagConversationRequest([ + 'conversationId' => '64619700005694', + 'tagId' => '7522907', + 'adminId' => '780', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$conversationId:** `string` — conversation_id + +
+
+ +
+
+ +**$tagId:** `string` — The unique identifier for the tag which is given by Intercom + +
+
+ +
+
+ +**$adminId:** `string` — The unique identifier for the admin which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
$client->tags->untagConversation($request) -> Tag +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can remove tag from a specific conversation. This will return a tag object for the tag that was removed from the conversation. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->tags->untagConversation( + new UntagConversationRequest([ + 'conversationId' => '64619700005694', + 'tagId' => '7522907', + 'adminId' => '123', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$conversationId:** `string` — conversation_id + +
+
+ +
+
+ +**$tagId:** `string` — tag_id + +
+
+ +
+
+ +**$adminId:** `string` — The unique identifier for the admin which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
$client->tags->list() -> TagList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all tags for a given workspace. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->tags->list(); +``` +
+
+
+
+ + +
+
+
+ +
$client->tags->create($request) -> Tag +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can use this endpoint to perform the following operations: + + **1. Create a new tag:** You can create a new tag by passing in the tag name as specified in "Create or Update Tag Request Payload" described below. + + **2. Update an existing tag:** You can update an existing tag by passing the id of the tag as specified in "Create or Update Tag Request Payload" described below. + + **3. Tag Companies:** You can tag single company or a list of companies. You can tag a company by passing in the tag name and the company details as specified in "Tag Company Request Payload" described below. Also, if the tag doesn't exist then a new one will be created automatically. + + **4. Untag Companies:** You can untag a single company or a list of companies. You can untag a company by passing in the tag id and the company details as specified in "Untag Company Request Payload" described below. + + **5. Tag Multiple Users:** You can tag a list of users. You can tag the users by passing in the tag name and the user details as specified in "Tag Users Request Payload" described below. + +Each operation will return a tag object. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->tags->create( + new CreateOrUpdateTagRequest([ + 'name' => 'test', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$request:** `CreateOrUpdateTagRequest|TagCompanyRequest|UntagCompanyRequest|TagMultipleUsersRequest` + +
+
+
+
+ + +
+
+
+ +
$client->tags->find($request) -> Tag +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of tags that are on the workspace by their id. +This will return a tag object. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->tags->find( + new FindTagRequest([ + 'tagId' => '123', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$tagId:** `string` — The unique identifier of a given tag + +
+
+
+
+ + +
+
+
+ +
$client->tags->delete($request) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can delete the details of tags that are on the workspace by passing in the id. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->tags->delete( + new DeleteTagRequest([ + 'tagId' => '123', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$tagId:** `string` — The unique identifier of a given tag + +
+
+
+
+ + +
+
+
+ +
$client->tags->tagTicket($request) -> Tag +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can tag a specific ticket. This will return a tag object for the tag that was added to the ticket. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->tags->tagTicket( + new TagTicketRequest([ + 'ticketId' => '64619700005694', + 'tagId' => '7522907', + 'adminId' => '780', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$ticketId:** `string` — ticket_id + +
+
+ +
+
+ +**$tagId:** `string` — The unique identifier for the tag which is given by Intercom + +
+
+ +
+
+ +**$adminId:** `string` — The unique identifier for the admin which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
$client->tags->untagTicket($request) -> Tag +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can remove tag from a specific ticket. This will return a tag object for the tag that was removed from the ticket. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->tags->untagTicket( + new UntagTicketRequest([ + 'ticketId' => '64619700005694', + 'tagId' => '7522907', + 'adminId' => '123', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$ticketId:** `string` — ticket_id + +
+
+ +
+
+ +**$tagId:** `string` — The unique identifier for the tag which is given by Intercom + +
+
+ +
+
+ +**$adminId:** `string` — The unique identifier for the admin which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +## Conversations +
$client->conversations->list($request) -> ConversationList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all conversations. + +You can optionally request the result page size and the cursor to start after to fetch the result. +{% admonition type="warning" name="Pagination" %} + You can use pagination to limit the number of results returned. The default is `20` results per page. + See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#pagination-for-list-apis) for more details on how to use the `starting_after` param. +{% /admonition %} +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->conversations->list( + new ListConversationsRequest([ + 'perPage' => 1, + 'startingAfter' => 'starting_after', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$perPage:** `?int` — How many results per page + +
+
+ +
+
+ +**$startingAfter:** `?string` — String used to get the next page of conversations. + +
+
+
+
+ + +
+
+
+ +
$client->conversations->create($request) -> Message +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a conversation that has been initiated by a contact (ie. user or lead). +The conversation can be an in-app message only. + +{% admonition type="info" name="Sending for visitors" %} +You can also send a message from a visitor by specifying their `user_id` or `id` value in the `from` field, along with a `type` field value of `contact`. +This visitor will be automatically converted to a contact with a lead role once the conversation is created. +{% /admonition %} + +This will return the Message model that has been created. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->conversations->create( + new CreateConversationRequest([ + 'from' => new CreateConversationRequestFrom([ + 'type' => CreateConversationRequestFromType::User->value, + 'id' => '6762f11b1bb69f9f2193bba3', + ]), + 'body' => 'Hello there', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$from:** `CreateConversationRequestFrom` + +
+
+ +
+
+ +**$body:** `string` — The content of the message. HTML is not supported. + +
+
+ +
+
+ +**$createdAt:** `?int` — 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. + +
+
+
+
+ + +
+
+
+ +
$client->conversations->find($request) -> Conversation +
+
+ +#### 📝 Description + +
+
+ +
+
+ + +You can fetch the details of a single conversation. + +This will return a single Conversation model with all its conversation parts. + +{% admonition type="warning" name="Hard limit of 500 parts" %} +The maximum number of conversation parts that can be returned via the API is 500. If you have more than that we will return the 500 most recent conversation parts. +{% /admonition %} + +For AI agent conversation metadata, please note that you need to have the agent enabled in your workspace, which is a [paid feature](https://www.intercom.com/help/en/articles/8205718-fin-resolutions#h_97f8c2e671). +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->conversations->find( + new FindConversationRequest([ + 'conversationId' => '123', + 'displayAs' => 'plaintext', + 'includeTranslations' => true, + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$conversationId:** `string` — The id of the conversation to target + +
+
+ +
+
+ +**$displayAs:** `?string` — Set to plaintext to retrieve conversation messages in plain text. + +
+
+ +
+
+ +**$includeTranslations:** `?bool` — If set to true, conversation parts will be translated to the detected language of the conversation. + +
+
+
+
+ + +
+
+
+ +
$client->conversations->update($request) -> Conversation +
+
+ +#### 📝 Description + +
+
+ +
+
+ + +You can update an existing conversation. + +{% admonition type="info" name="Replying and other actions" %} +If you want to reply to a coveration or take an action such as assign, unassign, open, close or snooze, take a look at the reply and manage endpoints. +{% /admonition %} + +{% admonition type="info" %} + This endpoint handles both **conversation updates** and **custom object associations**. + + See _`update a conversation with an association to a custom object instance`_ in the request/response examples to see the custom object association format. +{% /admonition %} + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->conversations->update( + new UpdateConversationRequest([ + 'conversationId' => 'conversation_id', + 'displayAs' => 'plaintext', + 'read' => true, + 'title' => 'new conversation title', + 'customAttributes' => [ + 'issue_type' => 'Billing', + 'priority' => 'High', + ], + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$conversationId:** `string` — The id of the conversation to target + +
+
+ +
+
+ +**$displayAs:** `?string` — Set to plaintext to retrieve conversation messages in plain text. + +
+
+ +
+
+ +**$read:** `?bool` — Mark a conversation as read within Intercom. + +
+
+ +
+
+ +**$title:** `?string` — The title given to the conversation + +
+
+ +
+
+ +**$customAttributes:** `?array` + +
+
+ +
+
+ +**$companyId:** `?string` — The ID of the company that the conversation is associated with. The unique identifier for the company which is given by Intercom. Set to nil to remove company. + +
+
+
+
+ + +
+
+
+ +
$client->conversations->deleteConversation($request) -> ConversationDeleted +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can delete a single conversation. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->conversations->deleteConversation( + new DeleteConversationRequest([ + 'conversationId' => 1, + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$conversationId:** `int` — id + +
+
+
+
+ + +
+
+
+ +
$client->conversations->search($request) -> ConversationList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can search for multiple conversations by the value of their attributes in order to fetch exactly which ones you want. + +To search for conversations, you need to send a `POST` request to `https://api.intercom.io/conversations/search`. + +This will accept a query object in the body which will define your filters in order to search for conversations. +{% admonition type="warning" name="Optimizing search queries" %} + Search queries can be complex, so optimizing them can help the performance of your search. + Use the `AND` and `OR` operators to combine multiple filters to get the exact results you need and utilize + pagination to limit the number of results returned. The default is `20` results per page and maximum is `150`. + See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#example-search-conversations-request) for more details on how to use the `starting_after` param. +{% /admonition %} + +### Nesting & Limitations + +You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). +There are some limitations to the amount of multiple's there can be: +- There's a limit of max 2 nested filters +- There's a limit of max 15 filters for each AND or OR group + +### Accepted Fields + +Most keys listed in the conversation model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as `created_at` accepts a date, the `value` cannot be a string such as `"foorbar"`). +The `source.body` field is unique as the search will not be performed against the entire value, but instead against every element of the value separately. For example, when searching for a conversation with a `"I need support"` body - the query should contain a `=` operator with the value `"support"` for such conversation to be returned. A query with a `=` operator and a `"need support"` value will not yield a result. + +| Field | Type | +| :---------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------- | +| id | String | +| created_at | Date (UNIX timestamp) | +| updated_at | Date (UNIX timestamp) | +| source.type | String
Accepted fields are `conversation`, `email`, `facebook`, `instagram`, `phone_call`, `phone_switch`, `push`, `sms`, `twitter` and `whatsapp`. | +| source.id | String | +| source.delivered_as | String | +| source.subject | String | +| source.body | String | +| source.author.id | String | +| source.author.type | String | +| source.author.name | String | +| source.author.email | String | +| source.url | String | +| contact_ids | String | +| teammate_ids | String | +| admin_assignee_id | String | +| team_assignee_id | String | +| channel_initiated | String | +| open | Boolean | +| read | Boolean | +| state | String | +| waiting_since | Date (UNIX timestamp) | +| snoozed_until | Date (UNIX timestamp) | +| tag_ids | String | +| priority | String | +| statistics.time_to_assignment | Integer | +| statistics.time_to_admin_reply | Integer | +| statistics.time_to_first_close | Integer | +| statistics.time_to_last_close | Integer | +| statistics.median_time_to_reply | Integer | +| statistics.first_contact_reply_at | Date (UNIX timestamp) | +| statistics.first_assignment_at | Date (UNIX timestamp) | +| statistics.first_admin_reply_at | Date (UNIX timestamp) | +| statistics.first_close_at | Date (UNIX timestamp) | +| statistics.last_assignment_at | Date (UNIX timestamp) | +| statistics.last_assignment_admin_reply_at | Date (UNIX timestamp) | +| statistics.last_contact_reply_at | Date (UNIX timestamp) | +| statistics.last_admin_reply_at | Date (UNIX timestamp) | +| statistics.last_close_at | Date (UNIX timestamp) | +| statistics.last_closed_by_id | String | +| statistics.count_reopens | Integer | +| statistics.count_assignments | Integer | +| statistics.count_conversation_parts | Integer | +| conversation_rating.requested_at | Date (UNIX timestamp) | +| conversation_rating.replied_at | Date (UNIX timestamp) | +| conversation_rating.score | Integer | +| conversation_rating.remark | String | +| conversation_rating.contact_id | String | +| conversation_rating.admin_d | String | +| ai_agent_participated | Boolean | +| ai_agent.resolution_state | String | +| ai_agent.last_answer_type | String | +| ai_agent.rating | Integer | +| ai_agent.rating_remark | String | +| ai_agent.source_type | String | +| ai_agent.source_title | String | + +### Accepted Operators + +The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string (`"="`). The operator has to be compatible with the field's type (eg. you cannot search with `>` for a given string value as it's only compatible for integer's and dates). + +| Operator | Valid Types | Description | +| :------- | :----------------------------- | :----------------------------------------------------------- | +| = | All | Equals | +| != | All | Doesn't Equal | +| IN | All | In Shortcut for `OR` queries Values most be in Array | +| NIN | All | Not In Shortcut for `OR !` queries Values must be in Array | +| > | Integer Date (UNIX Timestamp) | Greater (or equal) than | +| < | Integer Date (UNIX Timestamp) | Lower (or equal) than | +| ~ | String | Contains | +| !~ | String | Doesn't Contain | +| ^ | String | Starts With | +| $ | String | Ends With | +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->conversations->searchConversations( + new SearchRequest([ + 'query' => new SingleFilterSearchRequest([]), + 'pagination' => new StartingAfterPaging([ + 'perPage' => 5, + ]), + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$request:** `SearchRequest` + +
+
+
+
+ + +
+
+
+ +
$client->conversations->reply($request) -> Conversation +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can reply to a conversation with a message from an admin or on behalf of a contact, or with a note for admins. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->conversations->reply( + new ReplyToConversationRequest([ + 'conversationId' => '123 or "last"', + 'body' => new ContactReplyIntercomUserIdRequest([ + 'messageType' => 'comment', + 'type' => 'user', + 'body' => 'Thanks again :)', + 'intercomUserId' => '6762f1571bb69f9f2193bbbb', + ]), + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$conversationId:** `string` — The Intercom provisioned identifier for the conversation or the string "last" to reply to the last part of the conversation + +
+
+ +
+
+ +**$request:** `ContactReplyIntercomUserIdRequest|ContactReplyEmailRequest|ContactReplyUserIdRequest|AdminReplyConversationRequest` + +
+
+
+
+ + +
+
+
+ +
$client->conversations->manage($request) -> Conversation +
+
+ +#### 📝 Description + +
+
+ +
+
+ +For managing conversations you can: +- Close a conversation +- Snooze a conversation to reopen on a future date +- Open a conversation which is `snoozed` or `closed` +- Assign a conversation to an admin and/or team. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->conversations->manage( + new ManageConversationPartsRequest([ + 'conversationId' => '123', + 'body' => ConversationsManageRequestBody::close(new CloseConversationRequest([ + 'type' => 'admin', + 'adminId' => '12345', + ])), + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$conversationId:** `string` — The identifier for the conversation as given by Intercom. + +
+
+ +
+
+ +**$request:** `ConversationsManageRequestBody` + +
+
+
+
+ + +
+
+
+ +
$client->conversations->attachContactAsAdmin($request) -> Conversation +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can add participants who are contacts to a conversation, on behalf of either another contact or an admin. + +{% admonition type="warning" name="Contacts without an email" %} +If you add a contact via the email parameter and there is no user/lead found on that workspace with he given email, then we will create a new contact with `role` set to `lead`. +{% /admonition %} + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->conversations->attachContactAsAdmin( + new AttachContactToConversationRequest([ + 'conversationId' => '123', + 'adminId' => '12345', + 'customer' => new AttachContactToConversationRequestCustomerIntercomUserId([ + 'intercomUserId' => '6762f19b1bb69f9f2193bbd4', + ]), + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$conversationId:** `string` — The identifier for the conversation as given by Intercom. + +
+
+ +
+
+ +**$adminId:** `?string` — The `id` of the admin who is adding the new participant. + +
+
+ +
+
+ +**$customer:** `AttachContactToConversationRequestCustomerIntercomUserId|AttachContactToConversationRequestCustomerUserId|AttachContactToConversationRequestCustomerCustomer|null` + +
+
+
+
+ + +
+
+
+ +
$client->conversations->detachContactAsAdmin($request) -> Conversation +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can add participants who are contacts to a conversation, on behalf of either another contact or an admin. + +{% admonition type="warning" name="Contacts without an email" %} +If you add a contact via the email parameter and there is no user/lead found on that workspace with he given email, then we will create a new contact with `role` set to `lead`. +{% /admonition %} + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->conversations->detachContactAsAdmin( + new DetachContactFromConversationRequest([ + 'conversationId' => '123', + 'contactId' => '123', + 'adminId' => '5017690', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$conversationId:** `string` — The identifier for the conversation as given by Intercom. + +
+
+ +
+
+ +**$contactId:** `string` — The identifier for the contact as given by Intercom. + +
+
+ +
+
+ +**$adminId:** `string` — The `id` of the admin who is performing the action. + +
+
+
+
+ + +
+
+
+ +
$client->conversations->redactConversationPart($request) -> Conversation +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can redact a conversation part or the source message of a conversation (as seen in the source object). + +{% admonition type="info" name="Redacting parts and messages" %} +If you are redacting a conversation part, it must have a `body`. If you are redacting a source message, it must have been created by a contact. We will return a `conversation_part_not_redactable` error if these criteria are not met. +{% /admonition %} + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->conversations->redactConversationPart( + RedactConversationRequest::conversationPart(new RedactConversationRequestConversationPart([ + 'conversationId' => '19894788788', + 'conversationPartId' => '19381789428', + ])), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$request:** `RedactConversationRequest` + +
+
+
+
+ + +
+
+
+ +
$client->conversations->convertToTicket($request) -> ?Ticket +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can convert a conversation to a ticket. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->conversations->convertToTicket( + new ConvertConversationToTicketRequest([ + 'conversationId' => 1, + 'ticketTypeId' => '53', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$conversationId:** `int` — The id of the conversation to target + +
+
+ +
+
+ +**$ticketTypeId:** `string` — The ID of the type of ticket you want to convert the conversation to + +
+
+ +
+
+ +**$attributes:** `?array` + +
+
+
+
+ + +
+
+
+ +
$client->conversations->runAssignmentRules($request) -> Conversation +
+
+ +#### 📝 Description + +
+
+ +
+
+ +{% admonition type="danger" name="Deprecation of Run Assignment Rules" %} +Run assignment rules is now deprecated in version 2.12 and future versions and will be permanently removed on December 31, 2026. After this date, any requests made to this endpoint will fail. +{% /admonition %} +You can let a conversation be automatically assigned following assignment rules. +{% admonition type="warning" name="When using workflows" %} +It is not possible to use this endpoint with Workflows. +{% /admonition %} +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->conversations->runAssignmentRules( + new AutoAssignConversationRequest([ + 'conversationId' => '123', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$conversationId:** `string` — The identifier for the conversation as given by Intercom. + +
+
+
+
+ + +
+
+
+ +## Custom Channel Events +
$client->customChannelEvents->notifyNewConversation($request) -> CustomChannelNotificationResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Notifies Intercom that a new conversation was created in your custom channel/platform. This triggers conversation creation and workflow automations within Intercom for your custom channel integration. +> **Note:** This endpoint is currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->customChannelEvents->notifyNewConversation( + new CustomChannelBaseEvent([ + 'eventId' => 'event_id', + 'externalConversationId' => 'external_conversation_id', + 'contact' => new CustomChannelContact([ + 'type' => CustomChannelContactType::User->value, + 'externalId' => 'external_id', + ]), + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$request:** `CustomChannelBaseEvent` + +
+
+
+
+ + +
+
+
+ +
$client->customChannelEvents->notifyNewMessage($request) -> CustomChannelNotificationResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Notifies Intercom that a new message was sent in a conversation on your custom channel/platform. This allows Intercom to process the message and trigger any relevant workflow automations. +> **Note:** This endpoint is currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->customChannelEvents->notifyNewMessage( + new NotifyNewMessageRequest([ + 'eventId' => 'event_id', + 'externalConversationId' => 'external_conversation_id', + 'contact' => new CustomChannelContact([ + 'type' => CustomChannelContactType::User->value, + 'externalId' => 'external_id', + ]), + 'body' => 'body', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$body:** `string` — The message content sent by the user. + +
+
+
+
+ + +
+
+
+ +
$client->customChannelEvents->notifyQuickReplySelected($request) -> CustomChannelNotificationResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Notifies Intercom that a user selected a quick reply option in your custom channel/platform. This allows Intercom to process the response and trigger any relevant workflow automations. +> **Note:** This endpoint is currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->customChannelEvents->notifyQuickReplySelected( + new NotifyQuickReplySelectedRequest([ + 'eventId' => 'evt_67890', + 'externalConversationId' => 'conv_13579', + 'contact' => new CustomChannelContact([ + 'type' => CustomChannelContactType::User->value, + 'externalId' => 'user_003', + 'name' => 'Alice Example', + 'email' => 'alice@example.com', + ]), + 'quickReplyOptionId' => '1234', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$quickReplyOptionId:** `string` — Id of the selected quick reply option. + +
+
+
+
+ + +
+
+
+ +
$client->customChannelEvents->notifyAttributeCollected($request) -> CustomChannelNotificationResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Notifies Intercom that a user provided a response to an attribute collector in your custom channel/platform. This allows Intercom to process the attribute and trigger any relevant workflow automations. +> **Note:** This endpoint is currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->customChannelEvents->notifyAttributeCollected( + new NotifyAttributeCollectedRequest([ + 'eventId' => 'event_id', + 'externalConversationId' => 'external_conversation_id', + 'contact' => new CustomChannelContact([ + 'type' => CustomChannelContactType::User->value, + 'externalId' => 'external_id', + ]), + 'attribute' => new CustomChannelAttribute([ + 'id' => 'id', + 'value' => 'value', + ]), + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$attribute:** `CustomChannelAttribute` + +
+
+
+
+ + +
+
+
+ +## Custom Object Instances +
$client->customObjectInstances->getCustomObjectInstancesByExternalId($request) -> ?CustomObjectInstance +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Fetch a Custom Object Instance by external_id. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->customObjectInstances->getCustomObjectInstancesByExternalId( + new GetCustomObjectInstancesByExternalIdRequest([ + 'customObjectTypeIdentifier' => 'Order', + 'externalId' => 'external_id', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$customObjectTypeIdentifier:** `string` — The unique identifier of the custom object type that defines the structure of the custom object instance. + +
+
+ +
+
+ +**$externalId:** `string` + +
+
+
+
+ + +
+
+
+ +
$client->customObjectInstances->createCustomObjectInstances($request) -> ?CustomObjectInstance +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create or update a custom object instance +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->customObjectInstances->createCustomObjectInstances( + new CreateOrUpdateCustomObjectInstanceRequest([ + 'customObjectTypeIdentifier' => 'Order', + 'externalId' => '123', + 'externalCreatedAt' => 1392036272, + 'externalUpdatedAt' => 1392036272, + 'customAttributes' => [ + 'order_number' => 'ORDER-12345', + 'total_amount' => 'custom_attributes', + ], + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$customObjectTypeIdentifier:** `string` — The unique identifier of the custom object type that defines the structure of the custom object instance. + +
+
+ +
+
+ +**$externalId:** `?string` — A unique identifier for the Custom Object instance in the external system it originated from. + +
+
+ +
+
+ +**$externalCreatedAt:** `?int` — The time when the Custom Object instance was created in the external system it originated from. + +
+
+ +
+
+ +**$externalUpdatedAt:** `?int` — The time when the Custom Object instance was last updated in the external system it originated from. + +
+
+ +
+
+ +**$customAttributes:** `?array` — The custom attributes which are set for the Custom Object instance. + +
+
+
+
+ + +
+
+
+ +
$client->customObjectInstances->deleteCustomObjectInstancesById($request) -> CustomObjectInstanceDeleted +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Delete a single Custom Object instance by external_id. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->customObjectInstances->deleteCustomObjectInstancesById( + new DeleteCustomObjectInstancesByIdRequest([ + 'customObjectTypeIdentifier' => 'Order', + 'externalId' => 'external_id', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$customObjectTypeIdentifier:** `string` — The unique identifier of the custom object type that defines the structure of the custom object instance. + +
+
+ +
+
+ +**$externalId:** `string` + +
+
+
+
+ + +
+
+
+ +
$client->customObjectInstances->getCustomObjectInstancesById($request) -> ?CustomObjectInstance +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Fetch a Custom Object Instance by id. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->customObjectInstances->getCustomObjectInstancesById( + new GetCustomObjectInstancesByIdRequest([ + 'customObjectTypeIdentifier' => 'Order', + 'customObjectInstanceId' => 'custom_object_instance_id', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$customObjectTypeIdentifier:** `string` — The unique identifier of the custom object type that defines the structure of the custom object instance. + +
+
+ +
+
+ +**$customObjectInstanceId:** `string` — The id or external_id of the custom object instance + +
+
+
+
+ + +
+
+
+ +
$client->customObjectInstances->deleteCustomObjectInstancesByExternalId($request) -> CustomObjectInstanceDeleted +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Delete a single Custom Object instance using the Intercom defined id. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->customObjectInstances->deleteCustomObjectInstancesByExternalId( + new DeleteCustomObjectInstancesByExternalIdRequest([ + 'customObjectTypeIdentifier' => 'Order', + 'customObjectInstanceId' => 'custom_object_instance_id', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$customObjectTypeIdentifier:** `string` — The unique identifier of the custom object type that defines the structure of the custom object instance. + +
+
+ +
+
+ +**$customObjectInstanceId:** `string` — The Intercom defined id of the custom object instance + +
+
+
+
+ + +
+
+
+ +## Data Attributes +
$client->dataAttributes->list($request) -> DataAttributeList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all data attributes belonging to a workspace for contacts, companies or conversations. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->dataAttributes->list( + new ListDataAttributesRequest([ + 'model' => DataAttributesListRequestModel::Contact->value, + 'includeArchived' => true, + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$model:** `?string` — Specify the data attribute model to return. + +
+
+ +
+
+ +**$includeArchived:** `?bool` — Include archived attributes in the list. By default we return only non archived data attributes. + +
+
+
+
+ + +
+
+
+ +
$client->dataAttributes->create($request) -> DataAttribute +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a data attributes for a `contact` or a `company`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->dataAttributes->create( + new CreateDataAttributeRequestOptions([ + 'dataType' => 'string', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$request:** `CreateDataAttributeRequestOptions|CreateDataAttributeRequestOne` + +
+
+
+
+ + +
+
+
+ +
$client->dataAttributes->update($request) -> DataAttribute +
+
+ +#### 📝 Description + +
+
+ +
+
+ + +You can update a data attribute. + +> 🚧 Updating the data type is not possible +> +> It is currently a dangerous action to execute changing a data attribute's type via the API. You will need to update the type via the UI instead. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->dataAttributes->update( + new UpdateDataAttributeRequest([ + 'dataAttributeId' => 1, + 'body' => new UpdateDataAttributeRequestOptions([ + 'options' => [ + new UpdateDataAttributeRequestOptionsOptionsItem([ + 'value' => '1-10', + ]), + new UpdateDataAttributeRequestOptionsOptionsItem([ + 'value' => '11-20', + ]), + ], + ]), + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$dataAttributeId:** `int` — The data attribute id + +
+
+ +
+
+ +**$request:** `mixed` + +
+
+
+
+ + +
+
+
+ +## Events +
$client->events->list($request) -> DataEventSummary +
+
+ +#### 📝 Description + +
+
+ +
+
+ + +> 🚧 +> +> Please note that you can only 'list' events that are less than 90 days old. Event counts and summaries will still include your events older than 90 days but you cannot 'list' these events individually if they are older than 90 days + +The events belonging to a customer can be listed by sending a GET request to `https://api.intercom.io/events` with a user or lead identifier along with a `type` parameter. The identifier parameter can be one of `user_id`, `email` or `intercom_user_id`. The `type` parameter value must be `user`. + +- `https://api.intercom.io/events?type=user&user_id={user_id}` +- `https://api.intercom.io/events?type=user&email={email}` +- `https://api.intercom.io/events?type=user&intercom_user_id={id}` (this call can be used to list leads) + +The `email` parameter value should be [url encoded](http://en.wikipedia.org/wiki/Percent-encoding) when sending. + +You can optionally define the result page size as well with the `per_page` parameter. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->events->list( + new ListEventsRequest([ + 'userId' => 'user_id', + 'intercomUserId' => 'intercom_user_id', + 'email' => 'email', + 'type' => 'type', + 'summary' => true, + 'perPage' => 1, + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$userId:** `?string` — user_id query parameter + +
+
+ +
+
+ +**$intercomUserId:** `?string` — intercom_user_id query parameter + +
+
+ +
+
+ +**$email:** `?string` — email query parameter + +
+
+ +
+
+ +**$type:** `string` — The value must be user + +
+
+ +
+
+ +**$summary:** `?bool` — summary flag + +
+
+ +
+
+ +**$perPage:** `?int` — How many results to display per page. Defaults to 15 + +
+
+
+
+ + +
+
+
+ +
$client->events->create($request) +
+
+ +#### 📝 Description + +
+
+ +
+
+ + +You will need an Access Token that has write permissions to send Events. Once you have a key you can submit events via POST to the Events resource, which is located at https://api.intercom.io/events, or you can send events using one of the client libraries. When working with the HTTP API directly a client should send the event with a `Content-Type` of `application/json`. + +When using the JavaScript API, [adding the code to your app](http://docs.intercom.io/configuring-Intercom/tracking-user-events-in-your-app) makes the Events API available. Once added, you can submit an event using the `trackEvent` method. This will associate the event with the Lead or currently logged-in user or logged-out visitor/lead and send it to Intercom. The final parameter is a map that can be used to send optional metadata about the event. + +With the Ruby client you pass a hash describing the event to `Intercom::Event.create`, or call the `track_user` method directly on the current user object (e.g. `user.track_event`). + +**NB: For the JSON object types, please note that we do not currently support nested JSON structure.** + +| Type | Description | Example | +| :-------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------- | +| String | The value is a JSON String | `"source":"desktop"` | +| Number | The value is a JSON Number | `"load": 3.67` | +| Date | The key ends with the String `_date` and the value is a [Unix timestamp](http://en.wikipedia.org/wiki/Unix_time), assumed to be in the [UTC](http://en.wikipedia.org/wiki/Coordinated_Universal_Time) timezone. | `"contact_date": 1392036272` | +| Link | The value is a HTTP or HTTPS URI. | `"article": "https://example.org/ab1de.html"` | +| Rich Link | The value is a JSON object that contains `url` and `value` keys. | `"article": {"url": "https://example.org/ab1de.html", "value":"the dude abides"}` | +| Monetary Amount | The value is a JSON object that contains `amount` and `currency` keys. The `amount` key is a positive integer representing the amount in cents. The price in the example to the right denotes €349.99. | `"price": {"amount": 34999, "currency": "eur"}` | + +**Lead Events** + +When submitting events for Leads, you will need to specify the Lead's `id`. + +**Metadata behaviour** + +- We currently limit the number of tracked metadata keys to 10 per event. Once the quota is reached, we ignore any further keys we receive. The first 10 metadata keys are determined by the order in which they are sent in with the event. +- It is not possible to change the metadata keys once the event has been sent. A new event will need to be created with the new keys and you can archive the old one. +- There might be up to 24 hrs delay when you send a new metadata for an existing event. + +**Event de-duplication** + +The API may detect and ignore duplicate events. Each event is uniquely identified as a combination of the following data - the Workspace identifier, the Contact external identifier, the Data Event name and the Data Event created time. As a result, it is **strongly recommended** to send a second granularity Unix timestamp in the `created_at` field. + +Duplicated events are responded to using the normal `202 Accepted` code - an error is not thrown, however repeat requests will be counted against any rate limit that is in place. + +### HTTP API Responses + +- Successful responses to submitted events return `202 Accepted` with an empty body. +- Unauthorised access will be rejected with a `401 Unauthorized` or `403 Forbidden` response code. +- Events sent about users that cannot be found will return a `404 Not Found`. +- Event lists containing duplicate events will have those duplicates ignored. +- Server errors will return a `500` response code and may contain an error message in the body. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->events->create( + new CreateDataEventRequestWithId([ + 'id' => '8a88a590-e1c3-41e2-a502-e0649dbf721c', + 'eventName' => 'invited-friend', + 'createdAt' => 1671028894, + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$request:** `CreateDataEventRequestWithId|CreateDataEventRequestWithUserId|CreateDataEventRequestWithEmail` + +
+
+
+
+ + +
+
+
+ +
$client->events->summaries($request) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create event summaries for a user. Event summaries are used to track the number of times an event has occurred, the first time it occurred and the last time it occurred. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->events->summaries( + new ListEventSummariesRequest([]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$userId:** `?string` — Your identifier for the user. + +
+
+ +
+
+ +**$eventSummaries:** `?CreateDataEventSummariesRequestEventSummaries` — 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`. + +
+
+
+
+ + +
+
+
+ +## Jobs +
$client->jobs->status($request) -> Jobs +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve the status of job execution. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->jobs->status( + new JobsStatusRequest([ + 'jobId' => 'job_id', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$jobId:** `string` — The unique identifier for the job which is given by Intercom + +
+
+
+
+ + +
+
+
+ +## Messages +
$client->messages->create($request) -> Message +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a message that has been initiated by an admin. The conversation can be either an in-app message or an email. + +> 🚧 Sending for visitors +> +> There can be a short delay between when a contact is created and when a contact becomes available to be messaged through the API. A 404 Not Found error will be returned in this case. + +This will return the Message model that has been created. + +> 🚧 Retrieving Associated Conversations +> +> As this is a message, there will be no conversation present until the contact responds. Once they do, you will have to search for a contact's conversations with the id of the message. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->messages->create( + CreateMessageRequest::email(new CreateMessageRequestWithEmail([ + 'subject' => 'Thanks for everything', + 'body' => 'Hello there', + 'template' => 'plain', + 'from' => new CreateMessageRequestFrom([ + 'type' => 'admin', + 'id' => 394051, + ]), + 'to' => new CreateMessageRequestTo([ + 'type' => CreateMessageRequestType::User->value, + 'id' => '536e564f316c83104c000020', + ]), + ])), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$request:** `?CreateMessageRequest` + +
+
+
+
+ + +
+
+
+ +## Segments +
$client->segments->list($request) -> SegmentList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all segments. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->segments->list( + new ListSegmentsRequest([ + 'includeCount' => true, + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$includeCount:** `?bool` — It includes the count of contacts that belong to each segment. + +
+
+
+
+ + +
+
+
+ +
$client->segments->find($request) -> Segment +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single segment. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->segments->find( + new FindSegmentRequest([ + 'segmentId' => '123', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$segmentId:** `string` — The unique identified of a given segment. + +
+
+
+
+ + +
+
+
+ +## Subscription Types +
$client->subscriptionTypes->list() -> SubscriptionTypeList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can list all subscription types. A list of subscription type objects will be returned. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->subscriptionTypes->list(); +``` +
+
+
+
+ + +
+
+
+ +## PhoneCallRedirects +
$client->phoneCallRedirects->create($request) -> ?PhoneSwitch +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can use the API to deflect phone calls to the Intercom Messenger. +Calling this endpoint will send an SMS with a link to the Messenger to the phone number specified. + +If custom attributes are specified, they will be added to the user or lead's custom data attributes. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->phoneCallRedirects->create( + new CreatePhoneSwitchRequest([ + 'phone' => '+353832345678', + 'customAttributes' => [ + 'issue_type' => 'Billing', + 'priority' => 'High', + ], + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$request:** `?CreatePhoneSwitchRequest` + +
+
+
+
+ + +
+
+
+ +## Calls +
$client->calls->listCalls($request) -> CallList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve a paginated list of calls. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->calls->listCalls( + new ListCallsRequest([ + 'page' => 1, + 'perPage' => 1, + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$page:** `?int` — The page of results to fetch. Defaults to first page + +
+
+ +
+
+ +**$perPage:** `?int` — How many results to display per page. Defaults to 25. Max 25. + +
+
+
+
+ + +
+
+
+ +
$client->calls->showCall($request) -> Call +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve a single call by id. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->calls->showCall( + new ShowCallRequest([ + 'callId' => 'call_id', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$callId:** `string` — The id of the call to retrieve + +
+
+
+
+ + +
+
+
+ +
$client->calls->showCallRecording($request) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Redirects to a signed URL for the call's recording if it exists. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->calls->showCallRecording( + new ShowCallRecordingRequest([ + 'callId' => 'call_id', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$callId:** `string` — The id of the call + +
+
+
+
+ + +
+
+
+ +
$client->calls->showCallTranscript($request) -> string +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Returns the transcript for the specified call as a downloadable text file. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->calls->showCallTranscript( + new ShowCallTranscriptRequest([ + 'callId' => 'call_id', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$callId:** `string` — The id of the call + +
+
+
+
+ + +
+
+
+ +
$client->calls->listCallsWithTranscripts($request) -> ListCallsWithTranscriptsResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve calls by a list of conversation ids and include transcripts when available. +A maximum of 20 `conversation_ids` can be provided. If none are provided or more than 20 are provided, a 400 error is returned. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->calls->listCallsWithTranscripts( + new ListCallsWithTranscriptsRequest([ + 'conversationIds' => [ + '64619700005694', + '64619700005695', + ], + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$conversationIds:** `array` — A list of conversation ids to fetch calls for. Maximum 20. + +
+
+
+
+ + +
+
+
+ +## Teams +
$client->teams->list() -> TeamList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +This will return a list of team objects for the App. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->teams->list(); +``` +
+
+
+
+ + +
+
+
+ +
$client->teams->find($request) -> Team +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single team, containing an array of admins that belong to this team. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->teams->find( + new FindTeamRequest([ + 'teamId' => '123', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$teamId:** `string` — The unique identifier of a given team. + +
+
+
+
+ + +
+
+
+ +## Ticket States +
$client->ticketStates->listTicketStates() -> TicketStateList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can get a list of all ticket states for a workspace. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->ticketStates->listTicketStates(); +``` +
+
+
+
+ + +
+
+
+ +## Ticket Types +
$client->ticketTypes->list() -> TicketTypeList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can get a list of all ticket types for a workspace. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->ticketTypes->list(); +``` +
+
+
+
+ + +
+
+
+ +
$client->ticketTypes->create($request) -> ?TicketType +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a new ticket type. +> 📘 Creating ticket types. +> +> Every ticket type will be created with two default attributes: _default_title_ and _default_description_. +> For the `icon` propery, use an emoji from [Twemoji Cheatsheet](https://twemoji-cheatsheet.vercel.app/) +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->ticketTypes->create( + new CreateTicketTypeRequest([ + 'name' => 'Customer Issue', + 'description' => 'Customer Report Template', + 'category' => CreateTicketTypeRequestCategory::Customer->value, + 'icon' => '🎟️', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$request:** `?CreateTicketTypeRequest` + +
+
+
+
+ + +
+
+
+ +
$client->ticketTypes->get($request) -> ?TicketType +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single ticket type. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->ticketTypes->get( + new FindTicketTypeRequest([ + 'ticketTypeId' => 'ticket_type_id', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$ticketTypeId:** `string` — The unique identifier for the ticket type which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
$client->ticketTypes->update($request) -> ?TicketType +
+
+ +#### 📝 Description + +
+
+ +
+
+ + +You can update a ticket type. + +> 📘 Updating a ticket type. +> +> For the `icon` propery, use an emoji from [Twemoji Cheatsheet](https://twemoji-cheatsheet.vercel.app/) +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->ticketTypes->update( + new UpdateTicketTypeRequest([ + 'ticketTypeId' => 'ticket_type_id', + 'name' => 'Bug Report 2', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$ticketTypeId:** `string` — The unique identifier for the ticket type which is given by Intercom. + +
+
+ +
+
+ +**$name:** `?string` — The name of the ticket type. + +
+
+ +
+
+ +**$description:** `?string` — The description of the ticket type. + +
+
+ +
+
+ +**$category:** `?string` — Category of the Ticket Type. + +
+
+ +
+
+ +**$icon:** `?string` — The icon of the ticket type. + +
+
+ +
+
+ +**$archived:** `?bool` — The archived status of the ticket type. + +
+
+ +
+
+ +**$isInternal:** `?bool` — 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. + +
+
+
+
+ + +
+
+
+ +## Tickets +
$client->tickets->reply($request) -> TicketReply +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can reply to a ticket with a message from an admin or on behalf of a contact, or with a note for admins. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->tickets->reply( + new ReplyToTicketRequest([ + 'ticketId' => '123', + 'body' => new ContactReplyTicketIntercomUserIdRequest([ + 'messageType' => 'comment', + 'type' => 'user', + 'body' => 'Thanks again :)', + 'intercomUserId' => '6762f2971bb69f9f2193bc49', + ]), + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$ticketId:** `string` + +
+
+ +
+
+ +**$request:** `ContactReplyTicketIntercomUserIdRequest|ContactReplyTicketUserIdRequest|ContactReplyTicketEmailRequest|AdminReplyTicketRequest` + +
+
+
+
+ + +
+
+
+ +
$client->tickets->create($request) -> ?Ticket +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a new ticket. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->tickets->create( + new CreateTicketRequest([ + 'ticketTypeId' => '1234', + 'contacts' => [ + new CreateTicketRequestContactsItemId([ + 'id' => '6762f2d81bb69f9f2193bc54', + ]), + ], + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$skipNotifications:** `?bool` — Option to disable notifications when a Ticket is created. + +
+
+
+
+ + +
+
+
+ +
$client->tickets->enqueueCreateTicket($request) -> Jobs +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Enqueues ticket creation for asynchronous processing, returning if the job was enqueued successfully to be processed. We attempt to perform a best-effort validation on inputs before tasks are enqueued. If the given parameters are incorrect, we won't enqueue the job. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->tickets->enqueueCreateTicket( + new EnqueueCreateTicketRequest([ + 'ticketTypeId' => '1234', + 'contacts' => [ + new CreateTicketRequestContactsItemId([ + 'id' => '6762f2d81bb69f9f2193bc54', + ]), + ], + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$skipNotifications:** `?bool` — Option to disable notifications when a Ticket is created. + +
+
+
+
+ + +
+
+
+ +
$client->tickets->get($request) -> ?Ticket +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single ticket. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->tickets->get( + new FindTicketRequest([ + 'ticketId' => 'ticket_id', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$ticketId:** `string` — The unique identifier for the ticket which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
$client->tickets->update($request) -> ?Ticket +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can update a ticket. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->tickets->update( + new UpdateTicketRequest([ + 'ticketId' => 'ticket_id', + 'ticketAttributes' => [ + '_default_title_' => "example", + '_default_description_' => "there is a problem", + ], + 'ticketStateId' => '123', + 'open' => true, + 'snoozedUntil' => 1673609604, + 'adminId' => 991268011, + 'assigneeId' => '123', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$ticketId:** `string` — The unique identifier for the ticket which is given by Intercom + +
+
+ +
+
+ +**$ticketAttributes:** `?array` — The attributes set on the ticket. + +
+
+ +
+
+ +**$ticketStateId:** `?string` — The ID of the ticket state associated with the ticket type. + +
+
+ +
+
+ +**$companyId:** `?string` — The ID of the company that the ticket is associated with. The unique identifier for the company which is given by Intercom. Set to nil to remove company. + +
+
+ +
+
+ +**$open:** `?bool` — Specify if a ticket is open. Set to false to close a ticket. Closing a ticket will also unsnooze it. + +
+
+ +
+
+ +**$isShared:** `?bool` — Specify whether the ticket is visible to users. + +
+
+ +
+
+ +**$snoozedUntil:** `?int` — The time you want the ticket to reopen. + +
+
+ +
+
+ +**$adminId:** `?int` — The ID of the admin performing ticket update. Needed for workflows execution and attributing actions to specific admins. + +
+
+ +
+
+ +**$assigneeId:** `?string` — The ID of the admin or team to which the ticket is assigned. Set this 0 to unassign it. + +
+
+
+
+ + +
+
+
+ +
$client->tickets->deleteTicket($request) -> DeleteTicketResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can delete a ticket using the Intercom provided ID. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->tickets->deleteTicket( + new DeleteTicketRequest([ + 'ticketId' => 'ticket_id', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$ticketId:** `string` — The unique identifier for the ticket which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
$client->tickets->search($request) -> TicketList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can search for multiple tickets by the value of their attributes in order to fetch exactly which ones you want. + +To search for tickets, you send a `POST` request to `https://api.intercom.io/tickets/search`. + +This will accept a query object in the body which will define your filters. +{% admonition type="warning" name="Optimizing search queries" %} + Search queries can be complex, so optimizing them can help the performance of your search. + Use the `AND` and `OR` operators to combine multiple filters to get the exact results you need and utilize + pagination to limit the number of results returned. The default is `20` results per page. + See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#example-search-conversations-request) for more details on how to use the `starting_after` param. +{% /admonition %} + +### Nesting & Limitations + +You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). +There are some limitations to the amount of multiples there can be: +- There's a limit of max 2 nested filters +- There's a limit of max 15 filters for each AND or OR group + +### Accepted Fields + +Most keys listed as part of the Ticket model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as `created_at` accepts a date, the `value` cannot be a string such as `"foobar"`). +The `source.body` field is unique as the search will not be performed against the entire value, but instead against every element of the value separately. For example, when searching for a conversation with a `"I need support"` body - the query should contain a `=` operator with the value `"support"` for such conversation to be returned. A query with a `=` operator and a `"need support"` value will not yield a result. + +| Field | Type | +| :---------------------------------------- | :--------------------------------------------------------------------------------------- | +| id | String | +| created_at | Date (UNIX timestamp) | +| updated_at | Date (UNIX timestamp) | +| title | String | +| description | String | +| category | String | +| ticket_type_id | String | +| contact_ids | String | +| teammate_ids | String | +| admin_assignee_id | String | +| team_assignee_id | String | +| open | Boolean | +| state | String | +| snoozed_until | Date (UNIX timestamp) | +| ticket_attribute.{id} | String or Boolean or Date (UNIX timestamp) or Float or Integer | + +{% admonition type="info" name="Searching by Category" %} +When searching for tickets by the **`category`** field, specific terms must be used instead of the category names: +* For **Customer** category tickets, use the term `request`. +* For **Back-office** category tickets, use the term `task`. +* For **Tracker** category tickets, use the term `tracker`. +{% /admonition %} + +### Accepted Operators + +{% admonition type="info" name="Searching based on `created_at`" %} + You may use the `<=` or `>=` operators to search by `created_at`. +{% /admonition %} + +The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string (`"="`). The operator has to be compatible with the field's type (eg. you cannot search with `>` for a given string value as it's only compatible for integer's and dates). + +| Operator | Valid Types | Description | +| :------- | :----------------------------- | :----------------------------------------------------------- | +| = | All | Equals | +| != | All | Doesn't Equal | +| IN | All | In Shortcut for `OR` queries Values most be in Array | +| NIN | All | Not In Shortcut for `OR !` queries Values must be in Array | +| > | Integer Date (UNIX Timestamp) | Greater (or equal) than | +| < | Integer Date (UNIX Timestamp) | Lower (or equal) than | +| ~ | String | Contains | +| !~ | String | Doesn't Contain | +| ^ | String | Starts With | +| $ | String | Ends With | +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->tickets->searchTickets( + new SearchRequest([ + 'query' => new SingleFilterSearchRequest([]), + 'pagination' => new StartingAfterPaging([ + 'perPage' => 5, + ]), + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$request:** `SearchRequest` + +
+
+
+
+ + +
+
+
+ +## Visitors +
$client->visitors->find($request) -> ?Visitor +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single visitor. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->visitors->find( + new FindVisitorRequest([ + 'userId' => 'user_id', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$userId:** `string` — The user_id of the Visitor you want to retrieve. + +
+
+
+
+ + +
+
+
+ +
$client->visitors->update($request) -> ?Visitor +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Sending a PUT request to `/visitors` will result in an update of an existing Visitor. + +**Option 1.** You can update a visitor by passing in the `user_id` of the visitor in the Request body. + +**Option 2.** You can update a visitor by passing in the `id` of the visitor in the Request body. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->visitors->update( + new UpdateVisitorRequestWithId([ + 'id' => '6762f30c1bb69f9f2193bc5e', + 'name' => 'Gareth Bale', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$request:** `UpdateVisitorRequestWithId|UpdateVisitorRequestWithUserId` + +
+
+
+
+ + +
+
+
+ +
$client->visitors->mergeToContact($request) -> Contact +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can merge a Visitor to a Contact of role type `lead` or `user`. + +> 📘 What happens upon a visitor being converted? +> +> If the User exists, then the Visitor will be merged into it, the Visitor deleted and the User returned. If the User does not exist, the Visitor will be converted to a User, with the User identifiers replacing it's Visitor identifiers. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->visitors->convertVisitor( + new ConvertVisitorRequest([ + 'type' => 'user', + 'user' => [ + 'id' => "8a88a590-e1c3-41e2-a502-e0649dbf721c", + 'email' => "foo@bar.com", + ], + 'visitor' => [ + 'user_id' => "3ecf64d0-9ed1-4e9f-88e1-da7d6e6782f3", + ], + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$type:** `string` — Represents the role of the Contact model. Accepts `lead` or `user`. + +
+
+ +
+
+ +**$user:** `UserWithId|UserWithUserId` — The unique identifiers retained after converting or merging. + +
+
+ +
+
+ +**$visitor:** `VisitorWithId|VisitorWithUserId|VisitorWithEmail` — The unique identifiers to convert a single Visitor. + +
+
+
+
+ + +
+
+
+ +## HelpCenters Collections +
$client->helpCenters->collections->list($request) -> CollectionList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all collections by making a GET request to `https://api.intercom.io/help_center/collections`. + +Collections will be returned in descending order on the `updated_at` attribute. This means if you need to iterate through results then we'll show the most recently updated collections first. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->helpCenters->collections->list( + new ListCollectionsRequest([]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$page:** `?int` — The page of results to fetch. Defaults to first page + +
+
+ +
+
+ +**$perPage:** `?int` — How many results to display per page. Defaults to 15 + +
+
+
+
+ + +
+
+
+ +
$client->helpCenters->collections->create($request) -> Collection +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a new collection by making a POST request to `https://api.intercom.io/help_center/collections.` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->helpCenters->collections->create( + new CreateCollectionRequest([ + 'name' => 'Thanks for everything', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$name:** `string` — The name of the collection. For multilingual collections, this will be the name of the default language's content. + +
+
+ +
+
+ +**$description:** `?string` — The description of the collection. For multilingual collections, this will be the description of the default language's content. + +
+
+ +
+
+ +**$translatedContent:** `?GroupTranslatedContent` + +
+
+ +
+
+ +**$parentId:** `?string` — The id of the parent collection. If `null` then it will be created as the first level collection. + +
+
+ +
+
+ +**$helpCenterId:** `?int` — The id of the help center where the collection will be created. If `null` then it will be created in the default help center. + +
+
+
+
+ + +
+
+
+ +
$client->helpCenters->collections->find($request) -> Collection +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single collection by making a GET request to `https://api.intercom.io/help_center/collections/`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->helpCenters->collections->find( + new FindCollectionRequest([ + 'collectionId' => 1, + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$collectionId:** `int` — The unique identifier for the collection which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
$client->helpCenters->collections->update($request) -> Collection +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can update the details of a single collection by making a PUT request to `https://api.intercom.io/collections/`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->helpCenters->collections->update( + new UpdateCollectionRequest([ + 'collectionId' => 1, + 'name' => 'Update collection name', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$collectionId:** `int` — The unique identifier for the collection which is given by Intercom. + +
+
+ +
+
+ +**$name:** `?string` — The name of the collection. For multilingual collections, this will be the name of the default language's content. + +
+
+ +
+
+ +**$description:** `?string` — The description of the collection. For multilingual collections, this will be the description of the default language's content. + +
+
+ +
+
+ +**$translatedContent:** `?GroupTranslatedContent` + +
+
+ +
+
+ +**$parentId:** `?string` — The id of the parent collection. If `null` then it will be updated as the first level collection. + +
+
+
+
+ + +
+
+
+ +
$client->helpCenters->collections->delete($request) -> DeletedCollectionObject +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can delete a single collection by making a DELETE request to `https://api.intercom.io/collections/`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->helpCenters->collections->delete( + new DeleteCollectionRequest([ + 'collectionId' => 1, + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$collectionId:** `int` — The unique identifier for the collection which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +## News Items +
$client->news->items->list() -> PaginatedResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all news items +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->news->items->list(); +``` +
+
+
+
+ + +
+
+
+ +
$client->news->items->create($request) -> NewsItem +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a news item +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->news->items->create( + new NewsItemRequest([ + 'title' => 'Halloween is here!', + 'body' => '

New costumes in store for this spooky season

', + 'senderId' => 991267834, + 'state' => NewsItemRequestState::Live->value, + 'deliverSilently' => true, + 'labels' => [ + 'Product', + 'Update', + 'New', + ], + 'reactions' => [ + '😆', + '😅', + ], + 'newsfeedAssignments' => [ + new NewsfeedAssignment([ + 'newsfeedId' => 53, + 'publishedAt' => 1664638214, + ]), + ], + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$request:** `NewsItemRequest` + +
+
+
+
+ + +
+
+
+ +
$client->news->items->find($request) -> NewsItem +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single news item. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->news->items->find( + new FindNewsItemRequest([ + 'newsItemId' => 1, + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$newsItemId:** `int` — The unique identifier for the news item which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
$client->news->items->update($request) -> NewsItem +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->news->items->update( + new UpdateNewsItemRequest([ + 'newsItemId' => 1, + 'body' => new NewsItemRequest([ + 'title' => 'Christmas is here!', + 'body' => '

New gifts in store for the jolly season

', + 'senderId' => 991267845, + 'reactions' => [ + '😝', + '😂', + ], + ]), + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$newsItemId:** `int` — The unique identifier for the news item which is given by Intercom. + +
+
+ +
+
+ +**$request:** `NewsItemRequest` + +
+
+
+
+ + +
+
+
+ +
$client->news->items->delete($request) -> DeletedObject +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can delete a single news item. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->news->items->delete( + new DeleteNewsItemRequest([ + 'newsItemId' => 1, + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$newsItemId:** `int` — The unique identifier for the news item which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +## News Feeds +
$client->news->feeds->listItems($request) -> PaginatedResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all news items that are live on a given newsfeed +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->news->feeds->listItems( + new ListNewsFeedItemsRequest([ + 'newsfeedId' => '123', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$newsfeedId:** `string` — The unique identifier for the news feed item which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
$client->news->feeds->list() -> PaginatedResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all newsfeeds +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->news->feeds->list(); +``` +
+
+
+
+ + +
+
+
+ +
$client->news->feeds->find($request) -> Newsfeed +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single newsfeed +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->news->feeds->find( + new FindNewsFeedRequest([ + 'newsfeedId' => '123', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$newsfeedId:** `string` — The unique identifier for the news feed item which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +## TicketTypes Attributes +
$client->ticketTypes->attributes->create($request) -> ?TicketTypeAttribute +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a new attribute for a ticket type. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->ticketTypes->attributes->create( + new CreateTicketTypeAttributeRequest([ + 'ticketTypeId' => 'ticket_type_id', + 'name' => 'Attribute Title', + 'description' => 'Attribute Description', + 'dataType' => CreateTicketTypeAttributeRequestDataType::String->value, + 'requiredToCreate' => false, + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$ticketTypeId:** `string` — The unique identifier for the ticket type which is given by Intercom. + +
+
+ +
+
+ +**$name:** `string` — The name of the ticket type attribute + +
+
+ +
+
+ +**$description:** `string` — The description of the attribute presented to the teammate or contact + +
+
+ +
+
+ +**$dataType:** `string` — The data type of the attribute + +
+
+ +
+
+ +**$requiredToCreate:** `?bool` — Whether the attribute is required to be filled in when teammates are creating the ticket in Inbox. + +
+
+ +
+
+ +**$requiredToCreateForContacts:** `?bool` — Whether the attribute is required to be filled in when contacts are creating the ticket in Messenger. + +
+
+ +
+
+ +**$visibleOnCreate:** `?bool` — Whether the attribute is visible to teammates when creating a ticket in Inbox. + +
+
+ +
+
+ +**$visibleToContacts:** `?bool` — Whether the attribute is visible to contacts when creating a ticket in Messenger. + +
+
+ +
+
+ +**$multiline:** `?bool` — Whether the attribute allows multiple lines of text (only applicable to string attributes) + +
+
+ +
+
+ +**$listItems:** `?string` — A comma delimited list of items for the attribute value (only applicable to list attributes) + +
+
+ +
+
+ +**$allowMultipleValues:** `?bool` — Whether the attribute allows multiple files to be attached to it (only applicable to file attributes) + +
+
+
+
+ + +
+
+
+ +
$client->ticketTypes->attributes->update($request) -> ?TicketTypeAttribute +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can update an existing attribute for a ticket type. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->ticketTypes->attributes->update( + new UpdateTicketTypeAttributeRequest([ + 'ticketTypeId' => 'ticket_type_id', + 'attributeId' => 'attribute_id', + 'description' => 'New Attribute Description', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$ticketTypeId:** `string` — The unique identifier for the ticket type which is given by Intercom. + +
+
+ +
+
+ +**$attributeId:** `string` — The unique identifier for the ticket type attribute which is given by Intercom. + +
+
+ +
+
+ +**$name:** `?string` — The name of the ticket type attribute + +
+
+ +
+
+ +**$description:** `?string` — The description of the attribute presented to the teammate or contact + +
+
+ +
+
+ +**$requiredToCreate:** `?bool` — Whether the attribute is required to be filled in when teammates are creating the ticket in Inbox. + +
+
+ +
+
+ +**$requiredToCreateForContacts:** `?bool` — Whether the attribute is required to be filled in when contacts are creating the ticket in Messenger. + +
+
+ +
+
+ +**$visibleOnCreate:** `?bool` — Whether the attribute is visible to teammates when creating a ticket in Inbox. + +
+
+ +
+
+ +**$visibleToContacts:** `?bool` — Whether the attribute is visible to contacts when creating a ticket in Messenger. + +
+
+ +
+
+ +**$multiline:** `?bool` — Whether the attribute allows multiple lines of text (only applicable to string attributes) + +
+
+ +
+
+ +**$listItems:** `?string` — A comma delimited list of items for the attribute value (only applicable to list attributes) + +
+
+ +
+
+ +**$allowMultipleValues:** `?bool` — Whether the attribute allows multiple files to be attached to it (only applicable to file attributes) + +
+
+ +
+
+ +**$archived:** `?bool` — Whether the attribute should be archived and not shown during creation of the ticket (it will still be present on previously created tickets) + +
+
+
+
+ + +
+
+
+ +## Admins +
$client->unstable->admins->identifyAdmin() -> ?AdminWithApp +
+
+ +#### 📝 Description + +
+
+ +
+
+ + +You can view the currently authorised admin along with the embedded app object (a "workspace" in legacy terminology). + +> 🚧 Single Sign On +> +> If you are building a custom "Log in with Intercom" flow for your site, and you call the `/me` endpoint to identify the logged-in user, you should not accept any sign-ins from users with unverified email addresses as it poses a potential impersonation security risk. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->admins->identify(); +``` +
+
+
+
+ + +
+
+
+ +
$client->unstable->admins->setAwayAdmin($request) -> ?Admin +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can set an Admin as away for the Inbox. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->admins->setAwayAdmin( + new SetAwayAdminRequest([ + 'id' => 1, + 'awayModeEnabled' => true, + 'awayModeReassign' => true, + 'awayStatusReasonId' => 12345, + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `int` — The unique identifier of a given admin + +
+
+ +
+
+ +**$awayModeEnabled:** `bool` — Set to "true" to change the status of the admin to away. + +
+
+ +
+
+ +**$awayModeReassign:** `bool` — Set to "true" to assign any new conversation replies to your default inbox. + +
+
+ +
+
+ +**$awayStatusReasonId:** `?int` — The unique identifier of the away status reason + +
+
+
+
+ + +
+
+
+ +
$client->unstable->admins->listActivityLogs($request) -> ActivityLogList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can get a log of activities by all admins in an app. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->admins->listAllActivityLogs( + new ListAllActivityLogsRequest([ + 'createdAtAfter' => '1677253093', + 'createdAtBefore' => '1677861493', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$createdAtAfter:** `string` — The start date that you request data for. It must be formatted as a UNIX timestamp. + +
+
+ +
+
+ +**$createdAtBefore:** `?string` — The end date that you request data for. It must be formatted as a UNIX timestamp. + +
+
+
+
+ + +
+
+
+ +
$client->unstable->admins->listAdmins() -> AdminList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of admins for a given workspace. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->admins->list(); +``` +
+
+
+
+ + +
+
+
+ +
$client->unstable->admins->retrieveAdmin($request) -> ?Admin +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can retrieve the details of a single admin. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->admins->retrieveAdmin( + new RetrieveAdminRequest([ + 'id' => 1, + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `int` — The unique identifier of a given admin + +
+
+
+
+ + +
+
+
+ +## AI Content +
$client->unstable->aiContent->listContentImportSources() -> ContentImportSourcesList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can retrieve a list of all content import sources for a workspace. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->aiContent->listContentImportSources(); +``` +
+
+
+
+ + +
+
+
+ +
$client->unstable->aiContent->createContentImportSource($request) -> ContentImportSource +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a new content import source by sending a POST request to this endpoint. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->aiContent->createContentImportSource( + new CreateContentImportSourceRequest([ + 'syncBehavior' => 'api', + 'url' => 'https://www.example.com', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$syncBehavior:** `string` — If you intend to create or update External Pages via the API, this should be set to `api`. + +
+
+ +
+
+ +**$status:** `?string` — The status of the content import source. + +
+
+ +
+
+ +**$url:** `string` — The URL of the content import source. + +
+
+
+
+ + +
+
+
+ +
$client->unstable->aiContent->getContentImportSource($request) -> ContentImportSource +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->aiContent->getContentImportSource( + new GetContentImportSourceRequest([ + 'id' => 'id', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `string` — The unique identifier for the content import source which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
$client->unstable->aiContent->updateContentImportSource($request) -> ContentImportSource +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can update an existing content import source. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->aiContent->updateContentImportSource( + new UpdateContentImportSourceRequest([ + 'id' => 'id', + 'syncBehavior' => UpdateContentImportSourceRequestSyncBehavior::Api->value, + 'url' => 'https://www.example.com', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `string` — The unique identifier for the content import source which is given by Intercom. + +
+
+ +
+
+ +**$syncBehavior:** `string` — If you intend to create or update External Pages via the API, this should be set to `api`. You can not change the value to or from api. + +
+
+ +
+
+ +**$status:** `?string` — The status of the content import source. + +
+
+ +
+
+ +**$url:** `string` — The URL of the content import source. This may only be different from the existing value if the sync behavior is API. + +
+
+
+
+ + +
+
+
+ +
$client->unstable->aiContent->deleteContentImportSource($request) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can delete a content import source by making a DELETE request this endpoint. This will also delete all external pages that were imported from this source. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->aiContent->deleteContentImportSource( + new DeleteContentImportSourceRequest([ + 'id' => 'id', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `string` — The unique identifier for the content import source which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
$client->unstable->aiContent->listExternalPages() -> ExternalPagesList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can retrieve a list of all external pages for a workspace. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->aiContent->listExternalPages(); +``` +
+
+
+
+ + +
+
+
+ +
$client->unstable->aiContent->createExternalPage($request) -> ExternalPage +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a new external page by sending a POST request to this endpoint. If an external page already exists with the specified source_id and external_id, it will be updated instead. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->aiContent->createExternalPage( + new CreateExternalPageRequest([ + 'title' => 'Test', + 'html' => '

Test

', + 'url' => 'https://www.example.com', + 'locale' => 'en', + 'sourceId' => 44, + 'externalId' => 'abc1234', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$title:** `string` — The title of the external page. + +
+
+ +
+
+ +**$html:** `string` — The body of the external page in HTML. + +
+
+ +
+
+ +**$url:** `?string` — The URL of the external page. This will be used by Fin to link end users to the page it based its answer on. When a URL is not present, Fin will not reference the source. + +
+
+ +
+
+ +**$aiAgentAvailability:** `?bool` — Whether the external page should be used to answer questions by AI Agent. Will not default when updating an existing external page. + +
+
+ +
+
+ +**$aiCopilotAvailability:** `?bool` — Whether the external page should be used to answer questions by AI Copilot. Will not default when updating an existing external page. + +
+
+ +
+
+ +**$locale:** `string` — Always en + +
+
+ +
+
+ +**$sourceId:** `int` — The unique identifier for the source of the external page which was given by Intercom. Every external page must be associated with a Content Import Source which represents the place it comes from and from which it inherits a default audience (configured in the UI). For a new source, make a POST request to the Content Import Source endpoint and an ID for the source will be returned in the response. + +
+
+ +
+
+ +**$externalId:** `string` — The identifier for the external page which was given by the source. Must be unique for the source. + +
+
+
+
+ + +
+
+
+ +
$client->unstable->aiContent->getExternalPage($request) -> ExternalPage +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can retrieve an external page. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->aiContent->getExternalPage( + new GetExternalPageRequest([ + 'id' => 'id', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `string` — The unique identifier for the external page which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
$client->unstable->aiContent->updateExternalPage($request) -> ExternalPage +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can update an existing external page (if it was created via the API). +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->aiContent->updateExternalPage( + new UpdateExternalPageRequest([ + 'id' => 'id', + 'title' => 'Test', + 'html' => '

Test

', + 'url' => 'https://www.example.com', + 'locale' => 'en', + 'sourceId' => 47, + 'externalId' => '5678', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `string` — The unique identifier for the external page which is given by Intercom. + +
+
+ +
+
+ +**$title:** `string` — The title of the external page. + +
+
+ +
+
+ +**$html:** `string` — The body of the external page in HTML. + +
+
+ +
+
+ +**$url:** `string` — The URL of the external page. This will be used by Fin to link end users to the page it based its answer on. + +
+
+ +
+
+ +**$finAvailability:** `?bool` — Whether the external page should be used to answer questions by Fin. + +
+
+ +
+
+ +**$locale:** `string` — Always en + +
+
+ +
+
+ +**$sourceId:** `int` — The unique identifier for the source of the external page which was given by Intercom. Every external page must be associated with a Content Import Source which represents the place it comes from and from which it inherits a default audience (configured in the UI). For a new source, make a POST request to the Content Import Source endpoint and an ID for the source will be returned in the response. + +
+
+ +
+
+ +**$externalId:** `?string` — The identifier for the external page which was given by the source. Must be unique for the source. + +
+
+
+
+ + +
+
+
+ +
$client->unstable->aiContent->deleteExternalPage($request) -> ExternalPage +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Sending a DELETE request for an external page will remove it from the content library UI and from being used for AI answers. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->aiContent->deleteExternalPage( + new DeleteExternalPageRequest([ + 'id' => 'id', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `string` — The unique identifier for the external page which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +## Articles +
$client->unstable->articles->listArticles() -> ArticleList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all articles by making a GET request to `https://api.intercom.io/articles`. + +> 📘 How are the articles sorted and ordered? +> +> Articles will be returned in descending order on the `updated_at` attribute. This means if you need to iterate through results then we'll show the most recently updated articles first. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->articles->list( + new ListArticlesRequest([]), +); +``` +
+
+
+
+ + +
+
+
+ +
$client->unstable->articles->createArticle($request) -> Article +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a new article by making a POST request to `https://api.intercom.io/articles`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->articles->createArticle( + [ + 'key' => "value", + ], +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$request:** `mixed` + +
+
+
+
+ + +
+
+
+ +
$client->unstable->articles->retrieveArticle($request) -> Article +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single article by making a GET request to `https://api.intercom.io/articles/`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->articles->retrieveArticle( + new RetrieveArticleRequest([ + 'id' => 1, + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `int` — The unique identifier for the article which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
$client->unstable->articles->deleteArticle($request) -> DeletedArticleObject +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can delete a single article by making a DELETE request to `https://api.intercom.io/articles/`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->articles->deleteArticle( + new DeleteArticleRequest([ + 'id' => 1, + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `int` — The unique identifier for the article which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
$client->unstable->articles->searchArticles($request) -> ArticleSearchResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can search for articles by making a GET request to `https://api.intercom.io/articles/search`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->articles->search( + new SearchArticlesRequest([ + 'phrase' => 'Getting started', + 'state' => 'published', + 'helpCenterId' => 1, + 'highlight' => true, + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$phrase:** `?string` — The phrase within your articles to search for. + +
+
+ +
+
+ +**$state:** `?string` — The state of the Articles returned. One of `published`, `draft` or `all`. + +
+
+ +
+
+ +**$helpCenterId:** `?int` — The ID of the Help Center to search in. + +
+
+ +
+
+ +**$highlight:** `?bool` — Return a highlighted version of the matching content within your articles. Refer to the response schema for more details. + +
+
+
+
+ + +
+
+
+ +## Away Status Reasons +
$client->unstable->awayStatusReasons->listAwayStatusReasons() -> array +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Returns a list of all away status reasons configured for the workspace, including deleted ones. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->awayStatusReasons->listAwayStatusReasons(); +``` +
+
+
+
+ + +
+
+
+ +## Unstable Export +
$client->unstable->export->enqueueANewReportingDataExportJob($request) -> PostExportReportingDataEnqueueResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->export->enqueueANewReportingDataExportJob( + new PostExportReportingDataEnqueueRequest([ + 'datasetId' => 'conversation', + 'attributeIds' => [ + 'conversation_id', + 'conversation_started_at', + ], + 'startTime' => 1717490000, + 'endTime' => 1717510000, + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$datasetId:** `string` + +
+
+ +
+
+ +**$attributeIds:** `array` + +
+
+ +
+
+ +**$startTime:** `int` + +
+
+ +
+
+ +**$endTime:** `int` + +
+
+
+
+ + +
+
+
+ +
$client->unstable->export->listAvailableDatasetsAndAttributes() -> GetExportReportingDataGetDatasetsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->export->listAvailableDatasetsAndAttributes(); +``` +
+
+
+
+ + +
+
+
+ +## Help Center +
$client->unstable->helpCenter->listAllCollections() -> CollectionList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all collections by making a GET request to `https://api.intercom.io/help_center/collections`. + +Collections will be returned in descending order on the `updated_at` attribute. This means if you need to iterate through results then we'll show the most recently updated collections first. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->helpCenters->collections->list( + new ListCollectionsRequest([]), +); +``` +
+
+
+
+ + +
+
+
+ +
$client->unstable->helpCenter->createCollection($request) -> Collection +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a new collection by making a POST request to `https://api.intercom.io/help_center/collections.` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->helpCenters->collections->create( + new CreateCollectionRequest([ + 'name' => 'Thanks for everything', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$name:** `string` — The name of the collection. For multilingual collections, this will be the name of the default language's content. + +
+
+ +
+
+ +**$description:** `?string` — The description of the collection. For multilingual collections, this will be the description of the default language's content. + +
+
+ +
+
+ +**$translatedContent:** `?GroupTranslatedContent` + +
+
+ +
+
+ +**$parentId:** `?string` — The id of the parent collection. If `null` then it will be created as the first level collection. + +
+
+ +
+
+ +**$helpCenterId:** `?int` — The id of the help center where the collection will be created. If `null` then it will be created in the default help center. + +
+
+
+
+ + +
+
+
+ +
$client->unstable->helpCenter->retrieveCollection($request) -> Collection +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single collection by making a GET request to `https://api.intercom.io/help_center/collections/`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->helpCenter->retrieveCollection( + new RetrieveCollectionRequest([ + 'id' => 1, + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `int` — The unique identifier for the collection which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
$client->unstable->helpCenter->updateCollection($request) -> Collection +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can update the details of a single collection by making a PUT request to `https://api.intercom.io/collections/`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->helpCenter->updateCollection( + new UpdateCollectionRequest([ + 'id' => 1, + 'name' => 'Update collection name', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `int` — The unique identifier for the collection which is given by Intercom. + +
+
+ +
+
+ +**$name:** `?string` — The name of the collection. For multilingual collections, this will be the name of the default language's content. + +
+
+ +
+
+ +**$description:** `?string` — The description of the collection. For multilingual collections, this will be the description of the default language's content. + +
+
+ +
+
+ +**$translatedContent:** `?GroupTranslatedContent` + +
+
+ +
+
+ +**$parentId:** `?string` — The id of the parent collection. If `null` then it will be updated as the first level collection. + +
+
+
+
+ + +
+
+
+ +
$client->unstable->helpCenter->deleteCollection($request) -> DeletedCollectionObject +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can delete a single collection by making a DELETE request to `https://api.intercom.io/collections/`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->helpCenter->deleteCollection( + new DeleteCollectionRequest([ + 'id' => 1, + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `int` — The unique identifier for the collection which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
$client->unstable->helpCenter->retrieveHelpCenter($request) -> HelpCenter +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single Help Center by making a GET request to `https://api.intercom.io/help_center/help_center/`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->helpCenter->retrieveHelpCenter( + new RetrieveHelpCenterRequest([ + 'id' => 1, + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `int` — The unique identifier for the collection which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
$client->unstable->helpCenter->listHelpCenters() -> HelpCenterList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can list all Help Centers by making a GET request to `https://api.intercom.io/help_center/help_centers`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->helpCenters->list( + new ListHelpCentersRequest([]), +); +``` +
+
+
+
+ + +
+
+
+ +## Internal Articles +
$client->unstable->internalArticles->listInternalArticles() -> InternalArticleList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all internal articles by making a GET request to `https://api.intercom.io/internal_articles`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->internalArticles->listInternalArticles(); +``` +
+
+
+
+ + +
+
+
+ +
$client->unstable->internalArticles->createInternalArticle($request) -> InternalArticleListItem +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a new internal article by making a POST request to `https://api.intercom.io/internal_articles`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->internalArticles->createInternalArticle( + new CreateInternalArticleRequest([ + 'title' => 'Thanks for everything', + 'body' => 'Body of the Article', + 'authorId' => 991266252, + 'ownerId' => 991266252, + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$request:** `?CreateInternalArticleRequest` + +
+
+
+
+ + +
+
+
+ +
$client->unstable->internalArticles->retrieveInternalArticle($request) -> InternalArticleListItem +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single internal article by making a GET request to `https://api.intercom.io/internal_articles/`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->internalArticles->retrieveInternalArticle( + new RetrieveInternalArticleRequest([ + 'id' => 1, + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `int` — The unique identifier for the article which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
$client->unstable->internalArticles->updateInternalArticle($request) -> InternalArticleListItem +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can update the details of a single internal article by making a PUT request to `https://api.intercom.io/internal_articles/`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->internalArticles->updateInternalArticle( + new UpdateInternalArticleRequestBody([ + 'id' => 1, + 'title' => 'Christmas is here!', + 'body' => '

New gifts in store for the jolly season

', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `int` — The unique identifier for the internal article which is given by Intercom. + +
+
+ +
+
+ +**$title:** `?string` — The title of the article. + +
+
+ +
+
+ +**$body:** `?string` — The content of the article. + +
+
+ +
+
+ +**$authorId:** `?int` — The id of the author of the article. + +
+
+ +
+
+ +**$ownerId:** `?int` — The id of the author of the article. + +
+
+
+
+ + +
+
+
+ +
$client->unstable->internalArticles->deleteInternalArticle($request) -> DeletedInternalArticleObject +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can delete a single internal article by making a DELETE request to `https://api.intercom.io/internal_articles/`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->internalArticles->deleteInternalArticle( + new DeleteInternalArticleRequest([ + 'id' => 1, + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `int` — The unique identifier for the internal article which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
$client->unstable->internalArticles->searchInternalArticles($request) -> InternalArticleSearchResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can search for internal articles by making a GET request to `https://api.intercom.io/internal_articles/search`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->internalArticles->searchInternalArticles( + new SearchInternalArticlesRequest([ + 'folderId' => 'folder_id', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$folderId:** `?string` — The ID of the folder to search in. + +
+
+
+
+ + +
+
+
+ +## Companies +
$client->unstable->companies->retrieveCompany($request) -> CompanyList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a single company by passing in `company_id` or `name`. + + `https://api.intercom.io/companies?name={name}` + + `https://api.intercom.io/companies?company_id={company_id}` + +You can fetch all companies and filter by `segment_id` or `tag_id` as a query parameter. + + `https://api.intercom.io/companies?tag_id={tag_id}` + + `https://api.intercom.io/companies?segment_id={segment_id}` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->companies->retrieve( + new RetrieveCompanyRequest([ + 'name' => 'my company', + 'companyId' => '12345', + 'tagId' => '678910', + 'segmentId' => '98765', + 'page' => 1, + 'perPage' => 1, + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$name:** `?string` — The `name` of the company to filter by. + +
+
+ +
+
+ +**$companyId:** `?string` — The `company_id` of the company to filter by. + +
+
+ +
+
+ +**$tagId:** `?string` — The `tag_id` of the company to filter by. + +
+
+ +
+
+ +**$segmentId:** `?string` — The `segment_id` of the company to filter by. + +
+
+ +
+
+ +**$page:** `?int` — The page of results to fetch. Defaults to first page + +
+
+ +
+
+ +**$perPage:** `?int` — How many results to display per page. Defaults to 15 + +
+
+
+
+ + +
+
+
+ +
$client->unstable->companies->createOrUpdateCompany($request) -> Company +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create or update a company. + +Companies will be only visible in Intercom when there is at least one associated user. + +Companies are looked up via `company_id` in a `POST` request, if not found via `company_id`, the new company will be created, if found, that company will be updated. + +{% admonition type="warning" name="Using `company_id`" %} + You can set a unique `company_id` value when creating a company. However, it is not possible to update `company_id`. Be sure to set a unique value once upon creation of the company. +{% /admonition %} +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->companies->createOrUpdateCompany( + [ + 'key' => "value", + ], +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$request:** `mixed` + +
+
+
+
+ + +
+
+
+ +
$client->unstable->companies->retrieveACompanyById($request) -> Company +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a single company. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->companies->retrieveACompanyById( + new RetrieveACompanyByIdRequest([ + 'id' => '5f4d3c1c-7b1b-4d7d-a97e-6095715c6632', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `string` — The unique identifier for the company which is given by Intercom + +
+
+
+
+ + +
+
+
+ +
$client->unstable->companies->updateCompany($request) -> Company +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can update a single company using the Intercom provisioned `id`. + +{% admonition type="warning" name="Using `company_id`" %} + When updating a company it is not possible to update `company_id`. This can only be set once upon creation of the company. +{% /admonition %} +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->companies->updateCompany( + new UpdateCompanyRequest([ + 'id' => '5f4d3c1c-7b1b-4d7d-a97e-6095715c6632', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `string` — The unique identifier for the company which is given by Intercom + +
+
+
+
+ + +
+
+
+ +
$client->unstable->companies->deleteCompany($request) -> DeletedCompanyObject +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can delete a single company. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->companies->deleteCompany( + new DeleteCompanyRequest([ + 'id' => '5f4d3c1c-7b1b-4d7d-a97e-6095715c6632', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `string` — The unique identifier for the company which is given by Intercom + +
+
+
+
+ + +
+
+
+ +
$client->unstable->companies->listAttachedContacts($request) -> CompanyAttachedContacts +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all contacts that belong to a company. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->companies->listAttachedContacts( + new ListAttachedContactsRequest([ + 'id' => '5f4d3c1c-7b1b-4d7d-a97e-6095715c6632', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `string` — The unique identifier for the company which is given by Intercom + +
+
+
+
+ + +
+
+
+ +
$client->unstable->companies->listAttachedSegmentsForCompanies($request) -> CompanyAttachedSegments +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all segments that belong to a company. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->companies->listAttachedSegmentsForCompanies( + new ListAttachedSegmentsForCompaniesRequest([ + 'id' => '5f4d3c1c-7b1b-4d7d-a97e-6095715c6632', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `string` — The unique identifier for the company which is given by Intercom + +
+
+
+
+ + +
+
+
+ +
$client->unstable->companies->listAllCompanies($request) -> CompanyList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can list companies. The company list is sorted by the `last_request_at` field and by default is ordered descending, most recently requested first. + +Note that the API does not include companies who have no associated users in list responses. + +When using the Companies endpoint and the pages object to iterate through the returned companies, there is a limit of 10,000 Companies that can be returned. If you need to list or iterate on more than 10,000 Companies, please use the [Scroll API](https://developers.intercom.com/reference#iterating-over-all-companies). +{% admonition type="warning" name="Pagination" %} + You can use pagination to limit the number of results returned. The default is `20` results per page. + See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#pagination-for-list-apis) for more details on how to use the `starting_after` param. +{% /admonition %} +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->companies->list( + new ListCompaniesRequest([ + 'page' => 1, + 'perPage' => 1, + 'order' => 'desc', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$page:** `?int` — The page of results to fetch. Defaults to first page + +
+
+ +
+
+ +**$perPage:** `?int` — How many results to return per page. Defaults to 15 + +
+
+ +
+
+ +**$order:** `?string` — `asc` or `desc`. Return the companies in ascending or descending order. Defaults to desc + +
+
+
+
+ + +
+
+
+ +
$client->unstable->companies->scrollOverAllCompanies($request) -> ?CompanyScroll +
+
+ +#### 📝 Description + +
+
+ +
+
+ + The `list all companies` functionality does not work well for huge datasets, and can result in errors and performance problems when paging deeply. The Scroll API provides an efficient mechanism for iterating over all companies in a dataset. + +- Each app can only have 1 scroll open at a time. You'll get an error message if you try to have more than one open per app. +- If the scroll isn't used for 1 minute, it expires and calls with that scroll param will fail +- If the end of the scroll is reached, "companies" will be empty and the scroll parameter will expire + +{% admonition type="info" name="Scroll Parameter" %} + You can get the first page of companies by simply sending a GET request to the scroll endpoint. + For subsequent requests you will need to use the scroll parameter from the response. +{% /admonition %} +{% admonition type="danger" name="Scroll network timeouts" %} + Since scroll is often used on large datasets network errors such as timeouts can be encountered. When this occurs you will see a HTTP 500 error with the following message: + "Request failed due to an internal network error. Please restart the scroll operation." + If this happens, you will need to restart your scroll query: It is not possible to continue from a specific point when using scroll. +{% /admonition %} +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->companies->scroll( + new ScrollCompaniesRequest([ + 'scrollParam' => 'scroll_param', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$scrollParam:** `?string` — + +
+
+
+
+ + +
+
+
+ +
$client->unstable->companies->attachContactToACompany($request) -> Company +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can attach a company to a single contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->companies->attachContactToACompany( + new AttachContactToACompanyRequest([ + 'id' => 'id', + 'companyId' => '6762f09a1bb69f9f2193bb34', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `string` — The unique identifier for the contact which is given by Intercom + +
+
+ +
+
+ +**$companyId:** `string` — The unique identifier for the company which is given by Intercom + +
+
+
+
+ + +
+
+
+ +
$client->unstable->companies->detachContactFromACompany($request) -> Company +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can detach a company from a single contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->companies->detachContactFromACompany( + new DetachContactFromACompanyRequest([ + 'contactId' => '58a430d35458202d41b1e65b', + 'id' => '58a430d35458202d41b1e65b', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$contactId:** `string` — The unique identifier for the contact which is given by Intercom + +
+
+ +
+
+ +**$id:** `string` — The unique identifier for the company which is given by Intercom + +
+
+
+
+ + +
+
+
+ +## Notes +
$client->unstable->notes->listCompanyNotes($request) -> NoteList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of notes that are associated to a company. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->notes->listCompanyNotes( + new ListCompanyNotesRequest([ + 'id' => '5f4d3c1c-7b1b-4d7d-a97e-6095715c6632', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `string` — The unique identifier for the company which is given by Intercom + +
+
+
+
+ + +
+
+
+ +
$client->unstable->notes->listNotes($request) -> NoteList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of notes that are associated to a contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->notes->listNotes( + new ListNotesRequest([ + 'id' => 1, + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `int` — The unique identifier of a contact. + +
+
+
+
+ + +
+
+
+ +
$client->unstable->notes->createNote($request) -> Note +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can add a note to a single contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->notes->createNote( + new CreateNoteRequest([ + 'id' => 1, + 'body' => 'Hello', + 'contactId' => '6762f0ad1bb69f9f2193bb62', + 'adminId' => '123', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `int` — The unique identifier of a given contact. + +
+
+ +
+
+ +**$body:** `string` — The text of the note. + +
+
+ +
+
+ +**$contactId:** `?string` — The unique identifier of a given contact. + +
+
+ +
+
+ +**$adminId:** `?string` — The unique identifier of a given admin. + +
+
+
+
+ + +
+
+
+ +
$client->unstable->notes->retrieveNote($request) -> Note +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single note. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->notes->retrieveNote( + new RetrieveNoteRequest([ + 'id' => 1, + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `int` — The unique identifier of a given note + +
+
+
+
+ + +
+
+
+ +## Contacts +
$client->unstable->contacts->listCompaniesForAContact($request) -> ContactAttachedCompanies +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of companies that are associated to a contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->contacts->listCompaniesForAContact( + new ListCompaniesForAContactRequest([ + 'id' => '63a07ddf05a32042dffac965', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `string` — The unique identifier for the contact which is given by Intercom + +
+
+
+
+ + +
+
+
+ +
$client->unstable->contacts->listSegmentsForAContact($request) -> ContactSegments +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of segments that are associated to a contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->contacts->listAttachedSegments( + new ListSegmentsAttachedToContactRequest([ + 'contactId' => '63a07ddf05a32042dffac965', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$contactId:** `string` — The unique identifier for the contact which is given by Intercom + +
+
+
+
+ + +
+
+
+ +
$client->unstable->contacts->listSubscriptionsForAContact($request) -> SubscriptionTypeList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of subscription types that are attached to a contact. These can be subscriptions that a user has 'opted-in' to or has 'opted-out' from, depending on the subscription type. +This will return a list of Subscription Type objects that the contact is associated with. + +The data property will show a combined list of: + + 1.Opt-out subscription types that the user has opted-out from. + 2.Opt-in subscription types that the user has opted-in to receiving. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->contacts->listAttachedSubscriptions( + new ListAttachedSubscriptionsRequest([ + 'contactId' => '63a07ddf05a32042dffac965', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$contactId:** `string` — The unique identifier for the contact which is given by Intercom + +
+
+
+
+ + +
+
+
+ +
$client->unstable->contacts->listTagsForAContact($request) -> TagList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all tags that are attached to a specific contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->contacts->listAttachedTags( + new ListTagsAttachedToContactRequest([ + 'contactId' => '63a07ddf05a32042dffac965', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$contactId:** `string` — The unique identifier for the contact which is given by Intercom + +
+
+
+
+ + +
+
+
+ +
$client->unstable->contacts->showContact($request) -> ShowContactResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->contacts->showContact( + new ShowContactRequest([ + 'id' => '63a07ddf05a32042dffac965', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `string` — id + +
+
+
+
+ + +
+
+
+ +
$client->unstable->contacts->updateContact($request) -> UpdateContactResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can update an existing contact (ie. user or lead). + +{% admonition type="info" %} + This endpoint handles both **contact updates** and **custom object associations**. + + See _`update a contact with an association to a custom object instance`_ in the request/response examples to see the custom object association format. +{% /admonition %} +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->contacts->updateContact( + new UpdateContactRequest([ + 'id' => '63a07ddf05a32042dffac965', + 'email' => 'joebloggs@intercom.io', + 'name' => 'joe bloggs', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `string` — id + +
+
+ +
+
+ +**$role:** `?string` — The role of the contact. + +
+
+ +
+
+ +**$externalId:** `?string` — A unique identifier for the contact which is given to Intercom + +
+
+ +
+
+ +**$email:** `?string` — The contacts email + +
+
+ +
+
+ +**$phone:** `?string` — The contacts phone + +
+
+ +
+
+ +**$name:** `?string` — The contacts name + +
+
+ +
+
+ +**$avatar:** `?string` — An image URL containing the avatar of a contact + +
+
+ +
+
+ +**$signedUpAt:** `?int` — The time specified for when a contact signed up + +
+
+ +
+
+ +**$lastSeenAt:** `?int` — The time when the contact was last seen (either where the Intercom Messenger was installed or when specified manually) + +
+
+ +
+
+ +**$ownerId:** `?int` — The id of an admin that has been assigned account ownership of the contact + +
+
+ +
+
+ +**$unsubscribedFromEmails:** `?bool` — Whether the contact is unsubscribed from emails + +
+
+ +
+
+ +**$customAttributes:** `?array` — The custom attributes which are set for the contact + +
+
+
+
+ + +
+
+
+ +
$client->unstable->contacts->deleteContact($request) -> ContactDeleted +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can delete a single contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->contacts->deleteContact( + new DeleteContactRequest([ + 'id' => 'id', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `string` — id + +
+
+
+
+ + +
+
+
+ +
$client->unstable->contacts->mergeContact($request) -> MergeContactResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can merge a contact with a `role` of `lead` into a contact with a `role` of `user`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->contacts->mergeLeadInUser( + new MergeContactsRequest([ + 'leadId' => '6762f0d51bb69f9f2193bb7f', + 'contactId' => '6762f0d51bb69f9f2193bb80', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$from:** `?string` — The unique identifier for the contact to merge away from. Must be a lead. + +
+
+ +
+
+ +**$into:** `?string` — The unique identifier for the contact to merge into. Must be a user. + +
+
+
+
+ + +
+
+
+ +
$client->unstable->contacts->searchContacts($request) -> ContactList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can search for multiple contacts by the value of their attributes in order to fetch exactly who you want. + +To search for contacts, you need to send a `POST` request to `https://api.intercom.io/contacts/search`. + +This will accept a query object in the body which will define your filters in order to search for contacts. + +{% admonition type="warning" name="Optimizing search queries" %} + Search queries can be complex, so optimizing them can help the performance of your search. + Use the `AND` and `OR` operators to combine multiple filters to get the exact results you need and utilize + pagination to limit the number of results returned. The default is `50` results per page. + See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#example-search-conversations-request) for more details on how to use the `starting_after` param. +{% /admonition %} +### Contact Creation Delay + +If a contact has recently been created, there is a possibility that it will not yet be available when searching. This means that it may not appear in the response. This delay can take a few minutes. If you need to be instantly notified it is recommended to use webhooks and iterate to see if they match your search filters. + +### Nesting & Limitations + +You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). +There are some limitations to the amount of multiple's there can be: +* There's a limit of max 2 nested filters +* There's a limit of max 15 filters for each AND or OR group + +### Searching for Timestamp Fields + +All timestamp fields (created_at, updated_at etc.) are indexed as Dates for Contact Search queries; Datetime queries are not currently supported. This means you can only query for timestamp fields by day - not hour, minute or second. +For example, if you search for all Contacts with a created_at value greater (>) than 1577869200 (the UNIX timestamp for January 1st, 2020 9:00 AM), that will be interpreted as 1577836800 (January 1st, 2020 12:00 AM). The search results will then include Contacts created from January 2nd, 2020 12:00 AM onwards. +If you'd like to get contacts created on January 1st, 2020 you should search with a created_at value equal (=) to 1577836800 (January 1st, 2020 12:00 AM). +This behaviour applies only to timestamps used in search queries. The search results will still contain the full UNIX timestamp and be sorted accordingly. + +### Accepted Fields + +Most key listed as part of the Contacts Model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as `created_at` accepts a date, the `value` cannot be a string such as `"foorbar"`). + +| Field | Type | +| ---------------------------------- | ------------------------------ | +| id | String | +| role | String
Accepts user or lead | +| name | String | +| avatar | String | +| owner_id | Integer | +| email | String | +| email_domain | String | +| phone | String | +| formatted_phone | String | +| external_id | String | +| created_at | Date (UNIX Timestamp) | +| signed_up_at | Date (UNIX Timestamp) | +| updated_at | Date (UNIX Timestamp) | +| last_seen_at | Date (UNIX Timestamp) | +| last_contacted_at | Date (UNIX Timestamp) | +| last_replied_at | Date (UNIX Timestamp) | +| last_email_opened_at | Date (UNIX Timestamp) | +| last_email_clicked_at | Date (UNIX Timestamp) | +| language_override | String | +| browser | String | +| browser_language | String | +| os | String | +| location.country | String | +| location.region | String | +| location.city | String | +| unsubscribed_from_emails | Boolean | +| marked_email_as_spam | Boolean | +| has_hard_bounced | Boolean | +| ios_last_seen_at | Date (UNIX Timestamp) | +| ios_app_version | String | +| ios_device | String | +| ios_app_device | String | +| ios_os_version | String | +| ios_app_name | String | +| ios_sdk_version | String | +| android_last_seen_at | Date (UNIX Timestamp) | +| android_app_version | String | +| android_device | String | +| android_app_name | String | +| andoid_sdk_version | String | +| segment_id | String | +| tag_id | String | +| custom_attributes.{attribute_name} | String | + +### Accepted Operators + +{% admonition type="warning" name="Searching based on `created_at`" %} + You cannot use the `<=` or `>=` operators to search by `created_at`. +{% /admonition %} + +The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string (`"="`). The operator has to be compatible with the field's type (eg. you cannot search with `>` for a given string value as it's only compatible for integer's and dates). + +| Operator | Valid Types | Description | +| :------- | :------------------------------- | :--------------------------------------------------------------- | +| = | All | Equals | +| != | All | Doesn't Equal | +| IN | All | In
Shortcut for `OR` queries
Values must be in Array | +| NIN | All | Not In
Shortcut for `OR !` queries
Values must be in Array | +| > | Integer
Date (UNIX Timestamp) | Greater than | +| < | Integer
Date (UNIX Timestamp) | Lower than | +| ~ | String | Contains | +| !~ | String | Doesn't Contain | +| ^ | String | Starts With | +| $ | String | Ends With | +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->contacts->searchContacts( + new SearchRequest([ + 'query' => new SingleFilterSearchRequest([]), + 'pagination' => new StartingAfterPaging([ + 'perPage' => 5, + ]), + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$request:** `SearchRequest` + +
+
+
+
+ + +
+
+
+ +
$client->unstable->contacts->listContacts() -> ContactList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all contacts (ie. users or leads) in your workspace. +{% admonition type="warning" name="Pagination" %} + You can use pagination to limit the number of results returned. The default is `50` results per page. + See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#pagination-for-list-apis) for more details on how to use the `starting_after` param. +{% /admonition %} +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->contacts->list( + new ListContactsRequest([]), +); +``` +
+
+
+
+ + +
+
+
+ +
$client->unstable->contacts->createContact($request) -> CreateContactResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a new contact (ie. user or lead). +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->contacts->create( + new CreateContactRequestWithEmail([ + 'email' => 'joebloggs@intercom.io', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$request:** `mixed` + +
+
+
+
+ + +
+
+
+ +
$client->unstable->contacts->showContactByExternalId($request) -> ShowContactByExternalIdResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single contact by external ID. Note that this endpoint only supports users and not leads. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->contacts->showContactByExternalId( + new ShowContactByExternalIdRequest([ + 'externalId' => 'cdd29344-5e0c-4ef0-ac56-f9ba2979bc27', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$externalId:** `string` — The external ID of the user that you want to retrieve + +
+
+
+
+ + +
+
+
+ +
$client->unstable->contacts->archiveContact($request) -> ContactArchived +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can archive a single contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->contacts->archiveContact( + new ArchiveContactRequest([ + 'id' => '63a07ddf05a32042dffac965', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `string` — id + +
+
+
+
+ + +
+
+
+ +
$client->unstable->contacts->unarchiveContact($request) -> ContactUnarchived +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can unarchive a single contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->contacts->unarchiveContact( + new UnarchiveContactRequest([ + 'id' => '63a07ddf05a32042dffac965', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `string` — id + +
+
+
+
+ + +
+
+
+ +
$client->unstable->contacts->blockContact($request) -> ContactBlocked +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Block a single contact.
**Note:** conversations of the contact will also be archived during the process.
More details in [FAQ How do I block Inbox spam?](https://www.intercom.com/help/en/articles/8838656-inbox-faqs) +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->contacts->blockContact( + new BlockContactRequest([ + 'id' => '63a07ddf05a32042dffac965', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `string` — id + +
+
+
+
+ + +
+
+
+ +## Subscription Types +
$client->unstable->subscriptionTypes->attachSubscriptionTypeToContact($request) -> SubscriptionType +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can add a specific subscription to a contact. In Intercom, we have two different subscription types based on user consent - opt-out and opt-in: + + 1.Attaching a contact to an opt-out subscription type will opt that user out from receiving messages related to that subscription type. + + 2.Attaching a contact to an opt-in subscription type will opt that user in to receiving messages related to that subscription type. + +This will return a subscription type model for the subscription type that was added to the contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->contacts->attachSubscription( + new AttachSubscriptionToContactRequest([ + 'contactId' => '63a07ddf05a32042dffac965', + 'subscriptionId' => '37846', + 'consentType' => 'opt_in', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$contactId:** `string` — The unique identifier for the contact which is given by Intercom + +
+
+ +
+
+ +**$id:** `string` — The unique identifier for the subscription which is given by Intercom + +
+
+ +
+
+ +**$consentType:** `string` — The consent_type of a subscription, opt_out or opt_in. + +
+
+
+
+ + +
+
+
+ +
$client->unstable->subscriptionTypes->detachSubscriptionTypeToContact($request) -> SubscriptionType +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can remove a specific subscription from a contact. This will return a subscription type model for the subscription type that was removed from the contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->subscriptionTypes->detachSubscriptionTypeToContact( + new DetachSubscriptionTypeToContactRequest([ + 'contactId' => '63a07ddf05a32042dffac965', + 'id' => '37846', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$contactId:** `string` — The unique identifier for the contact which is given by Intercom + +
+
+ +
+
+ +**$id:** `string` — The unique identifier for the subscription type which is given by Intercom + +
+
+
+
+ + +
+
+
+ +
$client->unstable->subscriptionTypes->listSubscriptionTypes() -> SubscriptionTypeList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can list all subscription types. A list of subscription type objects will be returned. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->subscriptionTypes->list(); +``` +
+
+
+
+ + +
+
+
+ +## Tags +
$client->unstable->tags->attachTagToContact($request) -> Tag +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can tag a specific contact. This will return a tag object for the tag that was added to the contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->tags->tagContact( + new TagContactRequest([ + 'contactId' => '63a07ddf05a32042dffac965', + 'tagId' => '7522907', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$contactId:** `string` — The unique identifier for the contact which is given by Intercom + +
+
+ +
+
+ +**$id:** `string` — The unique identifier for the tag which is given by Intercom + +
+
+
+
+ + +
+
+
+ +
$client->unstable->tags->detachTagFromContact($request) -> Tag +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can remove tag from a specific contact. This will return a tag object for the tag that was removed from the contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->tags->detachTagFromContact( + new DetachTagFromContactRequest([ + 'contactId' => '63a07ddf05a32042dffac965', + 'id' => '7522907', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$contactId:** `string` — The unique identifier for the contact which is given by Intercom + +
+
+ +
+
+ +**$id:** `string` — The unique identifier for the tag which is given by Intercom + +
+
+
+
+ + +
+
+
+ +
$client->unstable->tags->attachTagToConversation($request) -> Tag +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can tag a specific conversation. This will return a tag object for the tag that was added to the conversation. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->tags->tagConversation( + new TagConversationRequest([ + 'conversationId' => '64619700005694', + 'tagId' => '7522907', + 'adminId' => '780', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$conversationId:** `string` — conversation_id + +
+
+ +
+
+ +**$id:** `string` — The unique identifier for the tag which is given by Intercom + +
+
+ +
+
+ +**$adminId:** `string` — The unique identifier for the admin which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
$client->unstable->tags->detachTagFromConversation($request) -> Tag +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can remove tag from a specific conversation. This will return a tag object for the tag that was removed from the conversation. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->tags->detachTagFromConversation( + new DetachTagFromConversationRequest([ + 'conversationId' => '64619700005694', + 'id' => '7522907', + 'adminId' => '123', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$conversationId:** `string` — conversation_id + +
+
+ +
+
+ +**$id:** `string` — id + +
+
+ +
+
+ +**$adminId:** `string` — The unique identifier for the admin which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
$client->unstable->tags->listTags() -> TagList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all tags for a given workspace. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->tags->list(); +``` +
+
+
+
+ + +
+
+
+ +
$client->unstable->tags->createTag($request) -> Tag +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can use this endpoint to perform the following operations: + + **1. Create a new tag:** You can create a new tag by passing in the tag name as specified in "Create or Update Tag Request Payload" described below. + + **2. Update an existing tag:** You can update an existing tag by passing the id of the tag as specified in "Create or Update Tag Request Payload" described below. + + **3. Tag Companies:** You can tag single company or a list of companies. You can tag a company by passing in the tag name and the company details as specified in "Tag Company Request Payload" described below. Also, if the tag doesn't exist then a new one will be created automatically. + + **4. Untag Companies:** You can untag a single company or a list of companies. You can untag a company by passing in the tag id and the company details as specified in "Untag Company Request Payload" described below. + + **5. Tag Multiple Users:** You can tag a list of users. You can tag the users by passing in the tag name and the user details as specified in "Tag Users Request Payload" described below. + +Each operation will return a tag object. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->tags->create( + new CreateOrUpdateTagRequest([ + 'name' => 'test', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$request:** `CreateOrUpdateTagRequest|TagCompanyRequest|UntagCompanyRequest|TagMultipleUsersRequest` + +
+
+
+
+ + +
+
+
+ +
$client->unstable->tags->findTag($request) -> Tag +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of tags that are on the workspace by their id. +This will return a tag object. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->tags->findTag( + new FindTagRequest([ + 'id' => '123', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `string` — The unique identifier of a given tag + +
+
+
+
+ + +
+
+
+ +
$client->unstable->tags->deleteTag($request) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can delete the details of tags that are on the workspace by passing in the id. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->tags->deleteTag( + new DeleteTagRequest([ + 'id' => '123', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `string` — The unique identifier of a given tag + +
+
+
+
+ + +
+
+
+ +
$client->unstable->tags->attachTagToTicket($request) -> Tag +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can tag a specific ticket. This will return a tag object for the tag that was added to the ticket. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->tags->tagTicket( + new TagTicketRequest([ + 'ticketId' => '64619700005694', + 'tagId' => '7522907', + 'adminId' => '780', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$ticketId:** `string` — ticket_id + +
+
+ +
+
+ +**$id:** `string` — The unique identifier for the tag which is given by Intercom + +
+
+ +
+
+ +**$adminId:** `string` — The unique identifier for the admin which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
$client->unstable->tags->detachTagFromTicket($request) -> Tag +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can remove tag from a specific ticket. This will return a tag object for the tag that was removed from the ticket. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->tags->detachTagFromTicket( + new DetachTagFromTicketRequest([ + 'ticketId' => '64619700005694', + 'id' => '7522907', + 'adminId' => '123', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$ticketId:** `string` — ticket_id + +
+
+ +
+
+ +**$id:** `string` — The unique identifier for the tag which is given by Intercom + +
+
+ +
+
+ +**$adminId:** `string` — The unique identifier for the admin which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +## Conversations +
$client->unstable->conversations->listConversations($request) -> ConversationList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all conversations. + +You can optionally request the result page size and the cursor to start after to fetch the result. +{% admonition type="warning" name="Pagination" %} + You can use pagination to limit the number of results returned. The default is `20` results per page. + See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#pagination-for-list-apis) for more details on how to use the `starting_after` param. +{% /admonition %} +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->conversations->list( + new ListConversationsRequest([ + 'perPage' => 1, + 'startingAfter' => 'starting_after', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$perPage:** `?int` — How many results per page + +
+
+ +
+
+ +**$startingAfter:** `?string` — String used to get the next page of conversations. + +
+
+
+
+ + +
+
+
+ +
$client->unstable->conversations->createConversation($request) -> Message +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a conversation that has been initiated by a contact (ie. user or lead). +The conversation can be an in-app message only. + +{% admonition type="info" name="Sending for visitors" %} +You can also send a message from a visitor by specifying their `user_id` or `id` value in the `from` field, along with a `type` field value of `contact`. +This visitor will be automatically converted to a contact with a lead role once the conversation is created. +{% /admonition %} + +This will return the Message model that has been created. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->conversations->create( + new CreateConversationRequest([ + 'from' => new CreateConversationRequestFrom([ + 'type' => CreateConversationRequestFromType::User->value, + 'id' => '6762f11b1bb69f9f2193bba3', + ]), + 'body' => 'Hello there', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$from:** `CreateConversationRequestFrom` + +
+
+ +
+
+ +**$body:** `string` — The content of the message. HTML is not supported. + +
+
+ +
+
+ +**$createdAt:** `?int` — 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. + +
+
+
+
+ + +
+
+
+ +
$client->unstable->conversations->retrieveConversation($request) -> Conversation +
+
+ +#### 📝 Description + +
+
+ +
+
+ + +You can fetch the details of a single conversation. + +This will return a single Conversation model with all its conversation parts. + +{% admonition type="warning" name="Hard limit of 500 parts" %} +The maximum number of conversation parts that can be returned via the API is 500. If you have more than that we will return the 500 most recent conversation parts. +{% /admonition %} + +For AI agent conversation metadata, please note that you need to have the agent enabled in your workspace, which is a [paid feature](https://www.intercom.com/help/en/articles/8205718-fin-resolutions#h_97f8c2e671). +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->conversations->retrieveConversation( + new RetrieveConversationRequest([ + 'id' => 1, + 'displayAs' => 'plaintext', + 'includeTranslations' => true, + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `int` — The id of the conversation to target + +
+
+ +
+
+ +**$displayAs:** `?string` — Set to plaintext to retrieve conversation messages in plain text. This affects both the body and subject fields. + +
+
+ +
+
+ +**$includeTranslations:** `?bool` — If set to true, conversation parts will be translated to the detected language of the conversation. + +
+
+
+
+ + +
+
+
+ +
$client->unstable->conversations->updateConversation($request) -> Conversation +
+
+ +#### 📝 Description + +
+
+ +
+
+ + +You can update an existing conversation. + +{% admonition type="info" name="Replying and other actions" %} +If you want to reply to a coveration or take an action such as assign, unassign, open, close or snooze, take a look at the reply and manage endpoints. +{% /admonition %} + +{% admonition type="info" %} + This endpoint handles both **conversation updates** and **custom object associations**. + + See _`update a conversation with an association to a custom object instance`_ in the request/response examples to see the custom object association format. +{% /admonition %} + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->conversations->updateConversation( + new UpdateConversationRequest([ + 'id' => 1, + 'displayAs' => 'plaintext', + 'read' => true, + 'title' => 'new conversation title', + 'customAttributes' => [ + 'issue_type' => 'Billing', + 'priority' => 'High', + ], + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `int` — The id of the conversation to target + +
+
+ +
+
+ +**$displayAs:** `?string` — Set to plaintext to retrieve conversation messages in plain text. This affects both the body and subject fields. + +
+
+ +
+
+ +**$read:** `?bool` — Mark a conversation as read within Intercom. + +
+
+ +
+
+ +**$title:** `?string` — The title given to the conversation + +
+
+ +
+
+ +**$customAttributes:** `?array` + +
+
+ +
+
+ +**$companyId:** `?string` — The ID of the company that the conversation is associated with. The unique identifier for the company which is given by Intercom. Set to nil to remove company. + +
+
+
+
+ + +
+
+
+ +
$client->unstable->conversations->deleteConversation($request) -> ConversationDeleted +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can delete a single conversation. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->conversations->deleteConversation( + new DeleteConversationRequest([ + 'id' => 1, + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `int` — id + +
+
+
+
+ + +
+
+
+ +
$client->unstable->conversations->searchConversations($request) -> ConversationList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can search for multiple conversations by the value of their attributes in order to fetch exactly which ones you want. + +To search for conversations, you need to send a `POST` request to `https://api.intercom.io/conversations/search`. + +This will accept a query object in the body which will define your filters in order to search for conversations. +{% admonition type="warning" name="Optimizing search queries" %} + Search queries can be complex, so optimizing them can help the performance of your search. + Use the `AND` and `OR` operators to combine multiple filters to get the exact results you need and utilize + pagination to limit the number of results returned. The default is `20` results per page and maximum is `150`. + See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#example-search-conversations-request) for more details on how to use the `starting_after` param. +{% /admonition %} + +### Nesting & Limitations + +You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). +There are some limitations to the amount of multiple's there can be: +- There's a limit of max 2 nested filters +- There's a limit of max 15 filters for each AND or OR group + +### Accepted Fields + +Most keys listed in the conversation model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as `created_at` accepts a date, the `value` cannot be a string such as `"foorbar"`). +The `source.body` field is unique as the search will not be performed against the entire value, but instead against every element of the value separately. For example, when searching for a conversation with a `"I need support"` body - the query should contain a `=` operator with the value `"support"` for such conversation to be returned. A query with a `=` operator and a `"need support"` value will not yield a result. + +| Field | Type | +| :---------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------- | +| id | String | +| created_at | Date (UNIX timestamp) | +| updated_at | Date (UNIX timestamp) | +| source.type | String
Accepted fields are `conversation`, `email`, `facebook`, `instagram`, `phone_call`, `phone_switch`, `push`, `sms`, `twitter` and `whatsapp`. | +| source.id | String | +| source.delivered_as | String | +| source.subject | String | +| source.body | String | +| source.author.id | String | +| source.author.type | String | +| source.author.name | String | +| source.author.email | String | +| source.url | String | +| contact_ids | String | +| teammate_ids | String | +| admin_assignee_id | String | +| team_assignee_id | String | +| channel_initiated | String | +| open | Boolean | +| read | Boolean | +| state | String | +| waiting_since | Date (UNIX timestamp) | +| snoozed_until | Date (UNIX timestamp) | +| tag_ids | String | +| priority | String | +| statistics.time_to_assignment | Integer | +| statistics.time_to_admin_reply | Integer | +| statistics.time_to_first_close | Integer | +| statistics.time_to_last_close | Integer | +| statistics.median_time_to_reply | Integer | +| statistics.first_contact_reply_at | Date (UNIX timestamp) | +| statistics.first_assignment_at | Date (UNIX timestamp) | +| statistics.first_admin_reply_at | Date (UNIX timestamp) | +| statistics.first_close_at | Date (UNIX timestamp) | +| statistics.last_assignment_at | Date (UNIX timestamp) | +| statistics.last_assignment_admin_reply_at | Date (UNIX timestamp) | +| statistics.last_contact_reply_at | Date (UNIX timestamp) | +| statistics.last_admin_reply_at | Date (UNIX timestamp) | +| statistics.last_close_at | Date (UNIX timestamp) | +| statistics.last_closed_by_id | String | +| statistics.count_reopens | Integer | +| statistics.count_assignments | Integer | +| statistics.count_conversation_parts | Integer | +| conversation_rating.requested_at | Date (UNIX timestamp) | +| conversation_rating.replied_at | Date (UNIX timestamp) | +| conversation_rating.score | Integer | +| conversation_rating.remark | String | +| conversation_rating.contact_id | String | +| conversation_rating.admin_d | String | +| ai_agent_participated | Boolean | +| ai_agent.resolution_state | String | +| ai_agent.last_answer_type | String | +| ai_agent.rating | Integer | +| ai_agent.rating_remark | String | +| ai_agent.source_type | String | +| ai_agent.source_title | String | + +### Accepted Operators + +The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string (`"="`). The operator has to be compatible with the field's type (eg. you cannot search with `>` for a given string value as it's only compatible for integer's and dates). + +| Operator | Valid Types | Description | +| :------- | :----------------------------- | :----------------------------------------------------------- | +| = | All | Equals | +| != | All | Doesn't Equal | +| IN | All | In Shortcut for `OR` queries Values most be in Array | +| NIN | All | Not In Shortcut for `OR !` queries Values must be in Array | +| > | Integer Date (UNIX Timestamp) | Greater (or equal) than | +| < | Integer Date (UNIX Timestamp) | Lower (or equal) than | +| ~ | String | Contains | +| !~ | String | Doesn't Contain | +| ^ | String | Starts With | +| $ | String | Ends With | +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->conversations->searchConversations( + new SearchRequest([ + 'query' => new SingleFilterSearchRequest([]), + 'pagination' => new StartingAfterPaging([ + 'perPage' => 5, + ]), + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$request:** `SearchRequest` + +
+
+
+
+ + +
+
+
+ +
$client->unstable->conversations->replyConversation($request) -> Conversation +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can reply to a conversation with a message from an admin or on behalf of a contact, or with a note for admins. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->conversations->replyConversation( + new ReplyConversationRequest([ + 'id' => '123 or "last"', + 'body' => new ContactReplyIntercomUserIdRequest([ + 'messageType' => 'comment', + 'type' => 'user', + 'body' => 'Thanks again :)', + 'intercomUserId' => '6762f1571bb69f9f2193bbbb', + ]), + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `string` — The Intercom provisioned identifier for the conversation or the string "last" to reply to the last part of the conversation + +
+
+ +
+
+ +**$request:** `ContactReplyIntercomUserIdRequest|ContactReplyEmailRequest|ContactReplyUserIdRequest|AdminReplyConversationRequest` + +
+
+
+
+ + +
+
+
+ +
$client->unstable->conversations->manageConversation($request) -> Conversation +
+
+ +#### 📝 Description + +
+
+ +
+
+ +For managing conversations you can: +- Close a conversation +- Snooze a conversation to reopen on a future date +- Open a conversation which is `snoozed` or `closed` +- Assign a conversation to an admin and/or team. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->conversations->manageConversation( + new ManageConversationRequest([ + 'id' => '123', + 'body' => ManageConversationRequestBody::close(new CloseConversationRequest([ + 'type' => 'admin', + 'adminId' => '12345', + ])), + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `string` — The identifier for the conversation as given by Intercom. + +
+
+ +
+
+ +**$request:** `ManageConversationRequestBody` + +
+
+
+
+ + +
+
+
+ +
$client->unstable->conversations->attachContactToConversation($request) -> Conversation +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can add participants who are contacts to a conversation, on behalf of either another contact or an admin. + +{% admonition type="warning" name="Contacts without an email" %} +If you add a contact via the email parameter and there is no user/lead found on that workspace with he given email, then we will create a new contact with `role` set to `lead`. +{% /admonition %} + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->conversations->attachContactToConversation( + new AttachContactToConversationRequest([ + 'id' => '123', + 'adminId' => '12345', + 'customer' => new AttachContactToConversationRequestCustomerIntercomUserId([ + 'intercomUserId' => '6762f19b1bb69f9f2193bbd4', + ]), + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `string` — The identifier for the conversation as given by Intercom. + +
+
+ +
+
+ +**$adminId:** `?string` — The `id` of the admin who is adding the new participant. + +
+
+ +
+
+ +**$customer:** `AttachContactToConversationRequestCustomerIntercomUserId|AttachContactToConversationRequestCustomerUserId|AttachContactToConversationRequestCustomerCustomer|null` + +
+
+
+
+ + +
+
+
+ +
$client->unstable->conversations->detachContactFromConversation($request) -> Conversation +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can add participants who are contacts to a conversation, on behalf of either another contact or an admin. + +{% admonition type="warning" name="Contacts without an email" %} +If you add a contact via the email parameter and there is no user/lead found on that workspace with he given email, then we will create a new contact with `role` set to `lead`. +{% /admonition %} + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->conversations->detachContactAsAdmin( + new DetachContactFromConversationRequest([ + 'conversationId' => '123', + 'contactId' => '123', + 'adminId' => '5017690', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$conversationId:** `string` — The identifier for the conversation as given by Intercom. + +
+
+ +
+
+ +**$contactId:** `string` — The identifier for the contact as given by Intercom. + +
+
+ +
+
+ +**$adminId:** `string` — The `id` of the admin who is performing the action. + +
+
+
+
+ + +
+
+
+ +
$client->unstable->conversations->redactConversation($request) -> Conversation +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can redact a conversation part or the source message of a conversation (as seen in the source object). + +{% admonition type="info" name="Redacting parts and messages" %} +If you are redacting a conversation part, it must have a `body`. If you are redacting a source message, it must have been created by a contact. We will return a `conversation_part_not_redactable` error if these criteria are not met. +{% /admonition %} + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->conversations->redactConversationPart( + RedactConversationRequest::conversationPart(new RedactConversationRequestConversationPart([ + 'conversationId' => '19894788788', + 'conversationPartId' => '19381789428', + ])), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$request:** `RedactConversationRequest` + +
+
+
+
+ + +
+
+
+ +
$client->unstable->conversations->convertConversationToTicket($request) -> ?Ticket +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can convert a conversation to a ticket. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->conversations->convertConversationToTicket( + new ConvertConversationToTicketRequest([ + 'id' => 1, + 'ticketTypeId' => '53', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `int` — The id of the conversation to target + +
+
+ +
+
+ +**$ticketTypeId:** `string` — The ID of the type of ticket you want to convert the conversation to + +
+
+ +
+
+ +**$attributes:** `?array` + +
+
+
+
+ + +
+
+
+ +## Unstable CustomChannelEvents +
$client->unstable->customChannelEvents->notifyNewConversation($request) -> CustomChannelNotificationResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Notifies Intercom that a new conversation was created in your custom channel/platform. This triggers conversation creation and workflow automations within Intercom for your custom channel integration. +> **Note:** This endpoint is currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->customChannelEvents->notifyNewConversation( + new CustomChannelBaseEvent([ + 'eventId' => 'evt_12345', + 'externalConversationId' => 'conv_67890', + 'contact' => new CustomChannelContact([ + 'type' => CustomChannelContactType::User->value, + 'externalId' => 'user_001', + 'name' => 'Jane Doe', + 'email' => 'jane.doe@example.com', + ]), + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$request:** `CustomChannelBaseEvent` + +
+
+
+
+ + +
+
+
+ +
$client->unstable->customChannelEvents->notifyNewMessage($request) -> CustomChannelNotificationResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Notifies Intercom that a new message was sent in a conversation on your custom channel/platform. This allows Intercom to process the message and trigger any relevant workflow automations. +> **Note:** This endpoint is currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->customChannelEvents->notifyNewMessage( + new NotifyNewMessageRequest([ + 'eventId' => 'evt_54321', + 'externalConversationId' => 'conv_98765', + 'contact' => new CustomChannelContact([ + 'type' => CustomChannelContactType::User->value, + 'externalId' => 'user_002', + 'name' => 'John Smith', + 'email' => 'john.smith@example.com', + ]), + 'body' => 'Hello, I need help with my order.', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$body:** `string` — The message content sent by the user. + +
+
+
+
+ + +
+
+
+ +
$client->unstable->customChannelEvents->notifyQuickReplySelected($request) -> CustomChannelNotificationResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Notifies Intercom that a user selected a quick reply option in your custom channel/platform. This allows Intercom to process the response and trigger any relevant workflow automations. +> **Note:** This endpoint is currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->customChannelEvents->notifyQuickReplySelected( + new NotifyQuickReplySelectedRequest([ + 'eventId' => 'evt_67890', + 'externalConversationId' => 'conv_13579', + 'contact' => new CustomChannelContact([ + 'type' => CustomChannelContactType::User->value, + 'externalId' => 'user_003', + 'name' => 'Alice Example', + 'email' => 'alice@example.com', + ]), + 'quickReplyOptionId' => '1234', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$quickReplyOptionId:** `string` — Id of the selected quick reply option. + +
+
+
+
+ + +
+
+
+ +
$client->unstable->customChannelEvents->notifyAttributeCollected($request) -> CustomChannelNotificationResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Notifies Intercom that a user provided a response to an attribute collector in your custom channel/platform. This allows Intercom to process the attribute and trigger any relevant workflow automations. +> **Note:** This endpoint is currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->customChannelEvents->notifyAttributeCollected( + new NotifyAttributeCollectedRequest([ + 'eventId' => 'evt_24680', + 'externalConversationId' => 'conv_11223', + 'contact' => new CustomChannelContact([ + 'type' => CustomChannelContactType::User->value, + 'externalId' => 'user_004', + 'name' => 'Bob Example', + 'email' => 'bob@example.com', + ]), + 'attribute' => new CustomChannelAttribute([ + 'id' => 'shipping_address', + 'value' => '123 Main St, Springfield', + ]), + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$attribute:** `CustomChannelAttribute` + +
+
+
+
+ + +
+
+
+ +## Custom Object Instances +
$client->unstable->customObjectInstances->getCustomObjectInstancesByExternalId($request) -> ?CustomObjectInstance +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Fetch a Custom Object Instance by external_id. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->customObjectInstances->getCustomObjectInstancesByExternalId( + new GetCustomObjectInstancesByExternalIdRequest([ + 'customObjectTypeIdentifier' => 'Order', + 'externalId' => 'external_id', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$customObjectTypeIdentifier:** `string` — The unique identifier of the custom object type that defines the structure of the custom object instance. + +
+
+ +
+
+ +**$externalId:** `string` + +
+
+
+
+ + +
+
+
+ +
$client->unstable->customObjectInstances->createCustomObjectInstances($request) -> ?CustomObjectInstance +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create or update a custom object instance +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->customObjectInstances->createCustomObjectInstances( + new CreateOrUpdateCustomObjectInstanceRequest([ + 'customObjectTypeIdentifier' => 'Order', + 'externalId' => '123', + 'externalCreatedAt' => 1392036272, + 'externalUpdatedAt' => 1392036272, + 'customAttributes' => [ + 'order_number' => 'ORDER-12345', + 'total_amount' => 'custom_attributes', + ], + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$customObjectTypeIdentifier:** `string` — The unique identifier of the custom object type that defines the structure of the custom object instance. + +
+
+ +
+
+ +**$externalId:** `?string` — A unique identifier for the Custom Object instance in the external system it originated from. + +
+
+ +
+
+ +**$externalCreatedAt:** `?int` — The time when the Custom Object instance was created in the external system it originated from. + +
+
+ +
+
+ +**$externalUpdatedAt:** `?int` — The time when the Custom Object instance was last updated in the external system it originated from. + +
+
+ +
+
+ +**$customAttributes:** `?array` — The custom attributes which are set for the Custom Object instance. + +
+
+
+
+ + +
+
+
+ +
$client->unstable->customObjectInstances->deleteCustomObjectInstancesById($request) -> CustomObjectInstanceDeleted +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Delete a single Custom Object instance by external_id. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->customObjectInstances->deleteCustomObjectInstancesById( + new DeleteCustomObjectInstancesByIdRequest([ + 'customObjectTypeIdentifier' => 'Order', + 'externalId' => 'external_id', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$customObjectTypeIdentifier:** `string` — The unique identifier of the custom object type that defines the structure of the custom object instance. + +
+
+ +
+
+ +**$externalId:** `string` + +
+
+
+
+ + +
+
+
+ +
$client->unstable->customObjectInstances->getCustomObjectInstancesById($request) -> ?CustomObjectInstance +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Fetch a Custom Object Instance by id. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->customObjectInstances->getCustomObjectInstancesById( + new GetCustomObjectInstancesByIdRequest([ + 'customObjectTypeIdentifier' => 'Order', + 'id' => 'id', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$customObjectTypeIdentifier:** `string` — The unique identifier of the custom object type that defines the structure of the custom object instance. + +
+
+ +
+
+ +**$id:** `string` — The id or external_id of the custom object instance + +
+
+
+
+ + +
+
+
+ +
$client->unstable->customObjectInstances->deleteCustomObjectInstancesByExternalId($request) -> CustomObjectInstanceDeleted +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Delete a single Custom Object instance using the Intercom defined id. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->customObjectInstances->deleteCustomObjectInstancesByExternalId( + new DeleteCustomObjectInstancesByExternalIdRequest([ + 'customObjectTypeIdentifier' => 'Order', + 'id' => 'id', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$customObjectTypeIdentifier:** `string` — The unique identifier of the custom object type that defines the structure of the custom object instance. + +
+
+ +
+
+ +**$id:** `string` — The Intercom defined id of the custom object instance + +
+
+
+
+ + +
+
+
+ +## Data Attributes +
$client->unstable->dataAttributes->lisDataAttributes($request) -> DataAttributeList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all data attributes belonging to a workspace for contacts, companies or conversations. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->dataAttributes->list( + new ListDataAttributesRequest([ + 'model' => DataAttributesListRequestModel::Contact->value, + 'includeArchived' => true, + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$model:** `?string` — Specify the data attribute model to return. + +
+
+ +
+
+ +**$includeArchived:** `?bool` — Include archived attributes in the list. By default we return only non archived data attributes. + +
+
+
+
+ + +
+
+
+ +
$client->unstable->dataAttributes->createDataAttribute($request) -> DataAttribute +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a data attributes for a `contact` or a `company`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->dataAttributes->createDataAttribute( + [ + 'key' => "value", + ], +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$request:** `mixed` + +
+
+
+
+ + +
+
+
+ +
$client->unstable->dataAttributes->updateDataAttribute($request) -> DataAttribute +
+
+ +#### 📝 Description + +
+
+ +
+
+ + +You can update a data attribute. + +> 🚧 Updating the data type is not possible +> +> It is currently a dangerous action to execute changing a data attribute's type via the API. You will need to update the type via the UI instead. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->dataAttributes->updateDataAttribute( + new UpdateDataAttributeRequest([ + 'id' => 1, + 'body' => [ + 'key' => "value", + ], + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `int` — The data attribute id + +
+
+ +
+
+ +**$request:** `mixed` + +
+
+
+
+ + +
+
+
+ +## Data Events +
$client->unstable->dataEvents->lisDataEvents($request) -> DataEventSummary +
+
+ +#### 📝 Description + +
+
+ +
+
+ + +> 🚧 +> +> Please note that you can only 'list' events that are less than 90 days old. Event counts and summaries will still include your events older than 90 days but you cannot 'list' these events individually if they are older than 90 days + +The events belonging to a customer can be listed by sending a GET request to `https://api.intercom.io/events` with a user or lead identifier along with a `type` parameter. The identifier parameter can be one of `user_id`, `email` or `intercom_user_id`. The `type` parameter value must be `user`. + +- `https://api.intercom.io/events?type=user&user_id={user_id}` +- `https://api.intercom.io/events?type=user&email={email}` +- `https://api.intercom.io/events?type=user&intercom_user_id={id}` (this call can be used to list leads) + +The `email` parameter value should be [url encoded](http://en.wikipedia.org/wiki/Percent-encoding) when sending. + +You can optionally define the result page size as well with the `per_page` parameter. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->dataEvents->lisDataEvents( + new LisDataEventsRequest([ + 'filter' => new LisDataEventsRequestFilterUserId([ + 'userId' => 'user_id', + ]), + 'type' => 'type', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$filter:** `LisDataEventsRequestFilterUserId|LisDataEventsRequestFilterIntercomUserId|LisDataEventsRequestFilterEmail` + +
+
+ +
+
+ +**$type:** `string` — The value must be user + +
+
+ +
+
+ +**$summary:** `?bool` — summary flag + +
+
+
+
+ + +
+
+
+ +
$client->unstable->dataEvents->createDataEvent($request) +
+
+ +#### 📝 Description + +
+
+ +
+
+ + +You will need an Access Token that has write permissions to send Events. Once you have a key you can submit events via POST to the Events resource, which is located at https://api.intercom.io/events, or you can send events using one of the client libraries. When working with the HTTP API directly a client should send the event with a `Content-Type` of `application/json`. + +When using the JavaScript API, [adding the code to your app](http://docs.intercom.io/configuring-Intercom/tracking-user-events-in-your-app) makes the Events API available. Once added, you can submit an event using the `trackEvent` method. This will associate the event with the Lead or currently logged-in user or logged-out visitor/lead and send it to Intercom. The final parameter is a map that can be used to send optional metadata about the event. + +With the Ruby client you pass a hash describing the event to `Intercom::Event.create`, or call the `track_user` method directly on the current user object (e.g. `user.track_event`). + +**NB: For the JSON object types, please note that we do not currently support nested JSON structure.** + +| Type | Description | Example | +| :-------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------- | +| String | The value is a JSON String | `"source":"desktop"` | +| Number | The value is a JSON Number | `"load": 3.67` | +| Date | The key ends with the String `_date` and the value is a [Unix timestamp](http://en.wikipedia.org/wiki/Unix_time), assumed to be in the [UTC](http://en.wikipedia.org/wiki/Coordinated_Universal_Time) timezone. | `"contact_date": 1392036272` | +| Link | The value is a HTTP or HTTPS URI. | `"article": "https://example.org/ab1de.html"` | +| Rich Link | The value is a JSON object that contains `url` and `value` keys. | `"article": {"url": "https://example.org/ab1de.html", "value":"the dude abides"}` | +| Monetary Amount | The value is a JSON object that contains `amount` and `currency` keys. The `amount` key is a positive integer representing the amount in cents. The price in the example to the right denotes €349.99. | `"price": {"amount": 34999, "currency": "eur"}` | + +**Lead Events** + +When submitting events for Leads, you will need to specify the Lead's `id`. + +**Metadata behaviour** + +- We currently limit the number of tracked metadata keys to 10 per event. Once the quota is reached, we ignore any further keys we receive. The first 10 metadata keys are determined by the order in which they are sent in with the event. +- It is not possible to change the metadata keys once the event has been sent. A new event will need to be created with the new keys and you can archive the old one. +- There might be up to 24 hrs delay when you send a new metadata for an existing event. + +**Event de-duplication** + +The API may detect and ignore duplicate events. Each event is uniquely identified as a combination of the following data - the Workspace identifier, the Contact external identifier, the Data Event name and the Data Event created time. As a result, it is **strongly recommended** to send a second granularity Unix timestamp in the `created_at` field. + +Duplicated events are responded to using the normal `202 Accepted` code - an error is not thrown, however repeat requests will be counted against any rate limit that is in place. + +### HTTP API Responses + +- Successful responses to submitted events return `202 Accepted` with an empty body. +- Unauthorised access will be rejected with a `401 Unauthorized` or `403 Forbidden` response code. +- Events sent about users that cannot be found will return a `404 Not Found`. +- Event lists containing duplicate events will have those duplicates ignored. +- Server errors will return a `500` response code and may contain an error message in the body. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->dataEvents->createDataEvent( + [ + 'key' => "value", + ], +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$request:** `mixed` + +
+
+
+
+ + +
+
+
+ +
$client->unstable->dataEvents->dataEventSummaries($request) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create event summaries for a user. Event summaries are used to track the number of times an event has occurred, the first time it occurred and the last time it occurred. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->events->summaries( + new ListEventSummariesRequest([]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$userId:** `?string` — Your identifier for the user. + +
+
+ +
+
+ +**$eventSummaries:** `?CreateDataEventSummariesRequestEventSummaries` — 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`. + +
+
+
+
+ + +
+
+
+ +## Data Export +
$client->unstable->dataExport->createDataExport($request) -> DataExport +
+
+ +#### 📝 Description + +
+
+ +
+
+ +To create your export job, you need to send a `POST` request to the export endpoint `https://api.intercom.io/export/content/data`. + +The only parameters you need to provide are the range of dates that you want exported. + +>🚧 Limit of one active job +> +> You can only have one active job per workspace. You will receive a HTTP status code of 429 with the message Exceeded rate limit of 1 pending message data export jobs if you attempt to create a second concurrent job. + +>❗️ Updated_at not included +> +> It should be noted that the timeframe only includes messages sent during the time period and not messages that were only updated during this period. For example, if a message was updated yesterday but sent two days ago, you would need to set the created_at_after date before the message was sent to include that in your retrieval job. + +>📘 Date ranges are inclusive +> +> Requesting data for 2018-06-01 until 2018-06-30 will get all data for those days including those specified - e.g. 2018-06-01 00:00:00 until 2018-06-30 23:59:99. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->dataExport->create( + new CreateDataExportRequest([ + 'createdAtAfter' => 1734519776, + 'createdAtBefore' => 1734537776, + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$createdAtAfter:** `int` — The start date that you request data for. It must be formatted as a unix timestamp. + +
+
+ +
+
+ +**$createdAtBefore:** `int` — The end date that you request data for. It must be formatted as a unix timestamp. + +
+
+
+
+ + +
+
+
+ +
$client->unstable->dataExport->getDataExport($request) -> DataExport +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can view the status of your job by sending a `GET` request to the URL +`https://api.intercom.io/export/content/data/{job_identifier}` - the `{job_identifier}` is the value returned in the response when you first created the export job. More on it can be seen in the Export Job Model. + +> 🚧 Jobs expire after two days +> All jobs that have completed processing (and are thus available to download from the provided URL) will have an expiry limit of two days from when the export ob completed. After this, the data will no longer be available. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->dataExport->find( + new FindDataExportRequest([ + 'jobIdentifier' => 'job_identifier', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$jobIdentifier:** `string` — job_identifier + +
+
+
+
+ + +
+
+
+ +
$client->unstable->dataExport->cancelDataExport($request) -> DataExport +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can cancel your job +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->dataExport->cancel( + new CancelDataExportRequest([ + 'jobIdentifier' => 'job_identifier', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$jobIdentifier:** `string` — job_identifier + +
+
+
+
+ + +
+
+
+ +
$client->unstable->dataExport->downloadDataExport($request) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +When a job has a status of complete, and thus a filled download_url, you can download your data by hitting that provided URL, formatted like so: https://api.intercom.io/download/content/data/xyz1234. + +Your exported message data will be streamed continuously back down to you in a gzipped CSV format. + +> 📘 Octet header required +> +> You will have to specify the header Accept: `application/octet-stream` when hitting this endpoint. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->dataExport->download( + new DownloadDataExportRequest([ + 'jobIdentifier' => 'job_identifier', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$jobIdentifier:** `string` — job_identifier + +
+
+
+
+ + +
+
+
+ +## Jobs +
$client->unstable->jobs->status($request) -> Jobs +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve the status of job execution. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->jobs->status( + new JobsStatusRequest([ + 'id' => 'id', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `string` — The unique identifier for the job which is given by Intercom + +
+
+
+
+ + +
+
+
+ +## Macros +
$client->unstable->macros->listMacros($request) -> MacroList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all macros (saved replies) in your workspace for use in automating responses. + +The macros are returned in descending order by updated_at. + +**Pagination** + +This endpoint uses cursor-based pagination via the `starting_after` parameter. The cursor is a Base64-encoded JSON array containing `[updated_at, id]` of the last item from the previous page. + +**Placeholder Transformation** + +The API transforms Intercom placeholders to a more standard XML-like format: +- From: `{{user.name | fallback: 'there'}}` +- To: `` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->macros->listMacros( + new ListMacrosRequest([ + 'perPage' => 1, + 'startingAfter' => 'WzE3MTk0OTM3NTcuMCwgIjEyMyJd', + 'updatedSince' => 1000000, + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$perPage:** `?int` — The number of results per page + +
+
+ +
+
+ +**$startingAfter:** `?string` — Base64-encoded cursor containing [updated_at, id] for pagination + +
+
+ +
+
+ +**$updatedSince:** `?int` — Unix timestamp to filter macros updated after this time + +
+
+
+
+ + +
+
+
+ +
$client->unstable->macros->getMacro($request) -> ?Macro +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a single macro (saved reply) by its ID. The macro will only be returned if it is visible to the authenticated user based on its visibility settings. + +**Visibility Rules** + +A macro is returned based on its `visible_to` setting: +- `everyone`: Always visible to all team members +- `specific_teams`: Only visible if the authenticated user belongs to one of the teams specified in `visible_to_team_ids` + +If a macro exists but is not visible to the authenticated user, a 404 error is returned. + +**Placeholder Transformation** + +The API transforms Intercom placeholders to a more standard XML-like format in the `body` field: +- From: `{{user.name | fallback: 'there'}}` +- To: `` + +Default values in placeholders are HTML-escaped for security. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->macros->getMacro( + new GetMacroRequest([ + 'id' => '123', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `string` — The unique identifier of the macro + +
+
+
+
+ + +
+
+
+ +## Messages +
$client->unstable->messages->createMessage($request) -> Message +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a message that has been initiated by an admin. The conversation can be either an in-app message, an email, sms or whatsapp. + +> 🚧 Sending for visitors +> +> There can be a short delay between when a contact is created and when a contact becomes available to be messaged through the API. A 404 Not Found error will be returned in this case. + +This will return the Message model that has been created. + +> 🚧 Retrieving Associated Conversations +> +> As this is a message, there will be no conversation present until the contact responds. Once they do, you will have to search for a contact's conversations with the id of the message. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->messages->createMessage( + [ + 'from' => [ + 'type' => "user", + 'id' => "6762f2341bb69f9f2193bc17", + ], + 'body' => "heyy", + 'referer' => "https://twitter.com/bob", + ], +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$request:** `mixed` + +
+
+
+
+ + +
+
+
+ +
$client->unstable->messages->getWhatsAppMessageStatus($request) -> WhatsappMessageStatusList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieves statuses of messages sent from the Outbound module. Currently, this API only supports WhatsApp messages. + + +This endpoint returns paginated status events for WhatsApp messages sent via the Outbound module, providing +information about delivery state and related message details. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->messages->getWhatsAppMessageStatus( + new GetWhatsAppMessageStatusRequest([ + 'rulesetId' => 'ruleset_id', + 'perPage' => 1, + 'startingAfter' => 'starting_after', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$rulesetId:** `string` — The unique identifier for the set of messages to check status for + +
+
+ +
+
+ +**$perPage:** `?int` — Number of results per page (default 50, max 100) + +
+
+ +
+
+ +**$startingAfter:** `?string` — Cursor for pagination, used to fetch the next page of results + +
+
+
+
+ + +
+
+
+ +## News +
$client->unstable->news->listNewsItems() -> PaginatedResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all news items +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->news->items->list(); +``` +
+
+
+
+ + +
+
+
+ +
$client->unstable->news->createNewsItem($request) -> NewsItem +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a news item +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->news->items->create( + new NewsItemRequest([ + 'title' => 'Halloween is here!', + 'body' => '

New costumes in store for this spooky season

', + 'senderId' => 991267834, + 'state' => NewsItemRequestState::Live->value, + 'deliverSilently' => true, + 'labels' => [ + 'Product', + 'Update', + 'New', + ], + 'reactions' => [ + '😆', + '😅', + ], + 'newsfeedAssignments' => [ + new NewsfeedAssignment([ + 'newsfeedId' => 53, + 'publishedAt' => 1664638214, + ]), + ], + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$request:** `NewsItemRequest` + +
+
+
+
+ + +
+
+
+ +
$client->unstable->news->retrieveNewsItem($request) -> NewsItem +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single news item. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->news->retrieveNewsItem( + new RetrieveNewsItemRequest([ + 'id' => 1, + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `int` — The unique identifier for the news item which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
$client->unstable->news->updateNewsItem($request) -> NewsItem +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->news->updateNewsItem( + new UpdateNewsItemRequest([ + 'id' => 1, + 'body' => new NewsItemRequest([ + 'title' => 'Christmas is here!', + 'body' => '

New gifts in store for the jolly season

', + 'senderId' => 991267845, + 'reactions' => [ + '😝', + '😂', + ], + ]), + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `int` — The unique identifier for the news item which is given by Intercom. + +
+
+ +
+
+ +**$request:** `NewsItemRequest` + +
+
+
+
+ + +
+
+
+ +
$client->unstable->news->deleteNewsItem($request) -> DeletedObject +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can delete a single news item. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->news->deleteNewsItem( + new DeleteNewsItemRequest([ + 'id' => 1, + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `int` — The unique identifier for the news item which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
$client->unstable->news->listLiveNewsfeedItems($request) -> PaginatedResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all news items that are live on a given newsfeed +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->news->listLiveNewsfeedItems( + new ListLiveNewsfeedItemsRequest([ + 'id' => '123', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `string` — The unique identifier for the news feed item which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
$client->unstable->news->listNewsfeeds() -> PaginatedResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all newsfeeds +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->news->feeds->list(); +``` +
+
+
+
+ + +
+
+
+ +
$client->unstable->news->retrieveNewsfeed($request) -> Newsfeed +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single newsfeed +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->news->retrieveNewsfeed( + new RetrieveNewsfeedRequest([ + 'id' => '123', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `string` — The unique identifier for the news feed item which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +## Segments +
$client->unstable->segments->listSegments($request) -> SegmentList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all segments. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->segments->list( + new ListSegmentsRequest([ + 'includeCount' => true, + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$includeCount:** `?bool` — It includes the count of contacts that belong to each segment. + +
+
+
+
+ + +
+
+
+ +
$client->unstable->segments->retrieveSegment($request) -> Segment +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single segment. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->segments->retrieveSegment( + new RetrieveSegmentRequest([ + 'id' => '123', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `string` — The unique identified of a given segment. + +
+
+
+
+ + +
+
+
+ +## Switch +
$client->unstable->switch_->createPhoneSwitch($request) -> ?PhoneSwitch +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can use the API to deflect phone calls to the Intercom Messenger. +Calling this endpoint will send an SMS with a link to the Messenger to the phone number specified. + +If custom attributes are specified, they will be added to the user or lead's custom data attributes. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->switch->createPhoneSwitch( + [ + 'key' => "value", + ], +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$request:** `mixed` + +
+
+
+
+ + +
+
+
+ +## Calls +
$client->unstable->calls->listCalls($request) -> CallList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve a paginated list of calls. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->calls->listCalls( + new ListCallsRequest([ + 'page' => 1, + 'perPage' => 1, + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$page:** `?int` — The page of results to fetch. Defaults to first page + +
+
+ +
+
+ +**$perPage:** `?int` — How many results to display per page. Defaults to 25. Max 25. + +
+
+
+
+ + +
+
+
+ +
$client->unstable->calls->showCall($request) -> Call +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve a single call by id. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->calls->showCall( + new ShowCallRequest([ + 'id' => 'id', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `string` — The id of the call to retrieve + +
+
+
+
+ + +
+
+
+ +
$client->unstable->calls->showCallRecording($request) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Redirects to a signed URL for the call's recording if it exists. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->calls->showCallRecording( + new ShowCallRecordingRequest([ + 'id' => 'id', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `string` — The id of the call + +
+
+
+
+ + +
+
+
+ +
$client->unstable->calls->showCallTranscript($request) -> string +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Returns the transcript for the specified call as a downloadable text file. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->calls->showCallTranscript( + new ShowCallTranscriptRequest([ + 'id' => 'id', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `string` — The id of the call + +
+
+
+
+ + +
+
+
+ +
$client->unstable->calls->listCallsWithTranscripts($request) -> ListCallsWithTranscriptsResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve calls by a list of conversation ids and include transcripts when available. +A maximum of 20 `conversation_ids` can be provided. If none are provided or more than 20 are provided, a 400 error is returned. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->calls->listCallsWithTranscripts( + new ListCallsWithTranscriptsRequest([ + 'conversationIds' => [ + '64619700005694', + '64619700005695', + ], + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$conversationIds:** `array` — A list of conversation ids to fetch calls for. Maximum 20. + +
+
+
+
+ + +
+
+
+ +
$client->unstable->calls->registerFinVoiceCall($request) -> AiCallResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Register a Fin Voice call with Intercom. This endpoint creates an external reference +that links an external call identifier to an Intercom call and conversation. + +The call can be from different sources: +- AWS Connect (default) +- Five9 +- Zoom Phone +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->calls->registerFinVoiceCall( + new RegisterFinVoiceCallRequest([ + 'phoneNumber' => '+1234567890', + 'callId' => 'call-123-abc', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$request:** `?RegisterFinVoiceCallRequest` + +
+
+
+
+ + +
+
+
+ +
$client->unstable->calls->collectFinVoiceCallById($request) -> AiCallResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve information about a Fin Voice call using the external reference ID. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->calls->collectFinVoiceCallById( + new CollectFinVoiceCallByIdRequest([ + 'id' => 1, + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `int` — The external reference ID + +
+
+
+
+ + +
+
+
+ +
$client->unstable->calls->collectFinVoiceCallByExternalId($request) -> AiCallResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve information about a Fin Voice call using the external call identifier. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->calls->collectFinVoiceCallByExternalId( + new CollectFinVoiceCallByExternalIdRequest([ + 'externalId' => 'external_id', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$externalId:** `string` — The external call identifier from the call provider + +
+
+
+
+ + +
+
+
+ +
$client->unstable->calls->collectFinVoiceCallByPhoneNumber($request) -> Error +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve information about a Fin Voice call using the phone number. + +Returns the most recent matched call for the given phone number, ordered by creation date. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->calls->collectFinVoiceCallByPhoneNumber( + new CollectFinVoiceCallByPhoneNumberRequest([ + 'phoneNumber' => 'phone_number', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$phoneNumber:** `string` — Phone number in E.164 format + +
+
+
+
+ + +
+
+
+ +## Teams +
$client->unstable->teams->listTeams() -> TeamList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +This will return a list of team objects for the App. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->teams->list(); +``` +
+
+
+
+ + +
+
+
+ +
$client->unstable->teams->retrieveTeam($request) -> Team +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single team, containing an array of admins that belong to this team. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->teams->retrieveTeam( + new RetrieveTeamRequest([ + 'id' => '123', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `string` — The unique identifier of a given team. + +
+
+
+
+ + +
+
+
+ +## Ticket States +
$client->unstable->ticketStates->listTicketStates() -> TicketStateList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can get a list of all ticket states for a workspace. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->ticketStates->listTicketStates(); +``` +
+
+
+
+ + +
+
+
+ +## Ticket Type Attributes +
$client->unstable->ticketTypeAttributes->createTicketTypeAttribute($request) -> ?TicketTypeAttribute +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a new attribute for a ticket type. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->ticketTypes->attributes->create( + new CreateTicketTypeAttributeRequest([ + 'ticketTypeId' => 'ticket_type_id', + 'name' => 'Attribute Title', + 'description' => 'Attribute Description', + 'dataType' => CreateTicketTypeAttributeRequestDataType::String->value, + 'requiredToCreate' => false, + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$ticketTypeId:** `string` — The unique identifier for the ticket type which is given by Intercom. + +
+
+ +
+
+ +**$name:** `string` — The name of the ticket type attribute + +
+
+ +
+
+ +**$description:** `string` — The description of the attribute presented to the teammate or contact + +
+
+ +
+
+ +**$dataType:** `string` — The data type of the attribute + +
+
+ +
+
+ +**$requiredToCreate:** `?bool` — Whether the attribute is required to be filled in when teammates are creating the ticket in Inbox. + +
+
+ +
+
+ +**$requiredToCreateForContacts:** `?bool` — Whether the attribute is required to be filled in when contacts are creating the ticket in Messenger. + +
+
+ +
+
+ +**$visibleOnCreate:** `?bool` — Whether the attribute is visible to teammates when creating a ticket in Inbox. + +
+
+ +
+
+ +**$visibleToContacts:** `?bool` — Whether the attribute is visible to contacts when creating a ticket in Messenger. + +
+
+ +
+
+ +**$multiline:** `?bool` — Whether the attribute allows multiple lines of text (only applicable to string attributes) + +
+
+ +
+
+ +**$listItems:** `?string` — A comma delimited list of items for the attribute value (only applicable to list attributes) + +
+
+ +
+
+ +**$allowMultipleValues:** `?bool` — Whether the attribute allows multiple files to be attached to it (only applicable to file attributes) + +
+
+
+
+ + +
+
+
+ +
$client->unstable->ticketTypeAttributes->updateTicketTypeAttribute($request) -> ?TicketTypeAttribute +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can update an existing attribute for a ticket type. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->ticketTypeAttributes->updateTicketTypeAttribute( + new UpdateTicketTypeAttributeRequest([ + 'ticketTypeId' => 'ticket_type_id', + 'id' => 'id', + 'description' => 'New Attribute Description', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$ticketTypeId:** `string` — The unique identifier for the ticket type which is given by Intercom. + +
+
+ +
+
+ +**$id:** `string` — The unique identifier for the ticket type attribute which is given by Intercom. + +
+
+ +
+
+ +**$name:** `?string` — The name of the ticket type attribute + +
+
+ +
+
+ +**$description:** `?string` — The description of the attribute presented to the teammate or contact + +
+
+ +
+
+ +**$requiredToCreate:** `?bool` — Whether the attribute is required to be filled in when teammates are creating the ticket in Inbox. + +
+
+ +
+
+ +**$requiredToCreateForContacts:** `?bool` — Whether the attribute is required to be filled in when contacts are creating the ticket in Messenger. + +
+
+ +
+
+ +**$visibleOnCreate:** `?bool` — Whether the attribute is visible to teammates when creating a ticket in Inbox. + +
+
+ +
+
+ +**$visibleToContacts:** `?bool` — Whether the attribute is visible to contacts when creating a ticket in Messenger. + +
+
+ +
+
+ +**$multiline:** `?bool` — Whether the attribute allows multiple lines of text (only applicable to string attributes) + +
+
+ +
+
+ +**$listItems:** `?string` — A comma delimited list of items for the attribute value (only applicable to list attributes) + +
+
+ +
+
+ +**$allowMultipleValues:** `?bool` — Whether the attribute allows multiple files to be attached to it (only applicable to file attributes) + +
+
+ +
+
+ +**$archived:** `?bool` — Whether the attribute should be archived and not shown during creation of the ticket (it will still be present on previously created tickets) + +
+
+
+
+ + +
+
+
+ +## Ticket Types +
$client->unstable->ticketTypes->listTicketTypes() -> TicketTypeList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can get a list of all ticket types for a workspace. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->ticketTypes->list(); +``` +
+
+
+
+ + +
+
+
+ +
$client->unstable->ticketTypes->createTicketType($request) -> ?TicketType +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a new ticket type. +> 📘 Creating ticket types. +> +> Every ticket type will be created with two default attributes: _default_title_ and _default_description_. +> For the `icon` propery, use an emoji from [Twemoji Cheatsheet](https://twemoji-cheatsheet.vercel.app/) +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->ticketTypes->createTicketType( + [ + 'key' => "value", + ], +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$request:** `mixed` + +
+
+
+
+ + +
+
+
+ +
$client->unstable->ticketTypes->getTicketType($request) -> ?TicketType +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single ticket type. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->ticketTypes->getTicketType( + new GetTicketTypeRequest([ + 'id' => 'id', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `string` — The unique identifier for the ticket type which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +## Tickets +
$client->unstable->tickets->replyTicket($request) -> TicketReply +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can reply to a ticket with a message from an admin or on behalf of a contact, or with a note for admins. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->tickets->replyTicket( + new ReplyTicketRequest([ + 'id' => '123', + 'body' => new ContactReplyTicketIntercomUserIdRequest([ + 'messageType' => 'comment', + 'type' => 'user', + 'body' => 'Thanks again :)', + 'intercomUserId' => '6762f2971bb69f9f2193bc49', + ]), + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `string` + +
+
+ +
+
+ +**$request:** `ContactReplyTicketIntercomUserIdRequest|ContactReplyTicketUserIdRequest|ContactReplyTicketEmailRequest|AdminReplyTicketRequest` + +
+
+
+
+ + +
+
+
+ +
$client->unstable->tickets->enqueueCreateTicket($request) -> Jobs +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Enqueues ticket creation for asynchronous processing, returning if the job was enqueued successfully to be processed. We attempt to perform a best-effort validation on inputs before tasks are enqueued. If the given parameters are incorrect, we won't enqueue the job. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->tickets->enqueueCreateTicket( + new EnqueueCreateTicketRequest([ + 'ticketTypeId' => '1234', + 'contacts' => [ + new CreateTicketRequestContactsItemId([ + 'id' => '6762f2d81bb69f9f2193bc54', + ]), + ], + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$skipNotifications:** `?bool` — Option to disable notifications when a Ticket is created. + +
+
+
+
+ + +
+
+
+ +
$client->unstable->tickets->getTicket($request) -> ?Ticket +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single ticket. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->tickets->getTicket( + new GetTicketRequest([ + 'id' => 'id', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `string` — The unique identifier for the ticket which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
$client->unstable->tickets->updateTicket($request) -> ?Ticket +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can update a ticket. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->tickets->updateTicket( + new UpdateTicketRequest([ + 'id' => 'id', + 'ticketAttributes' => [ + '_default_title_' => "example", + '_default_description_' => "there is a problem", + ], + 'ticketStateId' => '123', + 'open' => true, + 'snoozedUntil' => 1673609604, + 'adminId' => 991268011, + 'assigneeId' => '123', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `string` — The unique identifier for the ticket which is given by Intercom + +
+
+ +
+
+ +**$ticketAttributes:** `?array` — The attributes set on the ticket. + +
+
+ +
+
+ +**$ticketStateId:** `?string` — The ID of the ticket state associated with the ticket type. + +
+
+ +
+
+ +**$companyId:** `?string` — The ID of the company that the ticket is associated with. The unique identifier for the company which is given by Intercom. Set to nil to remove company. + +
+
+ +
+
+ +**$open:** `?bool` — Specify if a ticket is open. Set to false to close a ticket. Closing a ticket will also unsnooze it. + +
+
+ +
+
+ +**$isShared:** `?bool` — Specify whether the ticket is visible to users. + +
+
+ +
+
+ +**$snoozedUntil:** `?int` — The time you want the ticket to reopen. + +
+
+ +
+
+ +**$adminId:** `?int` — The ID of the admin performing ticket update. Needed for workflows execution and attributing actions to specific admins. + +
+
+ +
+
+ +**$assigneeId:** `?string` — The ID of the admin or team to which the ticket is assigned. Set this 0 to unassign it. + +
+
+
+
+ + +
+
+
+ +
$client->unstable->tickets->deleteTicket($request) -> DeleteTicketResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can delete a ticket using the Intercom provided ID. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->tickets->deleteTicket( + new DeleteTicketRequest([ + 'id' => 'id', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `string` — The unique identifier for the ticket which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
$client->unstable->tickets->searchTickets($request) -> TicketList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can search for multiple tickets by the value of their attributes in order to fetch exactly which ones you want. + +To search for tickets, you send a `POST` request to `https://api.intercom.io/tickets/search`. + +This will accept a query object in the body which will define your filters. +{% admonition type="warning" name="Optimizing search queries" %} + Search queries can be complex, so optimizing them can help the performance of your search. + Use the `AND` and `OR` operators to combine multiple filters to get the exact results you need and utilize + pagination to limit the number of results returned. The default is `20` results per page. + See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#example-search-conversations-request) for more details on how to use the `starting_after` param. +{% /admonition %} + +### Nesting & Limitations + +You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). +There are some limitations to the amount of multiples there can be: +- There's a limit of max 2 nested filters +- There's a limit of max 15 filters for each AND or OR group + +### Accepted Fields + +Most keys listed as part of the Ticket model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as `created_at` accepts a date, the `value` cannot be a string such as `"foobar"`). +The `source.body` field is unique as the search will not be performed against the entire value, but instead against every element of the value separately. For example, when searching for a conversation with a `"I need support"` body - the query should contain a `=` operator with the value `"support"` for such conversation to be returned. A query with a `=` operator and a `"need support"` value will not yield a result. + +| Field | Type | +| :---------------------------------------- | :--------------------------------------------------------------------------------------- | +| id | String | +| created_at | Date (UNIX timestamp) | +| updated_at | Date (UNIX timestamp) | +| title | String | +| description | String | +| category | String | +| ticket_type_id | String | +| contact_ids | String | +| teammate_ids | String | +| admin_assignee_id | String | +| team_assignee_id | String | +| open | Boolean | +| state | String | +| snoozed_until | Date (UNIX timestamp) | +| ticket_attribute.{id} | String or Boolean or Date (UNIX timestamp) or Float or Integer | + +{% admonition type="info" name="Searching by Category" %} +When searching for tickets by the **`category`** field, specific terms must be used instead of the category names: +* For **Customer** category tickets, use the term `request`. +* For **Back-office** category tickets, use the term `task`. +* For **Tracker** category tickets, use the term `tracker`. +{% /admonition %} + +### Accepted Operators + +{% admonition type="info" name="Searching based on `created_at`" %} + You may use the `<=` or `>=` operators to search by `created_at`. +{% /admonition %} + +The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string (`"="`). The operator has to be compatible with the field's type (eg. you cannot search with `>` for a given string value as it's only compatible for integer's and dates). + +| Operator | Valid Types | Description | +| :------- | :----------------------------- | :----------------------------------------------------------- | +| = | All | Equals | +| != | All | Doesn't Equal | +| IN | All | In Shortcut for `OR` queries Values most be in Array | +| NIN | All | Not In Shortcut for `OR !` queries Values must be in Array | +| > | Integer Date (UNIX Timestamp) | Greater (or equal) than | +| < | Integer Date (UNIX Timestamp) | Lower (or equal) than | +| ~ | String | Contains | +| !~ | String | Doesn't Contain | +| ^ | String | Starts With | +| $ | String | Ends With | +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->tickets->searchTickets( + new SearchRequest([ + 'query' => new SingleFilterSearchRequest([]), + 'pagination' => new StartingAfterPaging([ + 'perPage' => 5, + ]), + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$request:** `SearchRequest` + +
+
+
+
+ + +
+
+
+ +## Visitors +
$client->unstable->visitors->retrieveVisitorWithUserId($request) -> ?Visitor +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single visitor. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->visitors->find( + new FindVisitorRequest([ + 'userId' => 'user_id', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$userId:** `string` — The user_id of the Visitor you want to retrieve. + +
+
+
+
+ + +
+
+
+ +
$client->unstable->visitors->updateVisitor($request) -> ?Visitor +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Sending a PUT request to `/visitors` will result in an update of an existing Visitor. + +**Option 1.** You can update a visitor by passing in the `user_id` of the visitor in the Request body. + +**Option 2.** You can update a visitor by passing in the `id` of the visitor in the Request body. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->visitors->update( + new UpdateVisitorRequestWithId([ + 'id' => '6762f30c1bb69f9f2193bc5e', + 'name' => 'Gareth Bale', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$request:** `mixed` + +
+
+
+
+ + +
+
+
+ +
$client->unstable->visitors->convertVisitor($request) -> Contact +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can merge a Visitor to a Contact of role type `lead` or `user`. + +> 📘 What happens upon a visitor being converted? +> +> If the User exists, then the Visitor will be merged into it, the Visitor deleted and the User returned. If the User does not exist, the Visitor will be converted to a User, with the User identifiers replacing it's Visitor identifiers. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->visitors->convertVisitor( + new ConvertVisitorRequest([ + 'type' => 'user', + 'user' => [ + 'email' => "foo@bar.com", + ], + 'visitor' => [ + 'user_id' => "3ecf64d0-9ed1-4e9f-88e1-da7d6e6782f3", + ], + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$type:** `string` — Represents the role of the Contact model. Accepts `lead` or `user`. + +
+
+ +
+
+ +**$user:** `mixed` + +
+
+ +
+
+ +**$visitor:** `mixed` + +
+
+
+
+ + +
+
+
+ +## Brands +
$client->unstable->brands->listBrands() -> BrandList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieves all brands for the workspace, including the default brand. +The default brand id always matches the workspace +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->brands->listBrands(); +``` +
+
+
+
+ + +
+
+
+ +
$client->unstable->brands->retrieveBrand($request) -> Brand +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Fetches a specific brand by its unique identifier +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->brands->retrieveBrand( + new RetrieveBrandRequest([ + 'id' => 'id', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `string` — The unique identifier of the brand + +
+
+
+
+ + +
+
+
+ +## Emails +
$client->unstable->emails->listEmails() -> EmailList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Lists all sender email address settings for the workspace +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->emails->listEmails(); +``` +
+
+
+
+ + +
+
+
+ +
$client->unstable->emails->retrieveEmail($request) -> EmailSetting +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Fetches a specific email setting by its unique identifier +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->unstable->emails->retrieveEmail( + new RetrieveEmailRequest([ + 'id' => 'id', + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$id:** `string` — The unique identifier of the email setting + +
+
+
+
+ + +
+
+
diff --git a/src/Admins/AdminsClient.php b/src/Admins/AdminsClient.php index 82600c0..c563325 100644 --- a/src/Admins/AdminsClient.php +++ b/src/Admins/AdminsClient.php @@ -29,7 +29,7 @@ class AdminsClient * maxRetries?: int, * timeout?: float, * headers?: array, - * } $options + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator */ private array $options; @@ -72,11 +72,11 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return AdminWithApp + * @return ?AdminWithApp * @throws IntercomException * @throws IntercomApiException */ - public function identify(?array $options = null): AdminWithApp + public function identify(?array $options = null): ?AdminWithApp { $options = array_merge($this->options, $options ?? []); try { @@ -91,6 +91,9 @@ public function identify(?array $options = null): AdminWithApp $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return AdminWithApp::fromJson($json); } } catch (JsonException $e) { @@ -127,11 +130,11 @@ public function identify(?array $options = null): AdminWithApp * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Admin + * @return ?Admin * @throws IntercomException * @throws IntercomApiException */ - public function away(ConfigureAwayAdminRequest $request, ?array $options = null): Admin + public function away(ConfigureAwayAdminRequest $request, ?array $options = null): ?Admin { $options = array_merge($this->options, $options ?? []); try { @@ -147,6 +150,9 @@ public function away(ConfigureAwayAdminRequest $request, ?array $options = null) $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Admin::fromJson($json); } } catch (JsonException $e) { @@ -298,11 +304,11 @@ public function list(?array $options = null): AdminList * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Admin + * @return ?Admin * @throws IntercomException * @throws IntercomApiException */ - public function find(FindAdminRequest $request, ?array $options = null): Admin + public function find(FindAdminRequest $request, ?array $options = null): ?Admin { $options = array_merge($this->options, $options ?? []); try { @@ -317,6 +323,9 @@ public function find(FindAdminRequest $request, ?array $options = null): Admin $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Admin::fromJson($json); } } catch (JsonException $e) { diff --git a/src/Admins/Requests/ConfigureAwayAdminRequest.php b/src/Admins/Requests/ConfigureAwayAdminRequest.php index 37cee6d..caf75c2 100644 --- a/src/Admins/Requests/ConfigureAwayAdminRequest.php +++ b/src/Admins/Requests/ConfigureAwayAdminRequest.php @@ -8,9 +8,9 @@ class ConfigureAwayAdminRequest extends JsonSerializableType { /** - * @var string $adminId The unique identifier of a given admin + * @var int $adminId The unique identifier of a given admin */ - private string $adminId; + private int $adminId; /** * @var bool $awayModeEnabled Set to "true" to change the status of the admin to away. @@ -24,11 +24,18 @@ class ConfigureAwayAdminRequest extends JsonSerializableType #[JsonProperty('away_mode_reassign')] private bool $awayModeReassign; + /** + * @var ?int $awayStatusReasonId The unique identifier of the away status reason + */ + #[JsonProperty('away_status_reason_id')] + private ?int $awayStatusReasonId; + /** * @param array{ - * adminId: string, + * adminId: int, * awayModeEnabled: bool, * awayModeReassign: bool, + * awayStatusReasonId?: ?int, * } $values */ public function __construct( @@ -37,20 +44,21 @@ public function __construct( $this->adminId = $values['adminId']; $this->awayModeEnabled = $values['awayModeEnabled']; $this->awayModeReassign = $values['awayModeReassign']; + $this->awayStatusReasonId = $values['awayStatusReasonId'] ?? null; } /** - * @return string + * @return int */ - public function getAdminId(): string + public function getAdminId(): int { return $this->adminId; } /** - * @param string $value + * @param int $value */ - public function setAdminId(string $value): self + public function setAdminId(int $value): self { $this->adminId = $value; return $this; @@ -89,4 +97,21 @@ public function setAwayModeReassign(bool $value): self $this->awayModeReassign = $value; return $this; } + + /** + * @return ?int + */ + public function getAwayStatusReasonId(): ?int + { + return $this->awayStatusReasonId; + } + + /** + * @param ?int $value + */ + public function setAwayStatusReasonId(?int $value = null): self + { + $this->awayStatusReasonId = $value; + return $this; + } } diff --git a/src/Admins/Requests/FindAdminRequest.php b/src/Admins/Requests/FindAdminRequest.php index 3145be7..e21f226 100644 --- a/src/Admins/Requests/FindAdminRequest.php +++ b/src/Admins/Requests/FindAdminRequest.php @@ -7,13 +7,13 @@ class FindAdminRequest extends JsonSerializableType { /** - * @var string $adminId The unique identifier of a given admin + * @var int $adminId The unique identifier of a given admin */ - private string $adminId; + private int $adminId; /** * @param array{ - * adminId: string, + * adminId: int, * } $values */ public function __construct( @@ -23,17 +23,17 @@ public function __construct( } /** - * @return string + * @return int */ - public function getAdminId(): string + public function getAdminId(): int { return $this->adminId; } /** - * @param string $value + * @param int $value */ - public function setAdminId(string $value): self + public function setAdminId(int $value): self { $this->adminId = $value; return $this; diff --git a/src/Admins/Types/Admin.php b/src/Admins/Types/Admin.php index 6a01234..63f21ab 100644 --- a/src/Admins/Types/Admin.php +++ b/src/Admins/Types/Admin.php @@ -13,7 +13,7 @@ class Admin extends JsonSerializableType { /** - * @var ?'admin' $type String representing the object's type. Always has the value `admin`. + * @var ?string $type String representing the object's type. Always has the value `admin`. */ #[JsonProperty('type')] private ?string $type; @@ -54,6 +54,12 @@ class Admin extends JsonSerializableType #[JsonProperty('away_mode_reassign')] private bool $awayModeReassign; + /** + * @var ?int $awayStatusReasonId The unique identifier of the away status reason + */ + #[JsonProperty('away_status_reason_id')] + private ?int $awayStatusReasonId; + /** * @var bool $hasInboxSeat Identifies if this admin has a paid inbox seat to restrict/allow features that require them. */ @@ -87,8 +93,9 @@ class Admin extends JsonSerializableType * awayModeReassign: bool, * hasInboxSeat: bool, * teamIds: array, - * type?: ?'admin', + * type?: ?string, * jobTitle?: ?string, + * awayStatusReasonId?: ?int, * avatar?: ?AdminAvatar, * teamPriorityLevel?: ?TeamPriorityLevel, * } $values @@ -103,6 +110,7 @@ public function __construct( $this->jobTitle = $values['jobTitle'] ?? null; $this->awayModeEnabled = $values['awayModeEnabled']; $this->awayModeReassign = $values['awayModeReassign']; + $this->awayStatusReasonId = $values['awayStatusReasonId'] ?? null; $this->hasInboxSeat = $values['hasInboxSeat']; $this->teamIds = $values['teamIds']; $this->avatar = $values['avatar'] ?? null; @@ -110,7 +118,7 @@ public function __construct( } /** - * @return ?'admin' + * @return ?string */ public function getType(): ?string { @@ -118,7 +126,7 @@ public function getType(): ?string } /** - * @param ?'admin' $value + * @param ?string $value */ public function setType(?string $value = null): self { @@ -228,6 +236,23 @@ public function setAwayModeReassign(bool $value): self return $this; } + /** + * @return ?int + */ + public function getAwayStatusReasonId(): ?int + { + return $this->awayStatusReasonId; + } + + /** + * @param ?int $value + */ + public function setAwayStatusReasonId(?int $value = null): self + { + $this->awayStatusReasonId = $value; + return $this; + } + /** * @return bool */ diff --git a/src/AiAgent/Types/AiAgent.php b/src/AiAgent/Types/AiAgent.php index 76dc4b7..f940d42 100644 --- a/src/AiAgent/Types/AiAgent.php +++ b/src/AiAgent/Types/AiAgent.php @@ -12,10 +12,10 @@ class AiAgent extends JsonSerializableType { /** - * @var value-of $sourceType The type of the source that triggered AI Agent involvement in the conversation. + * @var ?value-of $sourceType The type of the source that triggered AI Agent involvement in the conversation. */ #[JsonProperty('source_type')] - private string $sourceType; + private ?string $sourceType; /** * @var ?string $sourceTitle The title of the source that triggered AI Agent involvement in the conversation. If this is `essentials_plan_setup` then it will return `null`. @@ -24,13 +24,13 @@ class AiAgent extends JsonSerializableType private ?string $sourceTitle; /** - * @var ?string $lastAnswerType The type of the last answer delivered by AI Agent. If no answer was delivered then this will return `null` + * @var ?value-of $lastAnswerType The type of the last answer delivered by AI Agent. If no answer was delivered then this will return `null` */ #[JsonProperty('last_answer_type')] private ?string $lastAnswerType; /** - * @var ?string $resolutionState The resolution state of AI Agent. If no AI or custom answer has been delivered then this will return `null`. + * @var ?value-of $resolutionState The resolution state of AI Agent. If no AI or custom answer has been delivered then this will return `null`. */ #[JsonProperty('resolution_state')] private ?string $resolutionState; @@ -47,6 +47,18 @@ class AiAgent extends JsonSerializableType #[JsonProperty('rating_remark')] private ?string $ratingRemark; + /** + * @var ?int $createdAt The time when the AI agent rating was created. + */ + #[JsonProperty('created_at')] + private ?int $createdAt; + + /** + * @var ?int $updatedAt The time when the AI agent rating was last updated. + */ + #[JsonProperty('updated_at')] + private ?int $updatedAt; + /** * @var ?ContentSourcesList $contentSources */ @@ -55,39 +67,43 @@ class AiAgent extends JsonSerializableType /** * @param array{ - * sourceType: value-of, + * sourceType?: ?value-of, * sourceTitle?: ?string, - * lastAnswerType?: ?string, - * resolutionState?: ?string, + * lastAnswerType?: ?value-of, + * resolutionState?: ?value-of, * rating?: ?int, * ratingRemark?: ?string, + * createdAt?: ?int, + * updatedAt?: ?int, * contentSources?: ?ContentSourcesList, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->sourceType = $values['sourceType']; + $this->sourceType = $values['sourceType'] ?? null; $this->sourceTitle = $values['sourceTitle'] ?? null; $this->lastAnswerType = $values['lastAnswerType'] ?? null; $this->resolutionState = $values['resolutionState'] ?? null; $this->rating = $values['rating'] ?? null; $this->ratingRemark = $values['ratingRemark'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; + $this->updatedAt = $values['updatedAt'] ?? null; $this->contentSources = $values['contentSources'] ?? null; } /** - * @return value-of + * @return ?value-of */ - public function getSourceType(): string + public function getSourceType(): ?string { return $this->sourceType; } /** - * @param value-of $value + * @param ?value-of $value */ - public function setSourceType(string $value): self + public function setSourceType(?string $value = null): self { $this->sourceType = $value; return $this; @@ -111,7 +127,7 @@ public function setSourceTitle(?string $value = null): self } /** - * @return ?string + * @return ?value-of */ public function getLastAnswerType(): ?string { @@ -119,7 +135,7 @@ public function getLastAnswerType(): ?string } /** - * @param ?string $value + * @param ?value-of $value */ public function setLastAnswerType(?string $value = null): self { @@ -128,7 +144,7 @@ public function setLastAnswerType(?string $value = null): self } /** - * @return ?string + * @return ?value-of */ public function getResolutionState(): ?string { @@ -136,7 +152,7 @@ public function getResolutionState(): ?string } /** - * @param ?string $value + * @param ?value-of $value */ public function setResolutionState(?string $value = null): self { @@ -178,6 +194,40 @@ public function setRatingRemark(?string $value = null): self return $this; } + /** + * @return ?int + */ + public function getCreatedAt(): ?int + { + return $this->createdAt; + } + + /** + * @param ?int $value + */ + public function setCreatedAt(?int $value = null): self + { + $this->createdAt = $value; + return $this; + } + + /** + * @return ?int + */ + public function getUpdatedAt(): ?int + { + return $this->updatedAt; + } + + /** + * @param ?int $value + */ + public function setUpdatedAt(?int $value = null): self + { + $this->updatedAt = $value; + return $this; + } + /** * @return ?ContentSourcesList */ diff --git a/src/AiAgent/Types/AiAgentLastAnswerType.php b/src/AiAgent/Types/AiAgentLastAnswerType.php new file mode 100644 index 0000000..f502e49 --- /dev/null +++ b/src/AiAgent/Types/AiAgentLastAnswerType.php @@ -0,0 +1,9 @@ +, + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator + */ + private array $options; + + /** + * @var RawClient $client + */ + private RawClient $client; + + /** + * @param RawClient $client + * @param ?array{ + * baseUrl?: string, + * client?: ClientInterface, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * } $options + */ + public function __construct( + RawClient $client, + ?array $options = null, + ) { + $this->client = $client; + $this->options = $options ?? []; + } + + /** + * You can retrieve a list of all content import sources for a workspace. + * + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return ContentImportSourcesList + * @throws IntercomException + * @throws IntercomApiException + */ + public function listContentImportSources(?array $options = null): ContentImportSourcesList + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "ai/content_import_sources", + method: HttpMethod::GET, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return ContentImportSourcesList::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * You can create a new content import source by sending a POST request to this endpoint. + * + * @param CreateContentImportSourceRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return ContentImportSource + * @throws IntercomException + * @throws IntercomApiException + */ + public function createContentImportSource(CreateContentImportSourceRequest $request, ?array $options = null): ContentImportSource + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "ai/content_import_sources", + method: HttpMethod::POST, + body: $request, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return ContentImportSource::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * @param GetContentImportSourceRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return ContentImportSource + * @throws IntercomException + * @throws IntercomApiException + */ + public function getContentImportSource(GetContentImportSourceRequest $request, ?array $options = null): ContentImportSource + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "ai/content_import_sources/{$request->getSourceId()}", + method: HttpMethod::GET, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return ContentImportSource::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * You can update an existing content import source. + * + * @param UpdateContentImportSourceRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return ContentImportSource + * @throws IntercomException + * @throws IntercomApiException + */ + public function updateContentImportSource(UpdateContentImportSourceRequest $request, ?array $options = null): ContentImportSource + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "ai/content_import_sources/{$request->getSourceId()}", + method: HttpMethod::PUT, + body: $request, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return ContentImportSource::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * You can delete a content import source by making a DELETE request this endpoint. This will also delete all external pages that were imported from this source. + * + * @param DeleteContentImportSourceRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @throws IntercomException + * @throws IntercomApiException + */ + public function deleteContentImportSource(DeleteContentImportSourceRequest $request, ?array $options = null): void + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "ai/content_import_sources/{$request->getSourceId()}", + method: HttpMethod::DELETE, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + return; + } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * You can retrieve a list of all external pages for a workspace. + * + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return ExternalPagesList + * @throws IntercomException + * @throws IntercomApiException + */ + public function listExternalPages(?array $options = null): ExternalPagesList + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "ai/external_pages", + method: HttpMethod::GET, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return ExternalPagesList::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * You can create a new external page by sending a POST request to this endpoint. If an external page already exists with the specified source_id and external_id, it will be updated instead. + * + * @param CreateExternalPageRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return ExternalPage + * @throws IntercomException + * @throws IntercomApiException + */ + public function createExternalPage(CreateExternalPageRequest $request, ?array $options = null): ExternalPage + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "ai/external_pages", + method: HttpMethod::POST, + body: $request, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return ExternalPage::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * You can retrieve an external page. + * + * @param GetExternalPageRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return ExternalPage + * @throws IntercomException + * @throws IntercomApiException + */ + public function getExternalPage(GetExternalPageRequest $request, ?array $options = null): ExternalPage + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "ai/external_pages/{$request->getPageId()}", + method: HttpMethod::GET, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return ExternalPage::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * You can update an existing external page (if it was created via the API). + * + * @param UpdateExternalPageRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return ExternalPage + * @throws IntercomException + * @throws IntercomApiException + */ + public function updateExternalPage(UpdateExternalPageRequest $request, ?array $options = null): ExternalPage + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "ai/external_pages/{$request->getPageId()}", + method: HttpMethod::PUT, + body: $request, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return ExternalPage::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * Sending a DELETE request for an external page will remove it from the content library UI and from being used for AI answers. + * + * @param DeleteExternalPageRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return ExternalPage + * @throws IntercomException + * @throws IntercomApiException + */ + public function deleteExternalPage(DeleteExternalPageRequest $request, ?array $options = null): ExternalPage + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "ai/external_pages/{$request->getPageId()}", + method: HttpMethod::DELETE, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return ExternalPage::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } +} diff --git a/src/AiContent/Requests/CreateContentImportSourceRequest.php b/src/AiContent/Requests/CreateContentImportSourceRequest.php new file mode 100644 index 0000000..123096c --- /dev/null +++ b/src/AiContent/Requests/CreateContentImportSourceRequest.php @@ -0,0 +1,94 @@ + $status The status of the content import source. + */ + #[JsonProperty('status')] + private ?string $status; + + /** + * @var string $url The URL of the content import source. + */ + #[JsonProperty('url')] + private string $url; + + /** + * @param array{ + * syncBehavior: 'api', + * url: string, + * status?: ?value-of, + * } $values + */ + public function __construct( + array $values, + ) { + $this->syncBehavior = $values['syncBehavior']; + $this->status = $values['status'] ?? null; + $this->url = $values['url']; + } + + /** + * @return 'api' + */ + public function getSyncBehavior(): string + { + return $this->syncBehavior; + } + + /** + * @param 'api' $value + */ + public function setSyncBehavior(string $value): self + { + $this->syncBehavior = $value; + return $this; + } + + /** + * @return ?value-of + */ + public function getStatus(): ?string + { + return $this->status; + } + + /** + * @param ?value-of $value + */ + public function setStatus(?string $value = null): self + { + $this->status = $value; + return $this; + } + + /** + * @return string + */ + public function getUrl(): string + { + return $this->url; + } + + /** + * @param string $value + */ + public function setUrl(string $value): self + { + $this->url = $value; + return $this; + } +} diff --git a/src/AiContent/Requests/CreateExternalPageRequest.php b/src/AiContent/Requests/CreateExternalPageRequest.php new file mode 100644 index 0000000..d4bc323 --- /dev/null +++ b/src/AiContent/Requests/CreateExternalPageRequest.php @@ -0,0 +1,218 @@ +title = $values['title']; + $this->html = $values['html']; + $this->url = $values['url'] ?? null; + $this->aiAgentAvailability = $values['aiAgentAvailability'] ?? null; + $this->aiCopilotAvailability = $values['aiCopilotAvailability'] ?? null; + $this->locale = $values['locale']; + $this->sourceId = $values['sourceId']; + $this->externalId = $values['externalId']; + } + + /** + * @return string + */ + public function getTitle(): string + { + return $this->title; + } + + /** + * @param string $value + */ + public function setTitle(string $value): self + { + $this->title = $value; + return $this; + } + + /** + * @return string + */ + public function getHtml(): string + { + return $this->html; + } + + /** + * @param string $value + */ + public function setHtml(string $value): self + { + $this->html = $value; + return $this; + } + + /** + * @return ?string + */ + public function getUrl(): ?string + { + return $this->url; + } + + /** + * @param ?string $value + */ + public function setUrl(?string $value = null): self + { + $this->url = $value; + return $this; + } + + /** + * @return ?bool + */ + public function getAiAgentAvailability(): ?bool + { + return $this->aiAgentAvailability; + } + + /** + * @param ?bool $value + */ + public function setAiAgentAvailability(?bool $value = null): self + { + $this->aiAgentAvailability = $value; + return $this; + } + + /** + * @return ?bool + */ + public function getAiCopilotAvailability(): ?bool + { + return $this->aiCopilotAvailability; + } + + /** + * @param ?bool $value + */ + public function setAiCopilotAvailability(?bool $value = null): self + { + $this->aiCopilotAvailability = $value; + return $this; + } + + /** + * @return 'en' + */ + public function getLocale(): string + { + return $this->locale; + } + + /** + * @param 'en' $value + */ + public function setLocale(string $value): self + { + $this->locale = $value; + return $this; + } + + /** + * @return int + */ + public function getSourceId(): int + { + return $this->sourceId; + } + + /** + * @param int $value + */ + public function setSourceId(int $value): self + { + $this->sourceId = $value; + return $this; + } + + /** + * @return string + */ + public function getExternalId(): string + { + return $this->externalId; + } + + /** + * @param string $value + */ + public function setExternalId(string $value): self + { + $this->externalId = $value; + return $this; + } +} diff --git a/src/AiContent/Requests/DeleteContentImportSourceRequest.php b/src/AiContent/Requests/DeleteContentImportSourceRequest.php new file mode 100644 index 0000000..ce218ec --- /dev/null +++ b/src/AiContent/Requests/DeleteContentImportSourceRequest.php @@ -0,0 +1,41 @@ +sourceId = $values['sourceId']; + } + + /** + * @return string + */ + public function getSourceId(): string + { + return $this->sourceId; + } + + /** + * @param string $value + */ + public function setSourceId(string $value): self + { + $this->sourceId = $value; + return $this; + } +} diff --git a/src/AiContent/Requests/DeleteExternalPageRequest.php b/src/AiContent/Requests/DeleteExternalPageRequest.php new file mode 100644 index 0000000..03748fc --- /dev/null +++ b/src/AiContent/Requests/DeleteExternalPageRequest.php @@ -0,0 +1,41 @@ +pageId = $values['pageId']; + } + + /** + * @return string + */ + public function getPageId(): string + { + return $this->pageId; + } + + /** + * @param string $value + */ + public function setPageId(string $value): self + { + $this->pageId = $value; + return $this; + } +} diff --git a/src/AiContent/Requests/GetContentImportSourceRequest.php b/src/AiContent/Requests/GetContentImportSourceRequest.php new file mode 100644 index 0000000..53bde83 --- /dev/null +++ b/src/AiContent/Requests/GetContentImportSourceRequest.php @@ -0,0 +1,41 @@ +sourceId = $values['sourceId']; + } + + /** + * @return string + */ + public function getSourceId(): string + { + return $this->sourceId; + } + + /** + * @param string $value + */ + public function setSourceId(string $value): self + { + $this->sourceId = $value; + return $this; + } +} diff --git a/src/AiContent/Requests/GetExternalPageRequest.php b/src/AiContent/Requests/GetExternalPageRequest.php new file mode 100644 index 0000000..c6b1074 --- /dev/null +++ b/src/AiContent/Requests/GetExternalPageRequest.php @@ -0,0 +1,41 @@ +pageId = $values['pageId']; + } + + /** + * @return string + */ + public function getPageId(): string + { + return $this->pageId; + } + + /** + * @param string $value + */ + public function setPageId(string $value): self + { + $this->pageId = $value; + return $this; + } +} diff --git a/src/AiContent/Requests/UpdateContentImportSourceRequest.php b/src/AiContent/Requests/UpdateContentImportSourceRequest.php new file mode 100644 index 0000000..c97d52c --- /dev/null +++ b/src/AiContent/Requests/UpdateContentImportSourceRequest.php @@ -0,0 +1,119 @@ + $syncBehavior If you intend to create or update External Pages via the API, this should be set to `api`. You can not change the value to or from api. + */ + #[JsonProperty('sync_behavior')] + private string $syncBehavior; + + /** + * @var ?value-of $status The status of the content import source. + */ + #[JsonProperty('status')] + private ?string $status; + + /** + * @var string $url The URL of the content import source. This may only be different from the existing value if the sync behavior is API. + */ + #[JsonProperty('url')] + private string $url; + + /** + * @param array{ + * sourceId: string, + * syncBehavior: value-of, + * url: string, + * status?: ?value-of, + * } $values + */ + public function __construct( + array $values, + ) { + $this->sourceId = $values['sourceId']; + $this->syncBehavior = $values['syncBehavior']; + $this->status = $values['status'] ?? null; + $this->url = $values['url']; + } + + /** + * @return string + */ + public function getSourceId(): string + { + return $this->sourceId; + } + + /** + * @param string $value + */ + public function setSourceId(string $value): self + { + $this->sourceId = $value; + return $this; + } + + /** + * @return value-of + */ + public function getSyncBehavior(): string + { + return $this->syncBehavior; + } + + /** + * @param value-of $value + */ + public function setSyncBehavior(string $value): self + { + $this->syncBehavior = $value; + return $this; + } + + /** + * @return ?value-of + */ + public function getStatus(): ?string + { + return $this->status; + } + + /** + * @param ?value-of $value + */ + public function setStatus(?string $value = null): self + { + $this->status = $value; + return $this; + } + + /** + * @return string + */ + public function getUrl(): string + { + return $this->url; + } + + /** + * @param string $value + */ + public function setUrl(string $value): self + { + $this->url = $value; + return $this; + } +} diff --git a/src/AiContent/Requests/UpdateExternalPageRequest.php b/src/AiContent/Requests/UpdateExternalPageRequest.php new file mode 100644 index 0000000..e77aa99 --- /dev/null +++ b/src/AiContent/Requests/UpdateExternalPageRequest.php @@ -0,0 +1,217 @@ +pageId = $values['pageId']; + $this->title = $values['title']; + $this->html = $values['html']; + $this->url = $values['url']; + $this->finAvailability = $values['finAvailability'] ?? null; + $this->locale = $values['locale']; + $this->sourceId = $values['sourceId']; + $this->externalId = $values['externalId'] ?? null; + } + + /** + * @return string + */ + public function getPageId(): string + { + return $this->pageId; + } + + /** + * @param string $value + */ + public function setPageId(string $value): self + { + $this->pageId = $value; + return $this; + } + + /** + * @return string + */ + public function getTitle(): string + { + return $this->title; + } + + /** + * @param string $value + */ + public function setTitle(string $value): self + { + $this->title = $value; + return $this; + } + + /** + * @return string + */ + public function getHtml(): string + { + return $this->html; + } + + /** + * @param string $value + */ + public function setHtml(string $value): self + { + $this->html = $value; + return $this; + } + + /** + * @return string + */ + public function getUrl(): string + { + return $this->url; + } + + /** + * @param string $value + */ + public function setUrl(string $value): self + { + $this->url = $value; + return $this; + } + + /** + * @return ?bool + */ + public function getFinAvailability(): ?bool + { + return $this->finAvailability; + } + + /** + * @param ?bool $value + */ + public function setFinAvailability(?bool $value = null): self + { + $this->finAvailability = $value; + return $this; + } + + /** + * @return 'en' + */ + public function getLocale(): string + { + return $this->locale; + } + + /** + * @param 'en' $value + */ + public function setLocale(string $value): self + { + $this->locale = $value; + return $this; + } + + /** + * @return int + */ + public function getSourceId(): int + { + return $this->sourceId; + } + + /** + * @param int $value + */ + public function setSourceId(int $value): self + { + $this->sourceId = $value; + return $this; + } + + /** + * @return ?string + */ + public function getExternalId(): ?string + { + return $this->externalId; + } + + /** + * @param ?string $value + */ + public function setExternalId(?string $value = null): self + { + $this->externalId = $value; + return $this; + } +} diff --git a/src/AiContent/Types/ContentImportSource.php b/src/AiContent/Types/ContentImportSource.php new file mode 100644 index 0000000..f0ef072 --- /dev/null +++ b/src/AiContent/Types/ContentImportSource.php @@ -0,0 +1,229 @@ + $syncBehavior If you intend to create or update External Pages via the API, this should be set to `api`. + */ + #[JsonProperty('sync_behavior')] + private string $syncBehavior; + + /** + * @var value-of $status The status of the content import source. + */ + #[JsonProperty('status')] + private string $status; + + /** + * @var string $url The URL of the root of the external source. + */ + #[JsonProperty('url')] + private string $url; + + /** + * @var int $createdAt The time when the content import source was created. + */ + #[JsonProperty('created_at')] + private int $createdAt; + + /** + * @var int $updatedAt The time when the content import source was last updated. + */ + #[JsonProperty('updated_at')] + private int $updatedAt; + + /** + * @param array{ + * type: 'content_import_source', + * id: int, + * lastSyncedAt: int, + * syncBehavior: value-of, + * status: value-of, + * url: string, + * createdAt: int, + * updatedAt: int, + * } $values + */ + public function __construct( + array $values, + ) { + $this->type = $values['type']; + $this->id = $values['id']; + $this->lastSyncedAt = $values['lastSyncedAt']; + $this->syncBehavior = $values['syncBehavior']; + $this->status = $values['status']; + $this->url = $values['url']; + $this->createdAt = $values['createdAt']; + $this->updatedAt = $values['updatedAt']; + } + + /** + * @return 'content_import_source' + */ + public function getType(): string + { + return $this->type; + } + + /** + * @param 'content_import_source' $value + */ + public function setType(string $value): self + { + $this->type = $value; + return $this; + } + + /** + * @return int + */ + public function getId(): int + { + return $this->id; + } + + /** + * @param int $value + */ + public function setId(int $value): self + { + $this->id = $value; + return $this; + } + + /** + * @return int + */ + public function getLastSyncedAt(): int + { + return $this->lastSyncedAt; + } + + /** + * @param int $value + */ + public function setLastSyncedAt(int $value): self + { + $this->lastSyncedAt = $value; + return $this; + } + + /** + * @return value-of + */ + public function getSyncBehavior(): string + { + return $this->syncBehavior; + } + + /** + * @param value-of $value + */ + public function setSyncBehavior(string $value): self + { + $this->syncBehavior = $value; + return $this; + } + + /** + * @return value-of + */ + public function getStatus(): string + { + return $this->status; + } + + /** + * @param value-of $value + */ + public function setStatus(string $value): self + { + $this->status = $value; + return $this; + } + + /** + * @return string + */ + public function getUrl(): string + { + return $this->url; + } + + /** + * @param string $value + */ + public function setUrl(string $value): self + { + $this->url = $value; + return $this; + } + + /** + * @return int + */ + public function getCreatedAt(): int + { + return $this->createdAt; + } + + /** + * @param int $value + */ + public function setCreatedAt(int $value): self + { + $this->createdAt = $value; + return $this; + } + + /** + * @return int + */ + public function getUpdatedAt(): int + { + return $this->updatedAt; + } + + /** + * @param int $value + */ + public function setUpdatedAt(int $value): self + { + $this->updatedAt = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/AiContent/Types/ContentImportSourceStatus.php b/src/AiContent/Types/ContentImportSourceStatus.php new file mode 100644 index 0000000..4c29bcf --- /dev/null +++ b/src/AiContent/Types/ContentImportSourceStatus.php @@ -0,0 +1,9 @@ + $data An array of Content Import Source objects + */ + #[JsonProperty('data'), ArrayType([ContentImportSource::class])] + private ?array $data; + + /** + * @param array{ + * type?: ?'list', + * pages?: ?PagesLink, + * totalCount?: ?int, + * data?: ?array, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->type = $values['type'] ?? null; + $this->pages = $values['pages'] ?? null; + $this->totalCount = $values['totalCount'] ?? null; + $this->data = $values['data'] ?? null; + } + + /** + * @return ?'list' + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?'list' $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?PagesLink + */ + public function getPages(): ?PagesLink + { + return $this->pages; + } + + /** + * @param ?PagesLink $value + */ + public function setPages(?PagesLink $value = null): self + { + $this->pages = $value; + return $this; + } + + /** + * @return ?int + */ + public function getTotalCount(): ?int + { + return $this->totalCount; + } + + /** + * @param ?int $value + */ + public function setTotalCount(?int $value = null): self + { + $this->totalCount = $value; + return $this; + } + + /** + * @return ?array + */ + public function getData(): ?array + { + return $this->data; + } + + /** + * @param ?array $value + */ + public function setData(?array $value = null): self + { + $this->data = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/AiContent/Types/CreateContentImportSourceRequestStatus.php b/src/AiContent/Types/CreateContentImportSourceRequestStatus.php new file mode 100644 index 0000000..449fdd7 --- /dev/null +++ b/src/AiContent/Types/CreateContentImportSourceRequestStatus.php @@ -0,0 +1,9 @@ +type = $values['type']; + $this->id = $values['id']; + $this->title = $values['title']; + $this->html = $values['html']; + $this->url = $values['url'] ?? null; + $this->aiAgentAvailability = $values['aiAgentAvailability']; + $this->aiCopilotAvailability = $values['aiCopilotAvailability']; + $this->finAvailability = $values['finAvailability'] ?? null; + $this->locale = $values['locale']; + $this->sourceId = $values['sourceId']; + $this->externalId = $values['externalId']; + $this->createdAt = $values['createdAt']; + $this->updatedAt = $values['updatedAt']; + $this->lastIngestedAt = $values['lastIngestedAt']; + } + + /** + * @return 'external_page' + */ + public function getType(): string + { + return $this->type; + } + + /** + * @param 'external_page' $value + */ + public function setType(string $value): self + { + $this->type = $value; + return $this; + } + + /** + * @return string + */ + public function getId(): string + { + return $this->id; + } + + /** + * @param string $value + */ + public function setId(string $value): self + { + $this->id = $value; + return $this; + } + + /** + * @return string + */ + public function getTitle(): string + { + return $this->title; + } + + /** + * @param string $value + */ + public function setTitle(string $value): self + { + $this->title = $value; + return $this; + } + + /** + * @return string + */ + public function getHtml(): string + { + return $this->html; + } + + /** + * @param string $value + */ + public function setHtml(string $value): self + { + $this->html = $value; + return $this; + } + + /** + * @return ?string + */ + public function getUrl(): ?string + { + return $this->url; + } + + /** + * @param ?string $value + */ + public function setUrl(?string $value = null): self + { + $this->url = $value; + return $this; + } + + /** + * @return bool + */ + public function getAiAgentAvailability(): bool + { + return $this->aiAgentAvailability; + } + + /** + * @param bool $value + */ + public function setAiAgentAvailability(bool $value): self + { + $this->aiAgentAvailability = $value; + return $this; + } + + /** + * @return bool + */ + public function getAiCopilotAvailability(): bool + { + return $this->aiCopilotAvailability; + } + + /** + * @param bool $value + */ + public function setAiCopilotAvailability(bool $value): self + { + $this->aiCopilotAvailability = $value; + return $this; + } + + /** + * @return ?bool + */ + public function getFinAvailability(): ?bool + { + return $this->finAvailability; + } + + /** + * @param ?bool $value + */ + public function setFinAvailability(?bool $value = null): self + { + $this->finAvailability = $value; + return $this; + } + + /** + * @return 'en' + */ + public function getLocale(): string + { + return $this->locale; + } + + /** + * @param 'en' $value + */ + public function setLocale(string $value): self + { + $this->locale = $value; + return $this; + } + + /** + * @return int + */ + public function getSourceId(): int + { + return $this->sourceId; + } + + /** + * @param int $value + */ + public function setSourceId(int $value): self + { + $this->sourceId = $value; + return $this; + } + + /** + * @return string + */ + public function getExternalId(): string + { + return $this->externalId; + } + + /** + * @param string $value + */ + public function setExternalId(string $value): self + { + $this->externalId = $value; + return $this; + } + + /** + * @return int + */ + public function getCreatedAt(): int + { + return $this->createdAt; + } + + /** + * @param int $value + */ + public function setCreatedAt(int $value): self + { + $this->createdAt = $value; + return $this; + } + + /** + * @return int + */ + public function getUpdatedAt(): int + { + return $this->updatedAt; + } + + /** + * @param int $value + */ + public function setUpdatedAt(int $value): self + { + $this->updatedAt = $value; + return $this; + } + + /** + * @return int + */ + public function getLastIngestedAt(): int + { + return $this->lastIngestedAt; + } + + /** + * @param int $value + */ + public function setLastIngestedAt(int $value): self + { + $this->lastIngestedAt = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/AiContent/Types/ExternalPagesList.php b/src/AiContent/Types/ExternalPagesList.php new file mode 100644 index 0000000..edb5cbc --- /dev/null +++ b/src/AiContent/Types/ExternalPagesList.php @@ -0,0 +1,131 @@ + $data An array of External Page objects + */ + #[JsonProperty('data'), ArrayType([ExternalPage::class])] + private ?array $data; + + /** + * @param array{ + * type?: ?'list', + * pages?: ?PagesLink, + * totalCount?: ?int, + * data?: ?array, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->type = $values['type'] ?? null; + $this->pages = $values['pages'] ?? null; + $this->totalCount = $values['totalCount'] ?? null; + $this->data = $values['data'] ?? null; + } + + /** + * @return ?'list' + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?'list' $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?PagesLink + */ + public function getPages(): ?PagesLink + { + return $this->pages; + } + + /** + * @param ?PagesLink $value + */ + public function setPages(?PagesLink $value = null): self + { + $this->pages = $value; + return $this; + } + + /** + * @return ?int + */ + public function getTotalCount(): ?int + { + return $this->totalCount; + } + + /** + * @param ?int $value + */ + public function setTotalCount(?int $value = null): self + { + $this->totalCount = $value; + return $this; + } + + /** + * @return ?array + */ + public function getData(): ?array + { + return $this->data; + } + + /** + * @param ?array $value + */ + public function setData(?array $value = null): self + { + $this->data = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/AiContent/Types/UpdateContentImportSourceRequestStatus.php b/src/AiContent/Types/UpdateContentImportSourceRequestStatus.php new file mode 100644 index 0000000..05f7273 --- /dev/null +++ b/src/AiContent/Types/UpdateContentImportSourceRequestStatus.php @@ -0,0 +1,9 @@ +contentType = $values['contentType']; - $this->url = $values['url']; - $this->title = $values['title']; - $this->locale = $values['locale']; + $this->contentType = $values['contentType'] ?? null; + $this->url = $values['url'] ?? null; + $this->title = $values['title'] ?? null; + $this->locale = $values['locale'] ?? null; } /** - * @return 'custom_answer' + * @return ?'custom_answer' */ - public function getContentType(): string + public function getContentType(): ?string { return $this->contentType; } /** - * @param 'custom_answer' $value + * @param ?'custom_answer' $value */ - public function setContentType(string $value): self + public function setContentType(?string $value = null): self { $this->contentType = $value; return $this; } /** - * @return string + * @return ?string */ - public function getUrl(): string + public function getUrl(): ?string { return $this->url; } /** - * @param string $value + * @param ?string $value */ - public function setUrl(string $value): self + public function setUrl(?string $value = null): self { $this->url = $value; return $this; } /** - * @return string + * @return ?string */ - public function getTitle(): string + public function getTitle(): ?string { return $this->title; } /** - * @param string $value + * @param ?string $value */ - public function setTitle(string $value): self + public function setTitle(?string $value = null): self { $this->title = $value; return $this; } /** - * @return string + * @return ?string */ - public function getLocale(): string + public function getLocale(): ?string { return $this->locale; } /** - * @param string $value + * @param ?string $value */ - public function setLocale(string $value): self + public function setLocale(?string $value = null): self { $this->locale = $value; return $this; diff --git a/src/Articles/ArticlesClient.php b/src/Articles/ArticlesClient.php index cc81580..d6c5f8e 100644 --- a/src/Articles/ArticlesClient.php +++ b/src/Articles/ArticlesClient.php @@ -9,7 +9,7 @@ use Intercom\Articles\Types\ArticleListItem; use Intercom\Core\Pagination\OffsetPager; use Intercom\Types\ArticleList; -use Intercom\Articles\Requests\CreateArticleRequest; +use Intercom\Types\CreateArticleRequest; use Intercom\Articles\Types\Article; use Intercom\Exceptions\IntercomException; use Intercom\Exceptions\IntercomApiException; @@ -24,7 +24,7 @@ use Intercom\Articles\Requests\DeleteArticleRequest; use Intercom\Types\DeletedArticleObject; use Intercom\Articles\Requests\SearchArticlesRequest; -use Intercom\Articles\Types\SearchArticlesResponse; +use Intercom\Articles\Types\ArticleSearchResponse; class ArticlesClient { @@ -35,7 +35,7 @@ class ArticlesClient * maxRetries?: int, * timeout?: float, * headers?: array, - * } $options + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator */ private array $options; @@ -101,7 +101,7 @@ public function list(ListArticlesRequest $request = new ListArticlesRequest(), ? /** * You can create a new article by making a POST request to `https://api.intercom.io/articles`. * - * @param CreateArticleRequest $request + * @param ?CreateArticleRequest $request * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -114,7 +114,7 @@ public function list(ListArticlesRequest $request = new ListArticlesRequest(), ? * @throws IntercomException * @throws IntercomApiException */ - public function create(CreateArticleRequest $request, ?array $options = null): Article + public function create(?CreateArticleRequest $request = null, ?array $options = null): Article { $options = array_merge($this->options, $options ?? []); try { @@ -332,11 +332,11 @@ public function delete(DeleteArticleRequest $request, ?array $options = null): D * queryParameters?: array, * bodyProperties?: array, * } $options - * @return SearchArticlesResponse + * @return ArticleSearchResponse * @throws IntercomException * @throws IntercomApiException */ - public function search(SearchArticlesRequest $request = new SearchArticlesRequest(), ?array $options = null): SearchArticlesResponse + public function search(SearchArticlesRequest $request = new SearchArticlesRequest(), ?array $options = null): ArticleSearchResponse { $options = array_merge($this->options, $options ?? []); $query = []; @@ -365,7 +365,7 @@ public function search(SearchArticlesRequest $request = new SearchArticlesReques $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); - return SearchArticlesResponse::fromJson($json); + return ArticleSearchResponse::fromJson($json); } } catch (JsonException $e) { throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); diff --git a/src/Articles/Requests/DeleteArticleRequest.php b/src/Articles/Requests/DeleteArticleRequest.php index ecc8079..de8e346 100644 --- a/src/Articles/Requests/DeleteArticleRequest.php +++ b/src/Articles/Requests/DeleteArticleRequest.php @@ -7,13 +7,13 @@ class DeleteArticleRequest extends JsonSerializableType { /** - * @var string $articleId The unique identifier for the article which is given by Intercom. + * @var int $articleId The unique identifier for the article which is given by Intercom. */ - private string $articleId; + private int $articleId; /** * @param array{ - * articleId: string, + * articleId: int, * } $values */ public function __construct( @@ -23,17 +23,17 @@ public function __construct( } /** - * @return string + * @return int */ - public function getArticleId(): string + public function getArticleId(): int { return $this->articleId; } /** - * @param string $value + * @param int $value */ - public function setArticleId(string $value): self + public function setArticleId(int $value): self { $this->articleId = $value; return $this; diff --git a/src/Articles/Requests/FindArticleRequest.php b/src/Articles/Requests/FindArticleRequest.php index ff372e2..999e915 100644 --- a/src/Articles/Requests/FindArticleRequest.php +++ b/src/Articles/Requests/FindArticleRequest.php @@ -7,13 +7,13 @@ class FindArticleRequest extends JsonSerializableType { /** - * @var string $articleId The unique identifier for the article which is given by Intercom. + * @var int $articleId The unique identifier for the article which is given by Intercom. */ - private string $articleId; + private int $articleId; /** * @param array{ - * articleId: string, + * articleId: int, * } $values */ public function __construct( @@ -23,17 +23,17 @@ public function __construct( } /** - * @return string + * @return int */ - public function getArticleId(): string + public function getArticleId(): int { return $this->articleId; } /** - * @param string $value + * @param int $value */ - public function setArticleId(string $value): self + public function setArticleId(int $value): self { $this->articleId = $value; return $this; diff --git a/src/Articles/Requests/UpdateArticleRequest.php b/src/Articles/Requests/UpdateArticleRequest.php index fdafae3..e29534e 100644 --- a/src/Articles/Requests/UpdateArticleRequest.php +++ b/src/Articles/Requests/UpdateArticleRequest.php @@ -4,16 +4,15 @@ use Intercom\Core\Json\JsonSerializableType; use Intercom\Core\Json\JsonProperty; -use Intercom\Articles\Types\UpdateArticleRequestBodyState; -use Intercom\Articles\Types\UpdateArticleRequestBodyParentType; +use Intercom\Articles\Types\UpdateArticleRequestState; use Intercom\Types\ArticleTranslatedContent; class UpdateArticleRequest extends JsonSerializableType { /** - * @var string $articleId The unique identifier for the article which is given by Intercom. + * @var int $articleId The unique identifier for the article which is given by Intercom. */ - private string $articleId; + private int $articleId; /** * @var ?string $title The title of the article.For multilingual articles, this will be the title of the default language's content. @@ -40,7 +39,7 @@ class UpdateArticleRequest extends JsonSerializableType private ?int $authorId; /** - * @var ?value-of $state 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. + * @var ?value-of $state 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')] private ?string $state; @@ -52,7 +51,7 @@ class UpdateArticleRequest extends JsonSerializableType private ?string $parentId; /** - * @var ?value-of $parentType The type of parent, which can either be a `collection` or `section`. + * @var ?string $parentType The type of parent, which can either be a `collection` or `section`. */ #[JsonProperty('parent_type')] private ?string $parentType; @@ -65,14 +64,14 @@ class UpdateArticleRequest extends JsonSerializableType /** * @param array{ - * articleId: string, + * articleId: int, * title?: ?string, * description?: ?string, * body?: ?string, * authorId?: ?int, - * state?: ?value-of, + * state?: ?value-of, * parentId?: ?string, - * parentType?: ?value-of, + * parentType?: ?string, * translatedContent?: ?ArticleTranslatedContent, * } $values */ @@ -91,17 +90,17 @@ public function __construct( } /** - * @return string + * @return int */ - public function getArticleId(): string + public function getArticleId(): int { return $this->articleId; } /** - * @param string $value + * @param int $value */ - public function setArticleId(string $value): self + public function setArticleId(int $value): self { $this->articleId = $value; return $this; @@ -176,7 +175,7 @@ public function setAuthorId(?int $value = null): self } /** - * @return ?value-of + * @return ?value-of */ public function getState(): ?string { @@ -184,7 +183,7 @@ public function getState(): ?string } /** - * @param ?value-of $value + * @param ?value-of $value */ public function setState(?string $value = null): self { @@ -210,7 +209,7 @@ public function setParentId(?string $value = null): self } /** - * @return ?value-of + * @return ?string */ public function getParentType(): ?string { @@ -218,7 +217,7 @@ public function getParentType(): ?string } /** - * @param ?value-of $value + * @param ?string $value */ public function setParentType(?string $value = null): self { diff --git a/src/Articles/Types/ArticleSearchHighlights.php b/src/Articles/Types/ArticleSearchHighlights.php index 7b88fe4..8cbd810 100644 --- a/src/Articles/Types/ArticleSearchHighlights.php +++ b/src/Articles/Types/ArticleSearchHighlights.php @@ -12,84 +12,84 @@ class ArticleSearchHighlights extends JsonSerializableType { /** - * @var string $articleId The ID of the corresponding article. + * @var ?string $articleId The ID of the corresponding article. */ #[JsonProperty('article_id')] - private string $articleId; + private ?string $articleId; /** - * @var array $highlightedTitle An Article title highlighted. + * @var ?array $highlightedTitle An Article title highlighted. */ #[JsonProperty('highlighted_title'), ArrayType([ArticleSearchHighlightsHighlightedTitleItem::class])] - private array $highlightedTitle; + private ?array $highlightedTitle; /** - * @var array> $highlightedSummary An Article description and body text highlighted. + * @var ?array> $highlightedSummary An Article description and body text highlighted. */ #[JsonProperty('highlighted_summary'), ArrayType([[ArticleSearchHighlightsHighlightedSummaryItemItem::class]])] - private array $highlightedSummary; + private ?array $highlightedSummary; /** * @param array{ - * articleId: string, - * highlightedTitle: array, - * highlightedSummary: array>, + * articleId?: ?string, + * highlightedTitle?: ?array, + * highlightedSummary?: ?array>, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->articleId = $values['articleId']; - $this->highlightedTitle = $values['highlightedTitle']; - $this->highlightedSummary = $values['highlightedSummary']; + $this->articleId = $values['articleId'] ?? null; + $this->highlightedTitle = $values['highlightedTitle'] ?? null; + $this->highlightedSummary = $values['highlightedSummary'] ?? null; } /** - * @return string + * @return ?string */ - public function getArticleId(): string + public function getArticleId(): ?string { return $this->articleId; } /** - * @param string $value + * @param ?string $value */ - public function setArticleId(string $value): self + public function setArticleId(?string $value = null): self { $this->articleId = $value; return $this; } /** - * @return array + * @return ?array */ - public function getHighlightedTitle(): array + public function getHighlightedTitle(): ?array { return $this->highlightedTitle; } /** - * @param array $value + * @param ?array $value */ - public function setHighlightedTitle(array $value): self + public function setHighlightedTitle(?array $value = null): self { $this->highlightedTitle = $value; return $this; } /** - * @return array> + * @return ?array> */ - public function getHighlightedSummary(): array + public function getHighlightedSummary(): ?array { return $this->highlightedSummary; } /** - * @param array> $value + * @param ?array> $value */ - public function setHighlightedSummary(array $value): self + public function setHighlightedSummary(?array $value = null): self { $this->highlightedSummary = $value; return $this; diff --git a/src/Articles/Types/SearchArticlesResponse.php b/src/Articles/Types/ArticleSearchResponse.php similarity index 56% rename from src/Articles/Types/SearchArticlesResponse.php rename to src/Articles/Types/ArticleSearchResponse.php index 79b8cd0..d432863 100644 --- a/src/Articles/Types/SearchArticlesResponse.php +++ b/src/Articles/Types/ArticleSearchResponse.php @@ -9,25 +9,25 @@ /** * The results of an Article search */ -class SearchArticlesResponse extends JsonSerializableType +class ArticleSearchResponse extends JsonSerializableType { /** - * @var 'list' $type The type of the object - `list`. + * @var ?'list' $type The type of the object - `list`. */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var int $totalCount The total number of Articles matching the search query + * @var ?int $totalCount The total number of Articles matching the search query */ #[JsonProperty('total_count')] - private int $totalCount; + private ?int $totalCount; /** - * @var SearchArticlesResponseData $data An object containing the results of the search. + * @var ?ArticleSearchResponseData $data An object containing the results of the search. */ #[JsonProperty('data')] - private SearchArticlesResponseData $data; + private ?ArticleSearchResponseData $data; /** * @var ?CursorPages $pages @@ -37,67 +37,67 @@ class SearchArticlesResponse extends JsonSerializableType /** * @param array{ - * type: 'list', - * totalCount: int, - * data: SearchArticlesResponseData, + * type?: ?'list', + * totalCount?: ?int, + * data?: ?ArticleSearchResponseData, * pages?: ?CursorPages, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->totalCount = $values['totalCount']; - $this->data = $values['data']; + $this->type = $values['type'] ?? null; + $this->totalCount = $values['totalCount'] ?? null; + $this->data = $values['data'] ?? null; $this->pages = $values['pages'] ?? null; } /** - * @return 'list' + * @return ?'list' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'list' $value + * @param ?'list' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return int + * @return ?int */ - public function getTotalCount(): int + public function getTotalCount(): ?int { return $this->totalCount; } /** - * @param int $value + * @param ?int $value */ - public function setTotalCount(int $value): self + public function setTotalCount(?int $value = null): self { $this->totalCount = $value; return $this; } /** - * @return SearchArticlesResponseData + * @return ?ArticleSearchResponseData */ - public function getData(): SearchArticlesResponseData + public function getData(): ?ArticleSearchResponseData { return $this->data; } /** - * @param SearchArticlesResponseData $value + * @param ?ArticleSearchResponseData $value */ - public function setData(SearchArticlesResponseData $value): self + public function setData(?ArticleSearchResponseData $value = null): self { $this->data = $value; return $this; diff --git a/src/Articles/Types/SearchArticlesResponseData.php b/src/Articles/Types/ArticleSearchResponseData.php similarity index 96% rename from src/Articles/Types/SearchArticlesResponseData.php rename to src/Articles/Types/ArticleSearchResponseData.php index f1634af..56054d1 100644 --- a/src/Articles/Types/SearchArticlesResponseData.php +++ b/src/Articles/Types/ArticleSearchResponseData.php @@ -9,7 +9,7 @@ /** * An object containing the results of the search. */ -class SearchArticlesResponseData extends JsonSerializableType +class ArticleSearchResponseData extends JsonSerializableType { /** * @var ?array
$articles An array of Article objects diff --git a/src/Articles/Types/UpdateArticleRequestBodyState.php b/src/Articles/Types/UpdateArticleRequestBodyState.php deleted file mode 100644 index b803af9..0000000 --- a/src/Articles/Types/UpdateArticleRequestBodyState.php +++ /dev/null @@ -1,9 +0,0 @@ -, + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator + */ + private array $options; + + /** + * @var RawClient $client + */ + private RawClient $client; + + /** + * @param RawClient $client + * @param ?array{ + * baseUrl?: string, + * client?: ClientInterface, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * } $options + */ + public function __construct( + RawClient $client, + ?array $options = null, + ) { + $this->client = $client; + $this->options = $options ?? []; + } + + /** + * Returns a list of all away status reasons configured for the workspace, including deleted ones. + * + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return array + * @throws IntercomException + * @throws IntercomApiException + */ + public function listAwayStatusReasons(?array $options = null): array + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "away_status_reasons", + method: HttpMethod::GET, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return JsonDecoder::decodeArray($json, [AwayStatusReason::class]); // @phpstan-ignore-line + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } +} diff --git a/src/Calls/CallsClient.php b/src/Calls/CallsClient.php new file mode 100644 index 0000000..37ada08 --- /dev/null +++ b/src/Calls/CallsClient.php @@ -0,0 +1,337 @@ +, + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator + */ + private array $options; + + /** + * @var RawClient $client + */ + private RawClient $client; + + /** + * @param RawClient $client + * @param ?array{ + * baseUrl?: string, + * client?: ClientInterface, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * } $options + */ + public function __construct( + RawClient $client, + ?array $options = null, + ) { + $this->client = $client; + $this->options = $options ?? []; + } + + /** + * Retrieve a paginated list of calls. + * + * @param ListCallsRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return CallList + * @throws IntercomException + * @throws IntercomApiException + */ + public function listCalls(ListCallsRequest $request = new ListCallsRequest(), ?array $options = null): CallList + { + $options = array_merge($this->options, $options ?? []); + $query = []; + if ($request->getPage() != null) { + $query['page'] = $request->getPage(); + } + if ($request->getPerPage() != null) { + $query['per_page'] = $request->getPerPage(); + } + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "calls", + method: HttpMethod::GET, + query: $query, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return CallList::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * Retrieve a single call by id. + * + * @param ShowCallRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return Call + * @throws IntercomException + * @throws IntercomApiException + */ + public function showCall(ShowCallRequest $request, ?array $options = null): Call + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "calls/{$request->getCallId()}", + method: HttpMethod::GET, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return Call::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * Redirects to a signed URL for the call's recording if it exists. + * + * @param ShowCallRecordingRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @throws IntercomException + * @throws IntercomApiException + */ + public function showCallRecording(ShowCallRecordingRequest $request, ?array $options = null): void + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "calls/{$request->getCallId()}/recording", + method: HttpMethod::GET, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + return; + } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * Returns the transcript for the specified call as a downloadable text file. + * + * @param ShowCallTranscriptRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return string + * @throws IntercomException + * @throws IntercomApiException + */ + public function showCallTranscript(ShowCallTranscriptRequest $request, ?array $options = null): string + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "calls/{$request->getCallId()}/transcript", + method: HttpMethod::GET, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + return $response->getBody()->getContents(); + } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * Retrieve calls by a list of conversation ids and include transcripts when available. + * A maximum of 20 `conversation_ids` can be provided. If none are provided or more than 20 are provided, a 400 error is returned. + * + * @param ListCallsWithTranscriptsRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return ListCallsWithTranscriptsResponse + * @throws IntercomException + * @throws IntercomApiException + */ + public function listCallsWithTranscripts(ListCallsWithTranscriptsRequest $request, ?array $options = null): ListCallsWithTranscriptsResponse + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "calls/search", + method: HttpMethod::POST, + body: $request, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return ListCallsWithTranscriptsResponse::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } +} diff --git a/src/Calls/Requests/ListCallsRequest.php b/src/Calls/Requests/ListCallsRequest.php new file mode 100644 index 0000000..cdfedbd --- /dev/null +++ b/src/Calls/Requests/ListCallsRequest.php @@ -0,0 +1,65 @@ +page = $values['page'] ?? null; + $this->perPage = $values['perPage'] ?? null; + } + + /** + * @return ?int + */ + public function getPage(): ?int + { + return $this->page; + } + + /** + * @param ?int $value + */ + public function setPage(?int $value = null): self + { + $this->page = $value; + return $this; + } + + /** + * @return ?int + */ + public function getPerPage(): ?int + { + return $this->perPage; + } + + /** + * @param ?int $value + */ + public function setPerPage(?int $value = null): self + { + $this->perPage = $value; + return $this; + } +} diff --git a/src/Calls/Requests/ListCallsWithTranscriptsRequest.php b/src/Calls/Requests/ListCallsWithTranscriptsRequest.php new file mode 100644 index 0000000..b6b3786 --- /dev/null +++ b/src/Calls/Requests/ListCallsWithTranscriptsRequest.php @@ -0,0 +1,44 @@ + $conversationIds A list of conversation ids to fetch calls for. Maximum 20. + */ + #[JsonProperty('conversation_ids'), ArrayType(['string'])] + private array $conversationIds; + + /** + * @param array{ + * conversationIds: array, + * } $values + */ + public function __construct( + array $values, + ) { + $this->conversationIds = $values['conversationIds']; + } + + /** + * @return array + */ + public function getConversationIds(): array + { + return $this->conversationIds; + } + + /** + * @param array $value + */ + public function setConversationIds(array $value): self + { + $this->conversationIds = $value; + return $this; + } +} diff --git a/src/Calls/Requests/ShowCallRecordingRequest.php b/src/Calls/Requests/ShowCallRecordingRequest.php new file mode 100644 index 0000000..b4a66ba --- /dev/null +++ b/src/Calls/Requests/ShowCallRecordingRequest.php @@ -0,0 +1,41 @@ +callId = $values['callId']; + } + + /** + * @return string + */ + public function getCallId(): string + { + return $this->callId; + } + + /** + * @param string $value + */ + public function setCallId(string $value): self + { + $this->callId = $value; + return $this; + } +} diff --git a/src/Calls/Requests/ShowCallRequest.php b/src/Calls/Requests/ShowCallRequest.php new file mode 100644 index 0000000..36756bd --- /dev/null +++ b/src/Calls/Requests/ShowCallRequest.php @@ -0,0 +1,41 @@ +callId = $values['callId']; + } + + /** + * @return string + */ + public function getCallId(): string + { + return $this->callId; + } + + /** + * @param string $value + */ + public function setCallId(string $value): self + { + $this->callId = $value; + return $this; + } +} diff --git a/src/Calls/Requests/ShowCallTranscriptRequest.php b/src/Calls/Requests/ShowCallTranscriptRequest.php new file mode 100644 index 0000000..3d35445 --- /dev/null +++ b/src/Calls/Requests/ShowCallTranscriptRequest.php @@ -0,0 +1,41 @@ +callId = $values['callId']; + } + + /** + * @return string + */ + public function getCallId(): string + { + return $this->callId; + } + + /** + * @param string $value + */ + public function setCallId(string $value): self + { + $this->callId = $value; + return $this; + } +} diff --git a/src/Calls/Traits/Call.php b/src/Calls/Traits/Call.php new file mode 100644 index 0000000..0d72c16 --- /dev/null +++ b/src/Calls/Traits/Call.php @@ -0,0 +1,530 @@ +type; + } + + /** + * @param ?string $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?string + */ + public function getId(): ?string + { + return $this->id; + } + + /** + * @param ?string $value + */ + public function setId(?string $value = null): self + { + $this->id = $value; + return $this; + } + + /** + * @return ?string + */ + public function getConversationId(): ?string + { + return $this->conversationId; + } + + /** + * @param ?string $value + */ + public function setConversationId(?string $value = null): self + { + $this->conversationId = $value; + return $this; + } + + /** + * @return ?string + */ + public function getAdminId(): ?string + { + return $this->adminId; + } + + /** + * @param ?string $value + */ + public function setAdminId(?string $value = null): self + { + $this->adminId = $value; + return $this; + } + + /** + * @return ?string + */ + public function getContactId(): ?string + { + return $this->contactId; + } + + /** + * @param ?string $value + */ + public function setContactId(?string $value = null): self + { + $this->contactId = $value; + return $this; + } + + /** + * @return ?string + */ + public function getState(): ?string + { + return $this->state; + } + + /** + * @param ?string $value + */ + public function setState(?string $value = null): self + { + $this->state = $value; + return $this; + } + + /** + * @return ( + * DateTime + * |int + * )|null + */ + public function getInitiatedAt(): DateTime|int|null + { + return $this->initiatedAt; + } + + /** + * @param ( + * DateTime + * |int + * )|null $value + */ + public function setInitiatedAt(DateTime|int|null $value = null): self + { + $this->initiatedAt = $value; + return $this; + } + + /** + * @return ( + * DateTime + * |int + * )|null + */ + public function getAnsweredAt(): DateTime|int|null + { + return $this->answeredAt; + } + + /** + * @param ( + * DateTime + * |int + * )|null $value + */ + public function setAnsweredAt(DateTime|int|null $value = null): self + { + $this->answeredAt = $value; + return $this; + } + + /** + * @return ( + * DateTime + * |int + * )|null + */ + public function getEndedAt(): DateTime|int|null + { + return $this->endedAt; + } + + /** + * @param ( + * DateTime + * |int + * )|null $value + */ + public function setEndedAt(DateTime|int|null $value = null): self + { + $this->endedAt = $value; + return $this; + } + + /** + * @return ( + * DateTime + * |int + * )|null + */ + public function getCreatedAt(): DateTime|int|null + { + return $this->createdAt; + } + + /** + * @param ( + * DateTime + * |int + * )|null $value + */ + public function setCreatedAt(DateTime|int|null $value = null): self + { + $this->createdAt = $value; + return $this; + } + + /** + * @return ( + * DateTime + * |int + * )|null + */ + public function getUpdatedAt(): DateTime|int|null + { + return $this->updatedAt; + } + + /** + * @param ( + * DateTime + * |int + * )|null $value + */ + public function setUpdatedAt(DateTime|int|null $value = null): self + { + $this->updatedAt = $value; + return $this; + } + + /** + * @return ?string + */ + public function getRecordingUrl(): ?string + { + return $this->recordingUrl; + } + + /** + * @param ?string $value + */ + public function setRecordingUrl(?string $value = null): self + { + $this->recordingUrl = $value; + return $this; + } + + /** + * @return ?string + */ + public function getTranscriptionUrl(): ?string + { + return $this->transcriptionUrl; + } + + /** + * @param ?string $value + */ + public function setTranscriptionUrl(?string $value = null): self + { + $this->transcriptionUrl = $value; + return $this; + } + + /** + * @return ?string + */ + public function getCallType(): ?string + { + return $this->callType; + } + + /** + * @param ?string $value + */ + public function setCallType(?string $value = null): self + { + $this->callType = $value; + return $this; + } + + /** + * @return ?string + */ + public function getDirection(): ?string + { + return $this->direction; + } + + /** + * @param ?string $value + */ + public function setDirection(?string $value = null): self + { + $this->direction = $value; + return $this; + } + + /** + * @return ?string + */ + public function getEndedReason(): ?string + { + return $this->endedReason; + } + + /** + * @param ?string $value + */ + public function setEndedReason(?string $value = null): self + { + $this->endedReason = $value; + return $this; + } + + /** + * @return ?string + */ + public function getPhone(): ?string + { + return $this->phone; + } + + /** + * @param ?string $value + */ + public function setPhone(?string $value = null): self + { + $this->phone = $value; + return $this; + } + + /** + * @return ?string + */ + public function getFinRecordingUrl(): ?string + { + return $this->finRecordingUrl; + } + + /** + * @param ?string $value + */ + public function setFinRecordingUrl(?string $value = null): self + { + $this->finRecordingUrl = $value; + return $this; + } + + /** + * @return ?string + */ + public function getFinTranscriptionUrl(): ?string + { + return $this->finTranscriptionUrl; + } + + /** + * @param ?string $value + */ + public function setFinTranscriptionUrl(?string $value = null): self + { + $this->finTranscriptionUrl = $value; + return $this; + } +} diff --git a/src/Calls/Types/Call.php b/src/Calls/Types/Call.php new file mode 100644 index 0000000..28d5c00 --- /dev/null +++ b/src/Calls/Types/Call.php @@ -0,0 +1,566 @@ +type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->conversationId = $values['conversationId'] ?? null; + $this->adminId = $values['adminId'] ?? null; + $this->contactId = $values['contactId'] ?? null; + $this->state = $values['state'] ?? null; + $this->initiatedAt = $values['initiatedAt'] ?? null; + $this->answeredAt = $values['answeredAt'] ?? null; + $this->endedAt = $values['endedAt'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; + $this->updatedAt = $values['updatedAt'] ?? null; + $this->recordingUrl = $values['recordingUrl'] ?? null; + $this->transcriptionUrl = $values['transcriptionUrl'] ?? null; + $this->callType = $values['callType'] ?? null; + $this->direction = $values['direction'] ?? null; + $this->endedReason = $values['endedReason'] ?? null; + $this->phone = $values['phone'] ?? null; + $this->finRecordingUrl = $values['finRecordingUrl'] ?? null; + $this->finTranscriptionUrl = $values['finTranscriptionUrl'] ?? null; + } + + /** + * @return ?string + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?string $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?string + */ + public function getId(): ?string + { + return $this->id; + } + + /** + * @param ?string $value + */ + public function setId(?string $value = null): self + { + $this->id = $value; + return $this; + } + + /** + * @return ?string + */ + public function getConversationId(): ?string + { + return $this->conversationId; + } + + /** + * @param ?string $value + */ + public function setConversationId(?string $value = null): self + { + $this->conversationId = $value; + return $this; + } + + /** + * @return ?string + */ + public function getAdminId(): ?string + { + return $this->adminId; + } + + /** + * @param ?string $value + */ + public function setAdminId(?string $value = null): self + { + $this->adminId = $value; + return $this; + } + + /** + * @return ?string + */ + public function getContactId(): ?string + { + return $this->contactId; + } + + /** + * @param ?string $value + */ + public function setContactId(?string $value = null): self + { + $this->contactId = $value; + return $this; + } + + /** + * @return ?string + */ + public function getState(): ?string + { + return $this->state; + } + + /** + * @param ?string $value + */ + public function setState(?string $value = null): self + { + $this->state = $value; + return $this; + } + + /** + * @return ( + * DateTime + * |int + * )|null + */ + public function getInitiatedAt(): DateTime|int|null + { + return $this->initiatedAt; + } + + /** + * @param ( + * DateTime + * |int + * )|null $value + */ + public function setInitiatedAt(DateTime|int|null $value = null): self + { + $this->initiatedAt = $value; + return $this; + } + + /** + * @return ( + * DateTime + * |int + * )|null + */ + public function getAnsweredAt(): DateTime|int|null + { + return $this->answeredAt; + } + + /** + * @param ( + * DateTime + * |int + * )|null $value + */ + public function setAnsweredAt(DateTime|int|null $value = null): self + { + $this->answeredAt = $value; + return $this; + } + + /** + * @return ( + * DateTime + * |int + * )|null + */ + public function getEndedAt(): DateTime|int|null + { + return $this->endedAt; + } + + /** + * @param ( + * DateTime + * |int + * )|null $value + */ + public function setEndedAt(DateTime|int|null $value = null): self + { + $this->endedAt = $value; + return $this; + } + + /** + * @return ( + * DateTime + * |int + * )|null + */ + public function getCreatedAt(): DateTime|int|null + { + return $this->createdAt; + } + + /** + * @param ( + * DateTime + * |int + * )|null $value + */ + public function setCreatedAt(DateTime|int|null $value = null): self + { + $this->createdAt = $value; + return $this; + } + + /** + * @return ( + * DateTime + * |int + * )|null + */ + public function getUpdatedAt(): DateTime|int|null + { + return $this->updatedAt; + } + + /** + * @param ( + * DateTime + * |int + * )|null $value + */ + public function setUpdatedAt(DateTime|int|null $value = null): self + { + $this->updatedAt = $value; + return $this; + } + + /** + * @return ?string + */ + public function getRecordingUrl(): ?string + { + return $this->recordingUrl; + } + + /** + * @param ?string $value + */ + public function setRecordingUrl(?string $value = null): self + { + $this->recordingUrl = $value; + return $this; + } + + /** + * @return ?string + */ + public function getTranscriptionUrl(): ?string + { + return $this->transcriptionUrl; + } + + /** + * @param ?string $value + */ + public function setTranscriptionUrl(?string $value = null): self + { + $this->transcriptionUrl = $value; + return $this; + } + + /** + * @return ?string + */ + public function getCallType(): ?string + { + return $this->callType; + } + + /** + * @param ?string $value + */ + public function setCallType(?string $value = null): self + { + $this->callType = $value; + return $this; + } + + /** + * @return ?string + */ + public function getDirection(): ?string + { + return $this->direction; + } + + /** + * @param ?string $value + */ + public function setDirection(?string $value = null): self + { + $this->direction = $value; + return $this; + } + + /** + * @return ?string + */ + public function getEndedReason(): ?string + { + return $this->endedReason; + } + + /** + * @param ?string $value + */ + public function setEndedReason(?string $value = null): self + { + $this->endedReason = $value; + return $this; + } + + /** + * @return ?string + */ + public function getPhone(): ?string + { + return $this->phone; + } + + /** + * @param ?string $value + */ + public function setPhone(?string $value = null): self + { + $this->phone = $value; + return $this; + } + + /** + * @return ?string + */ + public function getFinRecordingUrl(): ?string + { + return $this->finRecordingUrl; + } + + /** + * @param ?string $value + */ + public function setFinRecordingUrl(?string $value = null): self + { + $this->finRecordingUrl = $value; + return $this; + } + + /** + * @return ?string + */ + public function getFinTranscriptionUrl(): ?string + { + return $this->finTranscriptionUrl; + } + + /** + * @param ?string $value + */ + public function setFinTranscriptionUrl(?string $value = null): self + { + $this->finTranscriptionUrl = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Calls/Types/ListCallsWithTranscriptsResponse.php b/src/Calls/Types/ListCallsWithTranscriptsResponse.php new file mode 100644 index 0000000..811de6e --- /dev/null +++ b/src/Calls/Types/ListCallsWithTranscriptsResponse.php @@ -0,0 +1,77 @@ + $data + */ + #[JsonProperty('data'), ArrayType([ListCallsWithTranscriptsResponseDataItem::class])] + private ?array $data; + + /** + * @param array{ + * type?: ?string, + * data?: ?array, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->type = $values['type'] ?? null; + $this->data = $values['data'] ?? null; + } + + /** + * @return ?string + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?string $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?array + */ + public function getData(): ?array + { + return $this->data; + } + + /** + * @param ?array $value + */ + public function setData(?array $value = null): self + { + $this->data = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Calls/Types/ListCallsWithTranscriptsResponseDataItem.php b/src/Calls/Types/ListCallsWithTranscriptsResponseDataItem.php new file mode 100644 index 0000000..9e0bd98 --- /dev/null +++ b/src/Calls/Types/ListCallsWithTranscriptsResponseDataItem.php @@ -0,0 +1,134 @@ +> $transcript The call transcript if available, otherwise an empty array. + */ + #[JsonProperty('transcript'), ArrayType([['string' => 'mixed']])] + private ?array $transcript; + + /** + * @var ?string $transcriptStatus The status of the transcript if available. + */ + #[JsonProperty('transcript_status')] + private ?string $transcriptStatus; + + /** + * @param array{ + * type?: ?string, + * id?: ?string, + * conversationId?: ?string, + * adminId?: ?string, + * contactId?: ?string, + * state?: ?string, + * initiatedAt?: ( + * DateTime + * |int + * )|null, + * answeredAt?: ( + * DateTime + * |int + * )|null, + * endedAt?: ( + * DateTime + * |int + * )|null, + * createdAt?: ( + * DateTime + * |int + * )|null, + * updatedAt?: ( + * DateTime + * |int + * )|null, + * recordingUrl?: ?string, + * transcriptionUrl?: ?string, + * callType?: ?string, + * direction?: ?string, + * endedReason?: ?string, + * phone?: ?string, + * finRecordingUrl?: ?string, + * finTranscriptionUrl?: ?string, + * transcript?: ?array>, + * transcriptStatus?: ?string, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->conversationId = $values['conversationId'] ?? null; + $this->adminId = $values['adminId'] ?? null; + $this->contactId = $values['contactId'] ?? null; + $this->state = $values['state'] ?? null; + $this->initiatedAt = $values['initiatedAt'] ?? null; + $this->answeredAt = $values['answeredAt'] ?? null; + $this->endedAt = $values['endedAt'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; + $this->updatedAt = $values['updatedAt'] ?? null; + $this->recordingUrl = $values['recordingUrl'] ?? null; + $this->transcriptionUrl = $values['transcriptionUrl'] ?? null; + $this->callType = $values['callType'] ?? null; + $this->direction = $values['direction'] ?? null; + $this->endedReason = $values['endedReason'] ?? null; + $this->phone = $values['phone'] ?? null; + $this->finRecordingUrl = $values['finRecordingUrl'] ?? null; + $this->finTranscriptionUrl = $values['finTranscriptionUrl'] ?? null; + $this->transcript = $values['transcript'] ?? null; + $this->transcriptStatus = $values['transcriptStatus'] ?? null; + } + + /** + * @return ?array> + */ + public function getTranscript(): ?array + { + return $this->transcript; + } + + /** + * @param ?array> $value + */ + public function setTranscript(?array $value = null): self + { + $this->transcript = $value; + return $this; + } + + /** + * @return ?string + */ + public function getTranscriptStatus(): ?string + { + return $this->transcriptStatus; + } + + /** + * @param ?string $value + */ + public function setTranscriptStatus(?string $value = null): self + { + $this->transcriptStatus = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Companies/CompaniesClient.php b/src/Companies/CompaniesClient.php index e28bf0a..cf702c9 100644 --- a/src/Companies/CompaniesClient.php +++ b/src/Companies/CompaniesClient.php @@ -14,7 +14,7 @@ use JsonException; use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; -use Intercom\Companies\Requests\CreateOrUpdateCompanyRequest; +use Intercom\Types\CreateOrUpdateCompanyRequest; use Intercom\Companies\Types\Company; use Intercom\Companies\Requests\FindCompanyRequest; use Intercom\Companies\Requests\UpdateCompanyRequest; @@ -43,7 +43,7 @@ class CompaniesClient * maxRetries?: int, * timeout?: float, * headers?: array, - * } $options + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator */ private array $options; @@ -166,7 +166,7 @@ public function retrieve(RetrieveCompanyRequest $request = new RetrieveCompanyRe * You can set a unique `company_id` value when creating a company. However, it is not possible to update `company_id`. Be sure to set a unique value once upon creation of the company. * {% /admonition %} * - * @param CreateOrUpdateCompanyRequest $request + * @param ?CreateOrUpdateCompanyRequest $request * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -179,7 +179,7 @@ public function retrieve(RetrieveCompanyRequest $request = new RetrieveCompanyRe * @throws IntercomException * @throws IntercomApiException */ - public function createOrUpdate(CreateOrUpdateCompanyRequest $request = new CreateOrUpdateCompanyRequest(), ?array $options = null): Company + public function createOrUpdate(?CreateOrUpdateCompanyRequest $request = null, ?array $options = null): Company { $options = array_merge($this->options, $options ?? []); try { @@ -303,6 +303,7 @@ public function update(UpdateCompanyRequest $request, ?array $options = null): C baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, path: "companies/{$request->getCompanyId()}", method: HttpMethod::PUT, + body: $request->getBody(), ), $options, ); @@ -407,20 +408,12 @@ public function delete(DeleteCompanyRequest $request, ?array $options = null): D public function listAttachedContacts(ListAttachedContactsRequest $request, ?array $options = null): CompanyAttachedContacts { $options = array_merge($this->options, $options ?? []); - $query = []; - if ($request->getPage() != null) { - $query['page'] = $request->getPage(); - } - if ($request->getPerPage() != null) { - $query['per_page'] = $request->getPerPage(); - } try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, path: "companies/{$request->getCompanyId()}/contacts", method: HttpMethod::GET, - query: $query, ), $options, ); @@ -583,9 +576,9 @@ public function scroll(ScrollCompaniesRequest $request = new ScrollCompaniesRequ $request->setScrollParam($cursor); }, /* @phpstan-ignore-next-line */ - getNextCursor: fn (CompanyScroll $response) => $response?->getScrollParam() ?? null, + getNextCursor: fn (?CompanyScroll $response) => $response?->getScrollParam() ?? null, /* @phpstan-ignore-next-line */ - getItems: fn (CompanyScroll $response) => $response?->getData() ?? [], + getItems: fn (?CompanyScroll $response) => $response?->getData() ?? [], ); } @@ -800,11 +793,11 @@ private function _list(ListCompaniesRequest $request = new ListCompaniesRequest( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return CompanyScroll + * @return ?CompanyScroll * @throws IntercomException * @throws IntercomApiException */ - private function _scroll(ScrollCompaniesRequest $request = new ScrollCompaniesRequest(), ?array $options = null): CompanyScroll + private function _scroll(ScrollCompaniesRequest $request = new ScrollCompaniesRequest(), ?array $options = null): ?CompanyScroll { $options = array_merge($this->options, $options ?? []); $query = []; @@ -824,6 +817,9 @@ private function _scroll(ScrollCompaniesRequest $request = new ScrollCompaniesRe $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return CompanyScroll::fromJson($json); } } catch (JsonException $e) { diff --git a/src/Companies/Requests/ListAttachedContactsRequest.php b/src/Companies/Requests/ListAttachedContactsRequest.php index edcc04f..c10f4d5 100644 --- a/src/Companies/Requests/ListAttachedContactsRequest.php +++ b/src/Companies/Requests/ListAttachedContactsRequest.php @@ -11,29 +11,15 @@ class ListAttachedContactsRequest extends JsonSerializableType */ private string $companyId; - /** - * @var ?int $page The page of results to fetch. Defaults to first page - */ - private ?int $page; - - /** - * @var ?int $perPage How many results to return per page. Defaults to 15 - */ - private ?int $perPage; - /** * @param array{ * companyId: string, - * page?: ?int, - * perPage?: ?int, * } $values */ public function __construct( array $values, ) { $this->companyId = $values['companyId']; - $this->page = $values['page'] ?? null; - $this->perPage = $values['perPage'] ?? null; } /** @@ -52,38 +38,4 @@ public function setCompanyId(string $value): self $this->companyId = $value; return $this; } - - /** - * @return ?int - */ - public function getPage(): ?int - { - return $this->page; - } - - /** - * @param ?int $value - */ - public function setPage(?int $value = null): self - { - $this->page = $value; - return $this; - } - - /** - * @return ?int - */ - public function getPerPage(): ?int - { - return $this->perPage; - } - - /** - * @param ?int $value - */ - public function setPerPage(?int $value = null): self - { - $this->perPage = $value; - return $this; - } } diff --git a/src/Companies/Requests/UpdateCompanyRequest.php b/src/Companies/Requests/UpdateCompanyRequest.php index 0264668..4f2f65a 100644 --- a/src/Companies/Requests/UpdateCompanyRequest.php +++ b/src/Companies/Requests/UpdateCompanyRequest.php @@ -3,6 +3,7 @@ namespace Intercom\Companies\Requests; use Intercom\Core\Json\JsonSerializableType; +use Intercom\Types\UpdateCompanyRequestBody; class UpdateCompanyRequest extends JsonSerializableType { @@ -11,15 +12,22 @@ class UpdateCompanyRequest extends JsonSerializableType */ private string $companyId; + /** + * @var ?UpdateCompanyRequestBody $body + */ + private ?UpdateCompanyRequestBody $body; + /** * @param array{ * companyId: string, + * body?: ?UpdateCompanyRequestBody, * } $values */ public function __construct( array $values, ) { $this->companyId = $values['companyId']; + $this->body = $values['body'] ?? null; } /** @@ -38,4 +46,21 @@ public function setCompanyId(string $value): self $this->companyId = $value; return $this; } + + /** + * @return ?UpdateCompanyRequestBody + */ + public function getBody(): ?UpdateCompanyRequestBody + { + return $this->body; + } + + /** + * @param ?UpdateCompanyRequestBody $value + */ + public function setBody(?UpdateCompanyRequestBody $value = null): self + { + $this->body = $value; + return $this; + } } diff --git a/src/Companies/Types/Company.php b/src/Companies/Types/Company.php index 8c648d6..db5c581 100644 --- a/src/Companies/Types/Company.php +++ b/src/Companies/Types/Company.php @@ -11,6 +11,12 @@ */ class Company extends JsonSerializableType { + /** + * @var ?'company' $type Value is `company` + */ + #[JsonProperty('type')] + private ?string $type; + /** * @var string $id The Intercom defined id representing the company. */ @@ -130,6 +136,7 @@ class Company extends JsonSerializableType * monthlySpend: int, * sessionCount: int, * userCount: int, + * type?: ?'company', * plan?: ?CompanyPlan, * remoteCreatedAt?: ?int, * lastRequestAt?: ?int, @@ -144,6 +151,7 @@ class Company extends JsonSerializableType public function __construct( array $values, ) { + $this->type = $values['type'] ?? null; $this->id = $values['id']; $this->name = $values['name']; $this->appId = $values['appId']; @@ -164,6 +172,23 @@ public function __construct( $this->segments = $values['segments'] ?? null; } + /** + * @return ?'company' + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?'company' $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + /** * @return string */ diff --git a/src/Companies/Types/CompanyPlan.php b/src/Companies/Types/CompanyPlan.php index 5e4a0a8..af27360 100644 --- a/src/Companies/Types/CompanyPlan.php +++ b/src/Companies/Types/CompanyPlan.php @@ -8,7 +8,7 @@ class CompanyPlan extends JsonSerializableType { /** - * @var ?'plan' $type Value is always "plan" + * @var ?string $type Value is always "plan" */ #[JsonProperty('type')] private ?string $type; @@ -27,7 +27,7 @@ class CompanyPlan extends JsonSerializableType /** * @param array{ - * type?: ?'plan', + * type?: ?string, * id?: ?string, * name?: ?string, * } $values @@ -41,7 +41,7 @@ public function __construct( } /** - * @return ?'plan' + * @return ?string */ public function getType(): ?string { @@ -49,7 +49,7 @@ public function getType(): ?string } /** - * @param ?'plan' $value + * @param ?string $value */ public function setType(?string $value = null): self { diff --git a/src/Contacts/ContactsClient.php b/src/Contacts/ContactsClient.php index b389651..969f9df 100644 --- a/src/Contacts/ContactsClient.php +++ b/src/Contacts/ContactsClient.php @@ -27,12 +27,15 @@ use Intercom\Contacts\Requests\ListTagsAttachedToContactRequest; use Intercom\Types\TagList; use Intercom\Contacts\Requests\FindContactRequest; -use Intercom\Contacts\Types\Contact; +use Intercom\Contacts\Types\ContactsFindResponse; use Intercom\Contacts\Requests\UpdateContactRequest; +use Intercom\Contacts\Types\ContactsUpdateResponse; use Intercom\Contacts\Requests\DeleteContactRequest; use Intercom\Types\ContactDeleted; use Intercom\Contacts\Requests\MergeContactsRequest; +use Intercom\Contacts\Types\ContactsMergeLeadInUserResponse; use Intercom\Types\SearchRequest; +use Intercom\Contacts\Types\Contact; use Intercom\Core\Pagination\CursorPager; use Intercom\Core\Pagination\PaginationHelper; use Intercom\Types\ContactList; @@ -40,12 +43,17 @@ use Intercom\Types\CreateContactRequestWithEmail; use Intercom\Types\CreateContactRequestWithExternalId; use Intercom\Types\CreateContactRequestWithRole; +use Intercom\Contacts\Types\ContactsCreateResponse; use Intercom\Core\Json\JsonSerializer; use Intercom\Core\Types\Union; +use Intercom\Contacts\Requests\ShowContactByExternalIdRequest; +use Intercom\Contacts\Types\ShowContactByExternalIdResponse; use Intercom\Contacts\Requests\ArchiveContactRequest; use Intercom\Types\ContactArchived; use Intercom\Contacts\Requests\UnarchiveContactRequest; use Intercom\Types\ContactUnarchived; +use Intercom\Contacts\Requests\BlockContactRequest; +use Intercom\Types\ContactBlocked; class ContactsClient { @@ -56,7 +64,7 @@ class ContactsClient * maxRetries?: int, * timeout?: float, * headers?: array, - * } $options + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator */ private array $options; @@ -415,11 +423,11 @@ public function listAttachedTags(ListTagsAttachedToContactRequest $request, ?arr * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Contact + * @return ContactsFindResponse * @throws IntercomException * @throws IntercomApiException */ - public function find(FindContactRequest $request, ?array $options = null): Contact + public function find(FindContactRequest $request, ?array $options = null): ContactsFindResponse { $options = array_merge($this->options, $options ?? []); try { @@ -434,7 +442,7 @@ public function find(FindContactRequest $request, ?array $options = null): Conta $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); - return Contact::fromJson($json); + return ContactsFindResponse::fromJson($json); } } catch (JsonException $e) { throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); @@ -461,6 +469,12 @@ public function find(FindContactRequest $request, ?array $options = null): Conta /** * You can update an existing contact (ie. user or lead). * + * {% admonition type="info" %} + * This endpoint handles both **contact updates** and **custom object associations**. + * + * See _`update a contact with an association to a custom object instance`_ in the request/response examples to see the custom object association format. + * {% /admonition %} + * * @param UpdateContactRequest $request * @param ?array{ * baseUrl?: string, @@ -470,11 +484,11 @@ public function find(FindContactRequest $request, ?array $options = null): Conta * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Contact + * @return ContactsUpdateResponse * @throws IntercomException * @throws IntercomApiException */ - public function update(UpdateContactRequest $request, ?array $options = null): Contact + public function update(UpdateContactRequest $request, ?array $options = null): ContactsUpdateResponse { $options = array_merge($this->options, $options ?? []); try { @@ -490,7 +504,7 @@ public function update(UpdateContactRequest $request, ?array $options = null): C $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); - return Contact::fromJson($json); + return ContactsUpdateResponse::fromJson($json); } } catch (JsonException $e) { throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); @@ -581,11 +595,11 @@ public function delete(DeleteContactRequest $request, ?array $options = null): C * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Contact + * @return ContactsMergeLeadInUserResponse * @throws IntercomException * @throws IntercomApiException */ - public function mergeLeadInUser(MergeContactsRequest $request, ?array $options = null): Contact + public function mergeLeadInUser(MergeContactsRequest $request = new MergeContactsRequest(), ?array $options = null): ContactsMergeLeadInUserResponse { $options = array_merge($this->options, $options ?? []); try { @@ -601,7 +615,7 @@ public function mergeLeadInUser(MergeContactsRequest $request, ?array $options = $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); - return Contact::fromJson($json); + return ContactsMergeLeadInUserResponse::fromJson($json); } } catch (JsonException $e) { throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); @@ -801,11 +815,11 @@ public function list(ListContactsRequest $request = new ListContactsRequest(), ? * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Contact + * @return ContactsCreateResponse * @throws IntercomException * @throws IntercomApiException */ - public function create(CreateContactRequestWithEmail|CreateContactRequestWithExternalId|CreateContactRequestWithRole $request, ?array $options = null): Contact + public function create(CreateContactRequestWithEmail|CreateContactRequestWithExternalId|CreateContactRequestWithRole $request, ?array $options = null): ContactsCreateResponse { $options = array_merge($this->options, $options ?? []); try { @@ -821,7 +835,62 @@ public function create(CreateContactRequestWithEmail|CreateContactRequestWithExt $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); - return Contact::fromJson($json); + return ContactsCreateResponse::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * You can fetch the details of a single contact by external ID. Note that this endpoint only supports users and not leads. + * + * @param ShowContactByExternalIdRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return ShowContactByExternalIdResponse + * @throws IntercomException + * @throws IntercomApiException + */ + public function showContactByExternalId(ShowContactByExternalIdRequest $request, ?array $options = null): ShowContactByExternalIdResponse + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "contacts/find_by_external_id/{$request->getExternalId()}", + method: HttpMethod::GET, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return ShowContactByExternalIdResponse::fromJson($json); } } catch (JsonException $e) { throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); @@ -955,6 +1024,61 @@ public function unarchive(UnarchiveContactRequest $request, ?array $options = nu ); } + /** + * Block a single contact.
**Note:** conversations of the contact will also be archived during the process.
More details in [FAQ How do I block Inbox spam?](https://www.intercom.com/help/en/articles/8838656-inbox-faqs) + * + * @param BlockContactRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return ContactBlocked + * @throws IntercomException + * @throws IntercomApiException + */ + public function blockContact(BlockContactRequest $request, ?array $options = null): ContactBlocked + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "contacts/{$request->getContactId()}/block", + method: HttpMethod::POST, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return ContactBlocked::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + /** * You can fetch a list of companies that are associated to a contact. * diff --git a/src/Contacts/Requests/ArchiveContactRequest.php b/src/Contacts/Requests/ArchiveContactRequest.php index ba17d66..33e0383 100644 --- a/src/Contacts/Requests/ArchiveContactRequest.php +++ b/src/Contacts/Requests/ArchiveContactRequest.php @@ -7,7 +7,7 @@ class ArchiveContactRequest extends JsonSerializableType { /** - * @var string $contactId id + * @var string $contactId contact_id */ private string $contactId; diff --git a/src/Contacts/Requests/BlockContactRequest.php b/src/Contacts/Requests/BlockContactRequest.php new file mode 100644 index 0000000..97efed0 --- /dev/null +++ b/src/Contacts/Requests/BlockContactRequest.php @@ -0,0 +1,41 @@ +contactId = $values['contactId']; + } + + /** + * @return string + */ + public function getContactId(): string + { + return $this->contactId; + } + + /** + * @param string $value + */ + public function setContactId(string $value): self + { + $this->contactId = $value; + return $this; + } +} diff --git a/src/Contacts/Requests/DeleteContactRequest.php b/src/Contacts/Requests/DeleteContactRequest.php index d8e5171..bd7f7ad 100644 --- a/src/Contacts/Requests/DeleteContactRequest.php +++ b/src/Contacts/Requests/DeleteContactRequest.php @@ -7,7 +7,7 @@ class DeleteContactRequest extends JsonSerializableType { /** - * @var string $contactId id + * @var string $contactId contact_id */ private string $contactId; diff --git a/src/Contacts/Requests/FindContactRequest.php b/src/Contacts/Requests/FindContactRequest.php index 3383919..59294ed 100644 --- a/src/Contacts/Requests/FindContactRequest.php +++ b/src/Contacts/Requests/FindContactRequest.php @@ -7,7 +7,7 @@ class FindContactRequest extends JsonSerializableType { /** - * @var string $contactId id + * @var string $contactId contact_id */ private string $contactId; diff --git a/src/Contacts/Requests/MergeContactsRequest.php b/src/Contacts/Requests/MergeContactsRequest.php index cb58677..785c3f9 100644 --- a/src/Contacts/Requests/MergeContactsRequest.php +++ b/src/Contacts/Requests/MergeContactsRequest.php @@ -8,59 +8,59 @@ class MergeContactsRequest extends JsonSerializableType { /** - * @var string $leadId The unique identifier for the contact to merge away from. Must be a lead. + * @var ?string $leadId The unique identifier for the contact to merge away from. Must be a lead. */ #[JsonProperty('from')] - private string $leadId; + private ?string $leadId; /** - * @var string $contactId The unique identifier for the contact to merge into. Must be a user. + * @var ?string $contactId The unique identifier for the contact to merge into. Must be a user. */ #[JsonProperty('into')] - private string $contactId; + private ?string $contactId; /** * @param array{ - * leadId: string, - * contactId: string, + * leadId?: ?string, + * contactId?: ?string, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->leadId = $values['leadId']; - $this->contactId = $values['contactId']; + $this->leadId = $values['leadId'] ?? null; + $this->contactId = $values['contactId'] ?? null; } /** - * @return string + * @return ?string */ - public function getLeadId(): string + public function getLeadId(): ?string { return $this->leadId; } /** - * @param string $value + * @param ?string $value */ - public function setLeadId(string $value): self + public function setLeadId(?string $value = null): self { $this->leadId = $value; return $this; } /** - * @return string + * @return ?string */ - public function getContactId(): string + public function getContactId(): ?string { return $this->contactId; } /** - * @param string $value + * @param ?string $value */ - public function setContactId(string $value): self + public function setContactId(?string $value = null): self { $this->contactId = $value; return $this; diff --git a/src/Contacts/Requests/ShowContactByExternalIdRequest.php b/src/Contacts/Requests/ShowContactByExternalIdRequest.php new file mode 100644 index 0000000..4a367e7 --- /dev/null +++ b/src/Contacts/Requests/ShowContactByExternalIdRequest.php @@ -0,0 +1,41 @@ +externalId = $values['externalId']; + } + + /** + * @return string + */ + public function getExternalId(): string + { + return $this->externalId; + } + + /** + * @param string $value + */ + public function setExternalId(string $value): self + { + $this->externalId = $value; + return $this; + } +} diff --git a/src/Contacts/Requests/UnarchiveContactRequest.php b/src/Contacts/Requests/UnarchiveContactRequest.php index 4e5da9c..aaf4f5e 100644 --- a/src/Contacts/Requests/UnarchiveContactRequest.php +++ b/src/Contacts/Requests/UnarchiveContactRequest.php @@ -7,7 +7,7 @@ class UnarchiveContactRequest extends JsonSerializableType { /** - * @var string $contactId id + * @var string $contactId contact_id */ private string $contactId; diff --git a/src/Contacts/Traits/Contact.php b/src/Contacts/Traits/Contact.php new file mode 100644 index 0000000..068664e --- /dev/null +++ b/src/Contacts/Traits/Contact.php @@ -0,0 +1,1098 @@ + $customAttributes + * @property ?string $avatar + * @property ?ContactTags $tags + * @property ?ContactNotes $notes + * @property ?ContactCompanies $companies + * @property ?ContactLocation $location + * @property ?ContactSocialProfiles $socialProfiles + */ +trait Contact +{ + /** + * @var ?'contact' $type The type of object. + */ + #[JsonProperty('type')] + private ?string $type; + + /** + * @var ?string $id The unique identifier for the contact which is given by Intercom. + */ + #[JsonProperty('id')] + private ?string $id; + + /** + * @var ?string $externalId The unique identifier for the contact which is provided by the Client. + */ + #[JsonProperty('external_id')] + private ?string $externalId; + + /** + * @var ?string $workspaceId The id of the workspace which the contact belongs to. + */ + #[JsonProperty('workspace_id')] + private ?string $workspaceId; + + /** + * @var ?string $role The role of the contact. + */ + #[JsonProperty('role')] + private ?string $role; + + /** + * @var ?string $email The contact's email. + */ + #[JsonProperty('email')] + private ?string $email; + + /** + * @var ?string $emailDomain The contact's email domain. + */ + #[JsonProperty('email_domain')] + private ?string $emailDomain; + + /** + * @var ?string $phone The contacts phone. + */ + #[JsonProperty('phone')] + private ?string $phone; + + /** + * @var ?string $name The contacts name. + */ + #[JsonProperty('name')] + private ?string $name; + + /** + * @var ?int $ownerId The id of an admin that has been assigned account ownership of the contact. + */ + #[JsonProperty('owner_id')] + private ?int $ownerId; + + /** + * @var ?bool $hasHardBounced Whether the contact has had an email sent to them hard bounce. + */ + #[JsonProperty('has_hard_bounced')] + private ?bool $hasHardBounced; + + /** + * @var ?bool $markedEmailAsSpam Whether the contact has marked an email sent to them as spam. + */ + #[JsonProperty('marked_email_as_spam')] + private ?bool $markedEmailAsSpam; + + /** + * @var ?bool $unsubscribedFromEmails Whether the contact is unsubscribed from emails. + */ + #[JsonProperty('unsubscribed_from_emails')] + private ?bool $unsubscribedFromEmails; + + /** + * @var ?int $createdAt (UNIX timestamp) The time when the contact was created. + */ + #[JsonProperty('created_at')] + private ?int $createdAt; + + /** + * @var ?int $updatedAt (UNIX timestamp) The time when the contact was last updated. + */ + #[JsonProperty('updated_at')] + private ?int $updatedAt; + + /** + * @var ?int $signedUpAt (UNIX timestamp) The time specified for when a contact signed up. + */ + #[JsonProperty('signed_up_at')] + private ?int $signedUpAt; + + /** + * @var ?int $lastSeenAt (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')] + private ?int $lastSeenAt; + + /** + * @var ?int $lastRepliedAt (UNIX timestamp) The time when the contact last messaged in. + */ + #[JsonProperty('last_replied_at')] + private ?int $lastRepliedAt; + + /** + * @var ?int $lastContactedAt (UNIX timestamp) The time when the contact was last messaged. + */ + #[JsonProperty('last_contacted_at')] + private ?int $lastContactedAt; + + /** + * @var ?int $lastEmailOpenedAt (UNIX timestamp) The time when the contact last opened an email. + */ + #[JsonProperty('last_email_opened_at')] + private ?int $lastEmailOpenedAt; + + /** + * @var ?int $lastEmailClickedAt (UNIX timestamp) The time when the contact last clicked a link in an email. + */ + #[JsonProperty('last_email_clicked_at')] + private ?int $lastEmailClickedAt; + + /** + * @var ?string $languageOverride A preferred language setting for the contact, used by the Intercom Messenger even if their browser settings change. + */ + #[JsonProperty('language_override')] + private ?string $languageOverride; + + /** + * @var ?string $browser The name of the browser which the contact is using. + */ + #[JsonProperty('browser')] + private ?string $browser; + + /** + * @var ?string $browserVersion The version of the browser which the contact is using. + */ + #[JsonProperty('browser_version')] + private ?string $browserVersion; + + /** + * @var ?string $browserLanguage The language set by the browser which the contact is using. + */ + #[JsonProperty('browser_language')] + private ?string $browserLanguage; + + /** + * @var ?string $os The operating system which the contact is using. + */ + #[JsonProperty('os')] + private ?string $os; + + /** + * @var ?string $androidAppName The name of the Android app which the contact is using. + */ + #[JsonProperty('android_app_name')] + private ?string $androidAppName; + + /** + * @var ?string $androidAppVersion The version of the Android app which the contact is using. + */ + #[JsonProperty('android_app_version')] + private ?string $androidAppVersion; + + /** + * @var ?string $androidDevice The Android device which the contact is using. + */ + #[JsonProperty('android_device')] + private ?string $androidDevice; + + /** + * @var ?string $androidOsVersion The version of the Android OS which the contact is using. + */ + #[JsonProperty('android_os_version')] + private ?string $androidOsVersion; + + /** + * @var ?string $androidSdkVersion The version of the Android SDK which the contact is using. + */ + #[JsonProperty('android_sdk_version')] + private ?string $androidSdkVersion; + + /** + * @var ?int $androidLastSeenAt (UNIX timestamp) The time when the contact was last seen on an Android device. + */ + #[JsonProperty('android_last_seen_at')] + private ?int $androidLastSeenAt; + + /** + * @var ?string $iosAppName The name of the iOS app which the contact is using. + */ + #[JsonProperty('ios_app_name')] + private ?string $iosAppName; + + /** + * @var ?string $iosAppVersion The version of the iOS app which the contact is using. + */ + #[JsonProperty('ios_app_version')] + private ?string $iosAppVersion; + + /** + * @var ?string $iosDevice The iOS device which the contact is using. + */ + #[JsonProperty('ios_device')] + private ?string $iosDevice; + + /** + * @var ?string $iosOsVersion The version of iOS which the contact is using. + */ + #[JsonProperty('ios_os_version')] + private ?string $iosOsVersion; + + /** + * @var ?string $iosSdkVersion The version of the iOS SDK which the contact is using. + */ + #[JsonProperty('ios_sdk_version')] + private ?string $iosSdkVersion; + + /** + * @var ?int $iosLastSeenAt (UNIX timestamp) The last time the contact used the iOS app. + */ + #[JsonProperty('ios_last_seen_at')] + private ?int $iosLastSeenAt; + + /** + * @var ?array $customAttributes The custom attributes which are set for the contact. + */ + #[JsonProperty('custom_attributes'), ArrayType(['string' => 'mixed'])] + private ?array $customAttributes; + + /** + * @var ?string $avatar An image URL containing the avatar of a contact. + */ + #[JsonProperty('avatar')] + private ?string $avatar; + + /** + * @var ?ContactTags $tags + */ + #[JsonProperty('tags')] + private ?ContactTags $tags; + + /** + * @var ?ContactNotes $notes + */ + #[JsonProperty('notes')] + private ?ContactNotes $notes; + + /** + * @var ?ContactCompanies $companies + */ + #[JsonProperty('companies')] + private ?ContactCompanies $companies; + + /** + * @var ?ContactLocation $location + */ + #[JsonProperty('location')] + private ?ContactLocation $location; + + /** + * @var ?ContactSocialProfiles $socialProfiles + */ + #[JsonProperty('social_profiles')] + private ?ContactSocialProfiles $socialProfiles; + + /** + * @return ?'contact' + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?'contact' $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?string + */ + public function getId(): ?string + { + return $this->id; + } + + /** + * @param ?string $value + */ + public function setId(?string $value = null): self + { + $this->id = $value; + return $this; + } + + /** + * @return ?string + */ + public function getExternalId(): ?string + { + return $this->externalId; + } + + /** + * @param ?string $value + */ + public function setExternalId(?string $value = null): self + { + $this->externalId = $value; + return $this; + } + + /** + * @return ?string + */ + public function getWorkspaceId(): ?string + { + return $this->workspaceId; + } + + /** + * @param ?string $value + */ + public function setWorkspaceId(?string $value = null): self + { + $this->workspaceId = $value; + return $this; + } + + /** + * @return ?string + */ + public function getRole(): ?string + { + return $this->role; + } + + /** + * @param ?string $value + */ + public function setRole(?string $value = null): self + { + $this->role = $value; + return $this; + } + + /** + * @return ?string + */ + public function getEmail(): ?string + { + return $this->email; + } + + /** + * @param ?string $value + */ + public function setEmail(?string $value = null): self + { + $this->email = $value; + return $this; + } + + /** + * @return ?string + */ + public function getEmailDomain(): ?string + { + return $this->emailDomain; + } + + /** + * @param ?string $value + */ + public function setEmailDomain(?string $value = null): self + { + $this->emailDomain = $value; + return $this; + } + + /** + * @return ?string + */ + public function getPhone(): ?string + { + return $this->phone; + } + + /** + * @param ?string $value + */ + public function setPhone(?string $value = null): self + { + $this->phone = $value; + return $this; + } + + /** + * @return ?string + */ + public function getName(): ?string + { + return $this->name; + } + + /** + * @param ?string $value + */ + public function setName(?string $value = null): self + { + $this->name = $value; + return $this; + } + + /** + * @return ?int + */ + public function getOwnerId(): ?int + { + return $this->ownerId; + } + + /** + * @param ?int $value + */ + public function setOwnerId(?int $value = null): self + { + $this->ownerId = $value; + return $this; + } + + /** + * @return ?bool + */ + public function getHasHardBounced(): ?bool + { + return $this->hasHardBounced; + } + + /** + * @param ?bool $value + */ + public function setHasHardBounced(?bool $value = null): self + { + $this->hasHardBounced = $value; + return $this; + } + + /** + * @return ?bool + */ + public function getMarkedEmailAsSpam(): ?bool + { + return $this->markedEmailAsSpam; + } + + /** + * @param ?bool $value + */ + public function setMarkedEmailAsSpam(?bool $value = null): self + { + $this->markedEmailAsSpam = $value; + return $this; + } + + /** + * @return ?bool + */ + public function getUnsubscribedFromEmails(): ?bool + { + return $this->unsubscribedFromEmails; + } + + /** + * @param ?bool $value + */ + public function setUnsubscribedFromEmails(?bool $value = null): self + { + $this->unsubscribedFromEmails = $value; + return $this; + } + + /** + * @return ?int + */ + public function getCreatedAt(): ?int + { + return $this->createdAt; + } + + /** + * @param ?int $value + */ + public function setCreatedAt(?int $value = null): self + { + $this->createdAt = $value; + return $this; + } + + /** + * @return ?int + */ + public function getUpdatedAt(): ?int + { + return $this->updatedAt; + } + + /** + * @param ?int $value + */ + public function setUpdatedAt(?int $value = null): self + { + $this->updatedAt = $value; + return $this; + } + + /** + * @return ?int + */ + public function getSignedUpAt(): ?int + { + return $this->signedUpAt; + } + + /** + * @param ?int $value + */ + public function setSignedUpAt(?int $value = null): self + { + $this->signedUpAt = $value; + return $this; + } + + /** + * @return ?int + */ + public function getLastSeenAt(): ?int + { + return $this->lastSeenAt; + } + + /** + * @param ?int $value + */ + public function setLastSeenAt(?int $value = null): self + { + $this->lastSeenAt = $value; + return $this; + } + + /** + * @return ?int + */ + public function getLastRepliedAt(): ?int + { + return $this->lastRepliedAt; + } + + /** + * @param ?int $value + */ + public function setLastRepliedAt(?int $value = null): self + { + $this->lastRepliedAt = $value; + return $this; + } + + /** + * @return ?int + */ + public function getLastContactedAt(): ?int + { + return $this->lastContactedAt; + } + + /** + * @param ?int $value + */ + public function setLastContactedAt(?int $value = null): self + { + $this->lastContactedAt = $value; + return $this; + } + + /** + * @return ?int + */ + public function getLastEmailOpenedAt(): ?int + { + return $this->lastEmailOpenedAt; + } + + /** + * @param ?int $value + */ + public function setLastEmailOpenedAt(?int $value = null): self + { + $this->lastEmailOpenedAt = $value; + return $this; + } + + /** + * @return ?int + */ + public function getLastEmailClickedAt(): ?int + { + return $this->lastEmailClickedAt; + } + + /** + * @param ?int $value + */ + public function setLastEmailClickedAt(?int $value = null): self + { + $this->lastEmailClickedAt = $value; + return $this; + } + + /** + * @return ?string + */ + public function getLanguageOverride(): ?string + { + return $this->languageOverride; + } + + /** + * @param ?string $value + */ + public function setLanguageOverride(?string $value = null): self + { + $this->languageOverride = $value; + return $this; + } + + /** + * @return ?string + */ + public function getBrowser(): ?string + { + return $this->browser; + } + + /** + * @param ?string $value + */ + public function setBrowser(?string $value = null): self + { + $this->browser = $value; + return $this; + } + + /** + * @return ?string + */ + public function getBrowserVersion(): ?string + { + return $this->browserVersion; + } + + /** + * @param ?string $value + */ + public function setBrowserVersion(?string $value = null): self + { + $this->browserVersion = $value; + return $this; + } + + /** + * @return ?string + */ + public function getBrowserLanguage(): ?string + { + return $this->browserLanguage; + } + + /** + * @param ?string $value + */ + public function setBrowserLanguage(?string $value = null): self + { + $this->browserLanguage = $value; + return $this; + } + + /** + * @return ?string + */ + public function getOs(): ?string + { + return $this->os; + } + + /** + * @param ?string $value + */ + public function setOs(?string $value = null): self + { + $this->os = $value; + return $this; + } + + /** + * @return ?string + */ + public function getAndroidAppName(): ?string + { + return $this->androidAppName; + } + + /** + * @param ?string $value + */ + public function setAndroidAppName(?string $value = null): self + { + $this->androidAppName = $value; + return $this; + } + + /** + * @return ?string + */ + public function getAndroidAppVersion(): ?string + { + return $this->androidAppVersion; + } + + /** + * @param ?string $value + */ + public function setAndroidAppVersion(?string $value = null): self + { + $this->androidAppVersion = $value; + return $this; + } + + /** + * @return ?string + */ + public function getAndroidDevice(): ?string + { + return $this->androidDevice; + } + + /** + * @param ?string $value + */ + public function setAndroidDevice(?string $value = null): self + { + $this->androidDevice = $value; + return $this; + } + + /** + * @return ?string + */ + public function getAndroidOsVersion(): ?string + { + return $this->androidOsVersion; + } + + /** + * @param ?string $value + */ + public function setAndroidOsVersion(?string $value = null): self + { + $this->androidOsVersion = $value; + return $this; + } + + /** + * @return ?string + */ + public function getAndroidSdkVersion(): ?string + { + return $this->androidSdkVersion; + } + + /** + * @param ?string $value + */ + public function setAndroidSdkVersion(?string $value = null): self + { + $this->androidSdkVersion = $value; + return $this; + } + + /** + * @return ?int + */ + public function getAndroidLastSeenAt(): ?int + { + return $this->androidLastSeenAt; + } + + /** + * @param ?int $value + */ + public function setAndroidLastSeenAt(?int $value = null): self + { + $this->androidLastSeenAt = $value; + return $this; + } + + /** + * @return ?string + */ + public function getIosAppName(): ?string + { + return $this->iosAppName; + } + + /** + * @param ?string $value + */ + public function setIosAppName(?string $value = null): self + { + $this->iosAppName = $value; + return $this; + } + + /** + * @return ?string + */ + public function getIosAppVersion(): ?string + { + return $this->iosAppVersion; + } + + /** + * @param ?string $value + */ + public function setIosAppVersion(?string $value = null): self + { + $this->iosAppVersion = $value; + return $this; + } + + /** + * @return ?string + */ + public function getIosDevice(): ?string + { + return $this->iosDevice; + } + + /** + * @param ?string $value + */ + public function setIosDevice(?string $value = null): self + { + $this->iosDevice = $value; + return $this; + } + + /** + * @return ?string + */ + public function getIosOsVersion(): ?string + { + return $this->iosOsVersion; + } + + /** + * @param ?string $value + */ + public function setIosOsVersion(?string $value = null): self + { + $this->iosOsVersion = $value; + return $this; + } + + /** + * @return ?string + */ + public function getIosSdkVersion(): ?string + { + return $this->iosSdkVersion; + } + + /** + * @param ?string $value + */ + public function setIosSdkVersion(?string $value = null): self + { + $this->iosSdkVersion = $value; + return $this; + } + + /** + * @return ?int + */ + public function getIosLastSeenAt(): ?int + { + return $this->iosLastSeenAt; + } + + /** + * @param ?int $value + */ + public function setIosLastSeenAt(?int $value = null): self + { + $this->iosLastSeenAt = $value; + return $this; + } + + /** + * @return ?array + */ + public function getCustomAttributes(): ?array + { + return $this->customAttributes; + } + + /** + * @param ?array $value + */ + public function setCustomAttributes(?array $value = null): self + { + $this->customAttributes = $value; + return $this; + } + + /** + * @return ?string + */ + public function getAvatar(): ?string + { + return $this->avatar; + } + + /** + * @param ?string $value + */ + public function setAvatar(?string $value = null): self + { + $this->avatar = $value; + return $this; + } + + /** + * @return ?ContactTags + */ + public function getTags(): ?ContactTags + { + return $this->tags; + } + + /** + * @param ?ContactTags $value + */ + public function setTags(?ContactTags $value = null): self + { + $this->tags = $value; + return $this; + } + + /** + * @return ?ContactNotes + */ + public function getNotes(): ?ContactNotes + { + return $this->notes; + } + + /** + * @param ?ContactNotes $value + */ + public function setNotes(?ContactNotes $value = null): self + { + $this->notes = $value; + return $this; + } + + /** + * @return ?ContactCompanies + */ + public function getCompanies(): ?ContactCompanies + { + return $this->companies; + } + + /** + * @param ?ContactCompanies $value + */ + public function setCompanies(?ContactCompanies $value = null): self + { + $this->companies = $value; + return $this; + } + + /** + * @return ?ContactLocation + */ + public function getLocation(): ?ContactLocation + { + return $this->location; + } + + /** + * @param ?ContactLocation $value + */ + public function setLocation(?ContactLocation $value = null): self + { + $this->location = $value; + return $this; + } + + /** + * @return ?ContactSocialProfiles + */ + public function getSocialProfiles(): ?ContactSocialProfiles + { + return $this->socialProfiles; + } + + /** + * @param ?ContactSocialProfiles $value + */ + public function setSocialProfiles(?ContactSocialProfiles $value = null): self + { + $this->socialProfiles = $value; + return $this; + } +} diff --git a/src/Contacts/Types/Contact.php b/src/Contacts/Types/Contact.php index 22d2496..c16c44f 100644 --- a/src/Contacts/Types/Contact.php +++ b/src/Contacts/Types/Contact.php @@ -12,7 +12,7 @@ use Intercom\Types\ContactSocialProfiles; /** - * Contact are the objects that represent your leads and users in Intercom. + * Contacts represent your leads and users in Intercom. */ class Contact extends JsonSerializableType { @@ -23,10 +23,10 @@ class Contact extends JsonSerializableType private ?string $type; /** - * @var string $id The unique identifier for the contact which is given by Intercom. + * @var ?string $id The unique identifier for the contact which is given by Intercom. */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** * @var ?string $externalId The unique identifier for the contact which is provided by the Client. @@ -35,16 +35,16 @@ class Contact extends JsonSerializableType private ?string $externalId; /** - * @var string $workspaceId The id of the workspace which the contact belongs to. + * @var ?string $workspaceId The id of the workspace which the contact belongs to. */ #[JsonProperty('workspace_id')] - private string $workspaceId; + private ?string $workspaceId; /** - * @var string $role The role of the contact. + * @var ?string $role The role of the contact. */ #[JsonProperty('role')] - private string $role; + private ?string $role; /** * @var ?string $email The contact's email. @@ -64,12 +64,6 @@ class Contact extends JsonSerializableType #[JsonProperty('phone')] private ?string $phone; - /** - * @var ?string $formattedPhone The contacts phone number normalized to the E164 format - */ - #[JsonProperty('formatted_phone')] - private ?string $formattedPhone; - /** * @var ?string $name The contacts name. */ @@ -83,34 +77,34 @@ class Contact extends JsonSerializableType private ?int $ownerId; /** - * @var bool $hasHardBounced Whether the contact has had an email sent to them hard bounce. + * @var ?bool $hasHardBounced Whether the contact has had an email sent to them hard bounce. */ #[JsonProperty('has_hard_bounced')] - private bool $hasHardBounced; + private ?bool $hasHardBounced; /** - * @var bool $markedEmailAsSpam Whether the contact has marked an email sent to them as spam. + * @var ?bool $markedEmailAsSpam Whether the contact has marked an email sent to them as spam. */ #[JsonProperty('marked_email_as_spam')] - private bool $markedEmailAsSpam; + private ?bool $markedEmailAsSpam; /** - * @var bool $unsubscribedFromEmails Whether the contact is unsubscribed from emails. + * @var ?bool $unsubscribedFromEmails Whether the contact is unsubscribed from emails. */ #[JsonProperty('unsubscribed_from_emails')] - private bool $unsubscribedFromEmails; + private ?bool $unsubscribedFromEmails; /** - * @var int $createdAt (UNIX timestamp) The time when the contact was created. + * @var ?int $createdAt (UNIX timestamp) The time when the contact was created. */ #[JsonProperty('created_at')] - private int $createdAt; + private ?int $createdAt; /** - * @var int $updatedAt (UNIX timestamp) The time when the contact was last updated. + * @var ?int $updatedAt (UNIX timestamp) The time when the contact was last updated. */ #[JsonProperty('updated_at')] - private int $updatedAt; + private ?int $updatedAt; /** * @var ?int $signedUpAt (UNIX timestamp) The time specified for when a contact signed up. @@ -281,37 +275,34 @@ class Contact extends JsonSerializableType private ?ContactCompanies $companies; /** - * @var ContactLocation $location + * @var ?ContactLocation $location */ #[JsonProperty('location')] - private ContactLocation $location; + private ?ContactLocation $location; /** - * @var ContactSocialProfiles $socialProfiles + * @var ?ContactSocialProfiles $socialProfiles */ #[JsonProperty('social_profiles')] - private ContactSocialProfiles $socialProfiles; + private ?ContactSocialProfiles $socialProfiles; /** * @param array{ - * id: string, - * workspaceId: string, - * role: string, - * hasHardBounced: bool, - * markedEmailAsSpam: bool, - * unsubscribedFromEmails: bool, - * createdAt: int, - * updatedAt: int, - * location: ContactLocation, - * socialProfiles: ContactSocialProfiles, * type?: ?'contact', + * id?: ?string, * externalId?: ?string, + * workspaceId?: ?string, + * role?: ?string, * email?: ?string, * emailDomain?: ?string, * phone?: ?string, - * formattedPhone?: ?string, * name?: ?string, * ownerId?: ?int, + * hasHardBounced?: ?bool, + * markedEmailAsSpam?: ?bool, + * unsubscribedFromEmails?: ?bool, + * createdAt?: ?int, + * updatedAt?: ?int, * signedUpAt?: ?int, * lastSeenAt?: ?int, * lastRepliedAt?: ?int, @@ -340,27 +331,28 @@ class Contact extends JsonSerializableType * tags?: ?ContactTags, * notes?: ?ContactNotes, * companies?: ?ContactCompanies, + * location?: ?ContactLocation, + * socialProfiles?: ?ContactSocialProfiles, * } $values */ public function __construct( - array $values, + array $values = [], ) { $this->type = $values['type'] ?? null; - $this->id = $values['id']; + $this->id = $values['id'] ?? null; $this->externalId = $values['externalId'] ?? null; - $this->workspaceId = $values['workspaceId']; - $this->role = $values['role']; + $this->workspaceId = $values['workspaceId'] ?? null; + $this->role = $values['role'] ?? null; $this->email = $values['email'] ?? null; $this->emailDomain = $values['emailDomain'] ?? null; $this->phone = $values['phone'] ?? null; - $this->formattedPhone = $values['formattedPhone'] ?? null; $this->name = $values['name'] ?? null; $this->ownerId = $values['ownerId'] ?? null; - $this->hasHardBounced = $values['hasHardBounced']; - $this->markedEmailAsSpam = $values['markedEmailAsSpam']; - $this->unsubscribedFromEmails = $values['unsubscribedFromEmails']; - $this->createdAt = $values['createdAt']; - $this->updatedAt = $values['updatedAt']; + $this->hasHardBounced = $values['hasHardBounced'] ?? null; + $this->markedEmailAsSpam = $values['markedEmailAsSpam'] ?? null; + $this->unsubscribedFromEmails = $values['unsubscribedFromEmails'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; + $this->updatedAt = $values['updatedAt'] ?? null; $this->signedUpAt = $values['signedUpAt'] ?? null; $this->lastSeenAt = $values['lastSeenAt'] ?? null; $this->lastRepliedAt = $values['lastRepliedAt'] ?? null; @@ -389,8 +381,8 @@ public function __construct( $this->tags = $values['tags'] ?? null; $this->notes = $values['notes'] ?? null; $this->companies = $values['companies'] ?? null; - $this->location = $values['location']; - $this->socialProfiles = $values['socialProfiles']; + $this->location = $values['location'] ?? null; + $this->socialProfiles = $values['socialProfiles'] ?? null; } /** @@ -411,17 +403,17 @@ public function setType(?string $value = null): self } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; @@ -445,34 +437,34 @@ public function setExternalId(?string $value = null): self } /** - * @return string + * @return ?string */ - public function getWorkspaceId(): string + public function getWorkspaceId(): ?string { return $this->workspaceId; } /** - * @param string $value + * @param ?string $value */ - public function setWorkspaceId(string $value): self + public function setWorkspaceId(?string $value = null): self { $this->workspaceId = $value; return $this; } /** - * @return string + * @return ?string */ - public function getRole(): string + public function getRole(): ?string { return $this->role; } /** - * @param string $value + * @param ?string $value */ - public function setRole(string $value): self + public function setRole(?string $value = null): self { $this->role = $value; return $this; @@ -529,23 +521,6 @@ public function setPhone(?string $value = null): self return $this; } - /** - * @return ?string - */ - public function getFormattedPhone(): ?string - { - return $this->formattedPhone; - } - - /** - * @param ?string $value - */ - public function setFormattedPhone(?string $value = null): self - { - $this->formattedPhone = $value; - return $this; - } - /** * @return ?string */ @@ -581,85 +556,85 @@ public function setOwnerId(?int $value = null): self } /** - * @return bool + * @return ?bool */ - public function getHasHardBounced(): bool + public function getHasHardBounced(): ?bool { return $this->hasHardBounced; } /** - * @param bool $value + * @param ?bool $value */ - public function setHasHardBounced(bool $value): self + public function setHasHardBounced(?bool $value = null): self { $this->hasHardBounced = $value; return $this; } /** - * @return bool + * @return ?bool */ - public function getMarkedEmailAsSpam(): bool + public function getMarkedEmailAsSpam(): ?bool { return $this->markedEmailAsSpam; } /** - * @param bool $value + * @param ?bool $value */ - public function setMarkedEmailAsSpam(bool $value): self + public function setMarkedEmailAsSpam(?bool $value = null): self { $this->markedEmailAsSpam = $value; return $this; } /** - * @return bool + * @return ?bool */ - public function getUnsubscribedFromEmails(): bool + public function getUnsubscribedFromEmails(): ?bool { return $this->unsubscribedFromEmails; } /** - * @param bool $value + * @param ?bool $value */ - public function setUnsubscribedFromEmails(bool $value): self + public function setUnsubscribedFromEmails(?bool $value = null): self { $this->unsubscribedFromEmails = $value; return $this; } /** - * @return int + * @return ?int */ - public function getCreatedAt(): int + public function getCreatedAt(): ?int { return $this->createdAt; } /** - * @param int $value + * @param ?int $value */ - public function setCreatedAt(int $value): self + public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; return $this; } /** - * @return int + * @return ?int */ - public function getUpdatedAt(): int + public function getUpdatedAt(): ?int { return $this->updatedAt; } /** - * @param int $value + * @param ?int $value */ - public function setUpdatedAt(int $value): self + public function setUpdatedAt(?int $value = null): self { $this->updatedAt = $value; return $this; @@ -1142,34 +1117,34 @@ public function setCompanies(?ContactCompanies $value = null): self } /** - * @return ContactLocation + * @return ?ContactLocation */ - public function getLocation(): ContactLocation + public function getLocation(): ?ContactLocation { return $this->location; } /** - * @param ContactLocation $value + * @param ?ContactLocation $value */ - public function setLocation(ContactLocation $value): self + public function setLocation(?ContactLocation $value = null): self { $this->location = $value; return $this; } /** - * @return ContactSocialProfiles + * @return ?ContactSocialProfiles */ - public function getSocialProfiles(): ContactSocialProfiles + public function getSocialProfiles(): ?ContactSocialProfiles { return $this->socialProfiles; } /** - * @param ContactSocialProfiles $value + * @param ?ContactSocialProfiles $value */ - public function setSocialProfiles(ContactSocialProfiles $value): self + public function setSocialProfiles(?ContactSocialProfiles $value = null): self { $this->socialProfiles = $value; return $this; diff --git a/src/Contacts/Types/ContactsCreateResponse.php b/src/Contacts/Types/ContactsCreateResponse.php new file mode 100644 index 0000000..c01ea0b --- /dev/null +++ b/src/Contacts/Types/ContactsCreateResponse.php @@ -0,0 +1,149 @@ +, + * avatar?: ?string, + * tags?: ?ContactTags, + * notes?: ?ContactNotes, + * companies?: ?ContactCompanies, + * location?: ?ContactLocation, + * socialProfiles?: ?ContactSocialProfiles, + * enabledPushMessaging?: ?bool, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->externalId = $values['externalId'] ?? null; + $this->workspaceId = $values['workspaceId'] ?? null; + $this->role = $values['role'] ?? null; + $this->email = $values['email'] ?? null; + $this->emailDomain = $values['emailDomain'] ?? null; + $this->phone = $values['phone'] ?? null; + $this->name = $values['name'] ?? null; + $this->ownerId = $values['ownerId'] ?? null; + $this->hasHardBounced = $values['hasHardBounced'] ?? null; + $this->markedEmailAsSpam = $values['markedEmailAsSpam'] ?? null; + $this->unsubscribedFromEmails = $values['unsubscribedFromEmails'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; + $this->updatedAt = $values['updatedAt'] ?? null; + $this->signedUpAt = $values['signedUpAt'] ?? null; + $this->lastSeenAt = $values['lastSeenAt'] ?? null; + $this->lastRepliedAt = $values['lastRepliedAt'] ?? null; + $this->lastContactedAt = $values['lastContactedAt'] ?? null; + $this->lastEmailOpenedAt = $values['lastEmailOpenedAt'] ?? null; + $this->lastEmailClickedAt = $values['lastEmailClickedAt'] ?? null; + $this->languageOverride = $values['languageOverride'] ?? null; + $this->browser = $values['browser'] ?? null; + $this->browserVersion = $values['browserVersion'] ?? null; + $this->browserLanguage = $values['browserLanguage'] ?? null; + $this->os = $values['os'] ?? null; + $this->androidAppName = $values['androidAppName'] ?? null; + $this->androidAppVersion = $values['androidAppVersion'] ?? null; + $this->androidDevice = $values['androidDevice'] ?? null; + $this->androidOsVersion = $values['androidOsVersion'] ?? null; + $this->androidSdkVersion = $values['androidSdkVersion'] ?? null; + $this->androidLastSeenAt = $values['androidLastSeenAt'] ?? null; + $this->iosAppName = $values['iosAppName'] ?? null; + $this->iosAppVersion = $values['iosAppVersion'] ?? null; + $this->iosDevice = $values['iosDevice'] ?? null; + $this->iosOsVersion = $values['iosOsVersion'] ?? null; + $this->iosSdkVersion = $values['iosSdkVersion'] ?? null; + $this->iosLastSeenAt = $values['iosLastSeenAt'] ?? null; + $this->customAttributes = $values['customAttributes'] ?? null; + $this->avatar = $values['avatar'] ?? null; + $this->tags = $values['tags'] ?? null; + $this->notes = $values['notes'] ?? null; + $this->companies = $values['companies'] ?? null; + $this->location = $values['location'] ?? null; + $this->socialProfiles = $values['socialProfiles'] ?? null; + $this->enabledPushMessaging = $values['enabledPushMessaging'] ?? null; + } + + /** + * @return ?bool + */ + public function getEnabledPushMessaging(): ?bool + { + return $this->enabledPushMessaging; + } + + /** + * @param ?bool $value + */ + public function setEnabledPushMessaging(?bool $value = null): self + { + $this->enabledPushMessaging = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Contacts/Types/ContactsFindResponse.php b/src/Contacts/Types/ContactsFindResponse.php new file mode 100644 index 0000000..c108e48 --- /dev/null +++ b/src/Contacts/Types/ContactsFindResponse.php @@ -0,0 +1,149 @@ +, + * avatar?: ?string, + * tags?: ?ContactTags, + * notes?: ?ContactNotes, + * companies?: ?ContactCompanies, + * location?: ?ContactLocation, + * socialProfiles?: ?ContactSocialProfiles, + * enabledPushMessaging?: ?bool, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->externalId = $values['externalId'] ?? null; + $this->workspaceId = $values['workspaceId'] ?? null; + $this->role = $values['role'] ?? null; + $this->email = $values['email'] ?? null; + $this->emailDomain = $values['emailDomain'] ?? null; + $this->phone = $values['phone'] ?? null; + $this->name = $values['name'] ?? null; + $this->ownerId = $values['ownerId'] ?? null; + $this->hasHardBounced = $values['hasHardBounced'] ?? null; + $this->markedEmailAsSpam = $values['markedEmailAsSpam'] ?? null; + $this->unsubscribedFromEmails = $values['unsubscribedFromEmails'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; + $this->updatedAt = $values['updatedAt'] ?? null; + $this->signedUpAt = $values['signedUpAt'] ?? null; + $this->lastSeenAt = $values['lastSeenAt'] ?? null; + $this->lastRepliedAt = $values['lastRepliedAt'] ?? null; + $this->lastContactedAt = $values['lastContactedAt'] ?? null; + $this->lastEmailOpenedAt = $values['lastEmailOpenedAt'] ?? null; + $this->lastEmailClickedAt = $values['lastEmailClickedAt'] ?? null; + $this->languageOverride = $values['languageOverride'] ?? null; + $this->browser = $values['browser'] ?? null; + $this->browserVersion = $values['browserVersion'] ?? null; + $this->browserLanguage = $values['browserLanguage'] ?? null; + $this->os = $values['os'] ?? null; + $this->androidAppName = $values['androidAppName'] ?? null; + $this->androidAppVersion = $values['androidAppVersion'] ?? null; + $this->androidDevice = $values['androidDevice'] ?? null; + $this->androidOsVersion = $values['androidOsVersion'] ?? null; + $this->androidSdkVersion = $values['androidSdkVersion'] ?? null; + $this->androidLastSeenAt = $values['androidLastSeenAt'] ?? null; + $this->iosAppName = $values['iosAppName'] ?? null; + $this->iosAppVersion = $values['iosAppVersion'] ?? null; + $this->iosDevice = $values['iosDevice'] ?? null; + $this->iosOsVersion = $values['iosOsVersion'] ?? null; + $this->iosSdkVersion = $values['iosSdkVersion'] ?? null; + $this->iosLastSeenAt = $values['iosLastSeenAt'] ?? null; + $this->customAttributes = $values['customAttributes'] ?? null; + $this->avatar = $values['avatar'] ?? null; + $this->tags = $values['tags'] ?? null; + $this->notes = $values['notes'] ?? null; + $this->companies = $values['companies'] ?? null; + $this->location = $values['location'] ?? null; + $this->socialProfiles = $values['socialProfiles'] ?? null; + $this->enabledPushMessaging = $values['enabledPushMessaging'] ?? null; + } + + /** + * @return ?bool + */ + public function getEnabledPushMessaging(): ?bool + { + return $this->enabledPushMessaging; + } + + /** + * @param ?bool $value + */ + public function setEnabledPushMessaging(?bool $value = null): self + { + $this->enabledPushMessaging = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Contacts/Types/ContactsMergeLeadInUserResponse.php b/src/Contacts/Types/ContactsMergeLeadInUserResponse.php new file mode 100644 index 0000000..5c68910 --- /dev/null +++ b/src/Contacts/Types/ContactsMergeLeadInUserResponse.php @@ -0,0 +1,149 @@ +, + * avatar?: ?string, + * tags?: ?ContactTags, + * notes?: ?ContactNotes, + * companies?: ?ContactCompanies, + * location?: ?ContactLocation, + * socialProfiles?: ?ContactSocialProfiles, + * enabledPushMessaging?: ?bool, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->externalId = $values['externalId'] ?? null; + $this->workspaceId = $values['workspaceId'] ?? null; + $this->role = $values['role'] ?? null; + $this->email = $values['email'] ?? null; + $this->emailDomain = $values['emailDomain'] ?? null; + $this->phone = $values['phone'] ?? null; + $this->name = $values['name'] ?? null; + $this->ownerId = $values['ownerId'] ?? null; + $this->hasHardBounced = $values['hasHardBounced'] ?? null; + $this->markedEmailAsSpam = $values['markedEmailAsSpam'] ?? null; + $this->unsubscribedFromEmails = $values['unsubscribedFromEmails'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; + $this->updatedAt = $values['updatedAt'] ?? null; + $this->signedUpAt = $values['signedUpAt'] ?? null; + $this->lastSeenAt = $values['lastSeenAt'] ?? null; + $this->lastRepliedAt = $values['lastRepliedAt'] ?? null; + $this->lastContactedAt = $values['lastContactedAt'] ?? null; + $this->lastEmailOpenedAt = $values['lastEmailOpenedAt'] ?? null; + $this->lastEmailClickedAt = $values['lastEmailClickedAt'] ?? null; + $this->languageOverride = $values['languageOverride'] ?? null; + $this->browser = $values['browser'] ?? null; + $this->browserVersion = $values['browserVersion'] ?? null; + $this->browserLanguage = $values['browserLanguage'] ?? null; + $this->os = $values['os'] ?? null; + $this->androidAppName = $values['androidAppName'] ?? null; + $this->androidAppVersion = $values['androidAppVersion'] ?? null; + $this->androidDevice = $values['androidDevice'] ?? null; + $this->androidOsVersion = $values['androidOsVersion'] ?? null; + $this->androidSdkVersion = $values['androidSdkVersion'] ?? null; + $this->androidLastSeenAt = $values['androidLastSeenAt'] ?? null; + $this->iosAppName = $values['iosAppName'] ?? null; + $this->iosAppVersion = $values['iosAppVersion'] ?? null; + $this->iosDevice = $values['iosDevice'] ?? null; + $this->iosOsVersion = $values['iosOsVersion'] ?? null; + $this->iosSdkVersion = $values['iosSdkVersion'] ?? null; + $this->iosLastSeenAt = $values['iosLastSeenAt'] ?? null; + $this->customAttributes = $values['customAttributes'] ?? null; + $this->avatar = $values['avatar'] ?? null; + $this->tags = $values['tags'] ?? null; + $this->notes = $values['notes'] ?? null; + $this->companies = $values['companies'] ?? null; + $this->location = $values['location'] ?? null; + $this->socialProfiles = $values['socialProfiles'] ?? null; + $this->enabledPushMessaging = $values['enabledPushMessaging'] ?? null; + } + + /** + * @return ?bool + */ + public function getEnabledPushMessaging(): ?bool + { + return $this->enabledPushMessaging; + } + + /** + * @param ?bool $value + */ + public function setEnabledPushMessaging(?bool $value = null): self + { + $this->enabledPushMessaging = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Contacts/Types/ContactsUpdateResponse.php b/src/Contacts/Types/ContactsUpdateResponse.php new file mode 100644 index 0000000..c4a2e14 --- /dev/null +++ b/src/Contacts/Types/ContactsUpdateResponse.php @@ -0,0 +1,149 @@ +, + * avatar?: ?string, + * tags?: ?ContactTags, + * notes?: ?ContactNotes, + * companies?: ?ContactCompanies, + * location?: ?ContactLocation, + * socialProfiles?: ?ContactSocialProfiles, + * enabledPushMessaging?: ?bool, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->externalId = $values['externalId'] ?? null; + $this->workspaceId = $values['workspaceId'] ?? null; + $this->role = $values['role'] ?? null; + $this->email = $values['email'] ?? null; + $this->emailDomain = $values['emailDomain'] ?? null; + $this->phone = $values['phone'] ?? null; + $this->name = $values['name'] ?? null; + $this->ownerId = $values['ownerId'] ?? null; + $this->hasHardBounced = $values['hasHardBounced'] ?? null; + $this->markedEmailAsSpam = $values['markedEmailAsSpam'] ?? null; + $this->unsubscribedFromEmails = $values['unsubscribedFromEmails'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; + $this->updatedAt = $values['updatedAt'] ?? null; + $this->signedUpAt = $values['signedUpAt'] ?? null; + $this->lastSeenAt = $values['lastSeenAt'] ?? null; + $this->lastRepliedAt = $values['lastRepliedAt'] ?? null; + $this->lastContactedAt = $values['lastContactedAt'] ?? null; + $this->lastEmailOpenedAt = $values['lastEmailOpenedAt'] ?? null; + $this->lastEmailClickedAt = $values['lastEmailClickedAt'] ?? null; + $this->languageOverride = $values['languageOverride'] ?? null; + $this->browser = $values['browser'] ?? null; + $this->browserVersion = $values['browserVersion'] ?? null; + $this->browserLanguage = $values['browserLanguage'] ?? null; + $this->os = $values['os'] ?? null; + $this->androidAppName = $values['androidAppName'] ?? null; + $this->androidAppVersion = $values['androidAppVersion'] ?? null; + $this->androidDevice = $values['androidDevice'] ?? null; + $this->androidOsVersion = $values['androidOsVersion'] ?? null; + $this->androidSdkVersion = $values['androidSdkVersion'] ?? null; + $this->androidLastSeenAt = $values['androidLastSeenAt'] ?? null; + $this->iosAppName = $values['iosAppName'] ?? null; + $this->iosAppVersion = $values['iosAppVersion'] ?? null; + $this->iosDevice = $values['iosDevice'] ?? null; + $this->iosOsVersion = $values['iosOsVersion'] ?? null; + $this->iosSdkVersion = $values['iosSdkVersion'] ?? null; + $this->iosLastSeenAt = $values['iosLastSeenAt'] ?? null; + $this->customAttributes = $values['customAttributes'] ?? null; + $this->avatar = $values['avatar'] ?? null; + $this->tags = $values['tags'] ?? null; + $this->notes = $values['notes'] ?? null; + $this->companies = $values['companies'] ?? null; + $this->location = $values['location'] ?? null; + $this->socialProfiles = $values['socialProfiles'] ?? null; + $this->enabledPushMessaging = $values['enabledPushMessaging'] ?? null; + } + + /** + * @return ?bool + */ + public function getEnabledPushMessaging(): ?bool + { + return $this->enabledPushMessaging; + } + + /** + * @param ?bool $value + */ + public function setEnabledPushMessaging(?bool $value = null): self + { + $this->enabledPushMessaging = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Contacts/Types/ShowContactByExternalIdResponse.php b/src/Contacts/Types/ShowContactByExternalIdResponse.php new file mode 100644 index 0000000..1407850 --- /dev/null +++ b/src/Contacts/Types/ShowContactByExternalIdResponse.php @@ -0,0 +1,149 @@ +, + * avatar?: ?string, + * tags?: ?ContactTags, + * notes?: ?ContactNotes, + * companies?: ?ContactCompanies, + * location?: ?ContactLocation, + * socialProfiles?: ?ContactSocialProfiles, + * enabledPushMessaging?: ?bool, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->externalId = $values['externalId'] ?? null; + $this->workspaceId = $values['workspaceId'] ?? null; + $this->role = $values['role'] ?? null; + $this->email = $values['email'] ?? null; + $this->emailDomain = $values['emailDomain'] ?? null; + $this->phone = $values['phone'] ?? null; + $this->name = $values['name'] ?? null; + $this->ownerId = $values['ownerId'] ?? null; + $this->hasHardBounced = $values['hasHardBounced'] ?? null; + $this->markedEmailAsSpam = $values['markedEmailAsSpam'] ?? null; + $this->unsubscribedFromEmails = $values['unsubscribedFromEmails'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; + $this->updatedAt = $values['updatedAt'] ?? null; + $this->signedUpAt = $values['signedUpAt'] ?? null; + $this->lastSeenAt = $values['lastSeenAt'] ?? null; + $this->lastRepliedAt = $values['lastRepliedAt'] ?? null; + $this->lastContactedAt = $values['lastContactedAt'] ?? null; + $this->lastEmailOpenedAt = $values['lastEmailOpenedAt'] ?? null; + $this->lastEmailClickedAt = $values['lastEmailClickedAt'] ?? null; + $this->languageOverride = $values['languageOverride'] ?? null; + $this->browser = $values['browser'] ?? null; + $this->browserVersion = $values['browserVersion'] ?? null; + $this->browserLanguage = $values['browserLanguage'] ?? null; + $this->os = $values['os'] ?? null; + $this->androidAppName = $values['androidAppName'] ?? null; + $this->androidAppVersion = $values['androidAppVersion'] ?? null; + $this->androidDevice = $values['androidDevice'] ?? null; + $this->androidOsVersion = $values['androidOsVersion'] ?? null; + $this->androidSdkVersion = $values['androidSdkVersion'] ?? null; + $this->androidLastSeenAt = $values['androidLastSeenAt'] ?? null; + $this->iosAppName = $values['iosAppName'] ?? null; + $this->iosAppVersion = $values['iosAppVersion'] ?? null; + $this->iosDevice = $values['iosDevice'] ?? null; + $this->iosOsVersion = $values['iosOsVersion'] ?? null; + $this->iosSdkVersion = $values['iosSdkVersion'] ?? null; + $this->iosLastSeenAt = $values['iosLastSeenAt'] ?? null; + $this->customAttributes = $values['customAttributes'] ?? null; + $this->avatar = $values['avatar'] ?? null; + $this->tags = $values['tags'] ?? null; + $this->notes = $values['notes'] ?? null; + $this->companies = $values['companies'] ?? null; + $this->location = $values['location'] ?? null; + $this->socialProfiles = $values['socialProfiles'] ?? null; + $this->enabledPushMessaging = $values['enabledPushMessaging'] ?? null; + } + + /** + * @return ?bool + */ + public function getEnabledPushMessaging(): ?bool + { + return $this->enabledPushMessaging; + } + + /** + * @param ?bool $value + */ + public function setEnabledPushMessaging(?bool $value = null): self + { + $this->enabledPushMessaging = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Conversations/ConversationsClient.php b/src/Conversations/ConversationsClient.php index 159776c..f333ad1 100644 --- a/src/Conversations/ConversationsClient.php +++ b/src/Conversations/ConversationsClient.php @@ -8,7 +8,7 @@ use Intercom\Core\Pagination\Pager; use Intercom\Conversations\Types\Conversation; use Intercom\Core\Pagination\CursorPager; -use Intercom\Types\PaginatedConversationResponse; +use Intercom\Types\ConversationList; use Intercom\Conversations\Requests\CreateConversationRequest; use Intercom\Messages\Types\Message; use Intercom\Exceptions\IntercomException; @@ -21,16 +21,18 @@ use Psr\Http\Client\ClientExceptionInterface; use Intercom\Conversations\Requests\FindConversationRequest; use Intercom\Conversations\Requests\UpdateConversationRequest; +use Intercom\Conversations\Requests\DeleteConversationRequest; +use Intercom\Types\ConversationDeleted; use Intercom\Types\SearchRequest; use Intercom\Core\Pagination\PaginationHelper; use Intercom\Conversations\Requests\ReplyToConversationRequest; use Intercom\Conversations\Requests\ManageConversationPartsRequest; -use Intercom\Conversations\Requests\AutoAssignConversationRequest; use Intercom\Conversations\Requests\AttachContactToConversationRequest; use Intercom\Conversations\Requests\DetachContactFromConversationRequest; use Intercom\Types\RedactConversationRequest; use Intercom\Conversations\Requests\ConvertConversationToTicketRequest; use Intercom\Tickets\Types\Ticket; +use Intercom\Conversations\Requests\AutoAssignConversationRequest; class ConversationsClient { @@ -41,7 +43,7 @@ class ConversationsClient * maxRetries?: int, * timeout?: float, * headers?: array, - * } $options + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator */ private array $options; @@ -97,9 +99,9 @@ public function list(ListConversationsRequest $request = new ListConversationsRe $request->setStartingAfter($cursor); }, /* @phpstan-ignore-next-line */ - getNextCursor: fn (PaginatedConversationResponse $response) => $response?->getPages()?->getNext()?->getStartingAfter() ?? null, + getNextCursor: fn (ConversationList $response) => $response?->getPages()?->getNext()?->getStartingAfter() ?? null, /* @phpstan-ignore-next-line */ - getItems: fn (PaginatedConversationResponse $response) => $response?->getConversations() ?? [], + getItems: fn (ConversationList $response) => $response?->getConversations() ?? [], ); } @@ -114,6 +116,7 @@ public function list(ListConversationsRequest $request = new ListConversationsRe * * This will return the Message model that has been created. * + * * @param CreateConversationRequest $request * @param ?array{ * baseUrl?: string, @@ -199,6 +202,9 @@ public function find(FindConversationRequest $request, ?array $options = null): if ($request->getDisplayAs() != null) { $query['display_as'] = $request->getDisplayAs(); } + if ($request->getIncludeTranslations() != null) { + $query['include_translations'] = $request->getIncludeTranslations(); + } try { $response = $this->client->sendRequest( new JsonApiRequest( @@ -244,6 +250,13 @@ public function find(FindConversationRequest $request, ?array $options = null): * If you want to reply to a coveration or take an action such as assign, unassign, open, close or snooze, take a look at the reply and manage endpoints. * {% /admonition %} * + * {% admonition type="info" %} + * This endpoint handles both **conversation updates** and **custom object associations**. + * + * See _`update a conversation with an association to a custom object instance`_ in the request/response examples to see the custom object association format. + * {% /admonition %} + * + * * @param UpdateConversationRequest $request * @param ?array{ * baseUrl?: string, @@ -302,6 +315,61 @@ public function update(UpdateConversationRequest $request, ?array $options = nul ); } + /** + * You can delete a single conversation. + * + * @param DeleteConversationRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return ConversationDeleted + * @throws IntercomException + * @throws IntercomApiException + */ + public function deleteConversation(DeleteConversationRequest $request, ?array $options = null): ConversationDeleted + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "conversations/{$request->getConversationId()}", + method: HttpMethod::DELETE, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return ConversationDeleted::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + /** * You can search for multiple conversations by the value of their attributes in order to fetch exactly which ones you want. * @@ -324,7 +392,7 @@ public function update(UpdateConversationRequest $request, ?array $options = nul * * ### Accepted Fields * - * Most keys listed as part of the The conversation model is searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as `created_at` accepts a date, the `value` cannot be a string such as `"foorbar"`). + * Most keys listed in the conversation model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as `created_at` accepts a date, the `value` cannot be a string such as `"foorbar"`). * The `source.body` field is unique as the search will not be performed against the entire value, but instead against every element of the value separately. For example, when searching for a conversation with a `"I need support"` body - the query should contain a `=` operator with the value `"support"` for such conversation to be returned. A query with a `=` operator and a `"need support"` value will not yield a result. * * | Field | Type | @@ -423,9 +491,9 @@ public function search(SearchRequest $request, ?array $options = null): Pager PaginationHelper::setDeep($request, ["pagination", "startingAfter"], $cursor); }, /* @phpstan-ignore-next-line */ - getNextCursor: fn (PaginatedConversationResponse $response) => $response?->getPages()?->getNext()?->getStartingAfter() ?? null, + getNextCursor: fn (ConversationList $response) => $response?->getPages()?->getNext()?->getStartingAfter() ?? null, /* @phpstan-ignore-next-line */ - getItems: fn (PaginatedConversationResponse $response) => $response?->getConversations() ?? [], + getItems: fn (ConversationList $response) => $response?->getConversations() ?? [], ); } @@ -546,15 +614,14 @@ public function manage(ManageConversationPartsRequest $request, ?array $options } /** - * {% 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. + * You can add participants who are contacts to a conversation, on behalf of either another contact or an admin. + * + * {% admonition type="warning" name="Contacts without an email" %} + * If you add a contact via the email parameter and there is no user/lead found on that workspace with he given email, then we will create a new contact with `role` set to `lead`. * {% /admonition %} * - * @param AutoAssignConversationRequest $request + * + * @param AttachContactToConversationRequest $request * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -567,15 +634,16 @@ public function manage(ManageConversationPartsRequest $request, ?array $options * @throws IntercomException * @throws IntercomApiException */ - public function runAssignmentRules(AutoAssignConversationRequest $request, ?array $options = null): Conversation + public function attachContactAsAdmin(AttachContactToConversationRequest $request, ?array $options = null): Conversation { $options = array_merge($this->options, $options ?? []); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "conversations/{$request->getConversationId()}/run_assignment_rules", + path: "conversations/{$request->getConversationId()}/customers", method: HttpMethod::POST, + body: $request, ), $options, ); @@ -613,7 +681,8 @@ public function runAssignmentRules(AutoAssignConversationRequest $request, ?arra * If you add a contact via the email parameter and there is no user/lead found on that workspace with he given email, then we will create a new contact with `role` set to `lead`. * {% /admonition %} * - * @param AttachContactToConversationRequest $request + * + * @param DetachContactFromConversationRequest $request * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -626,15 +695,15 @@ public function runAssignmentRules(AutoAssignConversationRequest $request, ?arra * @throws IntercomException * @throws IntercomApiException */ - public function attachContactAsAdmin(AttachContactToConversationRequest $request, ?array $options = null): Conversation + public function detachContactAsAdmin(DetachContactFromConversationRequest $request, ?array $options = null): Conversation { $options = array_merge($this->options, $options ?? []); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "conversations/{$request->getConversationId()}/customers", - method: HttpMethod::POST, + path: "conversations/{$request->getConversationId()}/customers/{$request->getContactId()}", + method: HttpMethod::DELETE, body: $request, ), $options, @@ -667,13 +736,14 @@ public function attachContactAsAdmin(AttachContactToConversationRequest $request } /** - * You can add participants who are contacts to a conversation, on behalf of either another contact or an admin. + * You can redact a conversation part or the source message of a conversation (as seen in the source object). * - * {% admonition type="warning" name="Contacts without an email" %} - * If you add a contact via the email parameter and there is no user/lead found on that workspace with he given email, then we will create a new contact with `role` set to `lead`. + * {% admonition type="info" name="Redacting parts and messages" %} + * If you are redacting a conversation part, it must have a `body`. If you are redacting a source message, it must have been created by a contact. We will return a `conversation_part_not_redactable` error if these criteria are not met. * {% /admonition %} * - * @param DetachContactFromConversationRequest $request + * + * @param RedactConversationRequest $request * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -686,15 +756,15 @@ public function attachContactAsAdmin(AttachContactToConversationRequest $request * @throws IntercomException * @throws IntercomApiException */ - public function detachContactAsAdmin(DetachContactFromConversationRequest $request, ?array $options = null): Conversation + public function redactConversationPart(RedactConversationRequest $request, ?array $options = null): Conversation { $options = array_merge($this->options, $options ?? []); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "conversations/{$request->getConversationId()}/customers/{$request->getContactId()}", - method: HttpMethod::DELETE, + path: "conversations/redact", + method: HttpMethod::POST, body: $request, ), $options, @@ -727,13 +797,9 @@ public function detachContactAsAdmin(DetachContactFromConversationRequest $reque } /** - * You can redact a conversation part or the source message of a conversation (as seen in the source object). - * - * {% admonition type="info" name="Redacting parts and messages" %} - * If you are redacting a conversation part, it must have a `body`. If you are redacting a source message, it must have been created by a contact. We will return a `conversation_part_not_redactable` error if these criteria are not met. - * {% /admonition %} + * You can convert a conversation to a ticket. * - * @param RedactConversationRequest $request + * @param ConvertConversationToTicketRequest $request * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -742,18 +808,18 @@ public function detachContactAsAdmin(DetachContactFromConversationRequest $reque * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Conversation + * @return ?Ticket * @throws IntercomException * @throws IntercomApiException */ - public function redactConversationPart(RedactConversationRequest $request, ?array $options = null): Conversation + public function convertToTicket(ConvertConversationToTicketRequest $request, ?array $options = null): ?Ticket { $options = array_merge($this->options, $options ?? []); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "conversations/redact", + path: "conversations/{$request->getConversationId()}/convert", method: HttpMethod::POST, body: $request, ), @@ -762,7 +828,10 @@ public function redactConversationPart(RedactConversationRequest $request, ?arra $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); - return Conversation::fromJson($json); + if (empty($json)) { + return null; + } + return Ticket::fromJson($json); } } catch (JsonException $e) { throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); @@ -787,9 +856,15 @@ public function redactConversationPart(RedactConversationRequest $request, ?arra } /** - * You can convert a conversation to a ticket. + * {% admonition type="danger" name="Deprecation of Run Assignment Rules" %} + * Run assignment rules is now deprecated in version 2.12 and future versions and will be permanently removed on December 31, 2026. After this date, any requests made to this endpoint will fail. + * {% /admonition %} + * You can let a conversation be automatically assigned following assignment rules. + * {% admonition type="warning" name="When using workflows" %} + * It is not possible to use this endpoint with Workflows. + * {% /admonition %} * - * @param ConvertConversationToTicketRequest $request + * @param AutoAssignConversationRequest $request * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -798,27 +873,26 @@ public function redactConversationPart(RedactConversationRequest $request, ?arra * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Ticket + * @return Conversation * @throws IntercomException * @throws IntercomApiException */ - public function convertToTicket(ConvertConversationToTicketRequest $request, ?array $options = null): Ticket + public function runAssignmentRules(AutoAssignConversationRequest $request, ?array $options = null): Conversation { $options = array_merge($this->options, $options ?? []); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "conversations/{$request->getConversationId()}/convert", + path: "conversations/{$request->getConversationId()}/run_assignment_rules", method: HttpMethod::POST, - body: $request, ), $options, ); $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); - return Ticket::fromJson($json); + return Conversation::fromJson($json); } } catch (JsonException $e) { throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); @@ -860,11 +934,11 @@ public function convertToTicket(ConvertConversationToTicketRequest $request, ?ar * queryParameters?: array, * bodyProperties?: array, * } $options - * @return PaginatedConversationResponse + * @return ConversationList * @throws IntercomException * @throws IntercomApiException */ - private function _list(ListConversationsRequest $request = new ListConversationsRequest(), ?array $options = null): PaginatedConversationResponse + private function _list(ListConversationsRequest $request = new ListConversationsRequest(), ?array $options = null): ConversationList { $options = array_merge($this->options, $options ?? []); $query = []; @@ -887,7 +961,7 @@ private function _list(ListConversationsRequest $request = new ListConversations $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); - return PaginatedConversationResponse::fromJson($json); + return ConversationList::fromJson($json); } } catch (JsonException $e) { throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); @@ -933,7 +1007,7 @@ private function _list(ListConversationsRequest $request = new ListConversations * * ### Accepted Fields * - * Most keys listed as part of the The conversation model is searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as `created_at` accepts a date, the `value` cannot be a string such as `"foorbar"`). + * Most keys listed in the conversation model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as `created_at` accepts a date, the `value` cannot be a string such as `"foorbar"`). * The `source.body` field is unique as the search will not be performed against the entire value, but instead against every element of the value separately. For example, when searching for a conversation with a `"I need support"` body - the query should contain a `=` operator with the value `"support"` for such conversation to be returned. A query with a `=` operator and a `"need support"` value will not yield a result. * * | Field | Type | @@ -1021,11 +1095,11 @@ private function _list(ListConversationsRequest $request = new ListConversations * queryParameters?: array, * bodyProperties?: array, * } $options - * @return PaginatedConversationResponse + * @return ConversationList * @throws IntercomException * @throws IntercomApiException */ - private function _search(SearchRequest $request, ?array $options = null): PaginatedConversationResponse + private function _search(SearchRequest $request, ?array $options = null): ConversationList { $options = array_merge($this->options, $options ?? []); try { @@ -1041,7 +1115,7 @@ private function _search(SearchRequest $request, ?array $options = null): Pagina $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); - return PaginatedConversationResponse::fromJson($json); + return ConversationList::fromJson($json); } } catch (JsonException $e) { throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); diff --git a/src/Conversations/Requests/ConvertConversationToTicketRequest.php b/src/Conversations/Requests/ConvertConversationToTicketRequest.php index 71ed79e..d206e5c 100644 --- a/src/Conversations/Requests/ConvertConversationToTicketRequest.php +++ b/src/Conversations/Requests/ConvertConversationToTicketRequest.php @@ -9,9 +9,9 @@ class ConvertConversationToTicketRequest extends JsonSerializableType { /** - * @var string $conversationId The id of the conversation to target + * @var int $conversationId The id of the conversation to target */ - private string $conversationId; + private int $conversationId; /** * @var string $ticketTypeId The ID of the type of ticket you want to convert the conversation to @@ -27,7 +27,7 @@ class ConvertConversationToTicketRequest extends JsonSerializableType /** * @param array{ - * conversationId: string, + * conversationId: int, * ticketTypeId: string, * attributes?: ?array, * } $values @@ -41,17 +41,17 @@ public function __construct( } /** - * @return string + * @return int */ - public function getConversationId(): string + public function getConversationId(): int { return $this->conversationId; } /** - * @param string $value + * @param int $value */ - public function setConversationId(string $value): self + public function setConversationId(int $value): self { $this->conversationId = $value; return $this; diff --git a/src/Conversations/Requests/DeleteConversationRequest.php b/src/Conversations/Requests/DeleteConversationRequest.php new file mode 100644 index 0000000..915714d --- /dev/null +++ b/src/Conversations/Requests/DeleteConversationRequest.php @@ -0,0 +1,41 @@ +conversationId = $values['conversationId']; + } + + /** + * @return int + */ + public function getConversationId(): int + { + return $this->conversationId; + } + + /** + * @param int $value + */ + public function setConversationId(int $value): self + { + $this->conversationId = $value; + return $this; + } +} diff --git a/src/Conversations/Requests/FindConversationRequest.php b/src/Conversations/Requests/FindConversationRequest.php index 72b9922..2d46941 100644 --- a/src/Conversations/Requests/FindConversationRequest.php +++ b/src/Conversations/Requests/FindConversationRequest.php @@ -16,10 +16,16 @@ class FindConversationRequest extends JsonSerializableType */ private ?string $displayAs; + /** + * @var ?bool $includeTranslations If set to true, conversation parts will be translated to the detected language of the conversation. + */ + private ?bool $includeTranslations; + /** * @param array{ * conversationId: string, * displayAs?: ?string, + * includeTranslations?: ?bool, * } $values */ public function __construct( @@ -27,6 +33,7 @@ public function __construct( ) { $this->conversationId = $values['conversationId']; $this->displayAs = $values['displayAs'] ?? null; + $this->includeTranslations = $values['includeTranslations'] ?? null; } /** @@ -62,4 +69,21 @@ public function setDisplayAs(?string $value = null): self $this->displayAs = $value; return $this; } + + /** + * @return ?bool + */ + public function getIncludeTranslations(): ?bool + { + return $this->includeTranslations; + } + + /** + * @param ?bool $value + */ + public function setIncludeTranslations(?bool $value = null): self + { + $this->includeTranslations = $value; + return $this; + } } diff --git a/src/Conversations/Requests/UpdateConversationRequest.php b/src/Conversations/Requests/UpdateConversationRequest.php index e4dda34..f099504 100644 --- a/src/Conversations/Requests/UpdateConversationRequest.php +++ b/src/Conversations/Requests/UpdateConversationRequest.php @@ -4,7 +4,10 @@ use Intercom\Core\Json\JsonSerializableType; use Intercom\Core\Json\JsonProperty; +use DateTime; +use Intercom\Types\CustomObjectInstanceList; use Intercom\Core\Types\ArrayType; +use Intercom\Core\Types\Union; class UpdateConversationRequest extends JsonSerializableType { @@ -25,17 +28,41 @@ class UpdateConversationRequest extends JsonSerializableType private ?bool $read; /** - * @var ?array $customAttributes + * @var ?string $title The title given to the conversation */ - #[JsonProperty('custom_attributes'), ArrayType(['string' => 'mixed'])] + #[JsonProperty('title')] + private ?string $title; + + /** + * @var ?array $customAttributes + */ + #[JsonProperty('custom_attributes'), ArrayType(['string' => new Union('string', 'integer', 'datetime', CustomObjectInstanceList::class)])] private ?array $customAttributes; + /** + * @var ?string $companyId The ID of the company that the conversation is associated with. The unique identifier for the company which is given by Intercom. Set to nil to remove company. + */ + #[JsonProperty('company_id')] + private ?string $companyId; + /** * @param array{ * conversationId: string, * displayAs?: ?string, * read?: ?bool, - * customAttributes?: ?array, + * title?: ?string, + * customAttributes?: ?array, + * companyId?: ?string, * } $values */ public function __construct( @@ -44,7 +71,9 @@ public function __construct( $this->conversationId = $values['conversationId']; $this->displayAs = $values['displayAs'] ?? null; $this->read = $values['read'] ?? null; + $this->title = $values['title'] ?? null; $this->customAttributes = $values['customAttributes'] ?? null; + $this->companyId = $values['companyId'] ?? null; } /** @@ -99,7 +128,29 @@ public function setRead(?bool $value = null): self } /** - * @return ?array + * @return ?string + */ + public function getTitle(): ?string + { + return $this->title; + } + + /** + * @param ?string $value + */ + public function setTitle(?string $value = null): self + { + $this->title = $value; + return $this; + } + + /** + * @return ?array */ public function getCustomAttributes(): ?array { @@ -107,11 +158,33 @@ public function getCustomAttributes(): ?array } /** - * @param ?array $value + * @param ?array $value */ public function setCustomAttributes(?array $value = null): self { $this->customAttributes = $value; return $this; } + + /** + * @return ?string + */ + public function getCompanyId(): ?string + { + return $this->companyId; + } + + /** + * @param ?string $value + */ + public function setCompanyId(?string $value = null): self + { + $this->companyId = $value; + return $this; + } } diff --git a/src/Conversations/Types/Conversation.php b/src/Conversations/Types/Conversation.php index 1e693fb..90fa29b 100644 --- a/src/Conversations/Types/Conversation.php +++ b/src/Conversations/Types/Conversation.php @@ -9,7 +9,10 @@ use Intercom\Types\ConversationSource; use Intercom\Types\ConversationContacts; use Intercom\Types\ConversationTeammates; +use DateTime; +use Intercom\Types\CustomObjectInstanceList; use Intercom\Core\Types\ArrayType; +use Intercom\Core\Types\Union; use Intercom\Types\ConversationFirstContactReply; use Intercom\Types\SlaApplied; use Intercom\Types\ConversationStatistics; @@ -23,16 +26,16 @@ class Conversation extends JsonSerializableType { /** - * @var ?'conversation' $type Always conversation. + * @var ?string $type Always conversation. */ #[JsonProperty('type')] private ?string $type; /** - * @var string $id The id representing the conversation. + * @var ?string $id The id representing the conversation. */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** * @var ?string $title The title given to the conversation. @@ -41,16 +44,16 @@ class Conversation extends JsonSerializableType private ?string $title; /** - * @var int $createdAt The time the conversation was created. + * @var ?int $createdAt The time the conversation was created. */ #[JsonProperty('created_at')] - private int $createdAt; + private ?int $createdAt; /** - * @var int $updatedAt The last time the conversation was updated. + * @var ?int $updatedAt The last time the conversation was updated. */ #[JsonProperty('updated_at')] - private int $updatedAt; + private ?int $updatedAt; /** * @var ?int $waitingSince 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. @@ -65,22 +68,22 @@ class Conversation extends JsonSerializableType private ?int $snoozedUntil; /** - * @var bool $open Indicates whether a conversation is open (true) or closed (false). + * @var ?bool $open Indicates whether a conversation is open (true) or closed (false). */ #[JsonProperty('open')] - private bool $open; + private ?bool $open; /** - * @var value-of $state Can be set to "open", "closed" or "snoozed". + * @var ?value-of $state Can be set to "open", "closed" or "snoozed". */ #[JsonProperty('state')] - private string $state; + private ?string $state; /** - * @var bool $read Indicates whether a conversation has been read. + * @var ?bool $read Indicates whether a conversation has been read. */ #[JsonProperty('read')] - private bool $read; + private ?bool $read; /** * @var ?value-of $priority If marked as priority, it will return priority or else not_priority. @@ -100,6 +103,12 @@ class Conversation extends JsonSerializableType #[JsonProperty('team_assignee_id')] private ?string $teamAssigneeId; + /** + * @var ?string $companyId The ID of the company that the conversation is associated with. The unique identifier for the company which is given by Intercom. + */ + #[JsonProperty('company_id')] + private ?string $companyId; + /** * @var ?Tags $tags */ @@ -113,28 +122,33 @@ class Conversation extends JsonSerializableType private ?ConversationRating $conversationRating; /** - * @var ConversationSource $source + * @var ?ConversationSource $source */ #[JsonProperty('source')] - private ConversationSource $source; + private ?ConversationSource $source; /** - * @var ConversationContacts $contacts + * @var ?ConversationContacts $contacts */ #[JsonProperty('contacts')] - private ConversationContacts $contacts; + private ?ConversationContacts $contacts; /** - * @var ConversationTeammates $teammates + * @var ?ConversationTeammates $teammates */ #[JsonProperty('teammates')] - private ConversationTeammates $teammates; + private ?ConversationTeammates $teammates; /** - * @var array $customAttributes + * @var ?array $customAttributes */ - #[JsonProperty('custom_attributes'), ArrayType(['string' => 'mixed'])] - private array $customAttributes; + #[JsonProperty('custom_attributes'), ArrayType(['string' => new Union('string', 'integer', 'datetime', CustomObjectInstanceList::class)])] + private ?array $customAttributes; /** * @var ?ConversationFirstContactReply $firstContactReply @@ -180,25 +194,31 @@ class Conversation extends JsonSerializableType /** * @param array{ - * id: string, - * createdAt: int, - * updatedAt: int, - * open: bool, - * state: value-of, - * read: bool, - * source: ConversationSource, - * contacts: ConversationContacts, - * teammates: ConversationTeammates, - * customAttributes: array, - * type?: ?'conversation', + * type?: ?string, + * id?: ?string, * title?: ?string, + * createdAt?: ?int, + * updatedAt?: ?int, * waitingSince?: ?int, * snoozedUntil?: ?int, + * open?: ?bool, + * state?: ?value-of, + * read?: ?bool, * priority?: ?value-of, * adminAssigneeId?: ?int, * teamAssigneeId?: ?string, + * companyId?: ?string, * tags?: ?Tags, * conversationRating?: ?ConversationRating, + * source?: ?ConversationSource, + * contacts?: ?ConversationContacts, + * teammates?: ?ConversationTeammates, + * customAttributes?: ?array, * firstContactReply?: ?ConversationFirstContactReply, * slaApplied?: ?SlaApplied, * statistics?: ?ConversationStatistics, @@ -209,27 +229,28 @@ class Conversation extends JsonSerializableType * } $values */ public function __construct( - array $values, + array $values = [], ) { $this->type = $values['type'] ?? null; - $this->id = $values['id']; + $this->id = $values['id'] ?? null; $this->title = $values['title'] ?? null; - $this->createdAt = $values['createdAt']; - $this->updatedAt = $values['updatedAt']; + $this->createdAt = $values['createdAt'] ?? null; + $this->updatedAt = $values['updatedAt'] ?? null; $this->waitingSince = $values['waitingSince'] ?? null; $this->snoozedUntil = $values['snoozedUntil'] ?? null; - $this->open = $values['open']; - $this->state = $values['state']; - $this->read = $values['read']; + $this->open = $values['open'] ?? null; + $this->state = $values['state'] ?? null; + $this->read = $values['read'] ?? null; $this->priority = $values['priority'] ?? null; $this->adminAssigneeId = $values['adminAssigneeId'] ?? null; $this->teamAssigneeId = $values['teamAssigneeId'] ?? null; + $this->companyId = $values['companyId'] ?? null; $this->tags = $values['tags'] ?? null; $this->conversationRating = $values['conversationRating'] ?? null; - $this->source = $values['source']; - $this->contacts = $values['contacts']; - $this->teammates = $values['teammates']; - $this->customAttributes = $values['customAttributes']; + $this->source = $values['source'] ?? null; + $this->contacts = $values['contacts'] ?? null; + $this->teammates = $values['teammates'] ?? null; + $this->customAttributes = $values['customAttributes'] ?? null; $this->firstContactReply = $values['firstContactReply'] ?? null; $this->slaApplied = $values['slaApplied'] ?? null; $this->statistics = $values['statistics'] ?? null; @@ -240,7 +261,7 @@ public function __construct( } /** - * @return ?'conversation' + * @return ?string */ public function getType(): ?string { @@ -248,7 +269,7 @@ public function getType(): ?string } /** - * @param ?'conversation' $value + * @param ?string $value */ public function setType(?string $value = null): self { @@ -257,17 +278,17 @@ public function setType(?string $value = null): self } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; @@ -291,34 +312,34 @@ public function setTitle(?string $value = null): self } /** - * @return int + * @return ?int */ - public function getCreatedAt(): int + public function getCreatedAt(): ?int { return $this->createdAt; } /** - * @param int $value + * @param ?int $value */ - public function setCreatedAt(int $value): self + public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; return $this; } /** - * @return int + * @return ?int */ - public function getUpdatedAt(): int + public function getUpdatedAt(): ?int { return $this->updatedAt; } /** - * @param int $value + * @param ?int $value */ - public function setUpdatedAt(int $value): self + public function setUpdatedAt(?int $value = null): self { $this->updatedAt = $value; return $this; @@ -359,51 +380,51 @@ public function setSnoozedUntil(?int $value = null): self } /** - * @return bool + * @return ?bool */ - public function getOpen(): bool + public function getOpen(): ?bool { return $this->open; } /** - * @param bool $value + * @param ?bool $value */ - public function setOpen(bool $value): self + public function setOpen(?bool $value = null): self { $this->open = $value; return $this; } /** - * @return value-of + * @return ?value-of */ - public function getState(): string + public function getState(): ?string { return $this->state; } /** - * @param value-of $value + * @param ?value-of $value */ - public function setState(string $value): self + public function setState(?string $value = null): self { $this->state = $value; return $this; } /** - * @return bool + * @return ?bool */ - public function getRead(): bool + public function getRead(): ?bool { return $this->read; } /** - * @param bool $value + * @param ?bool $value */ - public function setRead(bool $value): self + public function setRead(?bool $value = null): self { $this->read = $value; return $this; @@ -460,6 +481,23 @@ public function setTeamAssigneeId(?string $value = null): self return $this; } + /** + * @return ?string + */ + public function getCompanyId(): ?string + { + return $this->companyId; + } + + /** + * @param ?string $value + */ + public function setCompanyId(?string $value = null): self + { + $this->companyId = $value; + return $this; + } + /** * @return ?Tags */ @@ -495,68 +533,78 @@ public function setConversationRating(?ConversationRating $value = null): self } /** - * @return ConversationSource + * @return ?ConversationSource */ - public function getSource(): ConversationSource + public function getSource(): ?ConversationSource { return $this->source; } /** - * @param ConversationSource $value + * @param ?ConversationSource $value */ - public function setSource(ConversationSource $value): self + public function setSource(?ConversationSource $value = null): self { $this->source = $value; return $this; } /** - * @return ConversationContacts + * @return ?ConversationContacts */ - public function getContacts(): ConversationContacts + public function getContacts(): ?ConversationContacts { return $this->contacts; } /** - * @param ConversationContacts $value + * @param ?ConversationContacts $value */ - public function setContacts(ConversationContacts $value): self + public function setContacts(?ConversationContacts $value = null): self { $this->contacts = $value; return $this; } /** - * @return ConversationTeammates + * @return ?ConversationTeammates */ - public function getTeammates(): ConversationTeammates + public function getTeammates(): ?ConversationTeammates { return $this->teammates; } /** - * @param ConversationTeammates $value + * @param ?ConversationTeammates $value */ - public function setTeammates(ConversationTeammates $value): self + public function setTeammates(?ConversationTeammates $value = null): self { $this->teammates = $value; return $this; } /** - * @return array + * @return ?array */ - public function getCustomAttributes(): array + public function getCustomAttributes(): ?array { return $this->customAttributes; } /** - * @param array $value + * @param ?array $value */ - public function setCustomAttributes(array $value): self + public function setCustomAttributes(?array $value = null): self { $this->customAttributes = $value; return $this; diff --git a/src/Core/Client/RawClient.php b/src/Core/Client/RawClient.php index 36bb80f..beb9792 100644 --- a/src/Core/Client/RawClient.php +++ b/src/Core/Client/RawClient.php @@ -253,6 +253,9 @@ private function encodeQueryValue(mixed $value): string if (is_string($value)) { return urlencode($value); } + if (is_bool($value)) { + return $value ? 'true' : 'false'; + } if (is_scalar($value)) { return urlencode((string)$value); } diff --git a/src/Core/Client/RetryMiddleware.php b/src/Core/Client/RetryMiddleware.php index e8219f5..eb2682c 100644 --- a/src/Core/Client/RetryMiddleware.php +++ b/src/Core/Client/RetryMiddleware.php @@ -16,6 +16,8 @@ class RetryMiddleware 'baseDelay' => 1000 ]; private const RETRY_STATUS_CODES = [408, 429]; + private const MAX_RETRY_DELAY = 60000; // 60 seconds in milliseconds + private const JITTER_FACTOR = 0.2; // 20% random jitter /** * @var callable(RequestInterface, array): PromiseInterface @@ -133,7 +135,7 @@ private function onFulfilled(RequestInterface $request, array $options): callabl return $value; } - return $this->doRetry($request, $options); + return $this->doRetry($request, $options, $value); }; } @@ -171,14 +173,87 @@ private function onRejected(RequestInterface $req, array $options): callable * delay: int, * retryAttempt: int, * } $options + * @param ?ResponseInterface $response * @return PromiseInterface */ - private function doRetry(RequestInterface $request, array $options): PromiseInterface + private function doRetry(RequestInterface $request, array $options, ?ResponseInterface $response = null): PromiseInterface { - $options['delay'] = $this->exponentialDelay(++$options['retryAttempt']); + $options['delay'] = $this->getRetryDelay(++$options['retryAttempt'], $response); return $this($request, $options); } + /** + * Calculate the retry delay based on response headers or exponential backoff. + * + * @param int $retryAttempt + * @param ?ResponseInterface $response + * @return int milliseconds + */ + private function getRetryDelay(int $retryAttempt, ?ResponseInterface $response): int + { + if ($response !== null) { + // Check Retry-After header + $retryAfter = $response->getHeaderLine('Retry-After'); + if ($retryAfter !== '') { + // Try parsing as integer (seconds) + if (is_numeric($retryAfter)) { + $retryAfterSeconds = (int)$retryAfter; + if ($retryAfterSeconds > 0) { + return min($retryAfterSeconds * 1000, self::MAX_RETRY_DELAY); + } + } + + // Try parsing as HTTP date + $retryAfterDate = strtotime($retryAfter); + if ($retryAfterDate !== false) { + $delay = ($retryAfterDate - time()) * 1000; + if ($delay > 0) { + return min(max($delay, 0), self::MAX_RETRY_DELAY); + } + } + } + + // Check X-RateLimit-Reset header + $rateLimitReset = $response->getHeaderLine('X-RateLimit-Reset'); + if ($rateLimitReset !== '' && is_numeric($rateLimitReset)) { + $resetTime = (int)$rateLimitReset; + $delay = ($resetTime * 1000) - (int)(microtime(true) * 1000); + if ($delay > 0) { + return $this->addPositiveJitter(min($delay, self::MAX_RETRY_DELAY)); + } + } + } + + // Fall back to exponential backoff with symmetric jitter + return $this->addSymmetricJitter( + min($this->exponentialDelay($retryAttempt), self::MAX_RETRY_DELAY) + ); + } + + /** + * Add positive jitter (0% to +20%) to the delay. + * + * @param int $delay + * @return int + */ + private function addPositiveJitter(int $delay): int + { + $jitterMultiplier = 1 + (mt_rand() / mt_getrandmax()) * self::JITTER_FACTOR; + return (int)($delay * $jitterMultiplier); + } + + /** + * Add symmetric jitter (-10% to +10%) to the delay. + * + * @param int $delay + * @return int + */ + private function addSymmetricJitter(int $delay): int + { + $jitterMultiplier = 1 + ((mt_rand() / mt_getrandmax()) - 0.5) * self::JITTER_FACTOR; + return (int)($delay * $jitterMultiplier); + } + /** * Default exponential backoff delay function. * diff --git a/src/Core/Json/JsonDeserializer.php b/src/Core/Json/JsonDeserializer.php index 825d08e..518dacc 100644 --- a/src/Core/Json/JsonDeserializer.php +++ b/src/Core/Json/JsonDeserializer.php @@ -95,7 +95,9 @@ public static function deserializeUnion(mixed $data, Union $type): mixed foreach ($type->types as $unionType) { try { return self::deserializeValue($data, $unionType); - } catch (Exception) { + } catch (\Throwable) { + // Catching Throwable instead of Exception to handle TypeError + // that occurs when assigning null to non-nullable typed properties continue; } } diff --git a/src/Core/Json/JsonSerializer.php b/src/Core/Json/JsonSerializer.php index d127923..b7500d7 100644 --- a/src/Core/Json/JsonSerializer.php +++ b/src/Core/Json/JsonSerializer.php @@ -24,13 +24,18 @@ public static function serializeDate(DateTime $date): string /** * Serializes a DateTime object into a string using the date-time format. + * Normalizes UTC times to use 'Z' suffix instead of '+00:00'. * * @param DateTime $date The DateTime object to serialize. * @return string The serialized date-time string. */ public static function serializeDateTime(DateTime $date): string { - return $date->format(Constant::DateTimeFormat); + $formatted = $date->format(Constant::DateTimeFormat); + if (str_ends_with($formatted, '+00:00')) { + return substr($formatted, 0, -6) . 'Z'; + } + return $formatted; } /** diff --git a/src/CustomChannelEvents/CustomChannelEventsClient.php b/src/CustomChannelEvents/CustomChannelEventsClient.php new file mode 100644 index 0000000..61b3dc1 --- /dev/null +++ b/src/CustomChannelEvents/CustomChannelEventsClient.php @@ -0,0 +1,284 @@ +, + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator + */ + private array $options; + + /** + * @var RawClient $client + */ + private RawClient $client; + + /** + * @param RawClient $client + * @param ?array{ + * baseUrl?: string, + * client?: ClientInterface, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * } $options + */ + public function __construct( + RawClient $client, + ?array $options = null, + ) { + $this->client = $client; + $this->options = $options ?? []; + } + + /** + * Notifies Intercom that a new conversation was created in your custom channel/platform. This triggers conversation creation and workflow automations within Intercom for your custom channel integration. + * > **Note:** This endpoint is currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. + * + * @param CustomChannelBaseEvent $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return CustomChannelNotificationResponse + * @throws IntercomException + * @throws IntercomApiException + */ + public function notifyNewConversation(CustomChannelBaseEvent $request, ?array $options = null): CustomChannelNotificationResponse + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "custom_channel_events/notify_new_conversation", + method: HttpMethod::POST, + body: $request, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return CustomChannelNotificationResponse::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * Notifies Intercom that a new message was sent in a conversation on your custom channel/platform. This allows Intercom to process the message and trigger any relevant workflow automations. + * > **Note:** This endpoint is currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. + * + * @param NotifyNewMessageRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return CustomChannelNotificationResponse + * @throws IntercomException + * @throws IntercomApiException + */ + public function notifyNewMessage(NotifyNewMessageRequest $request, ?array $options = null): CustomChannelNotificationResponse + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "custom_channel_events/notify_new_message", + method: HttpMethod::POST, + body: $request, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return CustomChannelNotificationResponse::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * Notifies Intercom that a user selected a quick reply option in your custom channel/platform. This allows Intercom to process the response and trigger any relevant workflow automations. + * > **Note:** This endpoint is currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. + * + * @param NotifyQuickReplySelectedRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return CustomChannelNotificationResponse + * @throws IntercomException + * @throws IntercomApiException + */ + public function notifyQuickReplySelected(NotifyQuickReplySelectedRequest $request, ?array $options = null): CustomChannelNotificationResponse + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "custom_channel_events/notify_quick_reply_selected", + method: HttpMethod::POST, + body: $request, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return CustomChannelNotificationResponse::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * Notifies Intercom that a user provided a response to an attribute collector in your custom channel/platform. This allows Intercom to process the attribute and trigger any relevant workflow automations. + * > **Note:** This endpoint is currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. + * + * @param NotifyAttributeCollectedRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return CustomChannelNotificationResponse + * @throws IntercomException + * @throws IntercomApiException + */ + public function notifyAttributeCollected(NotifyAttributeCollectedRequest $request, ?array $options = null): CustomChannelNotificationResponse + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "custom_channel_events/notify_attribute_collected", + method: HttpMethod::POST, + body: $request, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return CustomChannelNotificationResponse::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } +} diff --git a/src/CustomChannelEvents/Requests/NotifyAttributeCollectedRequest.php b/src/CustomChannelEvents/Requests/NotifyAttributeCollectedRequest.php new file mode 100644 index 0000000..e553b23 --- /dev/null +++ b/src/CustomChannelEvents/Requests/NotifyAttributeCollectedRequest.php @@ -0,0 +1,54 @@ +attribute = $values['attribute']; + $this->eventId = $values['eventId']; + $this->externalConversationId = $values['externalConversationId']; + $this->contact = $values['contact']; + } + + /** + * @return CustomChannelAttribute + */ + public function getAttribute(): CustomChannelAttribute + { + return $this->attribute; + } + + /** + * @param CustomChannelAttribute $value + */ + public function setAttribute(CustomChannelAttribute $value): self + { + $this->attribute = $value; + return $this; + } +} diff --git a/src/CustomChannelEvents/Requests/NotifyNewMessageRequest.php b/src/CustomChannelEvents/Requests/NotifyNewMessageRequest.php new file mode 100644 index 0000000..c505f7f --- /dev/null +++ b/src/CustomChannelEvents/Requests/NotifyNewMessageRequest.php @@ -0,0 +1,53 @@ +body = $values['body']; + $this->eventId = $values['eventId']; + $this->externalConversationId = $values['externalConversationId']; + $this->contact = $values['contact']; + } + + /** + * @return string + */ + public function getBody(): string + { + return $this->body; + } + + /** + * @param string $value + */ + public function setBody(string $value): self + { + $this->body = $value; + return $this; + } +} diff --git a/src/CustomChannelEvents/Requests/NotifyQuickReplySelectedRequest.php b/src/CustomChannelEvents/Requests/NotifyQuickReplySelectedRequest.php new file mode 100644 index 0000000..8c8ab64 --- /dev/null +++ b/src/CustomChannelEvents/Requests/NotifyQuickReplySelectedRequest.php @@ -0,0 +1,53 @@ +quickReplyOptionId = $values['quickReplyOptionId']; + $this->eventId = $values['eventId']; + $this->externalConversationId = $values['externalConversationId']; + $this->contact = $values['contact']; + } + + /** + * @return string + */ + public function getQuickReplyOptionId(): string + { + return $this->quickReplyOptionId; + } + + /** + * @param string $value + */ + public function setQuickReplyOptionId(string $value): self + { + $this->quickReplyOptionId = $value; + return $this; + } +} diff --git a/src/CustomObjectInstances/CustomObjectInstancesClient.php b/src/CustomObjectInstances/CustomObjectInstancesClient.php new file mode 100644 index 0000000..35109a4 --- /dev/null +++ b/src/CustomObjectInstances/CustomObjectInstancesClient.php @@ -0,0 +1,349 @@ +, + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator + */ + private array $options; + + /** + * @var RawClient $client + */ + private RawClient $client; + + /** + * @param RawClient $client + * @param ?array{ + * baseUrl?: string, + * client?: ClientInterface, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * } $options + */ + public function __construct( + RawClient $client, + ?array $options = null, + ) { + $this->client = $client; + $this->options = $options ?? []; + } + + /** + * Fetch a Custom Object Instance by external_id. + * + * @param GetCustomObjectInstancesByExternalIdRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return ?CustomObjectInstance + * @throws IntercomException + * @throws IntercomApiException + */ + public function getCustomObjectInstancesByExternalId(GetCustomObjectInstancesByExternalIdRequest $request, ?array $options = null): ?CustomObjectInstance + { + $options = array_merge($this->options, $options ?? []); + $query = []; + $query['external_id'] = $request->getExternalId(); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "custom_object_instances/{$request->getCustomObjectTypeIdentifier()}", + method: HttpMethod::GET, + query: $query, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } + return CustomObjectInstance::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * Create or update a custom object instance + * + * @param CreateOrUpdateCustomObjectInstanceRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return ?CustomObjectInstance + * @throws IntercomException + * @throws IntercomApiException + */ + public function createCustomObjectInstances(CreateOrUpdateCustomObjectInstanceRequest $request, ?array $options = null): ?CustomObjectInstance + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "custom_object_instances/{$request->getCustomObjectTypeIdentifier()}", + method: HttpMethod::POST, + body: $request, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } + return CustomObjectInstance::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * Delete a single Custom Object instance by external_id. + * + * @param DeleteCustomObjectInstancesByIdRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return CustomObjectInstanceDeleted + * @throws IntercomException + * @throws IntercomApiException + */ + public function deleteCustomObjectInstancesById(DeleteCustomObjectInstancesByIdRequest $request, ?array $options = null): CustomObjectInstanceDeleted + { + $options = array_merge($this->options, $options ?? []); + $query = []; + $query['external_id'] = $request->getExternalId(); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "custom_object_instances/{$request->getCustomObjectTypeIdentifier()}", + method: HttpMethod::DELETE, + query: $query, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return CustomObjectInstanceDeleted::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * Fetch a Custom Object Instance by id. + * + * @param GetCustomObjectInstancesByIdRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return ?CustomObjectInstance + * @throws IntercomException + * @throws IntercomApiException + */ + public function getCustomObjectInstancesById(GetCustomObjectInstancesByIdRequest $request, ?array $options = null): ?CustomObjectInstance + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "custom_object_instances/{$request->getCustomObjectTypeIdentifier()}/{$request->getCustomObjectInstanceId()}", + method: HttpMethod::GET, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } + return CustomObjectInstance::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * Delete a single Custom Object instance using the Intercom defined id. + * + * @param DeleteCustomObjectInstancesByExternalIdRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return CustomObjectInstanceDeleted + * @throws IntercomException + * @throws IntercomApiException + */ + public function deleteCustomObjectInstancesByExternalId(DeleteCustomObjectInstancesByExternalIdRequest $request, ?array $options = null): CustomObjectInstanceDeleted + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "custom_object_instances/{$request->getCustomObjectTypeIdentifier()}/{$request->getCustomObjectInstanceId()}", + method: HttpMethod::DELETE, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return CustomObjectInstanceDeleted::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } +} diff --git a/src/CustomObjectInstances/Requests/CreateOrUpdateCustomObjectInstanceRequest.php b/src/CustomObjectInstances/Requests/CreateOrUpdateCustomObjectInstanceRequest.php new file mode 100644 index 0000000..87d7f75 --- /dev/null +++ b/src/CustomObjectInstances/Requests/CreateOrUpdateCustomObjectInstanceRequest.php @@ -0,0 +1,144 @@ + $customAttributes The custom attributes which are set for the Custom Object instance. + */ + #[JsonProperty('custom_attributes'), ArrayType(['string' => new Union('string', 'null')])] + private ?array $customAttributes; + + /** + * @param array{ + * customObjectTypeIdentifier: string, + * externalId?: ?string, + * externalCreatedAt?: ?int, + * externalUpdatedAt?: ?int, + * customAttributes?: ?array, + * } $values + */ + public function __construct( + array $values, + ) { + $this->customObjectTypeIdentifier = $values['customObjectTypeIdentifier']; + $this->externalId = $values['externalId'] ?? null; + $this->externalCreatedAt = $values['externalCreatedAt'] ?? null; + $this->externalUpdatedAt = $values['externalUpdatedAt'] ?? null; + $this->customAttributes = $values['customAttributes'] ?? null; + } + + /** + * @return string + */ + public function getCustomObjectTypeIdentifier(): string + { + return $this->customObjectTypeIdentifier; + } + + /** + * @param string $value + */ + public function setCustomObjectTypeIdentifier(string $value): self + { + $this->customObjectTypeIdentifier = $value; + return $this; + } + + /** + * @return ?string + */ + public function getExternalId(): ?string + { + return $this->externalId; + } + + /** + * @param ?string $value + */ + public function setExternalId(?string $value = null): self + { + $this->externalId = $value; + return $this; + } + + /** + * @return ?int + */ + public function getExternalCreatedAt(): ?int + { + return $this->externalCreatedAt; + } + + /** + * @param ?int $value + */ + public function setExternalCreatedAt(?int $value = null): self + { + $this->externalCreatedAt = $value; + return $this; + } + + /** + * @return ?int + */ + public function getExternalUpdatedAt(): ?int + { + return $this->externalUpdatedAt; + } + + /** + * @param ?int $value + */ + public function setExternalUpdatedAt(?int $value = null): self + { + $this->externalUpdatedAt = $value; + return $this; + } + + /** + * @return ?array + */ + public function getCustomAttributes(): ?array + { + return $this->customAttributes; + } + + /** + * @param ?array $value + */ + public function setCustomAttributes(?array $value = null): self + { + $this->customAttributes = $value; + return $this; + } +} diff --git a/src/CustomObjectInstances/Requests/DeleteCustomObjectInstancesByExternalIdRequest.php b/src/CustomObjectInstances/Requests/DeleteCustomObjectInstancesByExternalIdRequest.php new file mode 100644 index 0000000..23b3ac8 --- /dev/null +++ b/src/CustomObjectInstances/Requests/DeleteCustomObjectInstancesByExternalIdRequest.php @@ -0,0 +1,65 @@ +customObjectTypeIdentifier = $values['customObjectTypeIdentifier']; + $this->customObjectInstanceId = $values['customObjectInstanceId']; + } + + /** + * @return string + */ + public function getCustomObjectTypeIdentifier(): string + { + return $this->customObjectTypeIdentifier; + } + + /** + * @param string $value + */ + public function setCustomObjectTypeIdentifier(string $value): self + { + $this->customObjectTypeIdentifier = $value; + return $this; + } + + /** + * @return string + */ + public function getCustomObjectInstanceId(): string + { + return $this->customObjectInstanceId; + } + + /** + * @param string $value + */ + public function setCustomObjectInstanceId(string $value): self + { + $this->customObjectInstanceId = $value; + return $this; + } +} diff --git a/src/CustomObjectInstances/Requests/DeleteCustomObjectInstancesByIdRequest.php b/src/CustomObjectInstances/Requests/DeleteCustomObjectInstancesByIdRequest.php new file mode 100644 index 0000000..ce7cd94 --- /dev/null +++ b/src/CustomObjectInstances/Requests/DeleteCustomObjectInstancesByIdRequest.php @@ -0,0 +1,65 @@ +customObjectTypeIdentifier = $values['customObjectTypeIdentifier']; + $this->externalId = $values['externalId']; + } + + /** + * @return string + */ + public function getCustomObjectTypeIdentifier(): string + { + return $this->customObjectTypeIdentifier; + } + + /** + * @param string $value + */ + public function setCustomObjectTypeIdentifier(string $value): self + { + $this->customObjectTypeIdentifier = $value; + return $this; + } + + /** + * @return string + */ + public function getExternalId(): string + { + return $this->externalId; + } + + /** + * @param string $value + */ + public function setExternalId(string $value): self + { + $this->externalId = $value; + return $this; + } +} diff --git a/src/CustomObjectInstances/Requests/GetCustomObjectInstancesByExternalIdRequest.php b/src/CustomObjectInstances/Requests/GetCustomObjectInstancesByExternalIdRequest.php new file mode 100644 index 0000000..dd31e84 --- /dev/null +++ b/src/CustomObjectInstances/Requests/GetCustomObjectInstancesByExternalIdRequest.php @@ -0,0 +1,65 @@ +customObjectTypeIdentifier = $values['customObjectTypeIdentifier']; + $this->externalId = $values['externalId']; + } + + /** + * @return string + */ + public function getCustomObjectTypeIdentifier(): string + { + return $this->customObjectTypeIdentifier; + } + + /** + * @param string $value + */ + public function setCustomObjectTypeIdentifier(string $value): self + { + $this->customObjectTypeIdentifier = $value; + return $this; + } + + /** + * @return string + */ + public function getExternalId(): string + { + return $this->externalId; + } + + /** + * @param string $value + */ + public function setExternalId(string $value): self + { + $this->externalId = $value; + return $this; + } +} diff --git a/src/CustomObjectInstances/Requests/GetCustomObjectInstancesByIdRequest.php b/src/CustomObjectInstances/Requests/GetCustomObjectInstancesByIdRequest.php new file mode 100644 index 0000000..71cf8a5 --- /dev/null +++ b/src/CustomObjectInstances/Requests/GetCustomObjectInstancesByIdRequest.php @@ -0,0 +1,65 @@ +customObjectTypeIdentifier = $values['customObjectTypeIdentifier']; + $this->customObjectInstanceId = $values['customObjectInstanceId']; + } + + /** + * @return string + */ + public function getCustomObjectTypeIdentifier(): string + { + return $this->customObjectTypeIdentifier; + } + + /** + * @param string $value + */ + public function setCustomObjectTypeIdentifier(string $value): self + { + $this->customObjectTypeIdentifier = $value; + return $this; + } + + /** + * @return string + */ + public function getCustomObjectInstanceId(): string + { + return $this->customObjectInstanceId; + } + + /** + * @param string $value + */ + public function setCustomObjectInstanceId(string $value): self + { + $this->customObjectInstanceId = $value; + return $this; + } +} diff --git a/src/CustomObjectInstances/Types/CustomObjectInstance.php b/src/CustomObjectInstances/Types/CustomObjectInstance.php new file mode 100644 index 0000000..85cab79 --- /dev/null +++ b/src/CustomObjectInstances/Types/CustomObjectInstance.php @@ -0,0 +1,230 @@ + $customAttributes The custom attributes you have set on the custom object instance. + */ + #[JsonProperty('custom_attributes'), ArrayType(['string' => 'string'])] + private ?array $customAttributes; + + /** + * @param array{ + * id?: ?string, + * externalId?: ?string, + * externalCreatedAt?: ?int, + * externalUpdatedAt?: ?int, + * createdAt?: ?int, + * updatedAt?: ?int, + * type?: ?string, + * customAttributes?: ?array, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->id = $values['id'] ?? null; + $this->externalId = $values['externalId'] ?? null; + $this->externalCreatedAt = $values['externalCreatedAt'] ?? null; + $this->externalUpdatedAt = $values['externalUpdatedAt'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; + $this->updatedAt = $values['updatedAt'] ?? null; + $this->type = $values['type'] ?? null; + $this->customAttributes = $values['customAttributes'] ?? null; + } + + /** + * @return ?string + */ + public function getId(): ?string + { + return $this->id; + } + + /** + * @param ?string $value + */ + public function setId(?string $value = null): self + { + $this->id = $value; + return $this; + } + + /** + * @return ?string + */ + public function getExternalId(): ?string + { + return $this->externalId; + } + + /** + * @param ?string $value + */ + public function setExternalId(?string $value = null): self + { + $this->externalId = $value; + return $this; + } + + /** + * @return ?int + */ + public function getExternalCreatedAt(): ?int + { + return $this->externalCreatedAt; + } + + /** + * @param ?int $value + */ + public function setExternalCreatedAt(?int $value = null): self + { + $this->externalCreatedAt = $value; + return $this; + } + + /** + * @return ?int + */ + public function getExternalUpdatedAt(): ?int + { + return $this->externalUpdatedAt; + } + + /** + * @param ?int $value + */ + public function setExternalUpdatedAt(?int $value = null): self + { + $this->externalUpdatedAt = $value; + return $this; + } + + /** + * @return ?int + */ + public function getCreatedAt(): ?int + { + return $this->createdAt; + } + + /** + * @param ?int $value + */ + public function setCreatedAt(?int $value = null): self + { + $this->createdAt = $value; + return $this; + } + + /** + * @return ?int + */ + public function getUpdatedAt(): ?int + { + return $this->updatedAt; + } + + /** + * @param ?int $value + */ + public function setUpdatedAt(?int $value = null): self + { + $this->updatedAt = $value; + return $this; + } + + /** + * @return ?string + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?string $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?array + */ + public function getCustomAttributes(): ?array + { + return $this->customAttributes; + } + + /** + * @param ?array $value + */ + public function setCustomAttributes(?array $value = null): self + { + $this->customAttributes = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/DataAttributes/DataAttributesClient.php b/src/DataAttributes/DataAttributesClient.php index 067b71a..a08503d 100644 --- a/src/DataAttributes/DataAttributesClient.php +++ b/src/DataAttributes/DataAttributesClient.php @@ -14,8 +14,11 @@ use JsonException; use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; -use Intercom\DataAttributes\Requests\CreateDataAttributeRequest; +use Intercom\Types\CreateDataAttributeRequestOptions; +use Intercom\Types\CreateDataAttributeRequestOne; use Intercom\DataAttributes\Types\DataAttribute; +use Intercom\Core\Json\JsonSerializer; +use Intercom\Core\Types\Union; use Intercom\DataAttributes\Requests\UpdateDataAttributeRequest; class DataAttributesClient @@ -27,7 +30,7 @@ class DataAttributesClient * maxRetries?: int, * timeout?: float, * headers?: array, - * } $options + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator */ private array $options; @@ -120,7 +123,10 @@ public function list(ListDataAttributesRequest $request = new ListDataAttributes /** * You can create a data attributes for a `contact` or a `company`. * - * @param CreateDataAttributeRequest $request + * @param ( + * CreateDataAttributeRequestOptions + * |CreateDataAttributeRequestOne + * ) $request * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -133,7 +139,7 @@ public function list(ListDataAttributesRequest $request = new ListDataAttributes * @throws IntercomException * @throws IntercomApiException */ - public function create(CreateDataAttributeRequest $request, ?array $options = null): DataAttribute + public function create(CreateDataAttributeRequestOptions|CreateDataAttributeRequestOne $request, ?array $options = null): DataAttribute { $options = array_merge($this->options, $options ?? []); try { @@ -142,7 +148,7 @@ public function create(CreateDataAttributeRequest $request, ?array $options = nu baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, path: "data_attributes", method: HttpMethod::POST, - body: $request, + body: JsonSerializer::serializeUnion($request, new Union(CreateDataAttributeRequestOptions::class, CreateDataAttributeRequestOne::class)), ), $options, ); @@ -203,7 +209,7 @@ public function update(UpdateDataAttributeRequest $request, ?array $options = nu baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, path: "data_attributes/{$request->getDataAttributeId()}", method: HttpMethod::PUT, - body: $request, + body: $request->getBody(), ), $options, ); diff --git a/src/DataAttributes/Requests/CreateDataAttributeRequest.php b/src/DataAttributes/Requests/CreateDataAttributeRequest.php deleted file mode 100644 index cc9a533..0000000 --- a/src/DataAttributes/Requests/CreateDataAttributeRequest.php +++ /dev/null @@ -1,171 +0,0 @@ - $model The model that the data attribute belongs to. - */ - #[JsonProperty('model')] - private string $model; - - /** - * @var value-of $dataType The type of data stored for this attribute. - */ - #[JsonProperty('data_type')] - private string $dataType; - - /** - * @var ?string $description The readable description you see in the UI for the attribute. - */ - #[JsonProperty('description')] - private ?string $description; - - /** - * @var ?array $options 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'), ArrayType(['string'])] - private ?array $options; - - /** - * @var ?bool $messengerWritable Can this attribute be updated by the Messenger - */ - #[JsonProperty('messenger_writable')] - private ?bool $messengerWritable; - - /** - * @param array{ - * name: string, - * model: value-of, - * dataType: value-of, - * description?: ?string, - * options?: ?array, - * messengerWritable?: ?bool, - * } $values - */ - public function __construct( - array $values, - ) { - $this->name = $values['name']; - $this->model = $values['model']; - $this->dataType = $values['dataType']; - $this->description = $values['description'] ?? null; - $this->options = $values['options'] ?? null; - $this->messengerWritable = $values['messengerWritable'] ?? null; - } - - /** - * @return string - */ - public function getName(): string - { - return $this->name; - } - - /** - * @param string $value - */ - public function setName(string $value): self - { - $this->name = $value; - return $this; - } - - /** - * @return value-of - */ - public function getModel(): string - { - return $this->model; - } - - /** - * @param value-of $value - */ - public function setModel(string $value): self - { - $this->model = $value; - return $this; - } - - /** - * @return value-of - */ - public function getDataType(): string - { - return $this->dataType; - } - - /** - * @param value-of $value - */ - public function setDataType(string $value): self - { - $this->dataType = $value; - return $this; - } - - /** - * @return ?string - */ - public function getDescription(): ?string - { - return $this->description; - } - - /** - * @param ?string $value - */ - public function setDescription(?string $value = null): self - { - $this->description = $value; - return $this; - } - - /** - * @return ?array - */ - public function getOptions(): ?array - { - return $this->options; - } - - /** - * @param ?array $value - */ - public function setOptions(?array $value = null): self - { - $this->options = $value; - return $this; - } - - /** - * @return ?bool - */ - public function getMessengerWritable(): ?bool - { - return $this->messengerWritable; - } - - /** - * @param ?bool $value - */ - public function setMessengerWritable(?bool $value = null): self - { - $this->messengerWritable = $value; - return $this; - } -} diff --git a/src/DataAttributes/Requests/UpdateDataAttributeRequest.php b/src/DataAttributes/Requests/UpdateDataAttributeRequest.php index 89d7986..b33619e 100644 --- a/src/DataAttributes/Requests/UpdateDataAttributeRequest.php +++ b/src/DataAttributes/Requests/UpdateDataAttributeRequest.php @@ -3,142 +3,76 @@ namespace Intercom\DataAttributes\Requests; use Intercom\Core\Json\JsonSerializableType; -use Intercom\Core\Json\JsonProperty; -use Intercom\DataAttributes\Types\UpdateDataAttributeRequestOptionsItem; -use Intercom\Core\Types\ArrayType; +use Intercom\Types\UpdateDataAttributeRequestOptions; class UpdateDataAttributeRequest extends JsonSerializableType { /** - * @var string $dataAttributeId The data attribute id + * @var int $dataAttributeId The data attribute id */ - private string $dataAttributeId; + private int $dataAttributeId; /** - * @var ?bool $archived Whether the attribute is to be archived or not. + * @var ( + * UpdateDataAttributeRequestOptions + * |mixed + * ) $body */ - #[JsonProperty('archived')] - private ?bool $archived; - - /** - * @var ?string $description The readable description you see in the UI for the attribute. - */ - #[JsonProperty('description')] - private ?string $description; - - /** - * @var ?array $options 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'), ArrayType([UpdateDataAttributeRequestOptionsItem::class])] - private ?array $options; - - /** - * @var ?bool $messengerWritable Can this attribute be updated by the Messenger - */ - #[JsonProperty('messenger_writable')] - private ?bool $messengerWritable; + private mixed $body; /** * @param array{ - * dataAttributeId: string, - * archived?: ?bool, - * description?: ?string, - * options?: ?array, - * messengerWritable?: ?bool, + * dataAttributeId: int, + * body: ( + * UpdateDataAttributeRequestOptions + * |mixed + * ), * } $values */ public function __construct( array $values, ) { $this->dataAttributeId = $values['dataAttributeId']; - $this->archived = $values['archived'] ?? null; - $this->description = $values['description'] ?? null; - $this->options = $values['options'] ?? null; - $this->messengerWritable = $values['messengerWritable'] ?? null; + $this->body = $values['body']; } /** - * @return string + * @return int */ - public function getDataAttributeId(): string + public function getDataAttributeId(): int { return $this->dataAttributeId; } /** - * @param string $value + * @param int $value */ - public function setDataAttributeId(string $value): self + public function setDataAttributeId(int $value): self { $this->dataAttributeId = $value; return $this; } /** - * @return ?bool - */ - public function getArchived(): ?bool - { - return $this->archived; - } - - /** - * @param ?bool $value - */ - public function setArchived(?bool $value = null): self - { - $this->archived = $value; - return $this; - } - - /** - * @return ?string - */ - public function getDescription(): ?string - { - return $this->description; - } - - /** - * @param ?string $value - */ - public function setDescription(?string $value = null): self - { - $this->description = $value; - return $this; - } - - /** - * @return ?array - */ - public function getOptions(): ?array - { - return $this->options; - } - - /** - * @param ?array $value - */ - public function setOptions(?array $value = null): self - { - $this->options = $value; - return $this; - } - - /** - * @return ?bool + * @return ( + * UpdateDataAttributeRequestOptions + * |mixed + * ) */ - public function getMessengerWritable(): ?bool + public function getBody(): mixed { - return $this->messengerWritable; + return $this->body; } /** - * @param ?bool $value + * @param ( + * UpdateDataAttributeRequestOptions + * |mixed + * ) $value */ - public function setMessengerWritable(?bool $value = null): self + public function setBody(mixed $value): self { - $this->messengerWritable = $value; + $this->body = $value; return $this; } } diff --git a/src/DataAttributes/Types/CreateDataAttributeRequestModel.php b/src/DataAttributes/Types/CreateDataAttributeRequestModel.php deleted file mode 100644 index 3049f73..0000000 --- a/src/DataAttributes/Types/CreateDataAttributeRequestModel.php +++ /dev/null @@ -1,9 +0,0 @@ -, - * } $options + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator */ private array $options; @@ -54,6 +57,124 @@ public function __construct( $this->options = $options ?? []; } + /** + * @param ExportReportingDataRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return DataExportExportReportingDataResponse + * @throws IntercomException + * @throws IntercomApiException + */ + public function exportReportingData(ExportReportingDataRequest $request, ?array $options = null): DataExportExportReportingDataResponse + { + $options = array_merge($this->options, $options ?? []); + $query = []; + $query['app_id'] = $request->getAppId(); + $query['client_id'] = $request->getClientId(); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "export/reporting_data/{$request->getJobIdentifier()}", + method: HttpMethod::GET, + query: $query, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return DataExportExportReportingDataResponse::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * Download the data from a completed reporting data export job. + * + * > Octet header required + * > + * > You will have to specify the header Accept: `application/octet-stream` when hitting this endpoint. + * + * @param DownloadReportingDataExportRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @throws IntercomException + * @throws IntercomApiException + */ + public function downloadReportingDataExport(DownloadReportingDataExportRequest $request, ?array $options = null): void + { + $options = array_merge($this->options, $options ?? []); + $query = []; + $query['app_id'] = $request->getAppId(); + $headers = []; + $headers['Accept'] = 'application/octet-stream'; + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "download/reporting_data/{$request->getJobIdentifier()}", + method: HttpMethod::GET, + headers: $headers, + query: $query, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + return; + } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + /** * To create your export job, you need to send a `POST` request to the export endpoint `https://api.intercom.io/export/content/data`. * diff --git a/src/DataExport/Requests/DownloadReportingDataExportRequest.php b/src/DataExport/Requests/DownloadReportingDataExportRequest.php new file mode 100644 index 0000000..3842c83 --- /dev/null +++ b/src/DataExport/Requests/DownloadReportingDataExportRequest.php @@ -0,0 +1,89 @@ +jobIdentifier = $values['jobIdentifier']; + $this->appId = $values['appId']; + $this->accept = $values['accept']; + } + + /** + * @return string + */ + public function getJobIdentifier(): string + { + return $this->jobIdentifier; + } + + /** + * @param string $value + */ + public function setJobIdentifier(string $value): self + { + $this->jobIdentifier = $value; + return $this; + } + + /** + * @return string + */ + public function getAppId(): string + { + return $this->appId; + } + + /** + * @param string $value + */ + public function setAppId(string $value): self + { + $this->appId = $value; + return $this; + } + + /** + * @return 'application/octet-stream' + */ + public function getAccept(): string + { + return $this->accept; + } + + /** + * @param 'application/octet-stream' $value + */ + public function setAccept(string $value): self + { + $this->accept = $value; + return $this; + } +} diff --git a/src/DataExport/Requests/ExportReportingDataRequest.php b/src/DataExport/Requests/ExportReportingDataRequest.php new file mode 100644 index 0000000..28ec1d2 --- /dev/null +++ b/src/DataExport/Requests/ExportReportingDataRequest.php @@ -0,0 +1,89 @@ +jobIdentifier = $values['jobIdentifier']; + $this->appId = $values['appId']; + $this->clientId = $values['clientId']; + } + + /** + * @return string + */ + public function getJobIdentifier(): string + { + return $this->jobIdentifier; + } + + /** + * @param string $value + */ + public function setJobIdentifier(string $value): self + { + $this->jobIdentifier = $value; + return $this; + } + + /** + * @return string + */ + public function getAppId(): string + { + return $this->appId; + } + + /** + * @param string $value + */ + public function setAppId(string $value): self + { + $this->appId = $value; + return $this; + } + + /** + * @return string + */ + public function getClientId(): string + { + return $this->clientId; + } + + /** + * @param string $value + */ + public function setClientId(string $value): self + { + $this->clientId = $value; + return $this; + } +} diff --git a/src/DataExport/Types/DataExport.php b/src/DataExport/Types/DataExport.php index 9b67502..a8c5b4b 100644 --- a/src/DataExport/Types/DataExport.php +++ b/src/DataExport/Types/DataExport.php @@ -11,109 +11,109 @@ class DataExport extends JsonSerializableType { /** - * @var string $jobIdentifier The identifier for your job. + * @var ?string $jobIdentifier The identifier for your job. */ #[JsonProperty('job_identifier')] - private string $jobIdentifier; + private ?string $jobIdentifier; /** - * @var value-of $status The current state of your job. + * @var ?value-of $status The current state of your job. */ #[JsonProperty('status')] - private string $status; + private ?string $status; /** - * @var string $downloadExpiresAt The time after which you will not be able to access the data. + * @var ?string $downloadExpiresAt The time after which you will not be able to access the data. */ #[JsonProperty('download_expires_at')] - private string $downloadExpiresAt; + private ?string $downloadExpiresAt; /** - * @var string $downloadUrl The location where you can download your data. + * @var ?string $downloadUrl The location where you can download your data. */ #[JsonProperty('download_url')] - private string $downloadUrl; + private ?string $downloadUrl; /** * @param array{ - * jobIdentifier: string, - * status: value-of, - * downloadExpiresAt: string, - * downloadUrl: string, + * jobIdentifier?: ?string, + * status?: ?value-of, + * downloadExpiresAt?: ?string, + * downloadUrl?: ?string, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->jobIdentifier = $values['jobIdentifier']; - $this->status = $values['status']; - $this->downloadExpiresAt = $values['downloadExpiresAt']; - $this->downloadUrl = $values['downloadUrl']; + $this->jobIdentifier = $values['jobIdentifier'] ?? null; + $this->status = $values['status'] ?? null; + $this->downloadExpiresAt = $values['downloadExpiresAt'] ?? null; + $this->downloadUrl = $values['downloadUrl'] ?? null; } /** - * @return string + * @return ?string */ - public function getJobIdentifier(): string + public function getJobIdentifier(): ?string { return $this->jobIdentifier; } /** - * @param string $value + * @param ?string $value */ - public function setJobIdentifier(string $value): self + public function setJobIdentifier(?string $value = null): self { $this->jobIdentifier = $value; return $this; } /** - * @return value-of + * @return ?value-of */ - public function getStatus(): string + public function getStatus(): ?string { return $this->status; } /** - * @param value-of $value + * @param ?value-of $value */ - public function setStatus(string $value): self + public function setStatus(?string $value = null): self { $this->status = $value; return $this; } /** - * @return string + * @return ?string */ - public function getDownloadExpiresAt(): string + public function getDownloadExpiresAt(): ?string { return $this->downloadExpiresAt; } /** - * @param string $value + * @param ?string $value */ - public function setDownloadExpiresAt(string $value): self + public function setDownloadExpiresAt(?string $value = null): self { $this->downloadExpiresAt = $value; return $this; } /** - * @return string + * @return ?string */ - public function getDownloadUrl(): string + public function getDownloadUrl(): ?string { return $this->downloadUrl; } /** - * @param string $value + * @param ?string $value */ - public function setDownloadUrl(string $value): self + public function setDownloadUrl(?string $value = null): self { $this->downloadUrl = $value; return $this; diff --git a/src/DataExport/Types/DataExportExportReportingDataResponse.php b/src/DataExport/Types/DataExportExportReportingDataResponse.php new file mode 100644 index 0000000..2c7db6f --- /dev/null +++ b/src/DataExport/Types/DataExportExportReportingDataResponse.php @@ -0,0 +1,126 @@ +jobIdentifier = $values['jobIdentifier'] ?? null; + $this->status = $values['status'] ?? null; + $this->downloadUrl = $values['downloadUrl'] ?? null; + $this->downloadExpiresAt = $values['downloadExpiresAt'] ?? null; + } + + /** + * @return ?string + */ + public function getJobIdentifier(): ?string + { + return $this->jobIdentifier; + } + + /** + * @param ?string $value + */ + public function setJobIdentifier(?string $value = null): self + { + $this->jobIdentifier = $value; + return $this; + } + + /** + * @return ?string + */ + public function getStatus(): ?string + { + return $this->status; + } + + /** + * @param ?string $value + */ + public function setStatus(?string $value = null): self + { + $this->status = $value; + return $this; + } + + /** + * @return ?string + */ + public function getDownloadUrl(): ?string + { + return $this->downloadUrl; + } + + /** + * @param ?string $value + */ + public function setDownloadUrl(?string $value = null): self + { + $this->downloadUrl = $value; + return $this; + } + + /** + * @return ?string + */ + public function getDownloadExpiresAt(): ?string + { + return $this->downloadExpiresAt; + } + + /** + * @param ?string $value + */ + public function setDownloadExpiresAt(?string $value = null): self + { + $this->downloadExpiresAt = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Events/EventsClient.php b/src/Events/EventsClient.php index 712d8bf..6856658 100644 --- a/src/Events/EventsClient.php +++ b/src/Events/EventsClient.php @@ -30,7 +30,7 @@ class EventsClient * maxRetries?: int, * timeout?: float, * headers?: array, - * } $options + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator */ private array $options; @@ -186,6 +186,7 @@ public function list(ListEventsRequest $request, ?array $options = null): DataEv * - Event lists containing duplicate events will have those duplicates ignored. * - Server errors will return a `500` response code and may contain an error message in the body. * + * * @param ( * CreateDataEventRequestWithId * |CreateDataEventRequestWithUserId @@ -242,6 +243,7 @@ public function create(CreateDataEventRequestWithId|CreateDataEventRequestWithUs /** * Create event summaries for a user. Event summaries are used to track the number of times an event has occurred, the first time it occurred and the last time it occurred. * + * * @param ListEventSummariesRequest $request * @param ?array{ * baseUrl?: string, diff --git a/src/Export/ExportClient.php b/src/Export/ExportClient.php new file mode 100644 index 0000000..544337f --- /dev/null +++ b/src/Export/ExportClient.php @@ -0,0 +1,160 @@ +, + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator + */ + private array $options; + + /** + * @var RawClient $client + */ + private RawClient $client; + + /** + * @param RawClient $client + * @param ?array{ + * baseUrl?: string, + * client?: ClientInterface, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * } $options + */ + public function __construct( + RawClient $client, + ?array $options = null, + ) { + $this->client = $client; + $this->options = $options ?? []; + } + + /** + * @param PostExportReportingDataEnqueueRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return PostExportReportingDataEnqueueResponse + * @throws IntercomException + * @throws IntercomApiException + */ + public function enqueueANewReportingDataExportJob(PostExportReportingDataEnqueueRequest $request, ?array $options = null): PostExportReportingDataEnqueueResponse + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "export/reporting_data/enqueue", + method: HttpMethod::POST, + body: $request, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return PostExportReportingDataEnqueueResponse::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return GetExportReportingDataGetDatasetsResponse + * @throws IntercomException + * @throws IntercomApiException + */ + public function listAvailableDatasetsAndAttributes(?array $options = null): GetExportReportingDataGetDatasetsResponse + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "export/reporting_data/get_datasets", + method: HttpMethod::GET, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return GetExportReportingDataGetDatasetsResponse::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } +} diff --git a/src/Export/Requests/PostExportReportingDataEnqueueRequest.php b/src/Export/Requests/PostExportReportingDataEnqueueRequest.php new file mode 100644 index 0000000..7be7a76 --- /dev/null +++ b/src/Export/Requests/PostExportReportingDataEnqueueRequest.php @@ -0,0 +1,119 @@ + $attributeIds + */ + #[JsonProperty('attribute_ids'), ArrayType(['string'])] + private array $attributeIds; + + /** + * @var int $startTime + */ + #[JsonProperty('start_time')] + private int $startTime; + + /** + * @var int $endTime + */ + #[JsonProperty('end_time')] + private int $endTime; + + /** + * @param array{ + * datasetId: string, + * attributeIds: array, + * startTime: int, + * endTime: int, + * } $values + */ + public function __construct( + array $values, + ) { + $this->datasetId = $values['datasetId']; + $this->attributeIds = $values['attributeIds']; + $this->startTime = $values['startTime']; + $this->endTime = $values['endTime']; + } + + /** + * @return string + */ + public function getDatasetId(): string + { + return $this->datasetId; + } + + /** + * @param string $value + */ + public function setDatasetId(string $value): self + { + $this->datasetId = $value; + return $this; + } + + /** + * @return array + */ + public function getAttributeIds(): array + { + return $this->attributeIds; + } + + /** + * @param array $value + */ + public function setAttributeIds(array $value): self + { + $this->attributeIds = $value; + return $this; + } + + /** + * @return int + */ + public function getStartTime(): int + { + return $this->startTime; + } + + /** + * @param int $value + */ + public function setStartTime(int $value): self + { + $this->startTime = $value; + return $this; + } + + /** + * @return int + */ + public function getEndTime(): int + { + return $this->endTime; + } + + /** + * @param int $value + */ + public function setEndTime(int $value): self + { + $this->endTime = $value; + return $this; + } +} diff --git a/src/Export/Types/GetExportReportingDataGetDatasetsResponse.php b/src/Export/Types/GetExportReportingDataGetDatasetsResponse.php new file mode 100644 index 0000000..76383f1 --- /dev/null +++ b/src/Export/Types/GetExportReportingDataGetDatasetsResponse.php @@ -0,0 +1,77 @@ + $data + */ + #[JsonProperty('data'), ArrayType([GetExportReportingDataGetDatasetsResponseDataItem::class])] + private ?array $data; + + /** + * @param array{ + * type?: ?string, + * data?: ?array, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->type = $values['type'] ?? null; + $this->data = $values['data'] ?? null; + } + + /** + * @return ?string + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?string $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?array + */ + public function getData(): ?array + { + return $this->data; + } + + /** + * @param ?array $value + */ + public function setData(?array $value = null): self + { + $this->data = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Export/Types/GetExportReportingDataGetDatasetsResponseDataItem.php b/src/Export/Types/GetExportReportingDataGetDatasetsResponseDataItem.php new file mode 100644 index 0000000..6ee1fed --- /dev/null +++ b/src/Export/Types/GetExportReportingDataGetDatasetsResponseDataItem.php @@ -0,0 +1,152 @@ + $attributes + */ + #[JsonProperty('attributes'), ArrayType([GetExportReportingDataGetDatasetsResponseDataItemAttributesItem::class])] + private ?array $attributes; + + /** + * @param array{ + * id?: ?string, + * name?: ?string, + * description?: ?string, + * defaultTimeAttributeId?: ?string, + * attributes?: ?array, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->id = $values['id'] ?? null; + $this->name = $values['name'] ?? null; + $this->description = $values['description'] ?? null; + $this->defaultTimeAttributeId = $values['defaultTimeAttributeId'] ?? null; + $this->attributes = $values['attributes'] ?? null; + } + + /** + * @return ?string + */ + public function getId(): ?string + { + return $this->id; + } + + /** + * @param ?string $value + */ + public function setId(?string $value = null): self + { + $this->id = $value; + return $this; + } + + /** + * @return ?string + */ + public function getName(): ?string + { + return $this->name; + } + + /** + * @param ?string $value + */ + public function setName(?string $value = null): self + { + $this->name = $value; + return $this; + } + + /** + * @return ?string + */ + public function getDescription(): ?string + { + return $this->description; + } + + /** + * @param ?string $value + */ + public function setDescription(?string $value = null): self + { + $this->description = $value; + return $this; + } + + /** + * @return ?string + */ + public function getDefaultTimeAttributeId(): ?string + { + return $this->defaultTimeAttributeId; + } + + /** + * @param ?string $value + */ + public function setDefaultTimeAttributeId(?string $value = null): self + { + $this->defaultTimeAttributeId = $value; + return $this; + } + + /** + * @return ?array + */ + public function getAttributes(): ?array + { + return $this->attributes; + } + + /** + * @param ?array $value + */ + public function setAttributes(?array $value = null): self + { + $this->attributes = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/SpacerComponent.php b/src/Export/Types/GetExportReportingDataGetDatasetsResponseDataItemAttributesItem.php similarity index 54% rename from src/Types/SpacerComponent.php rename to src/Export/Types/GetExportReportingDataGetDatasetsResponseDataItemAttributesItem.php index cf7331f..498da2b 100644 --- a/src/Types/SpacerComponent.php +++ b/src/Export/Types/GetExportReportingDataGetDatasetsResponseDataItemAttributesItem.php @@ -1,38 +1,35 @@ $size The amount of space between components. Default is `s`. + * @var ?string $name */ - #[JsonProperty('size')] - private ?string $size; + #[JsonProperty('name')] + private ?string $name; /** * @param array{ * id?: ?string, - * size?: ?value-of, + * name?: ?string, * } $values */ public function __construct( array $values = [], ) { $this->id = $values['id'] ?? null; - $this->size = $values['size'] ?? null; + $this->name = $values['name'] ?? null; } /** @@ -53,19 +50,19 @@ public function setId(?string $value = null): self } /** - * @return ?value-of + * @return ?string */ - public function getSize(): ?string + public function getName(): ?string { - return $this->size; + return $this->name; } /** - * @param ?value-of $value + * @param ?string $value */ - public function setSize(?string $value = null): self + public function setName(?string $value = null): self { - $this->size = $value; + $this->name = $value; return $this; } diff --git a/src/Export/Types/PostExportReportingDataEnqueueResponse.php b/src/Export/Types/PostExportReportingDataEnqueueResponse.php new file mode 100644 index 0000000..58a1807 --- /dev/null +++ b/src/Export/Types/PostExportReportingDataEnqueueResponse.php @@ -0,0 +1,126 @@ +jobIdentifier = $values['jobIdentifier'] ?? null; + $this->status = $values['status'] ?? null; + $this->downloadUrl = $values['downloadUrl'] ?? null; + $this->downloadExpiresAt = $values['downloadExpiresAt'] ?? null; + } + + /** + * @return ?string + */ + public function getJobIdentifier(): ?string + { + return $this->jobIdentifier; + } + + /** + * @param ?string $value + */ + public function setJobIdentifier(?string $value = null): self + { + $this->jobIdentifier = $value; + return $this; + } + + /** + * @return ?string + */ + public function getStatus(): ?string + { + return $this->status; + } + + /** + * @param ?string $value + */ + public function setStatus(?string $value = null): self + { + $this->status = $value; + return $this; + } + + /** + * @return ?string + */ + public function getDownloadUrl(): ?string + { + return $this->downloadUrl; + } + + /** + * @param ?string $value + */ + public function setDownloadUrl(?string $value = null): self + { + $this->downloadUrl = $value; + return $this; + } + + /** + * @return ?string + */ + public function getDownloadExpiresAt(): ?string + { + return $this->downloadExpiresAt; + } + + /** + * @param ?string $value + */ + public function setDownloadExpiresAt(?string $value = null): self + { + $this->downloadExpiresAt = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/HelpCenter/Types/HelpCenter.php b/src/HelpCenter/Types/HelpCenter.php index 2cf0b60..228b4de 100644 --- a/src/HelpCenter/Types/HelpCenter.php +++ b/src/HelpCenter/Types/HelpCenter.php @@ -11,22 +11,22 @@ class HelpCenter extends JsonSerializableType { /** - * @var string $id The unique identifier for the Help Center which is given by Intercom. + * @var ?string $id The unique identifier for the Help Center which is given by Intercom. */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** - * @var string $workspaceId The id of the workspace which the Help Center belongs to. + * @var ?string $workspaceId The id of the workspace which the Help Center belongs to. */ #[JsonProperty('workspace_id')] - private string $workspaceId; + private ?string $workspaceId; /** - * @var int $createdAt The time when the Help Center was created. + * @var ?int $createdAt The time when the Help Center was created. */ #[JsonProperty('created_at')] - private int $createdAt; + private ?int $createdAt; /** * @var ?int $updatedAt The time when the Help Center was last updated. @@ -35,92 +35,108 @@ class HelpCenter extends JsonSerializableType private ?int $updatedAt; /** - * @var string $identifier The identifier of the Help Center. This is used in the URL of the Help Center. + * @var ?string $identifier The identifier of the Help Center. This is used in the URL of the Help Center. */ #[JsonProperty('identifier')] - private string $identifier; + private ?string $identifier; /** - * @var bool $websiteTurnedOn Whether the Help Center is turned on or not. This is controlled in your Help Center settings. + * @var ?bool $websiteTurnedOn Whether the Help Center is turned on or not. This is controlled in your Help Center settings. */ #[JsonProperty('website_turned_on')] - private bool $websiteTurnedOn; + private ?bool $websiteTurnedOn; /** - * @var string $displayName The display name of the Help Center only seen by teammates. + * @var ?string $displayName The display name of the Help Center only seen by teammates. */ #[JsonProperty('display_name')] - private string $displayName; + private ?string $displayName; + + /** + * @var ?string $url The URL for the help center, if you have a custom domain then this will show the URL using the custom domain. + */ + #[JsonProperty('url')] + private ?string $url; + + /** + * @var ?string $customDomain Custom domain configured for the help center + */ + #[JsonProperty('custom_domain')] + private ?string $customDomain; /** * @param array{ - * id: string, - * workspaceId: string, - * createdAt: int, - * identifier: string, - * websiteTurnedOn: bool, - * displayName: string, + * id?: ?string, + * workspaceId?: ?string, + * createdAt?: ?int, * updatedAt?: ?int, + * identifier?: ?string, + * websiteTurnedOn?: ?bool, + * displayName?: ?string, + * url?: ?string, + * customDomain?: ?string, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->id = $values['id']; - $this->workspaceId = $values['workspaceId']; - $this->createdAt = $values['createdAt']; + $this->id = $values['id'] ?? null; + $this->workspaceId = $values['workspaceId'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; $this->updatedAt = $values['updatedAt'] ?? null; - $this->identifier = $values['identifier']; - $this->websiteTurnedOn = $values['websiteTurnedOn']; - $this->displayName = $values['displayName']; + $this->identifier = $values['identifier'] ?? null; + $this->websiteTurnedOn = $values['websiteTurnedOn'] ?? null; + $this->displayName = $values['displayName'] ?? null; + $this->url = $values['url'] ?? null; + $this->customDomain = $values['customDomain'] ?? null; } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; } /** - * @return string + * @return ?string */ - public function getWorkspaceId(): string + public function getWorkspaceId(): ?string { return $this->workspaceId; } /** - * @param string $value + * @param ?string $value */ - public function setWorkspaceId(string $value): self + public function setWorkspaceId(?string $value = null): self { $this->workspaceId = $value; return $this; } /** - * @return int + * @return ?int */ - public function getCreatedAt(): int + public function getCreatedAt(): ?int { return $this->createdAt; } /** - * @param int $value + * @param ?int $value */ - public function setCreatedAt(int $value): self + public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; return $this; @@ -144,56 +160,90 @@ public function setUpdatedAt(?int $value = null): self } /** - * @return string + * @return ?string */ - public function getIdentifier(): string + public function getIdentifier(): ?string { return $this->identifier; } /** - * @param string $value + * @param ?string $value */ - public function setIdentifier(string $value): self + public function setIdentifier(?string $value = null): self { $this->identifier = $value; return $this; } /** - * @return bool + * @return ?bool */ - public function getWebsiteTurnedOn(): bool + public function getWebsiteTurnedOn(): ?bool { return $this->websiteTurnedOn; } /** - * @param bool $value + * @param ?bool $value */ - public function setWebsiteTurnedOn(bool $value): self + public function setWebsiteTurnedOn(?bool $value = null): self { $this->websiteTurnedOn = $value; return $this; } /** - * @return string + * @return ?string */ - public function getDisplayName(): string + public function getDisplayName(): ?string { return $this->displayName; } /** - * @param string $value + * @param ?string $value */ - public function setDisplayName(string $value): self + public function setDisplayName(?string $value = null): self { $this->displayName = $value; return $this; } + /** + * @return ?string + */ + public function getUrl(): ?string + { + return $this->url; + } + + /** + * @param ?string $value + */ + public function setUrl(?string $value = null): self + { + $this->url = $value; + return $this; + } + + /** + * @return ?string + */ + public function getCustomDomain(): ?string + { + return $this->customDomain; + } + + /** + * @param ?string $value + */ + public function setCustomDomain(?string $value = null): self + { + $this->customDomain = $value; + return $this; + } + /** * @return string */ diff --git a/src/HelpCenter/Types/HelpCenterList.php b/src/HelpCenter/Types/HelpCenterList.php index 6165aa1..e9af781 100644 --- a/src/HelpCenter/Types/HelpCenterList.php +++ b/src/HelpCenter/Types/HelpCenterList.php @@ -12,59 +12,59 @@ class HelpCenterList extends JsonSerializableType { /** - * @var 'list' $type The type of the object - `list`. + * @var ?'list' $type The type of the object - `list`. */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var array $data An array of Help Center objects + * @var ?array $data An array of Help Center objects */ #[JsonProperty('data'), ArrayType([HelpCenter::class])] - private array $data; + private ?array $data; /** * @param array{ - * type: 'list', - * data: array, + * type?: ?'list', + * data?: ?array, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->data = $values['data']; + $this->type = $values['type'] ?? null; + $this->data = $values['data'] ?? null; } /** - * @return 'list' + * @return ?'list' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'list' $value + * @param ?'list' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return array + * @return ?array */ - public function getData(): array + public function getData(): ?array { return $this->data; } /** - * @param array $value + * @param ?array $value */ - public function setData(array $value): self + public function setData(?array $value = null): self { $this->data = $value; return $this; diff --git a/src/HelpCenters/Collections/CollectionsClient.php b/src/HelpCenters/Collections/CollectionsClient.php index 0a1f0f8..f3c92a7 100644 --- a/src/HelpCenters/Collections/CollectionsClient.php +++ b/src/HelpCenters/Collections/CollectionsClient.php @@ -32,7 +32,7 @@ class CollectionsClient * maxRetries?: int, * timeout?: float, * headers?: array, - * } $options + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator */ private array $options; diff --git a/src/HelpCenters/Collections/Requests/DeleteCollectionRequest.php b/src/HelpCenters/Collections/Requests/DeleteCollectionRequest.php index 0e91e4b..a1e9af1 100644 --- a/src/HelpCenters/Collections/Requests/DeleteCollectionRequest.php +++ b/src/HelpCenters/Collections/Requests/DeleteCollectionRequest.php @@ -7,13 +7,13 @@ class DeleteCollectionRequest extends JsonSerializableType { /** - * @var string $collectionId The unique identifier for the collection which is given by Intercom. + * @var int $collectionId The unique identifier for the collection which is given by Intercom. */ - private string $collectionId; + private int $collectionId; /** * @param array{ - * collectionId: string, + * collectionId: int, * } $values */ public function __construct( @@ -23,17 +23,17 @@ public function __construct( } /** - * @return string + * @return int */ - public function getCollectionId(): string + public function getCollectionId(): int { return $this->collectionId; } /** - * @param string $value + * @param int $value */ - public function setCollectionId(string $value): self + public function setCollectionId(int $value): self { $this->collectionId = $value; return $this; diff --git a/src/HelpCenters/Collections/Requests/FindCollectionRequest.php b/src/HelpCenters/Collections/Requests/FindCollectionRequest.php index d09948e..88e8f24 100644 --- a/src/HelpCenters/Collections/Requests/FindCollectionRequest.php +++ b/src/HelpCenters/Collections/Requests/FindCollectionRequest.php @@ -7,13 +7,13 @@ class FindCollectionRequest extends JsonSerializableType { /** - * @var string $collectionId The unique identifier for the collection which is given by Intercom. + * @var int $collectionId The unique identifier for the collection which is given by Intercom. */ - private string $collectionId; + private int $collectionId; /** * @param array{ - * collectionId: string, + * collectionId: int, * } $values */ public function __construct( @@ -23,17 +23,17 @@ public function __construct( } /** - * @return string + * @return int */ - public function getCollectionId(): string + public function getCollectionId(): int { return $this->collectionId; } /** - * @param string $value + * @param int $value */ - public function setCollectionId(string $value): self + public function setCollectionId(int $value): self { $this->collectionId = $value; return $this; diff --git a/src/HelpCenters/Collections/Requests/UpdateCollectionRequest.php b/src/HelpCenters/Collections/Requests/UpdateCollectionRequest.php index dfe8d95..77b90e8 100644 --- a/src/HelpCenters/Collections/Requests/UpdateCollectionRequest.php +++ b/src/HelpCenters/Collections/Requests/UpdateCollectionRequest.php @@ -9,9 +9,9 @@ class UpdateCollectionRequest extends JsonSerializableType { /** - * @var string $collectionId The unique identifier for the collection which is given by Intercom. + * @var int $collectionId The unique identifier for the collection which is given by Intercom. */ - private string $collectionId; + private int $collectionId; /** * @var ?string $name The name of the collection. For multilingual collections, this will be the name of the default language's content. @@ -39,7 +39,7 @@ class UpdateCollectionRequest extends JsonSerializableType /** * @param array{ - * collectionId: string, + * collectionId: int, * name?: ?string, * description?: ?string, * translatedContent?: ?GroupTranslatedContent, @@ -57,17 +57,17 @@ public function __construct( } /** - * @return string + * @return int */ - public function getCollectionId(): string + public function getCollectionId(): int { return $this->collectionId; } /** - * @param string $value + * @param int $value */ - public function setCollectionId(string $value): self + public function setCollectionId(int $value): self { $this->collectionId = $value; return $this; diff --git a/src/HelpCenters/HelpCentersClient.php b/src/HelpCenters/HelpCentersClient.php index 647a8cb..d552124 100644 --- a/src/HelpCenters/HelpCentersClient.php +++ b/src/HelpCenters/HelpCentersClient.php @@ -34,7 +34,7 @@ class HelpCentersClient * maxRetries?: int, * timeout?: float, * headers?: array, - * } $options + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator */ private array $options; diff --git a/src/HelpCenters/Requests/FindHelpCenterRequest.php b/src/HelpCenters/Requests/FindHelpCenterRequest.php index 72f7191..081e65b 100644 --- a/src/HelpCenters/Requests/FindHelpCenterRequest.php +++ b/src/HelpCenters/Requests/FindHelpCenterRequest.php @@ -7,13 +7,13 @@ class FindHelpCenterRequest extends JsonSerializableType { /** - * @var string $helpCenterId The unique identifier for the Help Center which is given by Intercom. + * @var int $helpCenterId The unique identifier for the collection which is given by Intercom. */ - private string $helpCenterId; + private int $helpCenterId; /** * @param array{ - * helpCenterId: string, + * helpCenterId: int, * } $values */ public function __construct( @@ -23,17 +23,17 @@ public function __construct( } /** - * @return string + * @return int */ - public function getHelpCenterId(): string + public function getHelpCenterId(): int { return $this->helpCenterId; } /** - * @param string $value + * @param int $value */ - public function setHelpCenterId(string $value): self + public function setHelpCenterId(int $value): self { $this->helpCenterId = $value; return $this; diff --git a/src/IntercomClient.php b/src/IntercomClient.php index b9c8a5e..555e479 100644 --- a/src/IntercomClient.php +++ b/src/IntercomClient.php @@ -3,21 +3,30 @@ namespace Intercom; use Intercom\Admins\AdminsClient; +use Intercom\AiContent\AiContentClient; use Intercom\Articles\ArticlesClient; +use Intercom\AwayStatusReasons\AwayStatusReasonsClient; +use Intercom\Export\ExportClient; +use Intercom\DataExport\DataExportClient; use Intercom\HelpCenters\HelpCentersClient; +use Intercom\InternalArticles\InternalArticlesClient; use Intercom\Companies\CompaniesClient; use Intercom\Contacts\ContactsClient; use Intercom\Notes\NotesClient; use Intercom\Tags\TagsClient; use Intercom\Conversations\ConversationsClient; +use Intercom\CustomChannelEvents\CustomChannelEventsClient; +use Intercom\CustomObjectInstances\CustomObjectInstancesClient; use Intercom\DataAttributes\DataAttributesClient; use Intercom\Events\EventsClient; -use Intercom\DataExport\DataExportClient; +use Intercom\Jobs\JobsClient; use Intercom\Messages\MessagesClient; use Intercom\Segments\SegmentsClient; use Intercom\SubscriptionTypes\SubscriptionTypesClient; use Intercom\PhoneCallRedirects\PhoneCallRedirectsClient; +use Intercom\Calls\CallsClient; use Intercom\Teams\TeamsClient; +use Intercom\TicketStates\TicketStatesClient; use Intercom\TicketTypes\TicketTypesClient; use Intercom\Tickets\TicketsClient; use Intercom\Visitors\VisitorsClient; @@ -34,16 +43,41 @@ class IntercomClient */ public AdminsClient $admins; + /** + * @var AiContentClient $aiContent + */ + public AiContentClient $aiContent; + /** * @var ArticlesClient $articles */ public ArticlesClient $articles; + /** + * @var AwayStatusReasonsClient $awayStatusReasons + */ + public AwayStatusReasonsClient $awayStatusReasons; + + /** + * @var ExportClient $export + */ + public ExportClient $export; + + /** + * @var DataExportClient $dataExport + */ + public DataExportClient $dataExport; + /** * @var HelpCentersClient $helpCenters */ public HelpCentersClient $helpCenters; + /** + * @var InternalArticlesClient $internalArticles + */ + public InternalArticlesClient $internalArticles; + /** * @var CompaniesClient $companies */ @@ -69,6 +103,16 @@ class IntercomClient */ public ConversationsClient $conversations; + /** + * @var CustomChannelEventsClient $customChannelEvents + */ + public CustomChannelEventsClient $customChannelEvents; + + /** + * @var CustomObjectInstancesClient $customObjectInstances + */ + public CustomObjectInstancesClient $customObjectInstances; + /** * @var DataAttributesClient $dataAttributes */ @@ -80,9 +124,9 @@ class IntercomClient public EventsClient $events; /** - * @var DataExportClient $dataExport + * @var JobsClient $jobs */ - public DataExportClient $dataExport; + public JobsClient $jobs; /** * @var MessagesClient $messages @@ -104,11 +148,21 @@ class IntercomClient */ public PhoneCallRedirectsClient $phoneCallRedirects; + /** + * @var CallsClient $calls + */ + public CallsClient $calls; + /** * @var TeamsClient $teams */ public TeamsClient $teams; + /** + * @var TicketStatesClient $ticketStates + */ + public TicketStatesClient $ticketStates; + /** * @var TicketTypesClient $ticketTypes */ @@ -141,7 +195,7 @@ class IntercomClient * maxRetries?: int, * timeout?: float, * headers?: array, - * } $options + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator */ private array $options; @@ -169,12 +223,13 @@ public function __construct( 'Authorization' => "Bearer $token", 'X-Fern-Language' => 'PHP', 'X-Fern-SDK-Name' => 'Intercom', - 'X-Fern-SDK-Version' => '0.0.325', - 'User-Agent' => 'intercom/intercom-php/0.0.325', - 'Intercom-Version' => '2.11', + 'X-Fern-SDK-Version' => '6.0.0', + 'User-Agent' => 'intercom/intercom-php/6.0.0', + 'Intercom-Version' => '2.14', ]; $this->options = $options ?? []; + $this->options['headers'] = array_merge( $defaultHeaders, $this->options['headers'] ?? [], @@ -185,21 +240,30 @@ public function __construct( ); $this->admins = new AdminsClient($this->client, $this->options); + $this->aiContent = new AiContentClient($this->client, $this->options); $this->articles = new ArticlesClient($this->client, $this->options); + $this->awayStatusReasons = new AwayStatusReasonsClient($this->client, $this->options); + $this->export = new ExportClient($this->client, $this->options); + $this->dataExport = new DataExportClient($this->client, $this->options); $this->helpCenters = new HelpCentersClient($this->client, $this->options); + $this->internalArticles = new InternalArticlesClient($this->client, $this->options); $this->companies = new CompaniesClient($this->client, $this->options); $this->contacts = new ContactsClient($this->client, $this->options); $this->notes = new NotesClient($this->client, $this->options); $this->tags = new TagsClient($this->client, $this->options); $this->conversations = new ConversationsClient($this->client, $this->options); + $this->customChannelEvents = new CustomChannelEventsClient($this->client, $this->options); + $this->customObjectInstances = new CustomObjectInstancesClient($this->client, $this->options); $this->dataAttributes = new DataAttributesClient($this->client, $this->options); $this->events = new EventsClient($this->client, $this->options); - $this->dataExport = new DataExportClient($this->client, $this->options); + $this->jobs = new JobsClient($this->client, $this->options); $this->messages = new MessagesClient($this->client, $this->options); $this->segments = new SegmentsClient($this->client, $this->options); $this->subscriptionTypes = new SubscriptionTypesClient($this->client, $this->options); $this->phoneCallRedirects = new PhoneCallRedirectsClient($this->client, $this->options); + $this->calls = new CallsClient($this->client, $this->options); $this->teams = new TeamsClient($this->client, $this->options); + $this->ticketStates = new TicketStatesClient($this->client, $this->options); $this->ticketTypes = new TicketTypesClient($this->client, $this->options); $this->tickets = new TicketsClient($this->client, $this->options); $this->visitors = new VisitorsClient($this->client, $this->options); diff --git a/src/InternalArticles/InternalArticlesClient.php b/src/InternalArticles/InternalArticlesClient.php new file mode 100644 index 0000000..2e8ade2 --- /dev/null +++ b/src/InternalArticles/InternalArticlesClient.php @@ -0,0 +1,396 @@ +, + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator + */ + private array $options; + + /** + * @var RawClient $client + */ + private RawClient $client; + + /** + * @param RawClient $client + * @param ?array{ + * baseUrl?: string, + * client?: ClientInterface, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * } $options + */ + public function __construct( + RawClient $client, + ?array $options = null, + ) { + $this->client = $client; + $this->options = $options ?? []; + } + + /** + * You can fetch a list of all internal articles by making a GET request to `https://api.intercom.io/internal_articles`. + * + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return InternalArticleList + * @throws IntercomException + * @throws IntercomApiException + */ + public function listInternalArticles(?array $options = null): InternalArticleList + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "internal_articles", + method: HttpMethod::GET, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return InternalArticleList::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * You can create a new internal article by making a POST request to `https://api.intercom.io/internal_articles`. + * + * @param ?CreateInternalArticleRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return InternalArticleListItem + * @throws IntercomException + * @throws IntercomApiException + */ + public function createInternalArticle(?CreateInternalArticleRequest $request = null, ?array $options = null): InternalArticleListItem + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "internal_articles", + method: HttpMethod::POST, + body: $request, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return InternalArticleListItem::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * You can fetch the details of a single internal article by making a GET request to `https://api.intercom.io/internal_articles/`. + * + * @param RetrieveInternalArticleRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return InternalArticleListItem + * @throws IntercomException + * @throws IntercomApiException + */ + public function retrieveInternalArticle(RetrieveInternalArticleRequest $request, ?array $options = null): InternalArticleListItem + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "internal_articles/{$request->getInternalArticleId()}", + method: HttpMethod::GET, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return InternalArticleListItem::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * You can update the details of a single internal article by making a PUT request to `https://api.intercom.io/internal_articles/`. + * + * @param UpdateInternalArticleRequestBody $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return InternalArticleListItem + * @throws IntercomException + * @throws IntercomApiException + */ + public function updateInternalArticle(UpdateInternalArticleRequestBody $request, ?array $options = null): InternalArticleListItem + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "internal_articles/{$request->getInternalArticleId()}", + method: HttpMethod::PUT, + body: $request, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return InternalArticleListItem::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * You can delete a single internal article by making a DELETE request to `https://api.intercom.io/internal_articles/`. + * + * @param DeleteInternalArticleRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return DeletedInternalArticleObject + * @throws IntercomException + * @throws IntercomApiException + */ + public function deleteInternalArticle(DeleteInternalArticleRequest $request, ?array $options = null): DeletedInternalArticleObject + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "internal_articles/{$request->getInternalArticleId()}", + method: HttpMethod::DELETE, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return DeletedInternalArticleObject::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * You can search for internal articles by making a GET request to `https://api.intercom.io/internal_articles/search`. + * + * @param SearchInternalArticlesRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return InternalArticleSearchResponse + * @throws IntercomException + * @throws IntercomApiException + */ + public function searchInternalArticles(SearchInternalArticlesRequest $request = new SearchInternalArticlesRequest(), ?array $options = null): InternalArticleSearchResponse + { + $options = array_merge($this->options, $options ?? []); + $query = []; + if ($request->getFolderId() != null) { + $query['folder_id'] = $request->getFolderId(); + } + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "internal_articles/search", + method: HttpMethod::GET, + query: $query, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return InternalArticleSearchResponse::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } +} diff --git a/src/InternalArticles/Requests/DeleteInternalArticleRequest.php b/src/InternalArticles/Requests/DeleteInternalArticleRequest.php new file mode 100644 index 0000000..2bdeb18 --- /dev/null +++ b/src/InternalArticles/Requests/DeleteInternalArticleRequest.php @@ -0,0 +1,41 @@ +internalArticleId = $values['internalArticleId']; + } + + /** + * @return int + */ + public function getInternalArticleId(): int + { + return $this->internalArticleId; + } + + /** + * @param int $value + */ + public function setInternalArticleId(int $value): self + { + $this->internalArticleId = $value; + return $this; + } +} diff --git a/src/InternalArticles/Requests/RetrieveInternalArticleRequest.php b/src/InternalArticles/Requests/RetrieveInternalArticleRequest.php new file mode 100644 index 0000000..cf95e1c --- /dev/null +++ b/src/InternalArticles/Requests/RetrieveInternalArticleRequest.php @@ -0,0 +1,41 @@ +internalArticleId = $values['internalArticleId']; + } + + /** + * @return int + */ + public function getInternalArticleId(): int + { + return $this->internalArticleId; + } + + /** + * @param int $value + */ + public function setInternalArticleId(int $value): self + { + $this->internalArticleId = $value; + return $this; + } +} diff --git a/src/InternalArticles/Requests/SearchInternalArticlesRequest.php b/src/InternalArticles/Requests/SearchInternalArticlesRequest.php new file mode 100644 index 0000000..1e6e267 --- /dev/null +++ b/src/InternalArticles/Requests/SearchInternalArticlesRequest.php @@ -0,0 +1,41 @@ +folderId = $values['folderId'] ?? null; + } + + /** + * @return ?string + */ + public function getFolderId(): ?string + { + return $this->folderId; + } + + /** + * @param ?string $value + */ + public function setFolderId(?string $value = null): self + { + $this->folderId = $value; + return $this; + } +} diff --git a/src/InternalArticles/Requests/UpdateInternalArticleRequestBody.php b/src/InternalArticles/Requests/UpdateInternalArticleRequestBody.php new file mode 100644 index 0000000..f947e15 --- /dev/null +++ b/src/InternalArticles/Requests/UpdateInternalArticleRequestBody.php @@ -0,0 +1,142 @@ +internalArticleId = $values['internalArticleId']; + $this->title = $values['title'] ?? null; + $this->body = $values['body'] ?? null; + $this->authorId = $values['authorId'] ?? null; + $this->ownerId = $values['ownerId'] ?? null; + } + + /** + * @return int + */ + public function getInternalArticleId(): int + { + return $this->internalArticleId; + } + + /** + * @param int $value + */ + public function setInternalArticleId(int $value): self + { + $this->internalArticleId = $value; + return $this; + } + + /** + * @return ?string + */ + public function getTitle(): ?string + { + return $this->title; + } + + /** + * @param ?string $value + */ + public function setTitle(?string $value = null): self + { + $this->title = $value; + return $this; + } + + /** + * @return ?string + */ + public function getBody(): ?string + { + return $this->body; + } + + /** + * @param ?string $value + */ + public function setBody(?string $value = null): self + { + $this->body = $value; + return $this; + } + + /** + * @return ?int + */ + public function getAuthorId(): ?int + { + return $this->authorId; + } + + /** + * @param ?int $value + */ + public function setAuthorId(?int $value = null): self + { + $this->authorId = $value; + return $this; + } + + /** + * @return ?int + */ + public function getOwnerId(): ?int + { + return $this->ownerId; + } + + /** + * @param ?int $value + */ + public function setOwnerId(?int $value = null): self + { + $this->ownerId = $value; + return $this; + } +} diff --git a/src/InternalArticles/Types/InternalArticleListItem.php b/src/InternalArticles/Types/InternalArticleListItem.php new file mode 100644 index 0000000..b548435 --- /dev/null +++ b/src/InternalArticles/Types/InternalArticleListItem.php @@ -0,0 +1,254 @@ +type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->title = $values['title'] ?? null; + $this->body = $values['body'] ?? null; + $this->ownerId = $values['ownerId'] ?? null; + $this->authorId = $values['authorId'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; + $this->updatedAt = $values['updatedAt'] ?? null; + $this->locale = $values['locale'] ?? null; + } + + /** + * @return ?'internal_article' + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?'internal_article' $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?string + */ + public function getId(): ?string + { + return $this->id; + } + + /** + * @param ?string $value + */ + public function setId(?string $value = null): self + { + $this->id = $value; + return $this; + } + + /** + * @return ?string + */ + public function getTitle(): ?string + { + return $this->title; + } + + /** + * @param ?string $value + */ + public function setTitle(?string $value = null): self + { + $this->title = $value; + return $this; + } + + /** + * @return ?string + */ + public function getBody(): ?string + { + return $this->body; + } + + /** + * @param ?string $value + */ + public function setBody(?string $value = null): self + { + $this->body = $value; + return $this; + } + + /** + * @return ?int + */ + public function getOwnerId(): ?int + { + return $this->ownerId; + } + + /** + * @param ?int $value + */ + public function setOwnerId(?int $value = null): self + { + $this->ownerId = $value; + return $this; + } + + /** + * @return ?int + */ + public function getAuthorId(): ?int + { + return $this->authorId; + } + + /** + * @param ?int $value + */ + public function setAuthorId(?int $value = null): self + { + $this->authorId = $value; + return $this; + } + + /** + * @return ?int + */ + public function getCreatedAt(): ?int + { + return $this->createdAt; + } + + /** + * @param ?int $value + */ + public function setCreatedAt(?int $value = null): self + { + $this->createdAt = $value; + return $this; + } + + /** + * @return ?int + */ + public function getUpdatedAt(): ?int + { + return $this->updatedAt; + } + + /** + * @param ?int $value + */ + public function setUpdatedAt(?int $value = null): self + { + $this->updatedAt = $value; + return $this; + } + + /** + * @return ?string + */ + public function getLocale(): ?string + { + return $this->locale; + } + + /** + * @param ?string $value + */ + public function setLocale(?string $value = null): self + { + $this->locale = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/InternalArticles/Types/InternalArticleSearchResponse.php b/src/InternalArticles/Types/InternalArticleSearchResponse.php new file mode 100644 index 0000000..bd420ad --- /dev/null +++ b/src/InternalArticles/Types/InternalArticleSearchResponse.php @@ -0,0 +1,130 @@ +type = $values['type'] ?? null; + $this->totalCount = $values['totalCount'] ?? null; + $this->data = $values['data'] ?? null; + $this->pages = $values['pages'] ?? null; + } + + /** + * @return ?'list' + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?'list' $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?int + */ + public function getTotalCount(): ?int + { + return $this->totalCount; + } + + /** + * @param ?int $value + */ + public function setTotalCount(?int $value = null): self + { + $this->totalCount = $value; + return $this; + } + + /** + * @return ?InternalArticleSearchResponseData + */ + public function getData(): ?InternalArticleSearchResponseData + { + return $this->data; + } + + /** + * @param ?InternalArticleSearchResponseData $value + */ + public function setData(?InternalArticleSearchResponseData $value = null): self + { + $this->data = $value; + return $this; + } + + /** + * @return ?CursorPages + */ + public function getPages(): ?CursorPages + { + return $this->pages; + } + + /** + * @param ?CursorPages $value + */ + public function setPages(?CursorPages $value = null): self + { + $this->pages = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/InternalArticles/Types/InternalArticleSearchResponseData.php b/src/InternalArticles/Types/InternalArticleSearchResponseData.php new file mode 100644 index 0000000..7dbcedd --- /dev/null +++ b/src/InternalArticles/Types/InternalArticleSearchResponseData.php @@ -0,0 +1,55 @@ + $internalArticles An array of Internal Article objects + */ + #[JsonProperty('internal_articles'), ArrayType([InternalArticleListItem::class])] + private ?array $internalArticles; + + /** + * @param array{ + * internalArticles?: ?array, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->internalArticles = $values['internalArticles'] ?? null; + } + + /** + * @return ?array + */ + public function getInternalArticles(): ?array + { + return $this->internalArticles; + } + + /** + * @param ?array $value + */ + public function setInternalArticles(?array $value = null): self + { + $this->internalArticles = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Jobs/JobsClient.php b/src/Jobs/JobsClient.php new file mode 100644 index 0000000..ccef60e --- /dev/null +++ b/src/Jobs/JobsClient.php @@ -0,0 +1,108 @@ +, + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator + */ + private array $options; + + /** + * @var RawClient $client + */ + private RawClient $client; + + /** + * @param RawClient $client + * @param ?array{ + * baseUrl?: string, + * client?: ClientInterface, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * } $options + */ + public function __construct( + RawClient $client, + ?array $options = null, + ) { + $this->client = $client; + $this->options = $options ?? []; + } + + /** + * Retrieve the status of job execution. + * + * @param JobsStatusRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return Jobs + * @throws IntercomException + * @throws IntercomApiException + */ + public function status(JobsStatusRequest $request, ?array $options = null): Jobs + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "jobs/status/{$request->getJobId()}", + method: HttpMethod::GET, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return Jobs::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } +} diff --git a/src/Jobs/Requests/JobsStatusRequest.php b/src/Jobs/Requests/JobsStatusRequest.php new file mode 100644 index 0000000..e5ee7be --- /dev/null +++ b/src/Jobs/Requests/JobsStatusRequest.php @@ -0,0 +1,41 @@ +jobId = $values['jobId']; + } + + /** + * @return string + */ + public function getJobId(): string + { + return $this->jobId; + } + + /** + * @param string $value + */ + public function setJobId(string $value): self + { + $this->jobId = $value; + return $this; + } +} diff --git a/src/Jobs/Types/Jobs.php b/src/Jobs/Types/Jobs.php new file mode 100644 index 0000000..6a096ea --- /dev/null +++ b/src/Jobs/Types/Jobs.php @@ -0,0 +1,204 @@ + $status The status of the job execution. + */ + #[JsonProperty('status')] + private ?string $status; + + /** + * @var ?string $resourceType The type of resource created during job execution. + */ + #[JsonProperty('resource_type')] + private ?string $resourceType; + + /** + * @var ?string $resourceId The id of the resource created during job execution (e.g. ticket id) + */ + #[JsonProperty('resource_id')] + private ?string $resourceId; + + /** + * @var ?string $resourceUrl The url of the resource created during job exeuction. Use this url to fetch the resource. + */ + #[JsonProperty('resource_url')] + private ?string $resourceUrl; + + /** + * @param array{ + * id: string, + * type?: ?'job', + * url?: ?string, + * status?: ?value-of, + * resourceType?: ?string, + * resourceId?: ?string, + * resourceUrl?: ?string, + * } $values + */ + public function __construct( + array $values, + ) { + $this->type = $values['type'] ?? null; + $this->id = $values['id']; + $this->url = $values['url'] ?? null; + $this->status = $values['status'] ?? null; + $this->resourceType = $values['resourceType'] ?? null; + $this->resourceId = $values['resourceId'] ?? null; + $this->resourceUrl = $values['resourceUrl'] ?? null; + } + + /** + * @return ?'job' + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?'job' $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return string + */ + public function getId(): string + { + return $this->id; + } + + /** + * @param string $value + */ + public function setId(string $value): self + { + $this->id = $value; + return $this; + } + + /** + * @return ?string + */ + public function getUrl(): ?string + { + return $this->url; + } + + /** + * @param ?string $value + */ + public function setUrl(?string $value = null): self + { + $this->url = $value; + return $this; + } + + /** + * @return ?value-of + */ + public function getStatus(): ?string + { + return $this->status; + } + + /** + * @param ?value-of $value + */ + public function setStatus(?string $value = null): self + { + $this->status = $value; + return $this; + } + + /** + * @return ?string + */ + public function getResourceType(): ?string + { + return $this->resourceType; + } + + /** + * @param ?string $value + */ + public function setResourceType(?string $value = null): self + { + $this->resourceType = $value; + return $this; + } + + /** + * @return ?string + */ + public function getResourceId(): ?string + { + return $this->resourceId; + } + + /** + * @param ?string $value + */ + public function setResourceId(?string $value = null): self + { + $this->resourceId = $value; + return $this; + } + + /** + * @return ?string + */ + public function getResourceUrl(): ?string + { + return $this->resourceUrl; + } + + /** + * @param ?string $value + */ + public function setResourceUrl(?string $value = null): self + { + $this->resourceUrl = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Jobs/Types/JobsStatus.php b/src/Jobs/Types/JobsStatus.php new file mode 100644 index 0000000..d613621 --- /dev/null +++ b/src/Jobs/Types/JobsStatus.php @@ -0,0 +1,10 @@ +, - * } $options + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator */ private array $options; @@ -64,7 +64,7 @@ public function __construct( * > * > As this is a message, there will be no conversation present until the contact responds. Once they do, you will have to search for a contact's conversations with the id of the message. * - * @param CreateMessageRequest $request + * @param ?CreateMessageRequest $request * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -77,7 +77,7 @@ public function __construct( * @throws IntercomException * @throws IntercomApiException */ - public function create(CreateMessageRequest $request, ?array $options = null): Message + public function create(?CreateMessageRequest $request = null, ?array $options = null): Message { $options = array_merge($this->options, $options ?? []); try { diff --git a/src/Messages/Types/Message.php b/src/Messages/Types/Message.php index 9572fd3..18bc460 100644 --- a/src/Messages/Types/Message.php +++ b/src/Messages/Types/Message.php @@ -29,10 +29,10 @@ class Message extends JsonSerializableType private int $createdAt; /** - * @var string $subject The subject of the message. Only present if message_type: email. + * @var ?string $subject The subject of the message. Only present if message_type: email. */ #[JsonProperty('subject')] - private string $subject; + private ?string $subject; /** * @var string $body The message body, which may contain HTML. @@ -47,20 +47,20 @@ class Message extends JsonSerializableType private string $messageType; /** - * @var string $conversationId The associated conversation_id + * @var ?string $conversationId The associated conversation_id */ #[JsonProperty('conversation_id')] - private string $conversationId; + private ?string $conversationId; /** * @param array{ * type: string, * id: string, * createdAt: int, - * subject: string, * body: string, * messageType: value-of, - * conversationId: string, + * subject?: ?string, + * conversationId?: ?string, * } $values */ public function __construct( @@ -69,10 +69,10 @@ public function __construct( $this->type = $values['type']; $this->id = $values['id']; $this->createdAt = $values['createdAt']; - $this->subject = $values['subject']; + $this->subject = $values['subject'] ?? null; $this->body = $values['body']; $this->messageType = $values['messageType']; - $this->conversationId = $values['conversationId']; + $this->conversationId = $values['conversationId'] ?? null; } /** @@ -127,17 +127,17 @@ public function setCreatedAt(int $value): self } /** - * @return string + * @return ?string */ - public function getSubject(): string + public function getSubject(): ?string { return $this->subject; } /** - * @param string $value + * @param ?string $value */ - public function setSubject(string $value): self + public function setSubject(?string $value = null): self { $this->subject = $value; return $this; @@ -178,17 +178,17 @@ public function setMessageType(string $value): self } /** - * @return string + * @return ?string */ - public function getConversationId(): string + public function getConversationId(): ?string { return $this->conversationId; } /** - * @param string $value + * @param ?string $value */ - public function setConversationId(string $value): self + public function setConversationId(?string $value = null): self { $this->conversationId = $value; return $this; diff --git a/src/News/Feeds/FeedsClient.php b/src/News/Feeds/FeedsClient.php index 82fdded..97e255b 100644 --- a/src/News/Feeds/FeedsClient.php +++ b/src/News/Feeds/FeedsClient.php @@ -5,7 +5,7 @@ use GuzzleHttp\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\News\Feeds\Requests\ListNewsFeedItemsRequest; -use Intercom\Types\PaginatedNewsItemResponse; +use Intercom\Types\PaginatedResponse; use Intercom\Exceptions\IntercomException; use Intercom\Exceptions\IntercomApiException; use Intercom\Core\Json\JsonApiRequest; @@ -14,7 +14,6 @@ use JsonException; use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; -use Intercom\Types\PaginatedNewsfeedResponse; use Intercom\News\Feeds\Requests\FindNewsFeedRequest; use Intercom\News\Types\Newsfeed; @@ -27,7 +26,7 @@ class FeedsClient * maxRetries?: int, * timeout?: float, * headers?: array, - * } $options + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator */ private array $options; @@ -66,11 +65,11 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return PaginatedNewsItemResponse + * @return PaginatedResponse * @throws IntercomException * @throws IntercomApiException */ - public function listItems(ListNewsFeedItemsRequest $request, ?array $options = null): PaginatedNewsItemResponse + public function listItems(ListNewsFeedItemsRequest $request, ?array $options = null): PaginatedResponse { $options = array_merge($this->options, $options ?? []); try { @@ -85,7 +84,7 @@ public function listItems(ListNewsFeedItemsRequest $request, ?array $options = n $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); - return PaginatedNewsItemResponse::fromJson($json); + return PaginatedResponse::fromJson($json); } } catch (JsonException $e) { throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); @@ -120,11 +119,11 @@ public function listItems(ListNewsFeedItemsRequest $request, ?array $options = n * queryParameters?: array, * bodyProperties?: array, * } $options - * @return PaginatedNewsfeedResponse + * @return PaginatedResponse * @throws IntercomException * @throws IntercomApiException */ - public function list(?array $options = null): PaginatedNewsfeedResponse + public function list(?array $options = null): PaginatedResponse { $options = array_merge($this->options, $options ?? []); try { @@ -139,7 +138,7 @@ public function list(?array $options = null): PaginatedNewsfeedResponse $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); - return PaginatedNewsfeedResponse::fromJson($json); + return PaginatedResponse::fromJson($json); } } catch (JsonException $e) { throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); diff --git a/src/News/Items/ItemsClient.php b/src/News/Items/ItemsClient.php index d6a5a64..f536ae3 100644 --- a/src/News/Items/ItemsClient.php +++ b/src/News/Items/ItemsClient.php @@ -4,7 +4,7 @@ use GuzzleHttp\ClientInterface; use Intercom\Core\Client\RawClient; -use Intercom\Types\PaginatedNewsItemResponse; +use Intercom\Types\PaginatedResponse; use Intercom\Exceptions\IntercomException; use Intercom\Exceptions\IntercomApiException; use Intercom\Core\Json\JsonApiRequest; @@ -29,7 +29,7 @@ class ItemsClient * maxRetries?: int, * timeout?: float, * headers?: array, - * } $options + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator */ private array $options; @@ -67,11 +67,11 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return PaginatedNewsItemResponse + * @return PaginatedResponse * @throws IntercomException * @throws IntercomApiException */ - public function list(?array $options = null): PaginatedNewsItemResponse + public function list(?array $options = null): PaginatedResponse { $options = array_merge($this->options, $options ?? []); try { @@ -86,7 +86,7 @@ public function list(?array $options = null): PaginatedNewsItemResponse $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); - return PaginatedNewsItemResponse::fromJson($json); + return PaginatedResponse::fromJson($json); } } catch (JsonException $e) { throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); diff --git a/src/News/Items/Requests/DeleteNewsItemRequest.php b/src/News/Items/Requests/DeleteNewsItemRequest.php index 395f60f..ffaeaaa 100644 --- a/src/News/Items/Requests/DeleteNewsItemRequest.php +++ b/src/News/Items/Requests/DeleteNewsItemRequest.php @@ -7,13 +7,13 @@ class DeleteNewsItemRequest extends JsonSerializableType { /** - * @var string $newsItemId The unique identifier for the news item which is given by Intercom. + * @var int $newsItemId The unique identifier for the news item which is given by Intercom. */ - private string $newsItemId; + private int $newsItemId; /** * @param array{ - * newsItemId: string, + * newsItemId: int, * } $values */ public function __construct( @@ -23,17 +23,17 @@ public function __construct( } /** - * @return string + * @return int */ - public function getNewsItemId(): string + public function getNewsItemId(): int { return $this->newsItemId; } /** - * @param string $value + * @param int $value */ - public function setNewsItemId(string $value): self + public function setNewsItemId(int $value): self { $this->newsItemId = $value; return $this; diff --git a/src/News/Items/Requests/FindNewsItemRequest.php b/src/News/Items/Requests/FindNewsItemRequest.php index c4ab230..9d019d4 100644 --- a/src/News/Items/Requests/FindNewsItemRequest.php +++ b/src/News/Items/Requests/FindNewsItemRequest.php @@ -7,13 +7,13 @@ class FindNewsItemRequest extends JsonSerializableType { /** - * @var string $newsItemId The unique identifier for the news item which is given by Intercom. + * @var int $newsItemId The unique identifier for the news item which is given by Intercom. */ - private string $newsItemId; + private int $newsItemId; /** * @param array{ - * newsItemId: string, + * newsItemId: int, * } $values */ public function __construct( @@ -23,17 +23,17 @@ public function __construct( } /** - * @return string + * @return int */ - public function getNewsItemId(): string + public function getNewsItemId(): int { return $this->newsItemId; } /** - * @param string $value + * @param int $value */ - public function setNewsItemId(string $value): self + public function setNewsItemId(int $value): self { $this->newsItemId = $value; return $this; diff --git a/src/News/Items/Requests/UpdateNewsItemRequest.php b/src/News/Items/Requests/UpdateNewsItemRequest.php index ee86162..79d0c2c 100644 --- a/src/News/Items/Requests/UpdateNewsItemRequest.php +++ b/src/News/Items/Requests/UpdateNewsItemRequest.php @@ -8,9 +8,9 @@ class UpdateNewsItemRequest extends JsonSerializableType { /** - * @var string $newsItemId The unique identifier for the news item which is given by Intercom. + * @var int $newsItemId The unique identifier for the news item which is given by Intercom. */ - private string $newsItemId; + private int $newsItemId; /** * @var NewsItemRequest $body @@ -19,7 +19,7 @@ class UpdateNewsItemRequest extends JsonSerializableType /** * @param array{ - * newsItemId: string, + * newsItemId: int, * body: NewsItemRequest, * } $values */ @@ -31,17 +31,17 @@ public function __construct( } /** - * @return string + * @return int */ - public function getNewsItemId(): string + public function getNewsItemId(): int { return $this->newsItemId; } /** - * @param string $value + * @param int $value */ - public function setNewsItemId(string $value): self + public function setNewsItemId(int $value): self { $this->newsItemId = $value; return $this; diff --git a/src/News/NewsClient.php b/src/News/NewsClient.php index 0c6d7a0..43dee00 100644 --- a/src/News/NewsClient.php +++ b/src/News/NewsClient.php @@ -26,7 +26,7 @@ class NewsClient * maxRetries?: int, * timeout?: float, * headers?: array, - * } $options + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator */ private array $options; diff --git a/src/News/Types/NewsItem.php b/src/News/Types/NewsItem.php index 9666a61..39403f5 100644 --- a/src/News/Types/NewsItem.php +++ b/src/News/Types/NewsItem.php @@ -13,46 +13,46 @@ class NewsItem extends JsonSerializableType { /** - * @var 'news-item' $type The type of object. + * @var ?'news-item' $type The type of object. */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var string $id The unique identifier for the news item which is given by Intercom. + * @var ?string $id The unique identifier for the news item which is given by Intercom. */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** - * @var string $workspaceId The id of the workspace which the news item belongs to. + * @var ?string $workspaceId The id of the workspace which the news item belongs to. */ #[JsonProperty('workspace_id')] - private string $workspaceId; + private ?string $workspaceId; /** - * @var string $title The title of the news item. + * @var ?string $title The title of the news item. */ #[JsonProperty('title')] - private string $title; + private ?string $title; /** - * @var string $body The news item body, which may contain HTML. + * @var ?string $body The news item body, which may contain HTML. */ #[JsonProperty('body')] - private string $body; + private ?string $body; /** - * @var int $senderId The id of the sender of the news item. Must be a teammate on the workspace. + * @var ?int $senderId The id of the sender of the news item. Must be a teammate on the workspace. */ #[JsonProperty('sender_id')] - private int $senderId; + private ?int $senderId; /** - * @var value-of $state News items will not be visible to your users in the assigned newsfeeds until they are set live. + * @var ?value-of $state News items will not be visible to your users in the assigned newsfeeds until they are set live. */ #[JsonProperty('state')] - private string $state; + private ?string $state; /** * @var ?array $newsfeedAssignments A list of newsfeed_assignments to assign to the specified newsfeed. @@ -85,10 +85,10 @@ class NewsItem extends JsonSerializableType private ?bool $deliverSilently; /** - * @var int $createdAt Timestamp for when the news item was created. + * @var ?int $createdAt Timestamp for when the news item was created. */ #[JsonProperty('created_at')] - private int $createdAt; + private ?int $createdAt; /** * @var ?int $updatedAt Timestamp for when the news item was last updated. @@ -98,155 +98,155 @@ class NewsItem extends JsonSerializableType /** * @param array{ - * type: 'news-item', - * id: string, - * workspaceId: string, - * title: string, - * body: string, - * senderId: int, - * state: value-of, - * createdAt: int, + * type?: ?'news-item', + * id?: ?string, + * workspaceId?: ?string, + * title?: ?string, + * body?: ?string, + * senderId?: ?int, + * state?: ?value-of, * newsfeedAssignments?: ?array, * labels?: ?array, * coverImageUrl?: ?string, * reactions?: ?array, * deliverSilently?: ?bool, + * createdAt?: ?int, * updatedAt?: ?int, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->id = $values['id']; - $this->workspaceId = $values['workspaceId']; - $this->title = $values['title']; - $this->body = $values['body']; - $this->senderId = $values['senderId']; - $this->state = $values['state']; + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->workspaceId = $values['workspaceId'] ?? null; + $this->title = $values['title'] ?? null; + $this->body = $values['body'] ?? null; + $this->senderId = $values['senderId'] ?? null; + $this->state = $values['state'] ?? null; $this->newsfeedAssignments = $values['newsfeedAssignments'] ?? null; $this->labels = $values['labels'] ?? null; $this->coverImageUrl = $values['coverImageUrl'] ?? null; $this->reactions = $values['reactions'] ?? null; $this->deliverSilently = $values['deliverSilently'] ?? null; - $this->createdAt = $values['createdAt']; + $this->createdAt = $values['createdAt'] ?? null; $this->updatedAt = $values['updatedAt'] ?? null; } /** - * @return 'news-item' + * @return ?'news-item' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'news-item' $value + * @param ?'news-item' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; } /** - * @return string + * @return ?string */ - public function getWorkspaceId(): string + public function getWorkspaceId(): ?string { return $this->workspaceId; } /** - * @param string $value + * @param ?string $value */ - public function setWorkspaceId(string $value): self + public function setWorkspaceId(?string $value = null): self { $this->workspaceId = $value; return $this; } /** - * @return string + * @return ?string */ - public function getTitle(): string + public function getTitle(): ?string { return $this->title; } /** - * @param string $value + * @param ?string $value */ - public function setTitle(string $value): self + public function setTitle(?string $value = null): self { $this->title = $value; return $this; } /** - * @return string + * @return ?string */ - public function getBody(): string + public function getBody(): ?string { return $this->body; } /** - * @param string $value + * @param ?string $value */ - public function setBody(string $value): self + public function setBody(?string $value = null): self { $this->body = $value; return $this; } /** - * @return int + * @return ?int */ - public function getSenderId(): int + public function getSenderId(): ?int { return $this->senderId; } /** - * @param int $value + * @param ?int $value */ - public function setSenderId(int $value): self + public function setSenderId(?int $value = null): self { $this->senderId = $value; return $this; } /** - * @return value-of + * @return ?value-of */ - public function getState(): string + public function getState(): ?string { return $this->state; } /** - * @param value-of $value + * @param ?value-of $value */ - public function setState(string $value): self + public function setState(?string $value = null): self { $this->state = $value; return $this; @@ -338,17 +338,17 @@ public function setDeliverSilently(?bool $value = null): self } /** - * @return int + * @return ?int */ - public function getCreatedAt(): int + public function getCreatedAt(): ?int { return $this->createdAt; } /** - * @param int $value + * @param ?int $value */ - public function setCreatedAt(int $value): self + public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; return $this; diff --git a/src/News/Types/Newsfeed.php b/src/News/Types/Newsfeed.php index 76e4150..406564e 100644 --- a/src/News/Types/Newsfeed.php +++ b/src/News/Types/Newsfeed.php @@ -13,28 +13,28 @@ class Newsfeed extends JsonSerializableType { /** - * @var string $id The unique identifier for the newsfeed which is given by Intercom. + * @var ?string $id The unique identifier for the newsfeed which is given by Intercom. */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** - * @var 'newsfeed' $type The type of object. + * @var ?'newsfeed' $type The type of object. */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var string $name The name of the newsfeed. This name will never be visible to your users. + * @var ?string $name The name of the newsfeed. This name will never be visible to your users. */ #[JsonProperty('name')] - private string $name; + private ?string $name; /** - * @var int $createdAt Timestamp for when the newsfeed was created. + * @var ?int $createdAt Timestamp for when the newsfeed was created. */ #[JsonProperty('created_at')] - private int $createdAt; + private ?int $createdAt; /** * @var ?int $updatedAt Timestamp for when the newsfeed was last updated. @@ -44,86 +44,86 @@ class Newsfeed extends JsonSerializableType /** * @param array{ - * id: string, - * type: 'newsfeed', - * name: string, - * createdAt: int, + * id?: ?string, + * type?: ?'newsfeed', + * name?: ?string, + * createdAt?: ?int, * updatedAt?: ?int, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->id = $values['id']; - $this->type = $values['type']; - $this->name = $values['name']; - $this->createdAt = $values['createdAt']; + $this->id = $values['id'] ?? null; + $this->type = $values['type'] ?? null; + $this->name = $values['name'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; $this->updatedAt = $values['updatedAt'] ?? null; } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; } /** - * @return 'newsfeed' + * @return ?'newsfeed' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'newsfeed' $value + * @param ?'newsfeed' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return string + * @return ?string */ - public function getName(): string + public function getName(): ?string { return $this->name; } /** - * @param string $value + * @param ?string $value */ - public function setName(string $value): self + public function setName(?string $value = null): self { $this->name = $value; return $this; } /** - * @return int + * @return ?int */ - public function getCreatedAt(): int + public function getCreatedAt(): ?int { return $this->createdAt; } /** - * @param int $value + * @param ?int $value */ - public function setCreatedAt(int $value): self + public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; return $this; diff --git a/src/News/Types/NewsfeedAssignment.php b/src/News/Types/NewsfeedAssignment.php index eff051f..58995f6 100644 --- a/src/News/Types/NewsfeedAssignment.php +++ b/src/News/Types/NewsfeedAssignment.php @@ -11,59 +11,59 @@ class NewsfeedAssignment extends JsonSerializableType { /** - * @var int $newsfeedId 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). + * @var ?int $newsfeedId 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')] - private int $newsfeedId; + private ?int $newsfeedId; /** - * @var int $publishedAt 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". + * @var ?int $publishedAt 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')] - private int $publishedAt; + private ?int $publishedAt; /** * @param array{ - * newsfeedId: int, - * publishedAt: int, + * newsfeedId?: ?int, + * publishedAt?: ?int, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->newsfeedId = $values['newsfeedId']; - $this->publishedAt = $values['publishedAt']; + $this->newsfeedId = $values['newsfeedId'] ?? null; + $this->publishedAt = $values['publishedAt'] ?? null; } /** - * @return int + * @return ?int */ - public function getNewsfeedId(): int + public function getNewsfeedId(): ?int { return $this->newsfeedId; } /** - * @param int $value + * @param ?int $value */ - public function setNewsfeedId(int $value): self + public function setNewsfeedId(?int $value = null): self { $this->newsfeedId = $value; return $this; } /** - * @return int + * @return ?int */ - public function getPublishedAt(): int + public function getPublishedAt(): ?int { return $this->publishedAt; } /** - * @param int $value + * @param ?int $value */ - public function setPublishedAt(int $value): self + public function setPublishedAt(?int $value = null): self { $this->publishedAt = $value; return $this; diff --git a/src/Notes/NotesClient.php b/src/Notes/NotesClient.php index eb0f5f9..4e36c93 100644 --- a/src/Notes/NotesClient.php +++ b/src/Notes/NotesClient.php @@ -29,7 +29,7 @@ class NotesClient * maxRetries?: int, * timeout?: float, * headers?: array, - * } $options + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator */ private array $options; diff --git a/src/Notes/Requests/FindNoteRequest.php b/src/Notes/Requests/FindNoteRequest.php index 1e3cede..7142d97 100644 --- a/src/Notes/Requests/FindNoteRequest.php +++ b/src/Notes/Requests/FindNoteRequest.php @@ -7,13 +7,13 @@ class FindNoteRequest extends JsonSerializableType { /** - * @var string $noteId The unique identifier of a given note + * @var int $noteId The unique identifier of a given note */ - private string $noteId; + private int $noteId; /** * @param array{ - * noteId: string, + * noteId: int, * } $values */ public function __construct( @@ -23,17 +23,17 @@ public function __construct( } /** - * @return string + * @return int */ - public function getNoteId(): string + public function getNoteId(): int { return $this->noteId; } /** - * @param string $value + * @param int $value */ - public function setNoteId(string $value): self + public function setNoteId(int $value): self { $this->noteId = $value; return $this; diff --git a/src/Notes/Types/Note.php b/src/Notes/Types/Note.php index f1cf502..5e47daa 100644 --- a/src/Notes/Types/Note.php +++ b/src/Notes/Types/Note.php @@ -12,22 +12,22 @@ class Note extends JsonSerializableType { /** - * @var 'note' $type String representing the object's type. Always has the value `note`. + * @var ?string $type String representing the object's type. Always has the value `note`. */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var string $id The id of the note. + * @var ?string $id The id of the note. */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** - * @var int $createdAt The time the note was created. + * @var ?int $createdAt The time the note was created. */ #[JsonProperty('created_at')] - private int $createdAt; + private ?int $createdAt; /** * @var ?NoteContact $contact Represents the contact that the note was created about. @@ -36,84 +36,84 @@ class Note extends JsonSerializableType private ?NoteContact $contact; /** - * @var Admin $author Optional. Represents the Admin that created the note. + * @var ?Admin $author Optional. Represents the Admin that created the note. */ #[JsonProperty('author')] - private Admin $author; + private ?Admin $author; /** - * @var string $body The body text of the note. + * @var ?string $body The body text of the note. */ #[JsonProperty('body')] - private string $body; + private ?string $body; /** * @param array{ - * type: 'note', - * id: string, - * createdAt: int, - * author: Admin, - * body: string, + * type?: ?string, + * id?: ?string, + * createdAt?: ?int, * contact?: ?NoteContact, + * author?: ?Admin, + * body?: ?string, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->id = $values['id']; - $this->createdAt = $values['createdAt']; + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; $this->contact = $values['contact'] ?? null; - $this->author = $values['author']; - $this->body = $values['body']; + $this->author = $values['author'] ?? null; + $this->body = $values['body'] ?? null; } /** - * @return 'note' + * @return ?string */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'note' $value + * @param ?string $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; } /** - * @return int + * @return ?int */ - public function getCreatedAt(): int + public function getCreatedAt(): ?int { return $this->createdAt; } /** - * @param int $value + * @param ?int $value */ - public function setCreatedAt(int $value): self + public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; return $this; @@ -137,34 +137,34 @@ public function setContact(?NoteContact $value = null): self } /** - * @return Admin + * @return ?Admin */ - public function getAuthor(): Admin + public function getAuthor(): ?Admin { return $this->author; } /** - * @param Admin $value + * @param ?Admin $value */ - public function setAuthor(Admin $value): self + public function setAuthor(?Admin $value = null): self { $this->author = $value; return $this; } /** - * @return string + * @return ?string */ - public function getBody(): string + public function getBody(): ?string { return $this->body; } /** - * @param string $value + * @param ?string $value */ - public function setBody(string $value): self + public function setBody(?string $value = null): self { $this->body = $value; return $this; diff --git a/src/Notes/Types/NoteContact.php b/src/Notes/Types/NoteContact.php index fc3623b..d6b0fc1 100644 --- a/src/Notes/Types/NoteContact.php +++ b/src/Notes/Types/NoteContact.php @@ -11,7 +11,7 @@ class NoteContact extends JsonSerializableType { /** - * @var ?'contact' $type String representing the object's type. Always has the value `contact`. + * @var ?string $type String representing the object's type. Always has the value `contact`. */ #[JsonProperty('type')] private ?string $type; @@ -24,7 +24,7 @@ class NoteContact extends JsonSerializableType /** * @param array{ - * type?: ?'contact', + * type?: ?string, * id?: ?string, * } $values */ @@ -36,7 +36,7 @@ public function __construct( } /** - * @return ?'contact' + * @return ?string */ public function getType(): ?string { @@ -44,7 +44,7 @@ public function getType(): ?string } /** - * @param ?'contact' $value + * @param ?string $value */ public function setType(?string $value = null): self { diff --git a/src/PhoneCallRedirects/PhoneCallRedirectsClient.php b/src/PhoneCallRedirects/PhoneCallRedirectsClient.php index bc05457..194ef68 100644 --- a/src/PhoneCallRedirects/PhoneCallRedirectsClient.php +++ b/src/PhoneCallRedirects/PhoneCallRedirectsClient.php @@ -4,7 +4,7 @@ use GuzzleHttp\ClientInterface; use Intercom\Core\Client\RawClient; -use Intercom\PhoneCallRedirects\Requests\CreatePhoneCallRedirectRequest; +use Intercom\Types\CreatePhoneSwitchRequest; use Intercom\Types\PhoneSwitch; use Intercom\Exceptions\IntercomException; use Intercom\Exceptions\IntercomApiException; @@ -24,7 +24,7 @@ class PhoneCallRedirectsClient * maxRetries?: int, * timeout?: float, * headers?: array, - * } $options + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator */ private array $options; @@ -57,7 +57,7 @@ public function __construct( * * If custom attributes are specified, they will be added to the user or lead's custom data attributes. * - * @param CreatePhoneCallRedirectRequest $request + * @param ?CreatePhoneSwitchRequest $request * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -66,11 +66,11 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return PhoneSwitch + * @return ?PhoneSwitch * @throws IntercomException * @throws IntercomApiException */ - public function create(CreatePhoneCallRedirectRequest $request, ?array $options = null): PhoneSwitch + public function create(?CreatePhoneSwitchRequest $request = null, ?array $options = null): ?PhoneSwitch { $options = array_merge($this->options, $options ?? []); try { @@ -86,6 +86,9 @@ public function create(CreatePhoneCallRedirectRequest $request, ?array $options $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return PhoneSwitch::fromJson($json); } } catch (JsonException $e) { diff --git a/src/Segments/SegmentsClient.php b/src/Segments/SegmentsClient.php index 9d96d43..0d883fb 100644 --- a/src/Segments/SegmentsClient.php +++ b/src/Segments/SegmentsClient.php @@ -26,7 +26,7 @@ class SegmentsClient * maxRetries?: int, * timeout?: float, * headers?: array, - * } $options + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator */ private array $options; diff --git a/src/Segments/Types/Segment.php b/src/Segments/Types/Segment.php index 77799c9..5dac3f5 100644 --- a/src/Segments/Types/Segment.php +++ b/src/Segments/Types/Segment.php @@ -11,28 +11,28 @@ class Segment extends JsonSerializableType { /** - * @var 'segment' $type The type of object. + * @var ?'segment' $type The type of object. */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var string $id The unique identifier representing the segment. + * @var ?string $id The unique identifier representing the segment. */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** - * @var string $name The name of the segment. + * @var ?string $name The name of the segment. */ #[JsonProperty('name')] - private string $name; + private ?string $name; /** - * @var int $createdAt The time the segment was created. + * @var ?int $createdAt The time the segment was created. */ #[JsonProperty('created_at')] - private int $createdAt; + private ?int $createdAt; /** * @var ?int $updatedAt The time the segment was updated. @@ -41,10 +41,10 @@ class Segment extends JsonSerializableType private ?int $updatedAt; /** - * @var value-of $personType Type of the contact: contact (lead) or user. + * @var ?value-of $personType Type of the contact: contact (lead) or user. */ #[JsonProperty('person_type')] - private string $personType; + private ?string $personType; /** * @var ?int $count The number of items in the user segment. It's returned when `include_count=true` is included in the request. @@ -54,90 +54,90 @@ class Segment extends JsonSerializableType /** * @param array{ - * type: 'segment', - * id: string, - * name: string, - * createdAt: int, - * personType: value-of, + * type?: ?'segment', + * id?: ?string, + * name?: ?string, + * createdAt?: ?int, * updatedAt?: ?int, + * personType?: ?value-of, * count?: ?int, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->id = $values['id']; - $this->name = $values['name']; - $this->createdAt = $values['createdAt']; + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->name = $values['name'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; $this->updatedAt = $values['updatedAt'] ?? null; - $this->personType = $values['personType']; + $this->personType = $values['personType'] ?? null; $this->count = $values['count'] ?? null; } /** - * @return 'segment' + * @return ?'segment' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'segment' $value + * @param ?'segment' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; } /** - * @return string + * @return ?string */ - public function getName(): string + public function getName(): ?string { return $this->name; } /** - * @param string $value + * @param ?string $value */ - public function setName(string $value): self + public function setName(?string $value = null): self { $this->name = $value; return $this; } /** - * @return int + * @return ?int */ - public function getCreatedAt(): int + public function getCreatedAt(): ?int { return $this->createdAt; } /** - * @param int $value + * @param ?int $value */ - public function setCreatedAt(int $value): self + public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; return $this; @@ -161,17 +161,17 @@ public function setUpdatedAt(?int $value = null): self } /** - * @return value-of + * @return ?value-of */ - public function getPersonType(): string + public function getPersonType(): ?string { return $this->personType; } /** - * @param value-of $value + * @param ?value-of $value */ - public function setPersonType(string $value): self + public function setPersonType(?string $value = null): self { $this->personType = $value; return $this; diff --git a/src/SubscriptionTypes/SubscriptionTypesClient.php b/src/SubscriptionTypes/SubscriptionTypesClient.php index 7485bc8..a1eb02d 100644 --- a/src/SubscriptionTypes/SubscriptionTypesClient.php +++ b/src/SubscriptionTypes/SubscriptionTypesClient.php @@ -23,7 +23,7 @@ class SubscriptionTypesClient * maxRetries?: int, * timeout?: float, * headers?: array, - * } $options + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator */ private array $options; diff --git a/src/SubscriptionTypes/Types/SubscriptionType.php b/src/SubscriptionTypes/Types/SubscriptionType.php index f2f03cb..78c12fd 100644 --- a/src/SubscriptionTypes/Types/SubscriptionType.php +++ b/src/SubscriptionTypes/Types/SubscriptionType.php @@ -13,184 +13,184 @@ class SubscriptionType extends JsonSerializableType { /** - * @var 'subscription' $type The type of the object - subscription + * @var ?'subscription' $type The type of the object - subscription */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var string $id The unique identifier representing the subscription type. + * @var ?string $id The unique identifier representing the subscription type. */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** - * @var value-of $state The state of the subscription type. + * @var ?value-of $state The state of the subscription type. */ #[JsonProperty('state')] - private string $state; + private ?string $state; /** - * @var Translation $defaultTranslation + * @var ?Translation $defaultTranslation */ #[JsonProperty('default_translation')] - private Translation $defaultTranslation; + private ?Translation $defaultTranslation; /** - * @var array $translations An array of translations objects with the localised version of the subscription type in each available locale within your translation settings. + * @var ?array $translations An array of translations objects with the localised version of the subscription type in each available locale within your translation settings. */ #[JsonProperty('translations'), ArrayType([Translation::class])] - private array $translations; + private ?array $translations; /** - * @var value-of $consentType Describes the type of consent. + * @var ?value-of $consentType Describes the type of consent. */ #[JsonProperty('consent_type')] - private string $consentType; + private ?string $consentType; /** - * @var array> $contentTypes The message types that this subscription supports - can contain `email` or `sms_message`. + * @var ?array> $contentTypes The message types that this subscription supports - can contain `email` or `sms_message`. */ #[JsonProperty('content_types'), ArrayType(['string'])] - private array $contentTypes; + private ?array $contentTypes; /** * @param array{ - * type: 'subscription', - * id: string, - * state: value-of, - * defaultTranslation: Translation, - * translations: array, - * consentType: value-of, - * contentTypes: array>, + * type?: ?'subscription', + * id?: ?string, + * state?: ?value-of, + * defaultTranslation?: ?Translation, + * translations?: ?array, + * consentType?: ?value-of, + * contentTypes?: ?array>, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->id = $values['id']; - $this->state = $values['state']; - $this->defaultTranslation = $values['defaultTranslation']; - $this->translations = $values['translations']; - $this->consentType = $values['consentType']; - $this->contentTypes = $values['contentTypes']; + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->state = $values['state'] ?? null; + $this->defaultTranslation = $values['defaultTranslation'] ?? null; + $this->translations = $values['translations'] ?? null; + $this->consentType = $values['consentType'] ?? null; + $this->contentTypes = $values['contentTypes'] ?? null; } /** - * @return 'subscription' + * @return ?'subscription' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'subscription' $value + * @param ?'subscription' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; } /** - * @return value-of + * @return ?value-of */ - public function getState(): string + public function getState(): ?string { return $this->state; } /** - * @param value-of $value + * @param ?value-of $value */ - public function setState(string $value): self + public function setState(?string $value = null): self { $this->state = $value; return $this; } /** - * @return Translation + * @return ?Translation */ - public function getDefaultTranslation(): Translation + public function getDefaultTranslation(): ?Translation { return $this->defaultTranslation; } /** - * @param Translation $value + * @param ?Translation $value */ - public function setDefaultTranslation(Translation $value): self + public function setDefaultTranslation(?Translation $value = null): self { $this->defaultTranslation = $value; return $this; } /** - * @return array + * @return ?array */ - public function getTranslations(): array + public function getTranslations(): ?array { return $this->translations; } /** - * @param array $value + * @param ?array $value */ - public function setTranslations(array $value): self + public function setTranslations(?array $value = null): self { $this->translations = $value; return $this; } /** - * @return value-of + * @return ?value-of */ - public function getConsentType(): string + public function getConsentType(): ?string { return $this->consentType; } /** - * @param value-of $value + * @param ?value-of $value */ - public function setConsentType(string $value): self + public function setConsentType(?string $value = null): self { $this->consentType = $value; return $this; } /** - * @return array> + * @return ?array> */ - public function getContentTypes(): array + public function getContentTypes(): ?array { return $this->contentTypes; } /** - * @param array> $value + * @param ?array> $value */ - public function setContentTypes(array $value): self + public function setContentTypes(?array $value = null): self { $this->contentTypes = $value; return $this; diff --git a/src/Tags/Requests/UntagConversationRequest.php b/src/Tags/Requests/UntagConversationRequest.php index 04f641e..5ea02a2 100644 --- a/src/Tags/Requests/UntagConversationRequest.php +++ b/src/Tags/Requests/UntagConversationRequest.php @@ -13,7 +13,7 @@ class UntagConversationRequest extends JsonSerializableType private string $conversationId; /** - * @var string $tagId id + * @var string $tagId tag_id */ private string $tagId; diff --git a/src/Tags/TagsClient.php b/src/Tags/TagsClient.php index befceb3..7523027 100644 --- a/src/Tags/TagsClient.php +++ b/src/Tags/TagsClient.php @@ -38,7 +38,7 @@ class TagsClient * maxRetries?: int, * timeout?: float, * headers?: array, - * } $options + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator */ private array $options; @@ -291,6 +291,7 @@ public function untagConversation(UntagConversationRequest $request, ?array $opt /** * You can fetch a list of all tags for a given workspace. * + * * @param ?array{ * baseUrl?: string, * maxRetries?: int, diff --git a/src/Tags/Types/TagBasic.php b/src/Tags/Types/TagBasic.php new file mode 100644 index 0000000..db26e45 --- /dev/null +++ b/src/Tags/Types/TagBasic.php @@ -0,0 +1,104 @@ +type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->name = $values['name'] ?? null; + } + + /** + * @return ?string + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?string $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?string + */ + public function getId(): ?string + { + return $this->id; + } + + /** + * @param ?string $value + */ + public function setId(?string $value = null): self + { + $this->id = $value; + return $this; + } + + /** + * @return ?string + */ + public function getName(): ?string + { + return $this->name; + } + + /** + * @param ?string $value + */ + public function setName(?string $value = null): self + { + $this->name = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Teams/TeamsClient.php b/src/Teams/TeamsClient.php index 29e949d..2e1d01e 100644 --- a/src/Teams/TeamsClient.php +++ b/src/Teams/TeamsClient.php @@ -25,7 +25,7 @@ class TeamsClient * maxRetries?: int, * timeout?: float, * headers?: array, - * } $options + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator */ private array $options; diff --git a/src/Teams/Types/Team.php b/src/Teams/Types/Team.php index 7c4dd31..5d01501 100644 --- a/src/Teams/Types/Team.php +++ b/src/Teams/Types/Team.php @@ -13,28 +13,28 @@ class Team extends JsonSerializableType { /** - * @var 'team' $type Value is always "team" + * @var ?string $type Value is always "team" */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var string $id The id of the team + * @var ?string $id The id of the team */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** - * @var string $name The name of the team + * @var ?string $name The name of the team */ #[JsonProperty('name')] - private string $name; + private ?string $name; /** - * @var array $adminIds The list of admin IDs that are a part of the team. + * @var ?array $adminIds The list of admin IDs that are a part of the team. */ #[JsonProperty('admin_ids'), ArrayType(['integer'])] - private array $adminIds; + private ?array $adminIds; /** * @var ?AdminPriorityLevel $adminPriorityLevel @@ -42,88 +42,104 @@ class Team extends JsonSerializableType #[JsonProperty('admin_priority_level')] private ?AdminPriorityLevel $adminPriorityLevel; + /** + * @var ?int $assignmentLimit The assignment limit for the team. This field is only present when the team's distribution type is load balanced. + */ + #[JsonProperty('assignment_limit')] + private ?int $assignmentLimit; + + /** + * @var ?string $distributionMethod Describes how assignments are distributed among the team members + */ + #[JsonProperty('distribution_method')] + private ?string $distributionMethod; + /** * @param array{ - * type: 'team', - * id: string, - * name: string, - * adminIds: array, + * type?: ?string, + * id?: ?string, + * name?: ?string, + * adminIds?: ?array, * adminPriorityLevel?: ?AdminPriorityLevel, + * assignmentLimit?: ?int, + * distributionMethod?: ?string, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->id = $values['id']; - $this->name = $values['name']; - $this->adminIds = $values['adminIds']; + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->name = $values['name'] ?? null; + $this->adminIds = $values['adminIds'] ?? null; $this->adminPriorityLevel = $values['adminPriorityLevel'] ?? null; + $this->assignmentLimit = $values['assignmentLimit'] ?? null; + $this->distributionMethod = $values['distributionMethod'] ?? null; } /** - * @return 'team' + * @return ?string */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'team' $value + * @param ?string $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; } /** - * @return string + * @return ?string */ - public function getName(): string + public function getName(): ?string { return $this->name; } /** - * @param string $value + * @param ?string $value */ - public function setName(string $value): self + public function setName(?string $value = null): self { $this->name = $value; return $this; } /** - * @return array + * @return ?array */ - public function getAdminIds(): array + public function getAdminIds(): ?array { return $this->adminIds; } /** - * @param array $value + * @param ?array $value */ - public function setAdminIds(array $value): self + public function setAdminIds(?array $value = null): self { $this->adminIds = $value; return $this; @@ -146,6 +162,40 @@ public function setAdminPriorityLevel(?AdminPriorityLevel $value = null): self return $this; } + /** + * @return ?int + */ + public function getAssignmentLimit(): ?int + { + return $this->assignmentLimit; + } + + /** + * @param ?int $value + */ + public function setAssignmentLimit(?int $value = null): self + { + $this->assignmentLimit = $value; + return $this; + } + + /** + * @return ?string + */ + public function getDistributionMethod(): ?string + { + return $this->distributionMethod; + } + + /** + * @param ?string $value + */ + public function setDistributionMethod(?string $value = null): self + { + $this->distributionMethod = $value; + return $this; + } + /** * @return string */ diff --git a/src/TicketStates/TicketStatesClient.php b/src/TicketStates/TicketStatesClient.php new file mode 100644 index 0000000..0b77d62 --- /dev/null +++ b/src/TicketStates/TicketStatesClient.php @@ -0,0 +1,106 @@ +, + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator + */ + private array $options; + + /** + * @var RawClient $client + */ + private RawClient $client; + + /** + * @param RawClient $client + * @param ?array{ + * baseUrl?: string, + * client?: ClientInterface, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * } $options + */ + public function __construct( + RawClient $client, + ?array $options = null, + ) { + $this->client = $client; + $this->options = $options ?? []; + } + + /** + * You can get a list of all ticket states for a workspace. + * + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return TicketStateList + * @throws IntercomException + * @throws IntercomApiException + */ + public function listTicketStates(?array $options = null): TicketStateList + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "ticket_states", + method: HttpMethod::GET, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return TicketStateList::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } +} diff --git a/src/TicketTypes/Attributes/AttributesClient.php b/src/TicketTypes/Attributes/AttributesClient.php index 4ce5155..1708e58 100644 --- a/src/TicketTypes/Attributes/AttributesClient.php +++ b/src/TicketTypes/Attributes/AttributesClient.php @@ -25,7 +25,7 @@ class AttributesClient * maxRetries?: int, * timeout?: float, * headers?: array, - * } $options + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator */ private array $options; @@ -64,11 +64,11 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return TicketTypeAttribute + * @return ?TicketTypeAttribute * @throws IntercomException * @throws IntercomApiException */ - public function create(CreateTicketTypeAttributeRequest $request, ?array $options = null): TicketTypeAttribute + public function create(CreateTicketTypeAttributeRequest $request, ?array $options = null): ?TicketTypeAttribute { $options = array_merge($this->options, $options ?? []); try { @@ -84,6 +84,9 @@ public function create(CreateTicketTypeAttributeRequest $request, ?array $option $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return TicketTypeAttribute::fromJson($json); } } catch (JsonException $e) { @@ -120,11 +123,11 @@ public function create(CreateTicketTypeAttributeRequest $request, ?array $option * queryParameters?: array, * bodyProperties?: array, * } $options - * @return TicketTypeAttribute + * @return ?TicketTypeAttribute * @throws IntercomException * @throws IntercomApiException */ - public function update(UpdateTicketTypeAttributeRequest $request, ?array $options = null): TicketTypeAttribute + public function update(UpdateTicketTypeAttributeRequest $request, ?array $options = null): ?TicketTypeAttribute { $options = array_merge($this->options, $options ?? []); try { @@ -140,6 +143,9 @@ public function update(UpdateTicketTypeAttributeRequest $request, ?array $option $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return TicketTypeAttribute::fromJson($json); } } catch (JsonException $e) { diff --git a/src/TicketTypes/Requests/UpdateTicketTypeRequest.php b/src/TicketTypes/Requests/UpdateTicketTypeRequest.php index d6d02f2..b3b7a62 100644 --- a/src/TicketTypes/Requests/UpdateTicketTypeRequest.php +++ b/src/TicketTypes/Requests/UpdateTicketTypeRequest.php @@ -4,7 +4,7 @@ use Intercom\Core\Json\JsonSerializableType; use Intercom\Core\Json\JsonProperty; -use Intercom\TicketTypes\Types\UpdateTicketTypeRequestBodyCategory; +use Intercom\TicketTypes\Types\UpdateTicketTypeRequestCategory; class UpdateTicketTypeRequest extends JsonSerializableType { @@ -26,7 +26,7 @@ class UpdateTicketTypeRequest extends JsonSerializableType private ?string $description; /** - * @var ?value-of $category Category of the Ticket Type. + * @var ?value-of $category Category of the Ticket Type. */ #[JsonProperty('category')] private ?string $category; @@ -54,7 +54,7 @@ class UpdateTicketTypeRequest extends JsonSerializableType * ticketTypeId: string, * name?: ?string, * description?: ?string, - * category?: ?value-of, + * category?: ?value-of, * icon?: ?string, * archived?: ?bool, * isInternal?: ?bool, @@ -124,7 +124,7 @@ public function setDescription(?string $value = null): self } /** - * @return ?value-of + * @return ?value-of */ public function getCategory(): ?string { @@ -132,7 +132,7 @@ public function getCategory(): ?string } /** - * @param ?value-of $value + * @param ?value-of $value */ public function setCategory(?string $value = null): self { diff --git a/src/TicketTypes/TicketTypesClient.php b/src/TicketTypes/TicketTypesClient.php index 8b179fa..ede3f0e 100644 --- a/src/TicketTypes/TicketTypesClient.php +++ b/src/TicketTypes/TicketTypesClient.php @@ -14,7 +14,7 @@ use JsonException; use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; -use Intercom\TicketTypes\Requests\CreateTicketTypeRequest; +use Intercom\Types\CreateTicketTypeRequest; use Intercom\Tickets\Types\TicketType; use Intercom\TicketTypes\Requests\FindTicketTypeRequest; use Intercom\TicketTypes\Requests\UpdateTicketTypeRequest; @@ -33,7 +33,7 @@ class TicketTypesClient * maxRetries?: int, * timeout?: float, * headers?: array, - * } $options + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator */ private array $options; @@ -122,7 +122,7 @@ public function list(?array $options = null): TicketTypeList * > Every ticket type will be created with two default attributes: _default_title_ and _default_description_. * > For the `icon` propery, use an emoji from [Twemoji Cheatsheet](https://twemoji-cheatsheet.vercel.app/) * - * @param CreateTicketTypeRequest $request + * @param ?CreateTicketTypeRequest $request * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -131,11 +131,11 @@ public function list(?array $options = null): TicketTypeList * queryParameters?: array, * bodyProperties?: array, * } $options - * @return TicketType + * @return ?TicketType * @throws IntercomException * @throws IntercomApiException */ - public function create(CreateTicketTypeRequest $request, ?array $options = null): TicketType + public function create(?CreateTicketTypeRequest $request = null, ?array $options = null): ?TicketType { $options = array_merge($this->options, $options ?? []); try { @@ -151,6 +151,9 @@ public function create(CreateTicketTypeRequest $request, ?array $options = null) $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return TicketType::fromJson($json); } } catch (JsonException $e) { @@ -187,11 +190,11 @@ public function create(CreateTicketTypeRequest $request, ?array $options = null) * queryParameters?: array, * bodyProperties?: array, * } $options - * @return TicketType + * @return ?TicketType * @throws IntercomException * @throws IntercomApiException */ - public function get(FindTicketTypeRequest $request, ?array $options = null): TicketType + public function get(FindTicketTypeRequest $request, ?array $options = null): ?TicketType { $options = array_merge($this->options, $options ?? []); try { @@ -206,6 +209,9 @@ public function get(FindTicketTypeRequest $request, ?array $options = null): Tic $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return TicketType::fromJson($json); } } catch (JsonException $e) { @@ -247,11 +253,11 @@ public function get(FindTicketTypeRequest $request, ?array $options = null): Tic * queryParameters?: array, * bodyProperties?: array, * } $options - * @return TicketType + * @return ?TicketType * @throws IntercomException * @throws IntercomApiException */ - public function update(UpdateTicketTypeRequest $request, ?array $options = null): TicketType + public function update(UpdateTicketTypeRequest $request, ?array $options = null): ?TicketType { $options = array_merge($this->options, $options ?? []); try { @@ -267,6 +273,9 @@ public function update(UpdateTicketTypeRequest $request, ?array $options = null) $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return TicketType::fromJson($json); } } catch (JsonException $e) { diff --git a/src/Unstable/Types/UpdateTicketTypeRequestCategory.php b/src/TicketTypes/Types/UpdateTicketTypeRequestCategory.php similarity index 80% rename from src/Unstable/Types/UpdateTicketTypeRequestCategory.php rename to src/TicketTypes/Types/UpdateTicketTypeRequestCategory.php index afab4ff..8cbdebc 100644 --- a/src/Unstable/Types/UpdateTicketTypeRequestCategory.php +++ b/src/TicketTypes/Types/UpdateTicketTypeRequestCategory.php @@ -1,6 +1,6 @@ , + * skipNotifications?: ?bool, + * conversationToLinkId?: ?string, + * companyId?: ?string, + * createdAt?: ?int, + * assignment?: ?CreateTicketRequestAssignment, + * } $values + */ + public function __construct( + array $values, + ) { + $this->skipNotifications = $values['skipNotifications'] ?? null; + $this->ticketTypeId = $values['ticketTypeId']; + $this->contacts = $values['contacts']; + $this->conversationToLinkId = $values['conversationToLinkId'] ?? null; + $this->companyId = $values['companyId'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; + $this->assignment = $values['assignment'] ?? null; + } + + /** + * @return ?bool + */ + public function getSkipNotifications(): ?bool + { + return $this->skipNotifications; + } + + /** + * @param ?bool $value + */ + public function setSkipNotifications(?bool $value = null): self + { + $this->skipNotifications = $value; + return $this; + } +} diff --git a/src/Tickets/Requests/DeleteTicketRequest.php b/src/Tickets/Requests/DeleteTicketRequest.php new file mode 100644 index 0000000..baaf0c8 --- /dev/null +++ b/src/Tickets/Requests/DeleteTicketRequest.php @@ -0,0 +1,41 @@ +ticketId = $values['ticketId']; + } + + /** + * @return string + */ + public function getTicketId(): string + { + return $this->ticketId; + } + + /** + * @param string $value + */ + public function setTicketId(string $value): self + { + $this->ticketId = $value; + return $this; + } +} diff --git a/src/Tickets/Requests/EnqueueCreateTicketRequest.php b/src/Tickets/Requests/EnqueueCreateTicketRequest.php new file mode 100644 index 0000000..ae05130 --- /dev/null +++ b/src/Tickets/Requests/EnqueueCreateTicketRequest.php @@ -0,0 +1,66 @@ +, + * skipNotifications?: ?bool, + * conversationToLinkId?: ?string, + * companyId?: ?string, + * createdAt?: ?int, + * assignment?: ?CreateTicketRequestAssignment, + * } $values + */ + public function __construct( + array $values, + ) { + $this->skipNotifications = $values['skipNotifications'] ?? null; + $this->ticketTypeId = $values['ticketTypeId']; + $this->contacts = $values['contacts']; + $this->conversationToLinkId = $values['conversationToLinkId'] ?? null; + $this->companyId = $values['companyId'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; + $this->assignment = $values['assignment'] ?? null; + } + + /** + * @return ?bool + */ + public function getSkipNotifications(): ?bool + { + return $this->skipNotifications; + } + + /** + * @param ?bool $value + */ + public function setSkipNotifications(?bool $value = null): self + { + $this->skipNotifications = $value; + return $this; + } +} diff --git a/src/Tickets/Requests/UpdateTicketRequest.php b/src/Tickets/Requests/UpdateTicketRequest.php index ee986ee..97dc6cd 100644 --- a/src/Tickets/Requests/UpdateTicketRequest.php +++ b/src/Tickets/Requests/UpdateTicketRequest.php @@ -5,8 +5,6 @@ use Intercom\Core\Json\JsonSerializableType; use Intercom\Core\Json\JsonProperty; use Intercom\Core\Types\ArrayType; -use Intercom\Tickets\Types\UpdateTicketRequestState; -use Intercom\Tickets\Types\UpdateTicketRequestAssignment; class UpdateTicketRequest extends JsonSerializableType { @@ -22,10 +20,16 @@ class UpdateTicketRequest extends JsonSerializableType private ?array $ticketAttributes; /** - * @var ?value-of $state The state of the ticket. + * @var ?string $ticketStateId The ID of the ticket state associated with the ticket type. */ - #[JsonProperty('state')] - private ?string $state; + #[JsonProperty('ticket_state_id')] + private ?string $ticketStateId; + + /** + * @var ?string $companyId The ID of the company that the ticket is associated with. The unique identifier for the company which is given by Intercom. Set to nil to remove company. + */ + #[JsonProperty('company_id')] + private ?string $companyId; /** * @var ?bool $open Specify if a ticket is open. Set to false to close a ticket. Closing a ticket will also unsnooze it. @@ -46,20 +50,28 @@ class UpdateTicketRequest extends JsonSerializableType private ?int $snoozedUntil; /** - * @var ?UpdateTicketRequestAssignment $assignment + * @var ?int $adminId The ID of the admin performing ticket update. Needed for workflows execution and attributing actions to specific admins. + */ + #[JsonProperty('admin_id')] + private ?int $adminId; + + /** + * @var ?string $assigneeId The ID of the admin or team to which the ticket is assigned. Set this 0 to unassign it. */ - #[JsonProperty('assignment')] - private ?UpdateTicketRequestAssignment $assignment; + #[JsonProperty('assignee_id')] + private ?string $assigneeId; /** * @param array{ * ticketId: string, * ticketAttributes?: ?array, - * state?: ?value-of, + * ticketStateId?: ?string, + * companyId?: ?string, * open?: ?bool, * isShared?: ?bool, * snoozedUntil?: ?int, - * assignment?: ?UpdateTicketRequestAssignment, + * adminId?: ?int, + * assigneeId?: ?string, * } $values */ public function __construct( @@ -67,11 +79,13 @@ public function __construct( ) { $this->ticketId = $values['ticketId']; $this->ticketAttributes = $values['ticketAttributes'] ?? null; - $this->state = $values['state'] ?? null; + $this->ticketStateId = $values['ticketStateId'] ?? null; + $this->companyId = $values['companyId'] ?? null; $this->open = $values['open'] ?? null; $this->isShared = $values['isShared'] ?? null; $this->snoozedUntil = $values['snoozedUntil'] ?? null; - $this->assignment = $values['assignment'] ?? null; + $this->adminId = $values['adminId'] ?? null; + $this->assigneeId = $values['assigneeId'] ?? null; } /** @@ -109,19 +123,36 @@ public function setTicketAttributes(?array $value = null): self } /** - * @return ?value-of + * @return ?string + */ + public function getTicketStateId(): ?string + { + return $this->ticketStateId; + } + + /** + * @param ?string $value + */ + public function setTicketStateId(?string $value = null): self + { + $this->ticketStateId = $value; + return $this; + } + + /** + * @return ?string */ - public function getState(): ?string + public function getCompanyId(): ?string { - return $this->state; + return $this->companyId; } /** - * @param ?value-of $value + * @param ?string $value */ - public function setState(?string $value = null): self + public function setCompanyId(?string $value = null): self { - $this->state = $value; + $this->companyId = $value; return $this; } @@ -177,19 +208,36 @@ public function setSnoozedUntil(?int $value = null): self } /** - * @return ?UpdateTicketRequestAssignment + * @return ?int + */ + public function getAdminId(): ?int + { + return $this->adminId; + } + + /** + * @param ?int $value + */ + public function setAdminId(?int $value = null): self + { + $this->adminId = $value; + return $this; + } + + /** + * @return ?string */ - public function getAssignment(): ?UpdateTicketRequestAssignment + public function getAssigneeId(): ?string { - return $this->assignment; + return $this->assigneeId; } /** - * @param ?UpdateTicketRequestAssignment $value + * @param ?string $value */ - public function setAssignment(?UpdateTicketRequestAssignment $value = null): self + public function setAssigneeId(?string $value = null): self { - $this->assignment = $value; + $this->assigneeId = $value; return $this; } } diff --git a/src/Tickets/TicketsClient.php b/src/Tickets/TicketsClient.php index 7b740ea..0ce8fb8 100644 --- a/src/Tickets/TicketsClient.php +++ b/src/Tickets/TicketsClient.php @@ -14,10 +14,14 @@ use JsonException; use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; -use Intercom\Types\CreateTicketRequest; +use Intercom\Tickets\Requests\CreateTicketRequest; use Intercom\Tickets\Types\Ticket; +use Intercom\Tickets\Requests\EnqueueCreateTicketRequest; +use Intercom\Jobs\Types\Jobs; use Intercom\Tickets\Requests\FindTicketRequest; use Intercom\Tickets\Requests\UpdateTicketRequest; +use Intercom\Tickets\Requests\DeleteTicketRequest; +use Intercom\Tickets\Types\DeleteTicketResponse; use Intercom\Types\SearchRequest; use Intercom\Core\Pagination\Pager; use Intercom\Core\Pagination\CursorPager; @@ -33,7 +37,7 @@ class TicketsClient * maxRetries?: int, * timeout?: float, * headers?: array, - * } $options + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator */ private array $options; @@ -128,11 +132,11 @@ public function reply(ReplyToTicketRequest $request, ?array $options = null): Ti * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Ticket + * @return ?Ticket * @throws IntercomException * @throws IntercomApiException */ - public function create(CreateTicketRequest $request, ?array $options = null): Ticket + public function create(CreateTicketRequest $request, ?array $options = null): ?Ticket { $options = array_merge($this->options, $options ?? []); try { @@ -148,6 +152,9 @@ public function create(CreateTicketRequest $request, ?array $options = null): Ti $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Ticket::fromJson($json); } } catch (JsonException $e) { @@ -172,6 +179,62 @@ public function create(CreateTicketRequest $request, ?array $options = null): Ti ); } + /** + * Enqueues ticket creation for asynchronous processing, returning if the job was enqueued successfully to be processed. We attempt to perform a best-effort validation on inputs before tasks are enqueued. If the given parameters are incorrect, we won't enqueue the job. + * + * @param EnqueueCreateTicketRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return Jobs + * @throws IntercomException + * @throws IntercomApiException + */ + public function enqueueCreateTicket(EnqueueCreateTicketRequest $request, ?array $options = null): Jobs + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "tickets/enqueue", + method: HttpMethod::POST, + body: $request, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return Jobs::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + /** * You can fetch the details of a single ticket. * @@ -184,11 +247,11 @@ public function create(CreateTicketRequest $request, ?array $options = null): Ti * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Ticket + * @return ?Ticket * @throws IntercomException * @throws IntercomApiException */ - public function get(FindTicketRequest $request, ?array $options = null): Ticket + public function get(FindTicketRequest $request, ?array $options = null): ?Ticket { $options = array_merge($this->options, $options ?? []); try { @@ -203,6 +266,9 @@ public function get(FindTicketRequest $request, ?array $options = null): Ticket $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Ticket::fromJson($json); } } catch (JsonException $e) { @@ -239,11 +305,11 @@ public function get(FindTicketRequest $request, ?array $options = null): Ticket * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Ticket + * @return ?Ticket * @throws IntercomException * @throws IntercomApiException */ - public function update(UpdateTicketRequest $request, ?array $options = null): Ticket + public function update(UpdateTicketRequest $request, ?array $options = null): ?Ticket { $options = array_merge($this->options, $options ?? []); try { @@ -259,6 +325,9 @@ public function update(UpdateTicketRequest $request, ?array $options = null): Ti $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Ticket::fromJson($json); } } catch (JsonException $e) { @@ -283,6 +352,61 @@ public function update(UpdateTicketRequest $request, ?array $options = null): Ti ); } + /** + * You can delete a ticket using the Intercom provided ID. + * + * @param DeleteTicketRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return DeleteTicketResponse + * @throws IntercomException + * @throws IntercomApiException + */ + public function deleteTicket(DeleteTicketRequest $request, ?array $options = null): DeleteTicketResponse + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "tickets/{$request->getTicketId()}", + method: HttpMethod::DELETE, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return DeleteTicketResponse::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + /** * You can search for multiple tickets by the value of their attributes in order to fetch exactly which ones you want. * @@ -306,14 +430,15 @@ public function update(UpdateTicketRequest $request, ?array $options = null): Ti * ### Accepted Fields * * Most keys listed as part of the Ticket model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as `created_at` accepts a date, the `value` cannot be a string such as `"foobar"`). + * The `source.body` field is unique as the search will not be performed against the entire value, but instead against every element of the value separately. For example, when searching for a conversation with a `"I need support"` body - the query should contain a `=` operator with the value `"support"` for such conversation to be returned. A query with a `=` operator and a `"need support"` value will not yield a result. * * | Field | Type | * | :---------------------------------------- | :--------------------------------------------------------------------------------------- | * | id | String | * | created_at | Date (UNIX timestamp) | * | updated_at | Date (UNIX timestamp) | - * | _default_title_ | String | - * | _default_description_ | String | + * | title | String | + * | description | String | * | category | String | * | ticket_type_id | String | * | contact_ids | String | @@ -325,6 +450,13 @@ public function update(UpdateTicketRequest $request, ?array $options = null): Ti * | snoozed_until | Date (UNIX timestamp) | * | ticket_attribute.{id} | String or Boolean or Date (UNIX timestamp) or Float or Integer | * + * {% admonition type="info" name="Searching by Category" %} + * When searching for tickets by the **`category`** field, specific terms must be used instead of the category names: + * * For **Customer** category tickets, use the term `request`. + * * For **Back-office** category tickets, use the term `task`. + * * For **Tracker** category tickets, use the term `tracker`. + * {% /admonition %} + * * ### Accepted Operators * * {% admonition type="info" name="Searching based on `created_at`" %} @@ -355,7 +487,7 @@ public function update(UpdateTicketRequest $request, ?array $options = null): Ti * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Pager + * @return Pager */ public function search(SearchRequest $request, ?array $options = null): Pager { @@ -395,14 +527,15 @@ public function search(SearchRequest $request, ?array $options = null): Pager * ### Accepted Fields * * Most keys listed as part of the Ticket model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as `created_at` accepts a date, the `value` cannot be a string such as `"foobar"`). + * The `source.body` field is unique as the search will not be performed against the entire value, but instead against every element of the value separately. For example, when searching for a conversation with a `"I need support"` body - the query should contain a `=` operator with the value `"support"` for such conversation to be returned. A query with a `=` operator and a `"need support"` value will not yield a result. * * | Field | Type | * | :---------------------------------------- | :--------------------------------------------------------------------------------------- | * | id | String | * | created_at | Date (UNIX timestamp) | * | updated_at | Date (UNIX timestamp) | - * | _default_title_ | String | - * | _default_description_ | String | + * | title | String | + * | description | String | * | category | String | * | ticket_type_id | String | * | contact_ids | String | @@ -414,6 +547,13 @@ public function search(SearchRequest $request, ?array $options = null): Pager * | snoozed_until | Date (UNIX timestamp) | * | ticket_attribute.{id} | String or Boolean or Date (UNIX timestamp) or Float or Integer | * + * {% admonition type="info" name="Searching by Category" %} + * When searching for tickets by the **`category`** field, specific terms must be used instead of the category names: + * * For **Customer** category tickets, use the term `request`. + * * For **Back-office** category tickets, use the term `task`. + * * For **Tracker** category tickets, use the term `tracker`. + * {% /admonition %} + * * ### Accepted Operators * * {% admonition type="info" name="Searching based on `created_at`" %} diff --git a/src/Tickets/Types/DeleteTicketResponse.php b/src/Tickets/Types/DeleteTicketResponse.php new file mode 100644 index 0000000..8bd5bc3 --- /dev/null +++ b/src/Tickets/Types/DeleteTicketResponse.php @@ -0,0 +1,104 @@ +id = $values['id'] ?? null; + $this->object = $values['object'] ?? null; + $this->deleted = $values['deleted'] ?? null; + } + + /** + * @return ?string + */ + public function getId(): ?string + { + return $this->id; + } + + /** + * @param ?string $value + */ + public function setId(?string $value = null): self + { + $this->id = $value; + return $this; + } + + /** + * @return ?'ticket' + */ + public function getObject(): ?string + { + return $this->object; + } + + /** + * @param ?'ticket' $value + */ + public function setObject(?string $value = null): self + { + $this->object = $value; + return $this; + } + + /** + * @return ?bool + */ + public function getDeleted(): ?bool + { + return $this->deleted; + } + + /** + * @param ?bool $value + */ + public function setDeleted(?bool $value = null): self + { + $this->deleted = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Tickets/Types/Ticket.php b/src/Tickets/Types/Ticket.php index 4e3cdf8..55be236 100644 --- a/src/Tickets/Types/Ticket.php +++ b/src/Tickets/Types/Ticket.php @@ -14,52 +14,52 @@ class Ticket extends JsonSerializableType { /** - * @var 'ticket' $type Always ticket + * @var ?'ticket' $type Always ticket */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var string $id The unique identifier for the ticket which is given by Intercom. + * @var ?string $id The unique identifier for the ticket which is given by Intercom. */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** - * @var string $ticketId The ID of the Ticket used in the Intercom Inbox and Messenger. Do not use ticket_id for API queries. + * @var ?string $ticketId The ID of the Ticket used in the Intercom Inbox and Messenger. Do not use ticket_id for API queries. */ #[JsonProperty('ticket_id')] - private string $ticketId; + private ?string $ticketId; /** - * @var value-of $category Category of the Ticket. + * @var ?value-of $category Category of the Ticket. */ #[JsonProperty('category')] - private string $category; + private ?string $category; /** - * @var array $ticketAttributes + * @var ?array $ticketAttributes */ #[JsonProperty('ticket_attributes'), ArrayType(['string' => 'mixed'])] - private array $ticketAttributes; + private ?array $ticketAttributes; /** - * @var value-of $ticketState The state the ticket is currently in + * @var ?TicketState $ticketState */ #[JsonProperty('ticket_state')] - private string $ticketState; + private ?TicketState $ticketState; /** - * @var TicketType $ticketType + * @var ?TicketType $ticketType */ #[JsonProperty('ticket_type')] - private TicketType $ticketType; + private ?TicketType $ticketType; /** - * @var TicketContacts $contacts + * @var ?TicketContacts $contacts */ #[JsonProperty('contacts')] - private TicketContacts $contacts; + private ?TicketContacts $contacts; /** * @var ?string $adminAssigneeId The id representing the admin assigned to the ticket. @@ -115,28 +115,16 @@ class Ticket extends JsonSerializableType #[JsonProperty('is_shared')] private ?bool $isShared; - /** - * @var ?string $ticketStateInternalLabel The state the ticket is currently in, in a human readable form - visible in Intercom - */ - #[JsonProperty('ticket_state_internal_label')] - private ?string $ticketStateInternalLabel; - - /** - * @var ?string $ticketStateExternalLabel 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')] - private ?string $ticketStateExternalLabel; - /** * @param array{ - * type: 'ticket', - * id: string, - * ticketId: string, - * category: value-of, - * ticketAttributes: array, - * ticketState: value-of, - * ticketType: TicketType, - * contacts: TicketContacts, + * type?: ?'ticket', + * id?: ?string, + * ticketId?: ?string, + * category?: ?value-of, + * ticketAttributes?: ?array, + * ticketState?: ?TicketState, + * ticketType?: ?TicketType, + * contacts?: ?TicketContacts, * adminAssigneeId?: ?string, * teamAssigneeId?: ?string, * createdAt?: ?int, @@ -146,21 +134,19 @@ class Ticket extends JsonSerializableType * linkedObjects?: ?LinkedObjectList, * ticketParts?: ?TicketParts, * isShared?: ?bool, - * ticketStateInternalLabel?: ?string, - * ticketStateExternalLabel?: ?string, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->id = $values['id']; - $this->ticketId = $values['ticketId']; - $this->category = $values['category']; - $this->ticketAttributes = $values['ticketAttributes']; - $this->ticketState = $values['ticketState']; - $this->ticketType = $values['ticketType']; - $this->contacts = $values['contacts']; + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->ticketId = $values['ticketId'] ?? null; + $this->category = $values['category'] ?? null; + $this->ticketAttributes = $values['ticketAttributes'] ?? null; + $this->ticketState = $values['ticketState'] ?? null; + $this->ticketType = $values['ticketType'] ?? null; + $this->contacts = $values['contacts'] ?? null; $this->adminAssigneeId = $values['adminAssigneeId'] ?? null; $this->teamAssigneeId = $values['teamAssigneeId'] ?? null; $this->createdAt = $values['createdAt'] ?? null; @@ -170,141 +156,139 @@ public function __construct( $this->linkedObjects = $values['linkedObjects'] ?? null; $this->ticketParts = $values['ticketParts'] ?? null; $this->isShared = $values['isShared'] ?? null; - $this->ticketStateInternalLabel = $values['ticketStateInternalLabel'] ?? null; - $this->ticketStateExternalLabel = $values['ticketStateExternalLabel'] ?? null; } /** - * @return 'ticket' + * @return ?'ticket' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'ticket' $value + * @param ?'ticket' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; } /** - * @return string + * @return ?string */ - public function getTicketId(): string + public function getTicketId(): ?string { return $this->ticketId; } /** - * @param string $value + * @param ?string $value */ - public function setTicketId(string $value): self + public function setTicketId(?string $value = null): self { $this->ticketId = $value; return $this; } /** - * @return value-of + * @return ?value-of */ - public function getCategory(): string + public function getCategory(): ?string { return $this->category; } /** - * @param value-of $value + * @param ?value-of $value */ - public function setCategory(string $value): self + public function setCategory(?string $value = null): self { $this->category = $value; return $this; } /** - * @return array + * @return ?array */ - public function getTicketAttributes(): array + public function getTicketAttributes(): ?array { return $this->ticketAttributes; } /** - * @param array $value + * @param ?array $value */ - public function setTicketAttributes(array $value): self + public function setTicketAttributes(?array $value = null): self { $this->ticketAttributes = $value; return $this; } /** - * @return value-of + * @return ?TicketState */ - public function getTicketState(): string + public function getTicketState(): ?TicketState { return $this->ticketState; } /** - * @param value-of $value + * @param ?TicketState $value */ - public function setTicketState(string $value): self + public function setTicketState(?TicketState $value = null): self { $this->ticketState = $value; return $this; } /** - * @return TicketType + * @return ?TicketType */ - public function getTicketType(): TicketType + public function getTicketType(): ?TicketType { return $this->ticketType; } /** - * @param TicketType $value + * @param ?TicketType $value */ - public function setTicketType(TicketType $value): self + public function setTicketType(?TicketType $value = null): self { $this->ticketType = $value; return $this; } /** - * @return TicketContacts + * @return ?TicketContacts */ - public function getContacts(): TicketContacts + public function getContacts(): ?TicketContacts { return $this->contacts; } /** - * @param TicketContacts $value + * @param ?TicketContacts $value */ - public function setContacts(TicketContacts $value): self + public function setContacts(?TicketContacts $value = null): self { $this->contacts = $value; return $this; @@ -463,40 +447,6 @@ public function setIsShared(?bool $value = null): self return $this; } - /** - * @return ?string - */ - public function getTicketStateInternalLabel(): ?string - { - return $this->ticketStateInternalLabel; - } - - /** - * @param ?string $value - */ - public function setTicketStateInternalLabel(?string $value = null): self - { - $this->ticketStateInternalLabel = $value; - return $this; - } - - /** - * @return ?string - */ - public function getTicketStateExternalLabel(): ?string - { - return $this->ticketStateExternalLabel; - } - - /** - * @param ?string $value - */ - public function setTicketStateExternalLabel(?string $value = null): self - { - $this->ticketStateExternalLabel = $value; - return $this; - } - /** * @return string */ diff --git a/src/Tickets/Types/TicketContacts.php b/src/Tickets/Types/TicketContacts.php index 593c9f7..34c40e1 100644 --- a/src/Tickets/Types/TicketContacts.php +++ b/src/Tickets/Types/TicketContacts.php @@ -13,59 +13,59 @@ class TicketContacts extends JsonSerializableType { /** - * @var 'contact.list' $type always contact.list + * @var ?'contact.list' $type always contact.list */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var array $contacts The list of contacts affected by this ticket. + * @var ?array $contacts The list of contacts affected by this ticket. */ #[JsonProperty('contacts'), ArrayType([ContactReference::class])] - private array $contacts; + private ?array $contacts; /** * @param array{ - * type: 'contact.list', - * contacts: array, + * type?: ?'contact.list', + * contacts?: ?array, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->contacts = $values['contacts']; + $this->type = $values['type'] ?? null; + $this->contacts = $values['contacts'] ?? null; } /** - * @return 'contact.list' + * @return ?'contact.list' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'contact.list' $value + * @param ?'contact.list' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return array + * @return ?array */ - public function getContacts(): array + public function getContacts(): ?array { return $this->contacts; } /** - * @param array $value + * @param ?array $value */ - public function setContacts(array $value): self + public function setContacts(?array $value = null): self { $this->contacts = $value; return $this; diff --git a/src/Tickets/Types/TicketPart.php b/src/Tickets/Types/TicketPart.php index cdccddd..d522f6d 100644 --- a/src/Tickets/Types/TicketPart.php +++ b/src/Tickets/Types/TicketPart.php @@ -15,22 +15,22 @@ class TicketPart extends JsonSerializableType { /** - * @var 'ticket_part' $type Always ticket_part + * @var ?string $type Always ticket_part */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var string $id The id representing the ticket part. + * @var ?string $id The id representing the ticket part. */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** - * @var string $partType The type of ticket part. + * @var ?string $partType The type of ticket part. */ #[JsonProperty('part_type')] - private string $partType; + private ?string $partType; /** * @var ?string $body The message body, which may contain HTML. @@ -45,16 +45,16 @@ class TicketPart extends JsonSerializableType private ?string $previousTicketState; /** - * @var value-of $ticketState The state of the ticket. + * @var ?value-of $ticketState The state of the ticket. */ #[JsonProperty('ticket_state')] - private string $ticketState; + private ?string $ticketState; /** - * @var int $createdAt The time the ticket part was created. + * @var ?int $createdAt The time the ticket part was created. */ #[JsonProperty('created_at')] - private int $createdAt; + private ?int $createdAt; /** * @var ?int $updatedAt The last time the ticket part was updated. @@ -92,87 +92,103 @@ class TicketPart extends JsonSerializableType #[JsonProperty('redacted')] private ?bool $redacted; + /** + * @var ?string $appPackageCode The app package code if this part was created via API. Note this field won't show if the part was not created via API. + */ + #[JsonProperty('app_package_code')] + private ?string $appPackageCode; + + /** + * @var ?TicketPartUpdatedAttributeData $updatedAttributeData The updated attribute data of the ticket part. Only present for attribute update parts. + */ + #[JsonProperty('updated_attribute_data')] + private ?TicketPartUpdatedAttributeData $updatedAttributeData; + /** * @param array{ - * type: 'ticket_part', - * id: string, - * partType: string, - * ticketState: value-of, - * createdAt: int, + * type?: ?string, + * id?: ?string, + * partType?: ?string, * body?: ?string, * previousTicketState?: ?value-of, + * ticketState?: ?value-of, + * createdAt?: ?int, * updatedAt?: ?int, * assignedTo?: ?Reference, * author?: ?TicketPartAuthor, * attachments?: ?array, * externalId?: ?string, * redacted?: ?bool, + * appPackageCode?: ?string, + * updatedAttributeData?: ?TicketPartUpdatedAttributeData, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->id = $values['id']; - $this->partType = $values['partType']; + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->partType = $values['partType'] ?? null; $this->body = $values['body'] ?? null; $this->previousTicketState = $values['previousTicketState'] ?? null; - $this->ticketState = $values['ticketState']; - $this->createdAt = $values['createdAt']; + $this->ticketState = $values['ticketState'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; $this->updatedAt = $values['updatedAt'] ?? null; $this->assignedTo = $values['assignedTo'] ?? null; $this->author = $values['author'] ?? null; $this->attachments = $values['attachments'] ?? null; $this->externalId = $values['externalId'] ?? null; $this->redacted = $values['redacted'] ?? null; + $this->appPackageCode = $values['appPackageCode'] ?? null; + $this->updatedAttributeData = $values['updatedAttributeData'] ?? null; } /** - * @return 'ticket_part' + * @return ?string */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'ticket_part' $value + * @param ?string $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; } /** - * @return string + * @return ?string */ - public function getPartType(): string + public function getPartType(): ?string { return $this->partType; } /** - * @param string $value + * @param ?string $value */ - public function setPartType(string $value): self + public function setPartType(?string $value = null): self { $this->partType = $value; return $this; @@ -213,34 +229,34 @@ public function setPreviousTicketState(?string $value = null): self } /** - * @return value-of + * @return ?value-of */ - public function getTicketState(): string + public function getTicketState(): ?string { return $this->ticketState; } /** - * @param value-of $value + * @param ?value-of $value */ - public function setTicketState(string $value): self + public function setTicketState(?string $value = null): self { $this->ticketState = $value; return $this; } /** - * @return int + * @return ?int */ - public function getCreatedAt(): int + public function getCreatedAt(): ?int { return $this->createdAt; } /** - * @param int $value + * @param ?int $value */ - public function setCreatedAt(int $value): self + public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; return $this; @@ -348,6 +364,40 @@ public function setRedacted(?bool $value = null): self return $this; } + /** + * @return ?string + */ + public function getAppPackageCode(): ?string + { + return $this->appPackageCode; + } + + /** + * @param ?string $value + */ + public function setAppPackageCode(?string $value = null): self + { + $this->appPackageCode = $value; + return $this; + } + + /** + * @return ?TicketPartUpdatedAttributeData + */ + public function getUpdatedAttributeData(): ?TicketPartUpdatedAttributeData + { + return $this->updatedAttributeData; + } + + /** + * @param ?TicketPartUpdatedAttributeData $value + */ + public function setUpdatedAttributeData(?TicketPartUpdatedAttributeData $value = null): self + { + $this->updatedAttributeData = $value; + return $this; + } + /** * @return string */ diff --git a/src/Tickets/Types/TicketPartUpdatedAttributeData.php b/src/Tickets/Types/TicketPartUpdatedAttributeData.php new file mode 100644 index 0000000..7686470 --- /dev/null +++ b/src/Tickets/Types/TicketPartUpdatedAttributeData.php @@ -0,0 +1,79 @@ +attribute = $values['attribute']; + $this->value = $values['value']; + } + + /** + * @return TicketPartUpdatedAttributeDataAttribute + */ + public function getAttribute(): TicketPartUpdatedAttributeDataAttribute + { + return $this->attribute; + } + + /** + * @param TicketPartUpdatedAttributeDataAttribute $value + */ + public function setAttribute(TicketPartUpdatedAttributeDataAttribute $value): self + { + $this->attribute = $value; + return $this; + } + + /** + * @return TicketPartUpdatedAttributeDataValue + */ + public function getValue(): TicketPartUpdatedAttributeDataValue + { + return $this->value; + } + + /** + * @param TicketPartUpdatedAttributeDataValue $value + */ + public function setValue(TicketPartUpdatedAttributeDataValue $value): self + { + $this->value = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/ContactCompany.php b/src/Tickets/Types/TicketPartUpdatedAttributeDataAttribute.php similarity index 62% rename from src/Types/ContactCompany.php rename to src/Tickets/Types/TicketPartUpdatedAttributeDataAttribute.php index 47daced..7acf082 100644 --- a/src/Types/ContactCompany.php +++ b/src/Tickets/Types/TicketPartUpdatedAttributeDataAttribute.php @@ -1,96 +1,96 @@ id = $values['id']; $this->type = $values['type']; - $this->url = $values['url']; + $this->id = $values['id']; + $this->label = $values['label']; } /** - * @return string + * @return 'attribute' */ - public function getId(): string + public function getType(): string { - return $this->id; + return $this->type; } /** - * @param string $value + * @param 'attribute' $value */ - public function setId(string $value): self + public function setType(string $value): self { - $this->id = $value; + $this->type = $value; return $this; } /** - * @return 'company' + * @return string */ - public function getType(): string + public function getId(): string { - return $this->type; + return $this->id; } /** - * @param 'company' $value + * @param string $value */ - public function setType(string $value): self + public function setId(string $value): self { - $this->type = $value; + $this->id = $value; return $this; } /** * @return string */ - public function getUrl(): string + public function getLabel(): string { - return $this->url; + return $this->label; } /** * @param string $value */ - public function setUrl(string $value): self + public function setLabel(string $value): self { - $this->url = $value; + $this->label = $value; return $this; } diff --git a/src/Tickets/Types/TicketPartUpdatedAttributeDataValue.php b/src/Tickets/Types/TicketPartUpdatedAttributeDataValue.php new file mode 100644 index 0000000..771084e --- /dev/null +++ b/src/Tickets/Types/TicketPartUpdatedAttributeDataValue.php @@ -0,0 +1,133 @@ + + * |null + * ) $id + */ + #[JsonProperty('id'), Union(new Union('string', 'null'), ['integer'])] + private string|array|null $id; + + /** + * @var ( + * string + * |array + * ) $label + */ + #[JsonProperty('label'), Union('string', ['string'])] + private string|array $label; + + /** + * @param array{ + * type: 'value', + * id: ( + * string + * |array + * |null + * ), + * label: ( + * string + * |array + * ), + * } $values + */ + public function __construct( + array $values, + ) { + $this->type = $values['type']; + $this->id = $values['id']; + $this->label = $values['label']; + } + + /** + * @return 'value' + */ + public function getType(): string + { + return $this->type; + } + + /** + * @param 'value' $value + */ + public function setType(string $value): self + { + $this->type = $value; + return $this; + } + + /** + * @return ( + * string + * |array + * |null + * ) + */ + public function getId(): string|array|null + { + return $this->id; + } + + /** + * @param ( + * string + * |array + * |null + * ) $value + */ + public function setId(string|array|null $value): self + { + $this->id = $value; + return $this; + } + + /** + * @return ( + * string + * |array + * ) + */ + public function getLabel(): string|array + { + return $this->label; + } + + /** + * @param ( + * string + * |array + * ) $value + */ + public function setLabel(string|array $value): self + { + $this->label = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Tickets/Types/TicketState.php b/src/Tickets/Types/TicketState.php new file mode 100644 index 0000000..5a2a5d9 --- /dev/null +++ b/src/Tickets/Types/TicketState.php @@ -0,0 +1,154 @@ + $category The category of the ticket state + */ + #[JsonProperty('category')] + private ?string $category; + + /** + * @var ?string $internalLabel The state the ticket is currently in, in a human readable form - visible in Intercom + */ + #[JsonProperty('internal_label')] + private ?string $internalLabel; + + /** + * @var ?string $externalLabel The state the ticket is currently in, in a human readable form - visible to customers, in the messenger, email and tickets portal. + */ + #[JsonProperty('external_label')] + private ?string $externalLabel; + + /** + * @param array{ + * type?: ?string, + * id?: ?string, + * category?: ?value-of, + * internalLabel?: ?string, + * externalLabel?: ?string, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->category = $values['category'] ?? null; + $this->internalLabel = $values['internalLabel'] ?? null; + $this->externalLabel = $values['externalLabel'] ?? null; + } + + /** + * @return ?string + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?string $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?string + */ + public function getId(): ?string + { + return $this->id; + } + + /** + * @param ?string $value + */ + public function setId(?string $value = null): self + { + $this->id = $value; + return $this; + } + + /** + * @return ?value-of + */ + public function getCategory(): ?string + { + return $this->category; + } + + /** + * @param ?value-of $value + */ + public function setCategory(?string $value = null): self + { + $this->category = $value; + return $this; + } + + /** + * @return ?string + */ + public function getInternalLabel(): ?string + { + return $this->internalLabel; + } + + /** + * @param ?string $value + */ + public function setInternalLabel(?string $value = null): self + { + $this->internalLabel = $value; + return $this; + } + + /** + * @return ?string + */ + public function getExternalLabel(): ?string + { + return $this->externalLabel; + } + + /** + * @param ?string $value + */ + public function setExternalLabel(?string $value = null): self + { + $this->externalLabel = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Tickets/Types/TicketTicketState.php b/src/Tickets/Types/TicketStateCategory.php similarity index 85% rename from src/Tickets/Types/TicketTicketState.php rename to src/Tickets/Types/TicketStateCategory.php index 1d0c664..9845f97 100644 --- a/src/Tickets/Types/TicketTicketState.php +++ b/src/Tickets/Types/TicketStateCategory.php @@ -2,7 +2,7 @@ namespace Intercom\Tickets\Types; -enum TicketTicketState: string +enum TicketStateCategory: string { case Submitted = "submitted"; case InProgress = "in_progress"; diff --git a/src/Tickets/Types/TicketStateDetailed.php b/src/Tickets/Types/TicketStateDetailed.php new file mode 100644 index 0000000..26803e2 --- /dev/null +++ b/src/Tickets/Types/TicketStateDetailed.php @@ -0,0 +1,204 @@ + $category The category of the ticket state + */ + #[JsonProperty('category')] + private ?string $category; + + /** + * @var ?string $internalLabel The state the ticket is currently in, in a human readable form - visible in Intercom + */ + #[JsonProperty('internal_label')] + private ?string $internalLabel; + + /** + * @var ?string $externalLabel The state the ticket is currently in, in a human readable form - visible to customers, in the messenger, email and tickets portal. + */ + #[JsonProperty('external_label')] + private ?string $externalLabel; + + /** + * @var ?bool $archived Whether the ticket state is archived + */ + #[JsonProperty('archived')] + private ?bool $archived; + + /** + * @var ?TicketStateDetailedTicketTypes $ticketTypes A list of ticket types associated with a given ticket state. + */ + #[JsonProperty('ticket_types')] + private ?TicketStateDetailedTicketTypes $ticketTypes; + + /** + * @param array{ + * type?: ?string, + * id?: ?string, + * category?: ?value-of, + * internalLabel?: ?string, + * externalLabel?: ?string, + * archived?: ?bool, + * ticketTypes?: ?TicketStateDetailedTicketTypes, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->category = $values['category'] ?? null; + $this->internalLabel = $values['internalLabel'] ?? null; + $this->externalLabel = $values['externalLabel'] ?? null; + $this->archived = $values['archived'] ?? null; + $this->ticketTypes = $values['ticketTypes'] ?? null; + } + + /** + * @return ?string + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?string $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?string + */ + public function getId(): ?string + { + return $this->id; + } + + /** + * @param ?string $value + */ + public function setId(?string $value = null): self + { + $this->id = $value; + return $this; + } + + /** + * @return ?value-of + */ + public function getCategory(): ?string + { + return $this->category; + } + + /** + * @param ?value-of $value + */ + public function setCategory(?string $value = null): self + { + $this->category = $value; + return $this; + } + + /** + * @return ?string + */ + public function getInternalLabel(): ?string + { + return $this->internalLabel; + } + + /** + * @param ?string $value + */ + public function setInternalLabel(?string $value = null): self + { + $this->internalLabel = $value; + return $this; + } + + /** + * @return ?string + */ + public function getExternalLabel(): ?string + { + return $this->externalLabel; + } + + /** + * @param ?string $value + */ + public function setExternalLabel(?string $value = null): self + { + $this->externalLabel = $value; + return $this; + } + + /** + * @return ?bool + */ + public function getArchived(): ?bool + { + return $this->archived; + } + + /** + * @param ?bool $value + */ + public function setArchived(?bool $value = null): self + { + $this->archived = $value; + return $this; + } + + /** + * @return ?TicketStateDetailedTicketTypes + */ + public function getTicketTypes(): ?TicketStateDetailedTicketTypes + { + return $this->ticketTypes; + } + + /** + * @param ?TicketStateDetailedTicketTypes $value + */ + public function setTicketTypes(?TicketStateDetailedTicketTypes $value = null): self + { + $this->ticketTypes = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Tickets/Types/UpdateTicketRequestState.php b/src/Tickets/Types/TicketStateDetailedCategory.php similarity index 69% rename from src/Tickets/Types/UpdateTicketRequestState.php rename to src/Tickets/Types/TicketStateDetailedCategory.php index 89728a6..b0b6643 100644 --- a/src/Tickets/Types/UpdateTicketRequestState.php +++ b/src/Tickets/Types/TicketStateDetailedCategory.php @@ -2,8 +2,9 @@ namespace Intercom\Tickets\Types; -enum UpdateTicketRequestState: string +enum TicketStateDetailedCategory: string { + case Submitted = "submitted"; case InProgress = "in_progress"; case WaitingOnCustomer = "waiting_on_customer"; case Resolved = "resolved"; diff --git a/src/Tickets/Types/TicketStateDetailedTicketTypes.php b/src/Tickets/Types/TicketStateDetailedTicketTypes.php new file mode 100644 index 0000000..cee96e1 --- /dev/null +++ b/src/Tickets/Types/TicketStateDetailedTicketTypes.php @@ -0,0 +1,81 @@ + $data A list of ticket type attributes associated with a given ticket type. + */ + #[JsonProperty('data'), ArrayType([new Union(TicketType::class, 'null')])] + private ?array $data; + + /** + * @param array{ + * type?: ?string, + * data?: ?array, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->type = $values['type'] ?? null; + $this->data = $values['data'] ?? null; + } + + /** + * @return ?string + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?string $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?array + */ + public function getData(): ?array + { + return $this->data; + } + + /** + * @param ?array $value + */ + public function setData(?array $value = null): self + { + $this->data = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Tickets/Types/TicketType.php b/src/Tickets/Types/TicketType.php index 82724e3..5e1bcd3 100644 --- a/src/Tickets/Types/TicketType.php +++ b/src/Tickets/Types/TicketType.php @@ -12,64 +12,70 @@ class TicketType extends JsonSerializableType { /** - * @var 'ticket_type' $type String representing the object's type. Always has the value `ticket_type`. + * @var ?string $type String representing the object's type. Always has the value `ticket_type`. */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var string $id The id representing the ticket type. + * @var ?string $id The id representing the ticket type. */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** - * @var value-of $category Category of the Ticket Type. + * @var ?value-of $category Category of the Ticket Type. */ #[JsonProperty('category')] - private string $category; + private ?string $category; /** - * @var string $name The name of the ticket type + * @var ?string $name The name of the ticket type */ #[JsonProperty('name')] - private string $name; + private ?string $name; /** - * @var string $description The description of the ticket type + * @var ?string $description The description of the ticket type */ #[JsonProperty('description')] - private string $description; + private ?string $description; /** - * @var string $icon The icon of the ticket type + * @var ?string $icon The icon of the ticket type */ #[JsonProperty('icon')] - private string $icon; + private ?string $icon; /** - * @var string $workspaceId The id of the workspace that the ticket type belongs to. + * @var ?string $workspaceId The id of the workspace that the ticket type belongs to. */ #[JsonProperty('workspace_id')] - private string $workspaceId; + private ?string $workspaceId; /** - * @var TicketTypeAttributeList $ticketTypeAttributes + * @var ?TicketTypeAttributeList $ticketTypeAttributes */ #[JsonProperty('ticket_type_attributes')] - private TicketTypeAttributeList $ticketTypeAttributes; + private ?TicketTypeAttributeList $ticketTypeAttributes; /** - * @var bool $archived Whether the ticket type is archived or not. + * @var ?TicketTypeTicketStates $ticketStates A list of ticket states associated with a given ticket type. + */ + #[JsonProperty('ticket_states')] + private ?TicketTypeTicketStates $ticketStates; + + /** + * @var ?bool $archived Whether the ticket type is archived or not. */ #[JsonProperty('archived')] - private bool $archived; + private ?bool $archived; /** - * @var int $createdAt The date and time the ticket type was created. + * @var ?int $createdAt The date and time the ticket type was created. */ #[JsonProperty('created_at')] - private int $createdAt; + private ?int $createdAt; /** * @var ?int $updatedAt The date and time the ticket type was last updated. @@ -79,200 +85,219 @@ class TicketType extends JsonSerializableType /** * @param array{ - * type: 'ticket_type', - * id: string, - * category: value-of, - * name: string, - * description: string, - * icon: string, - * workspaceId: string, - * ticketTypeAttributes: TicketTypeAttributeList, - * archived: bool, - * createdAt: int, + * type?: ?string, + * id?: ?string, + * category?: ?value-of, + * name?: ?string, + * description?: ?string, + * icon?: ?string, + * workspaceId?: ?string, + * ticketTypeAttributes?: ?TicketTypeAttributeList, + * ticketStates?: ?TicketTypeTicketStates, + * archived?: ?bool, + * createdAt?: ?int, * updatedAt?: ?int, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->id = $values['id']; - $this->category = $values['category']; - $this->name = $values['name']; - $this->description = $values['description']; - $this->icon = $values['icon']; - $this->workspaceId = $values['workspaceId']; - $this->ticketTypeAttributes = $values['ticketTypeAttributes']; - $this->archived = $values['archived']; - $this->createdAt = $values['createdAt']; + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->category = $values['category'] ?? null; + $this->name = $values['name'] ?? null; + $this->description = $values['description'] ?? null; + $this->icon = $values['icon'] ?? null; + $this->workspaceId = $values['workspaceId'] ?? null; + $this->ticketTypeAttributes = $values['ticketTypeAttributes'] ?? null; + $this->ticketStates = $values['ticketStates'] ?? null; + $this->archived = $values['archived'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; $this->updatedAt = $values['updatedAt'] ?? null; } /** - * @return 'ticket_type' + * @return ?string */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'ticket_type' $value + * @param ?string $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; } /** - * @return value-of + * @return ?value-of */ - public function getCategory(): string + public function getCategory(): ?string { return $this->category; } /** - * @param value-of $value + * @param ?value-of $value */ - public function setCategory(string $value): self + public function setCategory(?string $value = null): self { $this->category = $value; return $this; } /** - * @return string + * @return ?string */ - public function getName(): string + public function getName(): ?string { return $this->name; } /** - * @param string $value + * @param ?string $value */ - public function setName(string $value): self + public function setName(?string $value = null): self { $this->name = $value; return $this; } /** - * @return string + * @return ?string */ - public function getDescription(): string + public function getDescription(): ?string { return $this->description; } /** - * @param string $value + * @param ?string $value */ - public function setDescription(string $value): self + public function setDescription(?string $value = null): self { $this->description = $value; return $this; } /** - * @return string + * @return ?string */ - public function getIcon(): string + public function getIcon(): ?string { return $this->icon; } /** - * @param string $value + * @param ?string $value */ - public function setIcon(string $value): self + public function setIcon(?string $value = null): self { $this->icon = $value; return $this; } /** - * @return string + * @return ?string */ - public function getWorkspaceId(): string + public function getWorkspaceId(): ?string { return $this->workspaceId; } /** - * @param string $value + * @param ?string $value */ - public function setWorkspaceId(string $value): self + public function setWorkspaceId(?string $value = null): self { $this->workspaceId = $value; return $this; } /** - * @return TicketTypeAttributeList + * @return ?TicketTypeAttributeList */ - public function getTicketTypeAttributes(): TicketTypeAttributeList + public function getTicketTypeAttributes(): ?TicketTypeAttributeList { return $this->ticketTypeAttributes; } /** - * @param TicketTypeAttributeList $value + * @param ?TicketTypeAttributeList $value */ - public function setTicketTypeAttributes(TicketTypeAttributeList $value): self + public function setTicketTypeAttributes(?TicketTypeAttributeList $value = null): self { $this->ticketTypeAttributes = $value; return $this; } /** - * @return bool + * @return ?TicketTypeTicketStates */ - public function getArchived(): bool + public function getTicketStates(): ?TicketTypeTicketStates + { + return $this->ticketStates; + } + + /** + * @param ?TicketTypeTicketStates $value + */ + public function setTicketStates(?TicketTypeTicketStates $value = null): self + { + $this->ticketStates = $value; + return $this; + } + + /** + * @return ?bool + */ + public function getArchived(): ?bool { return $this->archived; } /** - * @param bool $value + * @param ?bool $value */ - public function setArchived(bool $value): self + public function setArchived(?bool $value = null): self { $this->archived = $value; return $this; } /** - * @return int + * @return ?int */ - public function getCreatedAt(): int + public function getCreatedAt(): ?int { return $this->createdAt; } /** - * @param int $value + * @param ?int $value */ - public function setCreatedAt(int $value): self + public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; return $this; diff --git a/src/Tickets/Types/TicketTypeTicketStates.php b/src/Tickets/Types/TicketTypeTicketStates.php new file mode 100644 index 0000000..8217a6b --- /dev/null +++ b/src/Tickets/Types/TicketTypeTicketStates.php @@ -0,0 +1,81 @@ + $data A list of ticket states associated with a given ticket type. + */ + #[JsonProperty('data'), ArrayType([new Union(TicketState::class, 'null')])] + private ?array $data; + + /** + * @param array{ + * type?: ?string, + * data?: ?array, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->type = $values['type'] ?? null; + $this->data = $values['data'] ?? null; + } + + /** + * @return ?string + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?string $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?array + */ + public function getData(): ?array + { + return $this->data; + } + + /** + * @param ?array $value + */ + public function setData(?array $value = null): self + { + $this->data = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Tickets/Types/UpdateTicketRequestAssignment.php b/src/Tickets/Types/UpdateTicketRequestAssignment.php deleted file mode 100644 index 0b55572..0000000 --- a/src/Tickets/Types/UpdateTicketRequestAssignment.php +++ /dev/null @@ -1,76 +0,0 @@ -adminId = $values['adminId'] ?? null; - $this->assigneeId = $values['assigneeId'] ?? null; - } - - /** - * @return ?string - */ - public function getAdminId(): ?string - { - return $this->adminId; - } - - /** - * @param ?string $value - */ - public function setAdminId(?string $value = null): self - { - $this->adminId = $value; - return $this; - } - - /** - * @return ?string - */ - public function getAssigneeId(): ?string - { - return $this->assigneeId; - } - - /** - * @param ?string $value - */ - public function setAssigneeId(?string $value = null): self - { - $this->assigneeId = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Traits/ContactReference.php b/src/Traits/ContactReference.php new file mode 100644 index 0000000..93d488a --- /dev/null +++ b/src/Traits/ContactReference.php @@ -0,0 +1,84 @@ +type; + } + + /** + * @param ?'contact' $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?string + */ + public function getId(): ?string + { + return $this->id; + } + + /** + * @param ?string $value + */ + public function setId(?string $value = null): self + { + $this->id = $value; + return $this; + } + + /** + * @return ?string + */ + public function getExternalId(): ?string + { + return $this->externalId; + } + + /** + * @param ?string $value + */ + public function setExternalId(?string $value = null): self + { + $this->externalId = $value; + return $this; + } +} diff --git a/src/Traits/ContactReplyBaseRequest.php b/src/Traits/ContactReplyBaseRequest.php index ec445fa..55b0e56 100644 --- a/src/Traits/ContactReplyBaseRequest.php +++ b/src/Traits/ContactReplyBaseRequest.php @@ -2,6 +2,7 @@ namespace Intercom\Traits; +use Intercom\Types\ContactReplyBaseRequestReplyOptionsItem; use Intercom\Core\Json\JsonProperty; use Intercom\Core\Types\ArrayType; @@ -11,6 +12,7 @@ * @property string $body * @property ?int $createdAt * @property ?array $attachmentUrls + * @property ?array $replyOptions */ trait ContactReplyBaseRequest { @@ -44,6 +46,12 @@ trait ContactReplyBaseRequest #[JsonProperty('attachment_urls'), ArrayType(['string'])] private ?array $attachmentUrls; + /** + * @var ?array $replyOptions The quick reply selection the contact wishes to respond with. These map to buttons displayed in the Messenger UI if sent by a bot, or the reply options sent by an Admin via the API. + */ + #[JsonProperty('reply_options'), ArrayType([ContactReplyBaseRequestReplyOptionsItem::class])] + private ?array $replyOptions; + /** * @return 'comment' */ @@ -128,4 +136,21 @@ public function setAttachmentUrls(?array $value = null): self $this->attachmentUrls = $value; return $this; } + + /** + * @return ?array + */ + public function getReplyOptions(): ?array + { + return $this->replyOptions; + } + + /** + * @param ?array $value + */ + public function setReplyOptions(?array $value = null): self + { + $this->replyOptions = $value; + return $this; + } } diff --git a/src/Traits/CreateTicketRequestBody.php b/src/Traits/CreateTicketRequestBody.php new file mode 100644 index 0000000..d4f36a9 --- /dev/null +++ b/src/Traits/CreateTicketRequestBody.php @@ -0,0 +1,184 @@ + $contacts + * @property ?string $conversationToLinkId + * @property ?string $companyId + * @property ?int $createdAt + * @property ?CreateTicketRequestAssignment $assignment + */ +trait CreateTicketRequestBody +{ + /** + * @var string $ticketTypeId The ID of the type of ticket you want to create + */ + #[JsonProperty('ticket_type_id')] + private string $ticketTypeId; + + /** + * @var array<( + * CreateTicketRequestContactsItemId + * |CreateTicketRequestContactsItemExternalId + * |CreateTicketRequestContactsItemEmail + * )> $contacts The list of contacts (users or leads) affected by this ticket. Currently only one is allowed + */ + #[JsonProperty('contacts'), ArrayType([new Union(CreateTicketRequestContactsItemId::class, CreateTicketRequestContactsItemExternalId::class, CreateTicketRequestContactsItemEmail::class)])] + private array $contacts; + + /** + * The ID of the conversation you want to link to the ticket. Here are the valid ways of linking two tickets: + * - conversation | back-office ticket + * - customer tickets | non-shared back-office ticket + * - conversation | tracker ticket + * - customer ticket | tracker ticket + * + * @var ?string $conversationToLinkId + */ + #[JsonProperty('conversation_to_link_id')] + private ?string $conversationToLinkId; + + /** + * @var ?string $companyId The ID of the company that the ticket is associated with. The unique identifier for the company which is given by Intercom + */ + #[JsonProperty('company_id')] + private ?string $companyId; + + /** + * @var ?int $createdAt The time the ticket was created. If not provided, the current time will be used. + */ + #[JsonProperty('created_at')] + private ?int $createdAt; + + /** + * @var ?CreateTicketRequestAssignment $assignment + */ + #[JsonProperty('assignment')] + private ?CreateTicketRequestAssignment $assignment; + + /** + * @return string + */ + public function getTicketTypeId(): string + { + return $this->ticketTypeId; + } + + /** + * @param string $value + */ + public function setTicketTypeId(string $value): self + { + $this->ticketTypeId = $value; + return $this; + } + + /** + * @return array<( + * CreateTicketRequestContactsItemId + * |CreateTicketRequestContactsItemExternalId + * |CreateTicketRequestContactsItemEmail + * )> + */ + public function getContacts(): array + { + return $this->contacts; + } + + /** + * @param array<( + * CreateTicketRequestContactsItemId + * |CreateTicketRequestContactsItemExternalId + * |CreateTicketRequestContactsItemEmail + * )> $value + */ + public function setContacts(array $value): self + { + $this->contacts = $value; + return $this; + } + + /** + * @return ?string + */ + public function getConversationToLinkId(): ?string + { + return $this->conversationToLinkId; + } + + /** + * @param ?string $value + */ + public function setConversationToLinkId(?string $value = null): self + { + $this->conversationToLinkId = $value; + return $this; + } + + /** + * @return ?string + */ + public function getCompanyId(): ?string + { + return $this->companyId; + } + + /** + * @param ?string $value + */ + public function setCompanyId(?string $value = null): self + { + $this->companyId = $value; + return $this; + } + + /** + * @return ?int + */ + public function getCreatedAt(): ?int + { + return $this->createdAt; + } + + /** + * @param ?int $value + */ + public function setCreatedAt(?int $value = null): self + { + $this->createdAt = $value; + return $this; + } + + /** + * @return ?CreateTicketRequestAssignment + */ + public function getAssignment(): ?CreateTicketRequestAssignment + { + return $this->assignment; + } + + /** + * @param ?CreateTicketRequestAssignment $value + */ + public function setAssignment(?CreateTicketRequestAssignment $value = null): self + { + $this->assignment = $value; + return $this; + } +} diff --git a/src/Traits/CustomChannelBaseEvent.php b/src/Traits/CustomChannelBaseEvent.php new file mode 100644 index 0000000..6e4cbae --- /dev/null +++ b/src/Traits/CustomChannelBaseEvent.php @@ -0,0 +1,83 @@ +eventId; + } + + /** + * @param string $value + */ + public function setEventId(string $value): self + { + $this->eventId = $value; + return $this; + } + + /** + * @return string + */ + public function getExternalConversationId(): string + { + return $this->externalConversationId; + } + + /** + * @param string $value + */ + public function setExternalConversationId(string $value): self + { + $this->externalConversationId = $value; + return $this; + } + + /** + * @return CustomChannelContact + */ + public function getContact(): CustomChannelContact + { + return $this->contact; + } + + /** + * @param CustomChannelContact $value + */ + public function setContact(CustomChannelContact $value): self + { + $this->contact = $value; + return $this; + } +} diff --git a/src/Traits/ListItem.php b/src/Traits/ListItem.php deleted file mode 100644 index ecf6ecb..0000000 --- a/src/Traits/ListItem.php +++ /dev/null @@ -1,205 +0,0 @@ -type; - } - - /** - * @param 'item' $value - */ - public function setType(string $value): self - { - $this->type = $value; - return $this; - } - - /** - * @return string - */ - public function getId(): string - { - return $this->id; - } - - /** - * @param string $value - */ - public function setId(string $value): self - { - $this->id = $value; - return $this; - } - - /** - * @return string - */ - public function getTitle(): string - { - return $this->title; - } - - /** - * @param string $value - */ - public function setTitle(string $value): self - { - $this->title = $value; - return $this; - } - - /** - * @return ?string - */ - public function getSubtitle(): ?string - { - return $this->subtitle; - } - - /** - * @param ?string $value - */ - public function setSubtitle(?string $value = null): self - { - $this->subtitle = $value; - return $this; - } - - /** - * @return ?string - */ - public function getTertiaryText(): ?string - { - return $this->tertiaryText; - } - - /** - * @param ?string $value - */ - public function setTertiaryText(?string $value = null): self - { - $this->tertiaryText = $value; - return $this; - } - - /** - * @return ?bool - */ - public function getRoundedImage(): ?bool - { - return $this->roundedImage; - } - - /** - * @param ?bool $value - */ - public function setRoundedImage(?bool $value = null): self - { - $this->roundedImage = $value; - return $this; - } - - /** - * @return ?bool - */ - public function getDisabled(): ?bool - { - return $this->disabled; - } - - /** - * @param ?bool $value - */ - public function setDisabled(?bool $value = null): self - { - $this->disabled = $value; - return $this; - } - - /** - * @return ?ActionComponent - */ - public function getAction(): ?ActionComponent - { - return $this->action; - } - - /** - * @param ?ActionComponent $value - */ - public function setAction(?ActionComponent $value = null): self - { - $this->action = $value; - return $this; - } -} diff --git a/src/Traits/QuickReplyOption.php b/src/Traits/QuickReplyOption.php new file mode 100644 index 0000000..077aee8 --- /dev/null +++ b/src/Traits/QuickReplyOption.php @@ -0,0 +1,58 @@ +text; + } + + /** + * @param string $value + */ + public function setText(string $value): self + { + $this->text = $value; + return $this; + } + + /** + * @return string + */ + public function getUuid(): string + { + return $this->uuid; + } + + /** + * @param string $value + */ + public function setUuid(string $value): self + { + $this->uuid = $value; + return $this; + } +} diff --git a/src/Types/ActivityLog.php b/src/Types/ActivityLog.php index d5d5687..c0c7f22 100644 --- a/src/Types/ActivityLog.php +++ b/src/Types/ActivityLog.php @@ -11,16 +11,16 @@ class ActivityLog extends JsonSerializableType { /** - * @var string $id The id representing the activity. + * @var ?string $id The id representing the activity. */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** - * @var ActivityLogPerformedBy $performedBy Details about the Admin involved in the activity. + * @var ?ActivityLogPerformedBy $performedBy Details about the Admin involved in the activity. */ #[JsonProperty('performed_by')] - private ActivityLogPerformedBy $performedBy; + private ?ActivityLogPerformedBy $performedBy; /** * @var ?ActivityLogMetadata $metadata @@ -35,10 +35,10 @@ class ActivityLog extends JsonSerializableType private ?int $createdAt; /** - * @var value-of $activityType + * @var ?value-of $activityType */ #[JsonProperty('activity_type')] - private string $activityType; + private ?string $activityType; /** * @var ?string $activityDescription A sentence or two describing the activity. @@ -48,54 +48,54 @@ class ActivityLog extends JsonSerializableType /** * @param array{ - * id: string, - * performedBy: ActivityLogPerformedBy, - * activityType: value-of, + * id?: ?string, + * performedBy?: ?ActivityLogPerformedBy, * metadata?: ?ActivityLogMetadata, * createdAt?: ?int, + * activityType?: ?value-of, * activityDescription?: ?string, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->id = $values['id']; - $this->performedBy = $values['performedBy']; + $this->id = $values['id'] ?? null; + $this->performedBy = $values['performedBy'] ?? null; $this->metadata = $values['metadata'] ?? null; $this->createdAt = $values['createdAt'] ?? null; - $this->activityType = $values['activityType']; + $this->activityType = $values['activityType'] ?? null; $this->activityDescription = $values['activityDescription'] ?? null; } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; } /** - * @return ActivityLogPerformedBy + * @return ?ActivityLogPerformedBy */ - public function getPerformedBy(): ActivityLogPerformedBy + public function getPerformedBy(): ?ActivityLogPerformedBy { return $this->performedBy; } /** - * @param ActivityLogPerformedBy $value + * @param ?ActivityLogPerformedBy $value */ - public function setPerformedBy(ActivityLogPerformedBy $value): self + public function setPerformedBy(?ActivityLogPerformedBy $value = null): self { $this->performedBy = $value; return $this; @@ -136,17 +136,17 @@ public function setCreatedAt(?int $value = null): self } /** - * @return value-of + * @return ?value-of */ - public function getActivityType(): string + public function getActivityType(): ?string { return $this->activityType; } /** - * @param value-of $value + * @param ?value-of $value */ - public function setActivityType(string $value): self + public function setActivityType(?string $value = null): self { $this->activityType = $value; return $this; diff --git a/src/Types/ActivityLogActivityType.php b/src/Types/ActivityLogActivityType.php index 82eb0da..fbb97d1 100644 --- a/src/Types/ActivityLogActivityType.php +++ b/src/Types/ActivityLogActivityType.php @@ -4,12 +4,15 @@ enum ActivityLogActivityType: string { - case AdminAssignmentLimitChange = "admin_assignment_limit_change"; + case AdminConversationAssignmentLimitChange = "admin_conversation_assignment_limit_change"; + case AdminTicketAssignmentLimitChange = "admin_ticket_assignment_limit_change"; case AdminAwayModeChange = "admin_away_mode_change"; case AdminDeletion = "admin_deletion"; case AdminDeprovisioned = "admin_deprovisioned"; case AdminImpersonationEnd = "admin_impersonation_end"; case AdminImpersonationStart = "admin_impersonation_start"; + case AdminImpersonationConsentApproved = "admin_impersonation_consent_approved"; + case AdminImpersonationConsentRevoked = "admin_impersonation_consent_revoked"; case AdminInviteChange = "admin_invite_change"; case AdminInviteCreation = "admin_invite_creation"; case AdminInviteDeletion = "admin_invite_deletion"; @@ -40,6 +43,7 @@ enum ActivityLogActivityType: string case AppWebhookCreation = "app_webhook_creation"; case AppWebhookDeletion = "app_webhook_deletion"; case ArticlesInMessengerEnabledChange = "articles_in_messenger_enabled_change"; + case AutomaticAwayModeSettingChange = "automatic_away_mode_setting_change"; case BulkDelete = "bulk_delete"; case BulkExport = "bulk_export"; case CampaignDeletion = "campaign_deletion"; @@ -48,14 +52,22 @@ enum ActivityLogActivityType: string case ConversationTopicChange = "conversation_topic_change"; case ConversationTopicCreation = "conversation_topic_creation"; case ConversationTopicDeletion = "conversation_topic_deletion"; + case CustomAuthenticationTokenCreation = "custom_authentication_token_creation"; case HelpCenterSettingsChange = "help_center_settings_change"; case InboundConversationsChange = "inbound_conversations_change"; case InboxAccessChange = "inbox_access_change"; + case MacroCreation = "macro_creation"; + case MacroDeletion = "macro_deletion"; + case MacroUpdated = "macro_updated"; + case MaliciousDomainsSettingChange = "malicious_domains_setting_change"; case MessageDeletion = "message_deletion"; case MessageStateChange = "message_state_change"; + case MessengerApiSecretCreation = "messenger_api_secret_creation"; + case MessengerApiSecretDeletion = "messenger_api_secret_deletion"; case MessengerLookAndFeelChange = "messenger_look_and_feel_change"; case MessengerSearchRequiredChange = "messenger_search_required_change"; case MessengerSpacesChange = "messenger_spaces_change"; + case OauthTokenRevocation = "oauth_token_revocation"; case OfficeHoursChange = "office_hours_change"; case RoleChange = "role_change"; case RoleCreation = "role_creation"; @@ -68,7 +80,21 @@ enum ActivityLogActivityType: string case SeatChange = "seat_change"; case SeatRevoke = "seat_revoke"; case SecuritySettingsChange = "security_settings_change"; + case StripInboundEmailLinksChange = "strip_inbound_email_links_change"; case TemporaryExpectationChange = "temporary_expectation_change"; + case TeamAssignmentLimitChange = "team_assignment_limit_change"; + case TrustedDomainsSettingChange = "trusted_domains_setting_change"; + case UnassignUnsnoozedAtCapacitySettingChange = "unassign_unsnoozed_at_capacity_setting_change"; case UpfrontEmailCollectionChange = "upfront_email_collection_change"; + case AllowedAttachmentFiletypesSettingChange = "allowed_attachment_filetypes_setting_change"; + case AttachUploadsInlineSettingChange = "attach_uploads_inline_setting_change"; + case TeammateGifsSettingChange = "teammate_gifs_setting_change"; + case UserCameraAttachmentsSettingChange = "user_camera_attachments_setting_change"; + case UserConversationAttachmentsSettingChange = "user_conversation_attachments_setting_change"; + case UserFileAttachmentsSettingChange = "user_file_attachments_setting_change"; + case UserGifsSettingChange = "user_gifs_setting_change"; + case UserMediaAttachmentsSettingChange = "user_media_attachments_setting_change"; + case UserVoiceNotesSettingChange = "user_voice_notes_setting_change"; case WelcomeMessageChange = "welcome_message_change"; + case WorkspaceDeletionRequest = "workspace_deletion_request"; } diff --git a/src/Types/ActivityLogList.php b/src/Types/ActivityLogList.php index 348cada..1f7695b 100644 --- a/src/Types/ActivityLogList.php +++ b/src/Types/ActivityLogList.php @@ -5,6 +5,7 @@ use Intercom\Core\Json\JsonSerializableType; use Intercom\Core\Json\JsonProperty; use Intercom\Core\Types\ArrayType; +use Intercom\Core\Types\Union; /** * A paginated list of activity logs. @@ -12,10 +13,10 @@ class ActivityLogList extends JsonSerializableType { /** - * @var 'activity_log.list' $type String representing the object's type. Always has the value `activity_log.list`. + * @var ?string $type String representing the object's type. Always has the value `activity_log.list`. */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** * @var ?CursorPages $pages @@ -24,38 +25,38 @@ class ActivityLogList extends JsonSerializableType private ?CursorPages $pages; /** - * @var array $activityLogs An array of activity logs + * @var ?array $activityLogs An array of activity logs */ - #[JsonProperty('activity_logs'), ArrayType([ActivityLog::class])] - private array $activityLogs; + #[JsonProperty('activity_logs'), ArrayType([new Union(ActivityLog::class, 'null')])] + private ?array $activityLogs; /** * @param array{ - * type: 'activity_log.list', - * activityLogs: array, + * type?: ?string, * pages?: ?CursorPages, + * activityLogs?: ?array, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; + $this->type = $values['type'] ?? null; $this->pages = $values['pages'] ?? null; - $this->activityLogs = $values['activityLogs']; + $this->activityLogs = $values['activityLogs'] ?? null; } /** - * @return 'activity_log.list' + * @return ?string */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'activity_log.list' $value + * @param ?string $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; @@ -79,17 +80,17 @@ public function setPages(?CursorPages $value = null): self } /** - * @return array + * @return ?array */ - public function getActivityLogs(): array + public function getActivityLogs(): ?array { return $this->activityLogs; } /** - * @param array $value + * @param ?array $value */ - public function setActivityLogs(array $value): self + public function setActivityLogs(?array $value = null): self { $this->activityLogs = $value; return $this; diff --git a/src/Types/ActivityLogMetadata.php b/src/Types/ActivityLogMetadata.php index 2990717..c230367 100644 --- a/src/Types/ActivityLogMetadata.php +++ b/src/Types/ActivityLogMetadata.php @@ -4,6 +4,9 @@ use Intercom\Core\Json\JsonSerializableType; use Intercom\Core\Json\JsonProperty; +use DateTime; +use Intercom\Core\Types\Date; +use Intercom\Core\Types\ArrayType; /** * Additional data provided about Admin activity. @@ -64,6 +67,60 @@ class ActivityLogMetadata extends JsonSerializableType #[JsonProperty('update_by_name')] private ?string $updateByName; + /** + * @var ?int $conversationAssignmentLimit The conversation assignment limit value for an admin. + */ + #[JsonProperty('conversation_assignment_limit')] + private ?int $conversationAssignmentLimit; + + /** + * @var ?int $ticketAssignmentLimit The ticket assignment limit value for an admin. + */ + #[JsonProperty('ticket_assignment_limit')] + private ?int $ticketAssignmentLimit; + + /** + * @var ?ActivityLogMetadataTeam $team Details about the team whose assignment limit was changed. + */ + #[JsonProperty('team')] + private ?ActivityLogMetadataTeam $team; + + /** + * @var ?int $teamAssignmentLimit The team assignment limit value (null if limit was removed). + */ + #[JsonProperty('team_assignment_limit')] + private ?int $teamAssignmentLimit; + + /** + * @var ?bool $enabled Indicates if the setting is enabled or disabled. + */ + #[JsonProperty('enabled')] + private ?bool $enabled; + + /** + * @var ?int $consentId The ID of the impersonation consent. + */ + #[JsonProperty('consent_id')] + private ?int $consentId; + + /** + * @var ?DateTime $expiredAt The timestamp when the impersonation consent expires. + */ + #[JsonProperty('expired_at'), Date(Date::TYPE_DATETIME)] + private ?DateTime $expiredAt; + + /** + * @var ?array $before The state of settings or values before the change. Structure varies by activity type. + */ + #[JsonProperty('before'), ArrayType(['string' => 'mixed'])] + private ?array $before; + + /** + * @var ?array $after The state of settings or values after the change. Structure varies by activity type. + */ + #[JsonProperty('after'), ArrayType(['string' => 'mixed'])] + private ?array $after; + /** * @param array{ * signInMethod?: ?string, @@ -75,6 +132,15 @@ class ActivityLogMetadata extends JsonSerializableType * autoChanged?: ?string, * updateBy?: ?int, * updateByName?: ?string, + * conversationAssignmentLimit?: ?int, + * ticketAssignmentLimit?: ?int, + * team?: ?ActivityLogMetadataTeam, + * teamAssignmentLimit?: ?int, + * enabled?: ?bool, + * consentId?: ?int, + * expiredAt?: ?DateTime, + * before?: ?array, + * after?: ?array, * } $values */ public function __construct( @@ -89,6 +155,15 @@ public function __construct( $this->autoChanged = $values['autoChanged'] ?? null; $this->updateBy = $values['updateBy'] ?? null; $this->updateByName = $values['updateByName'] ?? null; + $this->conversationAssignmentLimit = $values['conversationAssignmentLimit'] ?? null; + $this->ticketAssignmentLimit = $values['ticketAssignmentLimit'] ?? null; + $this->team = $values['team'] ?? null; + $this->teamAssignmentLimit = $values['teamAssignmentLimit'] ?? null; + $this->enabled = $values['enabled'] ?? null; + $this->consentId = $values['consentId'] ?? null; + $this->expiredAt = $values['expiredAt'] ?? null; + $this->before = $values['before'] ?? null; + $this->after = $values['after'] ?? null; } /** @@ -244,6 +319,159 @@ public function setUpdateByName(?string $value = null): self return $this; } + /** + * @return ?int + */ + public function getConversationAssignmentLimit(): ?int + { + return $this->conversationAssignmentLimit; + } + + /** + * @param ?int $value + */ + public function setConversationAssignmentLimit(?int $value = null): self + { + $this->conversationAssignmentLimit = $value; + return $this; + } + + /** + * @return ?int + */ + public function getTicketAssignmentLimit(): ?int + { + return $this->ticketAssignmentLimit; + } + + /** + * @param ?int $value + */ + public function setTicketAssignmentLimit(?int $value = null): self + { + $this->ticketAssignmentLimit = $value; + return $this; + } + + /** + * @return ?ActivityLogMetadataTeam + */ + public function getTeam(): ?ActivityLogMetadataTeam + { + return $this->team; + } + + /** + * @param ?ActivityLogMetadataTeam $value + */ + public function setTeam(?ActivityLogMetadataTeam $value = null): self + { + $this->team = $value; + return $this; + } + + /** + * @return ?int + */ + public function getTeamAssignmentLimit(): ?int + { + return $this->teamAssignmentLimit; + } + + /** + * @param ?int $value + */ + public function setTeamAssignmentLimit(?int $value = null): self + { + $this->teamAssignmentLimit = $value; + return $this; + } + + /** + * @return ?bool + */ + public function getEnabled(): ?bool + { + return $this->enabled; + } + + /** + * @param ?bool $value + */ + public function setEnabled(?bool $value = null): self + { + $this->enabled = $value; + return $this; + } + + /** + * @return ?int + */ + public function getConsentId(): ?int + { + return $this->consentId; + } + + /** + * @param ?int $value + */ + public function setConsentId(?int $value = null): self + { + $this->consentId = $value; + return $this; + } + + /** + * @return ?DateTime + */ + public function getExpiredAt(): ?DateTime + { + return $this->expiredAt; + } + + /** + * @param ?DateTime $value + */ + public function setExpiredAt(?DateTime $value = null): self + { + $this->expiredAt = $value; + return $this; + } + + /** + * @return ?array + */ + public function getBefore(): ?array + { + return $this->before; + } + + /** + * @param ?array $value + */ + public function setBefore(?array $value = null): self + { + $this->before = $value; + return $this; + } + + /** + * @return ?array + */ + public function getAfter(): ?array + { + return $this->after; + } + + /** + * @param ?array $value + */ + public function setAfter(?array $value = null): self + { + $this->after = $value; + return $this; + } + /** * @return string */ diff --git a/src/Types/ActivityLogMetadataTeam.php b/src/Types/ActivityLogMetadataTeam.php new file mode 100644 index 0000000..f535b0d --- /dev/null +++ b/src/Types/ActivityLogMetadataTeam.php @@ -0,0 +1,79 @@ +id = $values['id'] ?? null; + $this->name = $values['name'] ?? null; + } + + /** + * @return ?int + */ + public function getId(): ?int + { + return $this->id; + } + + /** + * @param ?int $value + */ + public function setId(?int $value = null): self + { + $this->id = $value; + return $this; + } + + /** + * @return ?string + */ + public function getName(): ?string + { + return $this->name; + } + + /** + * @param ?string $value + */ + public function setName(?string $value = null): self + { + $this->name = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/ActivityLogPerformedBy.php b/src/Types/ActivityLogPerformedBy.php index 0f2fee6..6abcfbd 100644 --- a/src/Types/ActivityLogPerformedBy.php +++ b/src/Types/ActivityLogPerformedBy.php @@ -11,7 +11,7 @@ class ActivityLogPerformedBy extends JsonSerializableType { /** - * @var ?'admin' $type String representing the object's type. Always has the value `admin`. + * @var ?string $type String representing the object's type. Always has the value `admin`. */ #[JsonProperty('type')] private ?string $type; @@ -36,7 +36,7 @@ class ActivityLogPerformedBy extends JsonSerializableType /** * @param array{ - * type?: ?'admin', + * type?: ?string, * id?: ?string, * email?: ?string, * ip?: ?string, @@ -52,7 +52,7 @@ public function __construct( } /** - * @return ?'admin' + * @return ?string */ public function getType(): ?string { @@ -60,7 +60,7 @@ public function getType(): ?string } /** - * @param ?'admin' $value + * @param ?string $value */ public function setType(?string $value = null): self { diff --git a/src/Types/AddressableList.php b/src/Types/AddressableList.php index 54942c8..b19309c 100644 --- a/src/Types/AddressableList.php +++ b/src/Types/AddressableList.php @@ -11,84 +11,84 @@ class AddressableList extends JsonSerializableType { /** - * @var string $type The addressable object type + * @var ?string $type The addressable object type */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var string $id The id of the addressable object + * @var ?string $id The id of the addressable object */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** - * @var string $url Url to get more company resources for this contact + * @var ?string $url Url to get more company resources for this contact */ #[JsonProperty('url')] - private string $url; + private ?string $url; /** * @param array{ - * type: string, - * id: string, - * url: string, + * type?: ?string, + * id?: ?string, + * url?: ?string, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->id = $values['id']; - $this->url = $values['url']; + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->url = $values['url'] ?? null; } /** - * @return string + * @return ?string */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param string $value + * @param ?string $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; } /** - * @return string + * @return ?string */ - public function getUrl(): string + public function getUrl(): ?string { return $this->url; } /** - * @param string $value + * @param ?string $value */ - public function setUrl(string $value): self + public function setUrl(?string $value = null): self { $this->url = $value; return $this; diff --git a/src/Types/AdminList.php b/src/Types/AdminList.php index cd10008..780b63b 100644 --- a/src/Types/AdminList.php +++ b/src/Types/AdminList.php @@ -6,6 +6,7 @@ use Intercom\Core\Json\JsonProperty; use Intercom\Admins\Types\Admin; use Intercom\Core\Types\ArrayType; +use Intercom\Core\Types\Union; /** * A list of admins associated with a given workspace. @@ -13,59 +14,59 @@ class AdminList extends JsonSerializableType { /** - * @var 'admin.list' $type String representing the object's type. Always has the value `admin.list`. + * @var ?string $type String representing the object's type. Always has the value `admin.list`. */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var array $admins A list of admins associated with a given workspace. + * @var ?array $admins A list of admins associated with a given workspace. */ - #[JsonProperty('admins'), ArrayType([Admin::class])] - private array $admins; + #[JsonProperty('admins'), ArrayType([new Union(Admin::class, 'null')])] + private ?array $admins; /** * @param array{ - * type: 'admin.list', - * admins: array, + * type?: ?string, + * admins?: ?array, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->admins = $values['admins']; + $this->type = $values['type'] ?? null; + $this->admins = $values['admins'] ?? null; } /** - * @return 'admin.list' + * @return ?string */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'admin.list' $value + * @param ?string $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return array + * @return ?array */ - public function getAdmins(): array + public function getAdmins(): ?array { return $this->admins; } /** - * @param array $value + * @param ?array $value */ - public function setAdmins(array $value): self + public function setAdmins(?array $value = null): self { $this->admins = $value; return $this; diff --git a/src/Types/AdminReplyConversationRequest.php b/src/Types/AdminReplyConversationRequest.php index e68388f..dbdabde 100644 --- a/src/Types/AdminReplyConversationRequest.php +++ b/src/Types/AdminReplyConversationRequest.php @@ -41,6 +41,12 @@ class AdminReplyConversationRequest extends JsonSerializableType #[JsonProperty('created_at')] private ?int $createdAt; + /** + * @var ?array $replyOptions The quick reply options to display to the end user. Must be present for quick_reply message types. + */ + #[JsonProperty('reply_options'), ArrayType([QuickReplyOption::class])] + private ?array $replyOptions; + /** * @var ?array $attachmentUrls A list of image URLs that will be added as attachments. You can include up to 10 URLs. */ @@ -60,6 +66,7 @@ class AdminReplyConversationRequest extends JsonSerializableType * adminId: string, * body?: ?string, * createdAt?: ?int, + * replyOptions?: ?array, * attachmentUrls?: ?array, * attachmentFiles?: ?array, * } $values @@ -72,6 +79,7 @@ public function __construct( $this->body = $values['body'] ?? null; $this->adminId = $values['adminId']; $this->createdAt = $values['createdAt'] ?? null; + $this->replyOptions = $values['replyOptions'] ?? null; $this->attachmentUrls = $values['attachmentUrls'] ?? null; $this->attachmentFiles = $values['attachmentFiles'] ?? null; } @@ -161,6 +169,23 @@ public function setCreatedAt(?int $value = null): self return $this; } + /** + * @return ?array + */ + public function getReplyOptions(): ?array + { + return $this->replyOptions; + } + + /** + * @param ?array $value + */ + public function setReplyOptions(?array $value = null): self + { + $this->replyOptions = $value; + return $this; + } + /** * @return ?array */ diff --git a/src/Types/AdminReplyConversationRequestMessageType.php b/src/Types/AdminReplyConversationRequestMessageType.php index a7c7fae..6cfcb82 100644 --- a/src/Types/AdminReplyConversationRequestMessageType.php +++ b/src/Types/AdminReplyConversationRequestMessageType.php @@ -6,4 +6,5 @@ enum AdminReplyConversationRequestMessageType: string { case Comment = "comment"; case Note = "note"; + case QuickReply = "quick_reply"; } diff --git a/src/Types/AdminWithApp.php b/src/Types/AdminWithApp.php index 4a1a2b9..0e37f30 100644 --- a/src/Types/AdminWithApp.php +++ b/src/Types/AdminWithApp.php @@ -12,58 +12,58 @@ class AdminWithApp extends JsonSerializableType { /** - * @var 'admin' $type String representing the object's type. Always has the value `admin`. + * @var ?string $type String representing the object's type. Always has the value `admin`. */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var string $id The id representing the admin. + * @var ?string $id The id representing the admin. */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** - * @var string $name The name of the admin. + * @var ?string $name The name of the admin. */ #[JsonProperty('name')] - private string $name; + private ?string $name; /** - * @var string $email The email of the admin. + * @var ?string $email The email of the admin. */ #[JsonProperty('email')] - private string $email; + private ?string $email; /** - * @var string $jobTitle The job title of the admin. + * @var ?string $jobTitle The job title of the admin. */ #[JsonProperty('job_title')] - private string $jobTitle; + private ?string $jobTitle; /** - * @var bool $awayModeEnabled Identifies if this admin is currently set in away mode. + * @var ?bool $awayModeEnabled Identifies if this admin is currently set in away mode. */ #[JsonProperty('away_mode_enabled')] - private bool $awayModeEnabled; + private ?bool $awayModeEnabled; /** - * @var bool $awayModeReassign Identifies if this admin is set to automatically reassign new conversations to the apps default inbox. + * @var ?bool $awayModeReassign Identifies if this admin is set to automatically reassign new conversations to the apps default inbox. */ #[JsonProperty('away_mode_reassign')] - private bool $awayModeReassign; + private ?bool $awayModeReassign; /** - * @var bool $hasInboxSeat Identifies if this admin has a paid inbox seat to restrict/allow features that require them. + * @var ?bool $hasInboxSeat Identifies if this admin has a paid inbox seat to restrict/allow features that require them. */ #[JsonProperty('has_inbox_seat')] - private bool $hasInboxSeat; + private ?bool $hasInboxSeat; /** - * @var array $teamIds This is a list of ids of the teams that this admin is part of. + * @var ?array $teamIds This is a list of ids of the teams that this admin is part of. */ #[JsonProperty('team_ids'), ArrayType(['integer'])] - private array $teamIds; + private ?array $teamIds; /** * @var ?AdminWithAppAvatar $avatar This object represents the avatar associated with the admin. @@ -85,185 +85,185 @@ class AdminWithApp extends JsonSerializableType /** * @param array{ - * type: 'admin', - * id: string, - * name: string, - * email: string, - * jobTitle: string, - * awayModeEnabled: bool, - * awayModeReassign: bool, - * hasInboxSeat: bool, - * teamIds: array, + * type?: ?string, + * id?: ?string, + * name?: ?string, + * email?: ?string, + * jobTitle?: ?string, + * awayModeEnabled?: ?bool, + * awayModeReassign?: ?bool, + * hasInboxSeat?: ?bool, + * teamIds?: ?array, * avatar?: ?AdminWithAppAvatar, * emailVerified?: ?bool, * app?: ?App, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->id = $values['id']; - $this->name = $values['name']; - $this->email = $values['email']; - $this->jobTitle = $values['jobTitle']; - $this->awayModeEnabled = $values['awayModeEnabled']; - $this->awayModeReassign = $values['awayModeReassign']; - $this->hasInboxSeat = $values['hasInboxSeat']; - $this->teamIds = $values['teamIds']; + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->name = $values['name'] ?? null; + $this->email = $values['email'] ?? null; + $this->jobTitle = $values['jobTitle'] ?? null; + $this->awayModeEnabled = $values['awayModeEnabled'] ?? null; + $this->awayModeReassign = $values['awayModeReassign'] ?? null; + $this->hasInboxSeat = $values['hasInboxSeat'] ?? null; + $this->teamIds = $values['teamIds'] ?? null; $this->avatar = $values['avatar'] ?? null; $this->emailVerified = $values['emailVerified'] ?? null; $this->app = $values['app'] ?? null; } /** - * @return 'admin' + * @return ?string */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'admin' $value + * @param ?string $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; } /** - * @return string + * @return ?string */ - public function getName(): string + public function getName(): ?string { return $this->name; } /** - * @param string $value + * @param ?string $value */ - public function setName(string $value): self + public function setName(?string $value = null): self { $this->name = $value; return $this; } /** - * @return string + * @return ?string */ - public function getEmail(): string + public function getEmail(): ?string { return $this->email; } /** - * @param string $value + * @param ?string $value */ - public function setEmail(string $value): self + public function setEmail(?string $value = null): self { $this->email = $value; return $this; } /** - * @return string + * @return ?string */ - public function getJobTitle(): string + public function getJobTitle(): ?string { return $this->jobTitle; } /** - * @param string $value + * @param ?string $value */ - public function setJobTitle(string $value): self + public function setJobTitle(?string $value = null): self { $this->jobTitle = $value; return $this; } /** - * @return bool + * @return ?bool */ - public function getAwayModeEnabled(): bool + public function getAwayModeEnabled(): ?bool { return $this->awayModeEnabled; } /** - * @param bool $value + * @param ?bool $value */ - public function setAwayModeEnabled(bool $value): self + public function setAwayModeEnabled(?bool $value = null): self { $this->awayModeEnabled = $value; return $this; } /** - * @return bool + * @return ?bool */ - public function getAwayModeReassign(): bool + public function getAwayModeReassign(): ?bool { return $this->awayModeReassign; } /** - * @param bool $value + * @param ?bool $value */ - public function setAwayModeReassign(bool $value): self + public function setAwayModeReassign(?bool $value = null): self { $this->awayModeReassign = $value; return $this; } /** - * @return bool + * @return ?bool */ - public function getHasInboxSeat(): bool + public function getHasInboxSeat(): ?bool { return $this->hasInboxSeat; } /** - * @param bool $value + * @param ?bool $value */ - public function setHasInboxSeat(bool $value): self + public function setHasInboxSeat(?bool $value = null): self { $this->hasInboxSeat = $value; return $this; } /** - * @return array + * @return ?array */ - public function getTeamIds(): array + public function getTeamIds(): ?array { return $this->teamIds; } /** - * @param array $value + * @param ?array $value */ - public function setTeamIds(array $value): self + public function setTeamIds(?array $value = null): self { $this->teamIds = $value; return $this; diff --git a/src/Types/AdminWithAppAvatar.php b/src/Types/AdminWithAppAvatar.php index 9066188..41f290c 100644 --- a/src/Types/AdminWithAppAvatar.php +++ b/src/Types/AdminWithAppAvatar.php @@ -11,7 +11,7 @@ class AdminWithAppAvatar extends JsonSerializableType { /** - * @var ?'avatar' $type This is a string that identifies the type of the object. It will always have the value `avatar`. + * @var ?string $type This is a string that identifies the type of the object. It will always have the value `avatar`. */ #[JsonProperty('type')] private ?string $type; @@ -24,7 +24,7 @@ class AdminWithAppAvatar extends JsonSerializableType /** * @param array{ - * type?: ?'avatar', + * type?: ?string, * imageUrl?: ?string, * } $values */ @@ -36,7 +36,7 @@ public function __construct( } /** - * @return ?'avatar' + * @return ?string */ public function getType(): ?string { @@ -44,7 +44,7 @@ public function getType(): ?string } /** - * @param ?'avatar' $value + * @param ?string $value */ public function setType(?string $value = null): self { diff --git a/src/Types/App.php b/src/Types/App.php index ee8a586..8d24f8a 100644 --- a/src/Types/App.php +++ b/src/Types/App.php @@ -11,184 +11,184 @@ class App extends JsonSerializableType { /** - * @var string $type + * @var ?string $type */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var string $idCode The id of the app. + * @var ?string $idCode The id of the app. */ #[JsonProperty('id_code')] - private string $idCode; + private ?string $idCode; /** - * @var string $name The name of the app. + * @var ?string $name The name of the app. */ #[JsonProperty('name')] - private string $name; + private ?string $name; /** - * @var string $region The Intercom region the app is located in. + * @var ?string $region The Intercom region the app is located in. */ #[JsonProperty('region')] - private string $region; + private ?string $region; /** - * @var string $timezone The timezone of the region where the app is located. + * @var ?string $timezone The timezone of the region where the app is located. */ #[JsonProperty('timezone')] - private string $timezone; + private ?string $timezone; /** - * @var int $createdAt When the app was created. + * @var ?int $createdAt When the app was created. */ #[JsonProperty('created_at')] - private int $createdAt; + private ?int $createdAt; /** - * @var bool $identityVerification Whether or not the app uses identity verification. + * @var ?bool $identityVerification Whether or not the app uses identity verification. */ #[JsonProperty('identity_verification')] - private bool $identityVerification; + private ?bool $identityVerification; /** * @param array{ - * type: string, - * idCode: string, - * name: string, - * region: string, - * timezone: string, - * createdAt: int, - * identityVerification: bool, + * type?: ?string, + * idCode?: ?string, + * name?: ?string, + * region?: ?string, + * timezone?: ?string, + * createdAt?: ?int, + * identityVerification?: ?bool, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->idCode = $values['idCode']; - $this->name = $values['name']; - $this->region = $values['region']; - $this->timezone = $values['timezone']; - $this->createdAt = $values['createdAt']; - $this->identityVerification = $values['identityVerification']; + $this->type = $values['type'] ?? null; + $this->idCode = $values['idCode'] ?? null; + $this->name = $values['name'] ?? null; + $this->region = $values['region'] ?? null; + $this->timezone = $values['timezone'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; + $this->identityVerification = $values['identityVerification'] ?? null; } /** - * @return string + * @return ?string */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param string $value + * @param ?string $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return string + * @return ?string */ - public function getIdCode(): string + public function getIdCode(): ?string { return $this->idCode; } /** - * @param string $value + * @param ?string $value */ - public function setIdCode(string $value): self + public function setIdCode(?string $value = null): self { $this->idCode = $value; return $this; } /** - * @return string + * @return ?string */ - public function getName(): string + public function getName(): ?string { return $this->name; } /** - * @param string $value + * @param ?string $value */ - public function setName(string $value): self + public function setName(?string $value = null): self { $this->name = $value; return $this; } /** - * @return string + * @return ?string */ - public function getRegion(): string + public function getRegion(): ?string { return $this->region; } /** - * @param string $value + * @param ?string $value */ - public function setRegion(string $value): self + public function setRegion(?string $value = null): self { $this->region = $value; return $this; } /** - * @return string + * @return ?string */ - public function getTimezone(): string + public function getTimezone(): ?string { return $this->timezone; } /** - * @param string $value + * @param ?string $value */ - public function setTimezone(string $value): self + public function setTimezone(?string $value = null): self { $this->timezone = $value; return $this; } /** - * @return int + * @return ?int */ - public function getCreatedAt(): int + public function getCreatedAt(): ?int { return $this->createdAt; } /** - * @param int $value + * @param ?int $value */ - public function setCreatedAt(int $value): self + public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; return $this; } /** - * @return bool + * @return ?bool */ - public function getIdentityVerification(): bool + public function getIdentityVerification(): ?bool { return $this->identityVerification; } /** - * @param bool $value + * @param ?bool $value */ - public function setIdentityVerification(bool $value): self + public function setIdentityVerification(?bool $value = null): self { $this->identityVerification = $value; return $this; diff --git a/src/Types/ArticleContent.php b/src/Types/ArticleContent.php index 9581cf4..6e4f6c1 100644 --- a/src/Types/ArticleContent.php +++ b/src/Types/ArticleContent.php @@ -11,40 +11,40 @@ class ArticleContent extends JsonSerializableType { /** - * @var 'article_content' $type The type of object - `article_content` . + * @var ?'article_content' $type The type of object - `article_content` . */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var string $title The title of the article. + * @var ?string $title The title of the article. */ #[JsonProperty('title')] - private string $title; + private ?string $title; /** - * @var string $description The description of the article. + * @var ?string $description The description of the article. */ #[JsonProperty('description')] - private string $description; + private ?string $description; /** - * @var string $body The body of the article. + * @var ?string $body The body of the article. */ #[JsonProperty('body')] - private string $body; + private ?string $body; /** - * @var int $authorId The ID of the author of the article. + * @var ?int $authorId The ID of the author of the article. */ #[JsonProperty('author_id')] - private int $authorId; + private ?int $authorId; /** - * @var value-of $state Whether the article is `published` or is a `draft` . + * @var ?value-of $state Whether the article is `published` or is a `draft` . */ #[JsonProperty('state')] - private string $state; + private ?string $state; /** * @var ?int $createdAt The time when the article was created (seconds). @@ -66,128 +66,128 @@ class ArticleContent extends JsonSerializableType /** * @param array{ - * type: 'article_content', - * title: string, - * description: string, - * body: string, - * authorId: int, - * state: value-of, + * type?: ?'article_content', + * title?: ?string, + * description?: ?string, + * body?: ?string, + * authorId?: ?int, + * state?: ?value-of, * createdAt?: ?int, * updatedAt?: ?int, * url?: ?string, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->title = $values['title']; - $this->description = $values['description']; - $this->body = $values['body']; - $this->authorId = $values['authorId']; - $this->state = $values['state']; + $this->type = $values['type'] ?? null; + $this->title = $values['title'] ?? null; + $this->description = $values['description'] ?? null; + $this->body = $values['body'] ?? null; + $this->authorId = $values['authorId'] ?? null; + $this->state = $values['state'] ?? null; $this->createdAt = $values['createdAt'] ?? null; $this->updatedAt = $values['updatedAt'] ?? null; $this->url = $values['url'] ?? null; } /** - * @return 'article_content' + * @return ?'article_content' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'article_content' $value + * @param ?'article_content' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return string + * @return ?string */ - public function getTitle(): string + public function getTitle(): ?string { return $this->title; } /** - * @param string $value + * @param ?string $value */ - public function setTitle(string $value): self + public function setTitle(?string $value = null): self { $this->title = $value; return $this; } /** - * @return string + * @return ?string */ - public function getDescription(): string + public function getDescription(): ?string { return $this->description; } /** - * @param string $value + * @param ?string $value */ - public function setDescription(string $value): self + public function setDescription(?string $value = null): self { $this->description = $value; return $this; } /** - * @return string + * @return ?string */ - public function getBody(): string + public function getBody(): ?string { return $this->body; } /** - * @param string $value + * @param ?string $value */ - public function setBody(string $value): self + public function setBody(?string $value = null): self { $this->body = $value; return $this; } /** - * @return int + * @return ?int */ - public function getAuthorId(): int + public function getAuthorId(): ?int { return $this->authorId; } /** - * @param int $value + * @param ?int $value */ - public function setAuthorId(int $value): self + public function setAuthorId(?int $value = null): self { $this->authorId = $value; return $this; } /** - * @return value-of + * @return ?value-of */ - public function getState(): string + public function getState(): ?string { return $this->state; } /** - * @param value-of $value + * @param ?value-of $value */ - public function setState(string $value): self + public function setState(?string $value = null): self { $this->state = $value; return $this; diff --git a/src/Types/ArticleList.php b/src/Types/ArticleList.php index c5a0907..f3600c2 100644 --- a/src/Types/ArticleList.php +++ b/src/Types/ArticleList.php @@ -13,10 +13,10 @@ class ArticleList extends JsonSerializableType { /** - * @var 'list' $type The type of the object - `list`. + * @var ?'list' $type The type of the object - `list`. */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** * @var mixed $pages @@ -25,46 +25,46 @@ class ArticleList extends JsonSerializableType private mixed $pages; /** - * @var int $totalCount A count of the total number of articles. + * @var ?int $totalCount A count of the total number of articles. */ #[JsonProperty('total_count')] - private int $totalCount; + private ?int $totalCount; /** - * @var array $data An array of Article objects + * @var ?array $data An array of Article objects */ #[JsonProperty('data'), ArrayType([ArticleListItem::class])] - private array $data; + private ?array $data; /** * @param array{ - * type: 'list', - * totalCount: int, - * data: array, + * type?: ?'list', * pages?: mixed, + * totalCount?: ?int, + * data?: ?array, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; + $this->type = $values['type'] ?? null; $this->pages = $values['pages'] ?? null; - $this->totalCount = $values['totalCount']; - $this->data = $values['data']; + $this->totalCount = $values['totalCount'] ?? null; + $this->data = $values['data'] ?? null; } /** - * @return 'list' + * @return ?'list' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'list' $value + * @param ?'list' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; @@ -88,34 +88,34 @@ public function setPages(mixed $value = null): self } /** - * @return int + * @return ?int */ - public function getTotalCount(): int + public function getTotalCount(): ?int { return $this->totalCount; } /** - * @param int $value + * @param ?int $value */ - public function setTotalCount(int $value): self + public function setTotalCount(?int $value = null): self { $this->totalCount = $value; return $this; } /** - * @return array + * @return ?array */ - public function getData(): array + public function getData(): ?array { return $this->data; } /** - * @param array $value + * @param ?array $value */ - public function setData(array $value): self + public function setData(?array $value = null): self { $this->data = $value; return $this; diff --git a/src/Types/AwayStatusReason.php b/src/Types/AwayStatusReason.php new file mode 100644 index 0000000..47e4886 --- /dev/null +++ b/src/Types/AwayStatusReason.php @@ -0,0 +1,226 @@ +type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->label = $values['label'] ?? null; + $this->emoji = $values['emoji'] ?? null; + $this->order = $values['order'] ?? null; + $this->deleted = $values['deleted'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; + $this->updatedAt = $values['updatedAt'] ?? null; + } + + /** + * @return ?string + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?string $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?string + */ + public function getId(): ?string + { + return $this->id; + } + + /** + * @param ?string $value + */ + public function setId(?string $value = null): self + { + $this->id = $value; + return $this; + } + + /** + * @return ?string + */ + public function getLabel(): ?string + { + return $this->label; + } + + /** + * @param ?string $value + */ + public function setLabel(?string $value = null): self + { + $this->label = $value; + return $this; + } + + /** + * @return ?string + */ + public function getEmoji(): ?string + { + return $this->emoji; + } + + /** + * @param ?string $value + */ + public function setEmoji(?string $value = null): self + { + $this->emoji = $value; + return $this; + } + + /** + * @return ?int + */ + public function getOrder(): ?int + { + return $this->order; + } + + /** + * @param ?int $value + */ + public function setOrder(?int $value = null): self + { + $this->order = $value; + return $this; + } + + /** + * @return ?bool + */ + public function getDeleted(): ?bool + { + return $this->deleted; + } + + /** + * @param ?bool $value + */ + public function setDeleted(?bool $value = null): self + { + $this->deleted = $value; + return $this; + } + + /** + * @return ?int + */ + public function getCreatedAt(): ?int + { + return $this->createdAt; + } + + /** + * @param ?int $value + */ + public function setCreatedAt(?int $value = null): self + { + $this->createdAt = $value; + return $this; + } + + /** + * @return ?int + */ + public function getUpdatedAt(): ?int + { + return $this->updatedAt; + } + + /** + * @param ?int $value + */ + public function setUpdatedAt(?int $value = null): self + { + $this->updatedAt = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/ButtonComponent.php b/src/Types/ButtonComponent.php deleted file mode 100644 index 99441a6..0000000 --- a/src/Types/ButtonComponent.php +++ /dev/null @@ -1,157 +0,0 @@ - $style Styles the button. Default is 'primary'. - */ - #[JsonProperty('style')] - private ?string $style; - - /** - * @var ?bool $disabled Styles the button and prevents the action. Default is false. - */ - #[JsonProperty('disabled')] - private ?bool $disabled; - - /** - * @param array{ - * id: string, - * label: string, - * action: ActionComponent, - * style?: ?value-of, - * disabled?: ?bool, - * } $values - */ - public function __construct( - array $values, - ) { - $this->id = $values['id']; - $this->label = $values['label']; - $this->action = $values['action']; - $this->style = $values['style'] ?? null; - $this->disabled = $values['disabled'] ?? null; - } - - /** - * @return string - */ - public function getId(): string - { - return $this->id; - } - - /** - * @param string $value - */ - public function setId(string $value): self - { - $this->id = $value; - return $this; - } - - /** - * @return string - */ - public function getLabel(): string - { - return $this->label; - } - - /** - * @param string $value - */ - public function setLabel(string $value): self - { - $this->label = $value; - return $this; - } - - /** - * @return ActionComponent - */ - public function getAction(): ActionComponent - { - return $this->action; - } - - /** - * @param ActionComponent $value - */ - public function setAction(ActionComponent $value): self - { - $this->action = $value; - return $this; - } - - /** - * @return ?value-of - */ - public function getStyle(): ?string - { - return $this->style; - } - - /** - * @param ?value-of $value - */ - public function setStyle(?string $value = null): self - { - $this->style = $value; - return $this; - } - - /** - * @return ?bool - */ - public function getDisabled(): ?bool - { - return $this->disabled; - } - - /** - * @param ?bool $value - */ - public function setDisabled(?bool $value = null): self - { - $this->disabled = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/ButtonComponentStyle.php b/src/Types/ButtonComponentStyle.php deleted file mode 100644 index f048958..0000000 --- a/src/Types/ButtonComponentStyle.php +++ /dev/null @@ -1,10 +0,0 @@ - $data A list of calls. */ - #[JsonProperty('pages')] - private ?CursorPages $pages; + #[JsonProperty('data'), ArrayType([Call::class])] + private ?array $data; /** - * @var int $totalCount A count of the total number of News Items. + * @var ?int $totalCount Total number of items available. */ #[JsonProperty('total_count')] - private int $totalCount; + private ?int $totalCount; /** - * @var array $data An array of News Items + * @var ?CursorPages $pages */ - #[JsonProperty('data'), ArrayType([NewsItem::class])] - private array $data; + #[JsonProperty('pages')] + private ?CursorPages $pages; /** * @param array{ - * type: 'list', - * totalCount: int, - * data: array, + * type?: ?string, + * data?: ?array, + * totalCount?: ?int, * pages?: ?CursorPages, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; + $this->type = $values['type'] ?? null; + $this->data = $values['data'] ?? null; + $this->totalCount = $values['totalCount'] ?? null; $this->pages = $values['pages'] ?? null; - $this->totalCount = $values['totalCount']; - $this->data = $values['data']; } /** - * @return 'list' + * @return ?string */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'list' $value + * @param ?string $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return ?CursorPages + * @return ?array */ - public function getPages(): ?CursorPages + public function getData(): ?array { - return $this->pages; + return $this->data; } /** - * @param ?CursorPages $value + * @param ?array $value */ - public function setPages(?CursorPages $value = null): self + public function setData(?array $value = null): self { - $this->pages = $value; + $this->data = $value; return $this; } /** - * @return int + * @return ?int */ - public function getTotalCount(): int + public function getTotalCount(): ?int { return $this->totalCount; } /** - * @param int $value + * @param ?int $value */ - public function setTotalCount(int $value): self + public function setTotalCount(?int $value = null): self { $this->totalCount = $value; return $this; } /** - * @return array + * @return ?CursorPages */ - public function getData(): array + public function getPages(): ?CursorPages { - return $this->data; + return $this->pages; } /** - * @param array $value + * @param ?CursorPages $value */ - public function setData(array $value): self + public function setPages(?CursorPages $value = null): self { - $this->data = $value; + $this->pages = $value; return $this; } diff --git a/src/Types/CanvasObject.php b/src/Types/CanvasObject.php deleted file mode 100644 index 42288ca..0000000 --- a/src/Types/CanvasObject.php +++ /dev/null @@ -1,110 +0,0 @@ - $storedData Optional Stored Data that you want to be returned in the next sent request. Max Size is 64KB. - */ - #[JsonProperty('stored_data'), ArrayType(['string' => 'mixed'])] - private ?array $storedData; - - /** - * @param array{ - * content: ContentObject, - * contentUrl?: ?string, - * storedData?: ?array, - * } $values - */ - public function __construct( - array $values, - ) { - $this->content = $values['content']; - $this->contentUrl = $values['contentUrl'] ?? null; - $this->storedData = $values['storedData'] ?? null; - } - - /** - * @return ContentObject - */ - public function getContent(): ContentObject - { - return $this->content; - } - - /** - * @param ContentObject $value - */ - public function setContent(ContentObject $value): self - { - $this->content = $value; - return $this; - } - - /** - * @return ?string - */ - public function getContentUrl(): ?string - { - return $this->contentUrl; - } - - /** - * @param ?string $value - */ - public function setContentUrl(?string $value = null): self - { - $this->contentUrl = $value; - return $this; - } - - /** - * @return ?array - */ - public function getStoredData(): ?array - { - return $this->storedData; - } - - /** - * @param ?array $value - */ - public function setStoredData(?array $value = null): self - { - $this->storedData = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/CheckboxComponent.php b/src/Types/CheckboxComponent.php deleted file mode 100644 index 8029155..0000000 --- a/src/Types/CheckboxComponent.php +++ /dev/null @@ -1,184 +0,0 @@ - $option The list of options. Minimum of 1. - */ - #[JsonProperty('option'), ArrayType([CheckboxOption::class])] - private array $option; - - /** - * @var string $label The text shown above the options. - */ - #[JsonProperty('label')] - private string $label; - - /** - * @var ?array $value The option's that are selected by default. - */ - #[JsonProperty('value'), ArrayType(['string'])] - private ?array $value; - - /** - * @var ?value-of $saveState Styles the input. Default is `unsaved`. Prevent action with `saved`. - */ - #[JsonProperty('save_state')] - private ?string $saveState; - - /** - * @var ?bool $disabled Styles all options and prevents the action. Default is false. Will be overridden if save_state is saved. - */ - #[JsonProperty('disabled')] - private ?bool $disabled; - - /** - * @param array{ - * id: string, - * option: array, - * label: string, - * value?: ?array, - * saveState?: ?value-of, - * disabled?: ?bool, - * } $values - */ - public function __construct( - array $values, - ) { - $this->id = $values['id']; - $this->option = $values['option']; - $this->label = $values['label']; - $this->value = $values['value'] ?? null; - $this->saveState = $values['saveState'] ?? null; - $this->disabled = $values['disabled'] ?? null; - } - - /** - * @return string - */ - public function getId(): string - { - return $this->id; - } - - /** - * @param string $value - */ - public function setId(string $value): self - { - $this->id = $value; - return $this; - } - - /** - * @return array - */ - public function getOption(): array - { - return $this->option; - } - - /** - * @param array $value - */ - public function setOption(array $value): self - { - $this->option = $value; - return $this; - } - - /** - * @return string - */ - public function getLabel(): string - { - return $this->label; - } - - /** - * @param string $value - */ - public function setLabel(string $value): self - { - $this->label = $value; - return $this; - } - - /** - * @return ?array - */ - public function getValue(): ?array - { - return $this->value; - } - - /** - * @param ?array $value - */ - public function setValue(?array $value = null): self - { - $this->value = $value; - return $this; - } - - /** - * @return ?value-of - */ - public function getSaveState(): ?string - { - return $this->saveState; - } - - /** - * @param ?value-of $value - */ - public function setSaveState(?string $value = null): self - { - $this->saveState = $value; - return $this; - } - - /** - * @return ?bool - */ - public function getDisabled(): ?bool - { - return $this->disabled; - } - - /** - * @param ?bool $value - */ - public function setDisabled(?bool $value = null): self - { - $this->disabled = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/CheckboxComponentSaveState.php b/src/Types/CheckboxComponentSaveState.php deleted file mode 100644 index fc07bc6..0000000 --- a/src/Types/CheckboxComponentSaveState.php +++ /dev/null @@ -1,10 +0,0 @@ -type = $values['type']; - $this->id = $values['id']; - $this->text = $values['text']; - $this->disabled = $values['disabled'] ?? null; - } - - /** - * @return 'option' - */ - public function getType(): string - { - return $this->type; - } - - /** - * @param 'option' $value - */ - public function setType(string $value): self - { - $this->type = $value; - return $this; - } - - /** - * @return string - */ - public function getId(): string - { - return $this->id; - } - - /** - * @param string $value - */ - public function setId(string $value): self - { - $this->id = $value; - return $this; - } - - /** - * @return string - */ - public function getText(): string - { - return $this->text; - } - - /** - * @param string $value - */ - public function setText(string $value): self - { - $this->text = $value; - return $this; - } - - /** - * @return ?bool - */ - public function getDisabled(): ?bool - { - return $this->disabled; - } - - /** - * @param ?bool $value - */ - public function setDisabled(?bool $value = null): self - { - $this->disabled = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/CollectionList.php b/src/Types/CollectionList.php index 22e19ca..42714b4 100644 --- a/src/Types/CollectionList.php +++ b/src/Types/CollectionList.php @@ -13,10 +13,10 @@ class CollectionList extends JsonSerializableType { /** - * @var 'list' $type The type of the object - `list`. + * @var ?'list' $type The type of the object - `list`. */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** * @var ?OffsetPages $pages @@ -25,46 +25,46 @@ class CollectionList extends JsonSerializableType private ?OffsetPages $pages; /** - * @var int $totalCount A count of the total number of collections. + * @var ?int $totalCount A count of the total number of collections. */ #[JsonProperty('total_count')] - private int $totalCount; + private ?int $totalCount; /** - * @var array $data An array of collection objects + * @var ?array $data An array of collection objects */ #[JsonProperty('data'), ArrayType([Collection::class])] - private array $data; + private ?array $data; /** * @param array{ - * type: 'list', - * totalCount: int, - * data: array, + * type?: ?'list', * pages?: ?OffsetPages, + * totalCount?: ?int, + * data?: ?array, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; + $this->type = $values['type'] ?? null; $this->pages = $values['pages'] ?? null; - $this->totalCount = $values['totalCount']; - $this->data = $values['data']; + $this->totalCount = $values['totalCount'] ?? null; + $this->data = $values['data'] ?? null; } /** - * @return 'list' + * @return ?'list' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'list' $value + * @param ?'list' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; @@ -88,34 +88,34 @@ public function setPages(?OffsetPages $value = null): self } /** - * @return int + * @return ?int */ - public function getTotalCount(): int + public function getTotalCount(): ?int { return $this->totalCount; } /** - * @param int $value + * @param ?int $value */ - public function setTotalCount(int $value): self + public function setTotalCount(?int $value = null): self { $this->totalCount = $value; return $this; } /** - * @return array + * @return ?array */ - public function getData(): array + public function getData(): ?array { return $this->data; } /** - * @param array $value + * @param ?array $value */ - public function setData(array $value): self + public function setData(?array $value = null): self { $this->data = $value; return $this; diff --git a/src/Types/CompanyAttachedContacts.php b/src/Types/CompanyAttachedContacts.php index a6f51d7..58daef1 100644 --- a/src/Types/CompanyAttachedContacts.php +++ b/src/Types/CompanyAttachedContacts.php @@ -13,22 +13,22 @@ class CompanyAttachedContacts extends JsonSerializableType { /** - * @var 'list' $type The type of object - `list` + * @var ?'list' $type The type of object - `list` */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var array $data An array containing Contact Objects + * @var ?array $data An array containing Contact Objects */ #[JsonProperty('data'), ArrayType([Contact::class])] - private array $data; + private ?array $data; /** - * @var int $totalCount The total number of contacts + * @var ?int $totalCount The total number of contacts */ #[JsonProperty('total_count')] - private int $totalCount; + private ?int $totalCount; /** * @var ?CursorPages $pages @@ -38,67 +38,67 @@ class CompanyAttachedContacts extends JsonSerializableType /** * @param array{ - * type: 'list', - * data: array, - * totalCount: int, + * type?: ?'list', + * data?: ?array, + * totalCount?: ?int, * pages?: ?CursorPages, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->data = $values['data']; - $this->totalCount = $values['totalCount']; + $this->type = $values['type'] ?? null; + $this->data = $values['data'] ?? null; + $this->totalCount = $values['totalCount'] ?? null; $this->pages = $values['pages'] ?? null; } /** - * @return 'list' + * @return ?'list' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'list' $value + * @param ?'list' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return array + * @return ?array */ - public function getData(): array + public function getData(): ?array { return $this->data; } /** - * @param array $value + * @param ?array $value */ - public function setData(array $value): self + public function setData(?array $value = null): self { $this->data = $value; return $this; } /** - * @return int + * @return ?int */ - public function getTotalCount(): int + public function getTotalCount(): ?int { return $this->totalCount; } /** - * @param int $value + * @param ?int $value */ - public function setTotalCount(int $value): self + public function setTotalCount(?int $value = null): self { $this->totalCount = $value; return $this; diff --git a/src/Types/CompanyAttachedSegments.php b/src/Types/CompanyAttachedSegments.php index 29efd83..4fd56eb 100644 --- a/src/Types/CompanyAttachedSegments.php +++ b/src/Types/CompanyAttachedSegments.php @@ -13,59 +13,59 @@ class CompanyAttachedSegments extends JsonSerializableType { /** - * @var 'list' $type The type of object - `list` + * @var ?'list' $type The type of object - `list` */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var array $data An array containing Segment Objects + * @var ?array $data An array containing Segment Objects */ #[JsonProperty('data'), ArrayType([Segment::class])] - private array $data; + private ?array $data; /** * @param array{ - * type: 'list', - * data: array, + * type?: ?'list', + * data?: ?array, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->data = $values['data']; + $this->type = $values['type'] ?? null; + $this->data = $values['data'] ?? null; } /** - * @return 'list' + * @return ?'list' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'list' $value + * @param ?'list' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return array + * @return ?array */ - public function getData(): array + public function getData(): ?array { return $this->data; } /** - * @param array $value + * @param ?array $value */ - public function setData(array $value): self + public function setData(?array $value = null): self { $this->data = $value; return $this; diff --git a/src/Types/CompanyData.php b/src/Types/CompanyData.php new file mode 100644 index 0000000..11bef28 --- /dev/null +++ b/src/Types/CompanyData.php @@ -0,0 +1,104 @@ +id = $values['id'] ?? null; + $this->type = $values['type'] ?? null; + $this->url = $values['url'] ?? null; + } + + /** + * @return ?string + */ + public function getId(): ?string + { + return $this->id; + } + + /** + * @param ?string $value + */ + public function setId(?string $value = null): self + { + $this->id = $value; + return $this; + } + + /** + * @return ?'company' + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?'company' $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?string + */ + public function getUrl(): ?string + { + return $this->url; + } + + /** + * @param ?string $value + */ + public function setUrl(?string $value = null): self + { + $this->url = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/CompanyList.php b/src/Types/CompanyList.php index 7999660..45fab89 100644 --- a/src/Types/CompanyList.php +++ b/src/Types/CompanyList.php @@ -12,6 +12,12 @@ */ class CompanyList extends JsonSerializableType { + /** + * @var ?'list' $type The type of object - `list`. + */ + #[JsonProperty('type')] + private ?string $type; + /** * @var ?OffsetPages $pages */ @@ -19,30 +25,49 @@ class CompanyList extends JsonSerializableType private ?OffsetPages $pages; /** - * @var int $totalCount The total number of companies. + * @var ?int $totalCount The total number of companies. */ #[JsonProperty('total_count')] - private int $totalCount; + private ?int $totalCount; /** - * @var array $data An array containing Company Objects. + * @var ?array $data An array containing Company Objects. */ #[JsonProperty('data'), ArrayType([Company::class])] - private array $data; + private ?array $data; /** * @param array{ - * totalCount: int, - * data: array, + * type?: ?'list', * pages?: ?OffsetPages, + * totalCount?: ?int, + * data?: ?array, * } $values */ public function __construct( - array $values, + array $values = [], ) { + $this->type = $values['type'] ?? null; $this->pages = $values['pages'] ?? null; - $this->totalCount = $values['totalCount']; - $this->data = $values['data']; + $this->totalCount = $values['totalCount'] ?? null; + $this->data = $values['data'] ?? null; + } + + /** + * @return ?'list' + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?'list' $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; } /** @@ -63,34 +88,34 @@ public function setPages(?OffsetPages $value = null): self } /** - * @return int + * @return ?int */ - public function getTotalCount(): int + public function getTotalCount(): ?int { return $this->totalCount; } /** - * @param int $value + * @param ?int $value */ - public function setTotalCount(int $value): self + public function setTotalCount(?int $value = null): self { $this->totalCount = $value; return $this; } /** - * @return array + * @return ?array */ - public function getData(): array + public function getData(): ?array { return $this->data; } /** - * @param array $value + * @param ?array $value */ - public function setData(array $value): self + public function setData(?array $value = null): self { $this->data = $value; return $this; diff --git a/src/Types/CompanyScroll.php b/src/Types/CompanyScroll.php index 4cdedff..88c3774 100644 --- a/src/Types/CompanyScroll.php +++ b/src/Types/CompanyScroll.php @@ -13,16 +13,16 @@ class CompanyScroll extends JsonSerializableType { /** - * @var 'list' $type The type of object - `list` + * @var ?'list' $type The type of object - `list` */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var array $data + * @var ?array $data */ #[JsonProperty('data'), ArrayType([Company::class])] - private array $data; + private ?array $data; /** * @var ?CursorPages $pages @@ -44,52 +44,52 @@ class CompanyScroll extends JsonSerializableType /** * @param array{ - * type: 'list', - * data: array, + * type?: ?'list', + * data?: ?array, * pages?: ?CursorPages, * totalCount?: ?int, * scrollParam?: ?string, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->data = $values['data']; + $this->type = $values['type'] ?? null; + $this->data = $values['data'] ?? null; $this->pages = $values['pages'] ?? null; $this->totalCount = $values['totalCount'] ?? null; $this->scrollParam = $values['scrollParam'] ?? null; } /** - * @return 'list' + * @return ?'list' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'list' $value + * @param ?'list' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return array + * @return ?array */ - public function getData(): array + public function getData(): ?array { return $this->data; } /** - * @param array $value + * @param ?array $value */ - public function setData(array $value): self + public function setData(?array $value = null): self { $this->data = $value; return $this; diff --git a/src/Types/Component.php b/src/Types/Component.php deleted file mode 100644 index 425b440..0000000 --- a/src/Types/Component.php +++ /dev/null @@ -1,703 +0,0 @@ -type = $values['type']; - $this->value = $values['value']; - } - - /** - * @return ( - * 'button' - * |'checkbox' - * |'dropdown' - * |'input' - * |'list' - * |'single-select' - * |'textarea' - * |'data-table' - * |'divider' - * |'image' - * |'spacer' - * |'text' - * |'_unknown' - * ) - */ - public function getType(): string - { - return $this->type; - } - - /** - * @return ( - * ButtonComponent - * |CheckboxComponent - * |DropdownComponent - * |InputComponent - * |ListComponent - * |SingleSelectComponent - * |TextAreaComponent - * |DataTableComponent - * |DividerComponent - * |ImageComponent - * |SpacerComponent - * |TextComponent - * |mixed - * ) - */ - public function getValue(): mixed - { - return $this->value; - } - - /** - * @param ButtonComponent $button - * @return Component - */ - public static function button(ButtonComponent $button): Component - { - return new Component([ - 'type' => 'button', - 'value' => $button, - ]); - } - - /** - * @param CheckboxComponent $checkbox - * @return Component - */ - public static function checkbox(CheckboxComponent $checkbox): Component - { - return new Component([ - 'type' => 'checkbox', - 'value' => $checkbox, - ]); - } - - /** - * @param DropdownComponent $dropdown - * @return Component - */ - public static function dropdown(DropdownComponent $dropdown): Component - { - return new Component([ - 'type' => 'dropdown', - 'value' => $dropdown, - ]); - } - - /** - * @param InputComponent $input - * @return Component - */ - public static function input(InputComponent $input): Component - { - return new Component([ - 'type' => 'input', - 'value' => $input, - ]); - } - - /** - * @param ListComponent $list - * @return Component - */ - public static function list(ListComponent $list): Component - { - return new Component([ - 'type' => 'list', - 'value' => $list, - ]); - } - - /** - * @param SingleSelectComponent $singleSelect - * @return Component - */ - public static function singleSelect(SingleSelectComponent $singleSelect): Component - { - return new Component([ - 'type' => 'single-select', - 'value' => $singleSelect, - ]); - } - - /** - * @param TextAreaComponent $textarea - * @return Component - */ - public static function textarea(TextAreaComponent $textarea): Component - { - return new Component([ - 'type' => 'textarea', - 'value' => $textarea, - ]); - } - - /** - * @param DataTableComponent $dataTable - * @return Component - */ - public static function dataTable(DataTableComponent $dataTable): Component - { - return new Component([ - 'type' => 'data-table', - 'value' => $dataTable, - ]); - } - - /** - * @param DividerComponent $divider - * @return Component - */ - public static function divider(DividerComponent $divider): Component - { - return new Component([ - 'type' => 'divider', - 'value' => $divider, - ]); - } - - /** - * @param ImageComponent $image - * @return Component - */ - public static function image(ImageComponent $image): Component - { - return new Component([ - 'type' => 'image', - 'value' => $image, - ]); - } - - /** - * @param SpacerComponent $spacer - * @return Component - */ - public static function spacer(SpacerComponent $spacer): Component - { - return new Component([ - 'type' => 'spacer', - 'value' => $spacer, - ]); - } - - /** - * @param TextComponent $text - * @return Component - */ - public static function text(TextComponent $text): Component - { - return new Component([ - 'type' => 'text', - 'value' => $text, - ]); - } - - /** - * @return bool - */ - public function isButton(): bool - { - return $this->value instanceof ButtonComponent && $this->type === 'button'; - } - - /** - * @return ButtonComponent - */ - public function asButton(): ButtonComponent - { - if (!($this->value instanceof ButtonComponent && $this->type === 'button')) { - throw new Exception( - "Expected button; got " . $this->type . " with value of type " . get_debug_type($this->value), - ); - } - - return $this->value; - } - - /** - * @return bool - */ - public function isCheckbox(): bool - { - return $this->value instanceof CheckboxComponent && $this->type === 'checkbox'; - } - - /** - * @return CheckboxComponent - */ - public function asCheckbox(): CheckboxComponent - { - if (!($this->value instanceof CheckboxComponent && $this->type === 'checkbox')) { - throw new Exception( - "Expected checkbox; got " . $this->type . " with value of type " . get_debug_type($this->value), - ); - } - - return $this->value; - } - - /** - * @return bool - */ - public function isDropdown(): bool - { - return $this->value instanceof DropdownComponent && $this->type === 'dropdown'; - } - - /** - * @return DropdownComponent - */ - public function asDropdown(): DropdownComponent - { - if (!($this->value instanceof DropdownComponent && $this->type === 'dropdown')) { - throw new Exception( - "Expected dropdown; got " . $this->type . " with value of type " . get_debug_type($this->value), - ); - } - - return $this->value; - } - - /** - * @return bool - */ - public function isInput(): bool - { - return $this->value instanceof InputComponent && $this->type === 'input'; - } - - /** - * @return InputComponent - */ - public function asInput(): InputComponent - { - if (!($this->value instanceof InputComponent && $this->type === 'input')) { - throw new Exception( - "Expected input; got " . $this->type . " with value of type " . get_debug_type($this->value), - ); - } - - return $this->value; - } - - /** - * @return bool - */ - public function isList_(): bool - { - return $this->value instanceof ListComponent && $this->type === 'list'; - } - - /** - * @return ListComponent - */ - public function asList_(): ListComponent - { - if (!($this->value instanceof ListComponent && $this->type === 'list')) { - throw new Exception( - "Expected list; got " . $this->type . " with value of type " . get_debug_type($this->value), - ); - } - - return $this->value; - } - - /** - * @return bool - */ - public function isSingleSelect(): bool - { - return $this->value instanceof SingleSelectComponent && $this->type === 'single-select'; - } - - /** - * @return SingleSelectComponent - */ - public function asSingleSelect(): SingleSelectComponent - { - if (!($this->value instanceof SingleSelectComponent && $this->type === 'single-select')) { - throw new Exception( - "Expected single-select; got " . $this->type . " with value of type " . get_debug_type($this->value), - ); - } - - return $this->value; - } - - /** - * @return bool - */ - public function isTextarea(): bool - { - return $this->value instanceof TextAreaComponent && $this->type === 'textarea'; - } - - /** - * @return TextAreaComponent - */ - public function asTextarea(): TextAreaComponent - { - if (!($this->value instanceof TextAreaComponent && $this->type === 'textarea')) { - throw new Exception( - "Expected textarea; got " . $this->type . " with value of type " . get_debug_type($this->value), - ); - } - - return $this->value; - } - - /** - * @return bool - */ - public function isDataTable(): bool - { - return $this->value instanceof DataTableComponent && $this->type === 'data-table'; - } - - /** - * @return DataTableComponent - */ - public function asDataTable(): DataTableComponent - { - if (!($this->value instanceof DataTableComponent && $this->type === 'data-table')) { - throw new Exception( - "Expected data-table; got " . $this->type . " with value of type " . get_debug_type($this->value), - ); - } - - return $this->value; - } - - /** - * @return bool - */ - public function isDivider(): bool - { - return $this->value instanceof DividerComponent && $this->type === 'divider'; - } - - /** - * @return DividerComponent - */ - public function asDivider(): DividerComponent - { - if (!($this->value instanceof DividerComponent && $this->type === 'divider')) { - throw new Exception( - "Expected divider; got " . $this->type . " with value of type " . get_debug_type($this->value), - ); - } - - return $this->value; - } - - /** - * @return bool - */ - public function isImage(): bool - { - return $this->value instanceof ImageComponent && $this->type === 'image'; - } - - /** - * @return ImageComponent - */ - public function asImage(): ImageComponent - { - if (!($this->value instanceof ImageComponent && $this->type === 'image')) { - throw new Exception( - "Expected image; got " . $this->type . " with value of type " . get_debug_type($this->value), - ); - } - - return $this->value; - } - - /** - * @return bool - */ - public function isSpacer(): bool - { - return $this->value instanceof SpacerComponent && $this->type === 'spacer'; - } - - /** - * @return SpacerComponent - */ - public function asSpacer(): SpacerComponent - { - if (!($this->value instanceof SpacerComponent && $this->type === 'spacer')) { - throw new Exception( - "Expected spacer; got " . $this->type . " with value of type " . get_debug_type($this->value), - ); - } - - return $this->value; - } - - /** - * @return bool - */ - public function isText(): bool - { - return $this->value instanceof TextComponent && $this->type === 'text'; - } - - /** - * @return TextComponent - */ - public function asText(): TextComponent - { - if (!($this->value instanceof TextComponent && $this->type === 'text')) { - throw new Exception( - "Expected text; got " . $this->type . " with value of type " . get_debug_type($this->value), - ); - } - - return $this->value; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } - - /** - * @return array - */ - public function jsonSerialize(): array - { - $result = []; - $result['type'] = $this->type; - - $base = parent::jsonSerialize(); - $result = array_merge($base, $result); - - switch ($this->type) { - case 'button': - $value = $this->asButton()->jsonSerialize(); - $result = array_merge($value, $result); - break; - case 'checkbox': - $value = $this->asCheckbox()->jsonSerialize(); - $result = array_merge($value, $result); - break; - case 'dropdown': - $value = $this->asDropdown()->jsonSerialize(); - $result = array_merge($value, $result); - break; - case 'input': - $value = $this->asInput()->jsonSerialize(); - $result = array_merge($value, $result); - break; - case 'list': - $value = $this->asList_()->jsonSerialize(); - $result = array_merge($value, $result); - break; - case 'single-select': - $value = $this->asSingleSelect()->jsonSerialize(); - $result = array_merge($value, $result); - break; - case 'textarea': - $value = $this->asTextarea()->jsonSerialize(); - $result = array_merge($value, $result); - break; - case 'data-table': - $value = $this->asDataTable()->jsonSerialize(); - $result = array_merge($value, $result); - break; - case 'divider': - $value = $this->asDivider()->jsonSerialize(); - $result = array_merge($value, $result); - break; - case 'image': - $value = $this->asImage()->jsonSerialize(); - $result = array_merge($value, $result); - break; - case 'spacer': - $value = $this->asSpacer()->jsonSerialize(); - $result = array_merge($value, $result); - break; - case 'text': - $value = $this->asText()->jsonSerialize(); - $result = array_merge($value, $result); - break; - case '_unknown': - default: - if (is_null($this->value)) { - break; - } - if ($this->value instanceof JsonSerializableType) { - $value = $this->value->jsonSerialize(); - $result = array_merge($value, $result); - } elseif (is_array($this->value)) { - $result = array_merge($this->value, $result); - } - } - - return $result; - } - - /** - * @param string $json - */ - public static function fromJson(string $json): static - { - $decodedJson = JsonDecoder::decode($json); - if (!is_array($decodedJson)) { - throw new Exception("Unexpected non-array decoded type: " . gettype($decodedJson)); - } - return self::jsonDeserialize($decodedJson); - } - - /** - * @param array $data - */ - public static function jsonDeserialize(array $data): static - { - $args = []; - if (!array_key_exists('type', $data)) { - throw new Exception( - "JSON data is missing property 'type'", - ); - } - $type = $data['type']; - if (!(is_string($type))) { - throw new Exception( - "Expected property 'type' in JSON data to be string, instead received " . get_debug_type($data['type']), - ); - } - - $args['type'] = $type; - switch ($type) { - case 'button': - $args['value'] = ButtonComponent::jsonDeserialize($data); - break; - case 'checkbox': - $args['value'] = CheckboxComponent::jsonDeserialize($data); - break; - case 'dropdown': - $args['value'] = DropdownComponent::jsonDeserialize($data); - break; - case 'input': - $args['value'] = InputComponent::jsonDeserialize($data); - break; - case 'list': - $args['value'] = ListComponent::jsonDeserialize($data); - break; - case 'single-select': - $args['value'] = SingleSelectComponent::jsonDeserialize($data); - break; - case 'textarea': - $args['value'] = TextAreaComponent::jsonDeserialize($data); - break; - case 'data-table': - $args['value'] = DataTableComponent::jsonDeserialize($data); - break; - case 'divider': - $args['value'] = DividerComponent::jsonDeserialize($data); - break; - case 'image': - $args['value'] = ImageComponent::jsonDeserialize($data); - break; - case 'spacer': - $args['value'] = SpacerComponent::jsonDeserialize($data); - break; - case 'text': - $args['value'] = TextComponent::jsonDeserialize($data); - break; - case '_unknown': - default: - $args['type'] = '_unknown'; - $args['value'] = $data; - } - - // @phpstan-ignore-next-line - return new static($args); - } -} diff --git a/src/Types/ConfigureRequestComponentId.php b/src/Types/ConfigureRequestComponentId.php deleted file mode 100644 index f7308bb..0000000 --- a/src/Types/ConfigureRequestComponentId.php +++ /dev/null @@ -1,203 +0,0 @@ - $inputValues A list of key/value pairs of data, inputted by the teammate on the current canvas. - */ - #[JsonProperty('input_values'), ArrayType(['string' => 'mixed'])] - private array $inputValues; - - /** - * @param array{ - * workspaceId: string, - * workspaceRegion: string, - * componentId: string, - * admin: Admin, - * context: Context, - * currentCanvas: CanvasObject, - * inputValues: array, - * } $values - */ - public function __construct( - array $values, - ) { - $this->workspaceId = $values['workspaceId']; - $this->workspaceRegion = $values['workspaceRegion']; - $this->componentId = $values['componentId']; - $this->admin = $values['admin']; - $this->context = $values['context']; - $this->currentCanvas = $values['currentCanvas']; - $this->inputValues = $values['inputValues']; - } - - /** - * @return string - */ - public function getWorkspaceId(): string - { - return $this->workspaceId; - } - - /** - * @param string $value - */ - public function setWorkspaceId(string $value): self - { - $this->workspaceId = $value; - return $this; - } - - /** - * @return string - */ - public function getWorkspaceRegion(): string - { - return $this->workspaceRegion; - } - - /** - * @param string $value - */ - public function setWorkspaceRegion(string $value): self - { - $this->workspaceRegion = $value; - return $this; - } - - /** - * @return string - */ - public function getComponentId(): string - { - return $this->componentId; - } - - /** - * @param string $value - */ - public function setComponentId(string $value): self - { - $this->componentId = $value; - return $this; - } - - /** - * @return Admin - */ - public function getAdmin(): Admin - { - return $this->admin; - } - - /** - * @param Admin $value - */ - public function setAdmin(Admin $value): self - { - $this->admin = $value; - return $this; - } - - /** - * @return Context - */ - public function getContext(): Context - { - return $this->context; - } - - /** - * @param Context $value - */ - public function setContext(Context $value): self - { - $this->context = $value; - return $this; - } - - /** - * @return CanvasObject - */ - public function getCurrentCanvas(): CanvasObject - { - return $this->currentCanvas; - } - - /** - * @param CanvasObject $value - */ - public function setCurrentCanvas(CanvasObject $value): self - { - $this->currentCanvas = $value; - return $this; - } - - /** - * @return array - */ - public function getInputValues(): array - { - return $this->inputValues; - } - - /** - * @param array $value - */ - public function setInputValues(array $value): self - { - $this->inputValues = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/ConfigureRequestZero.php b/src/Types/ConfigureRequestZero.php deleted file mode 100644 index 0ed4292..0000000 --- a/src/Types/ConfigureRequestZero.php +++ /dev/null @@ -1,102 +0,0 @@ -workspaceId = $values['workspaceId']; - $this->admin = $values['admin']; - $this->context = $values['context']; - } - - /** - * @return string - */ - public function getWorkspaceId(): string - { - return $this->workspaceId; - } - - /** - * @param string $value - */ - public function setWorkspaceId(string $value): self - { - $this->workspaceId = $value; - return $this; - } - - /** - * @return Admin - */ - public function getAdmin(): Admin - { - return $this->admin; - } - - /** - * @param Admin $value - */ - public function setAdmin(Admin $value): self - { - $this->admin = $value; - return $this; - } - - /** - * @return Context - */ - public function getContext(): Context - { - return $this->context; - } - - /** - * @param Context $value - */ - public function setContext(Context $value): self - { - $this->context = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/ConfigureResponseCanvas.php b/src/Types/ConfigureResponseCanvas.php deleted file mode 100644 index cfe2f39..0000000 --- a/src/Types/ConfigureResponseCanvas.php +++ /dev/null @@ -1,51 +0,0 @@ -canvas = $values['canvas']; - } - - /** - * @return CanvasObject - */ - public function getCanvas(): CanvasObject - { - return $this->canvas; - } - - /** - * @param CanvasObject $value - */ - public function setCanvas(CanvasObject $value): self - { - $this->canvas = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/ContactArchived.php b/src/Types/ContactArchived.php index 5624a93..7e22c6c 100644 --- a/src/Types/ContactArchived.php +++ b/src/Types/ContactArchived.php @@ -3,6 +3,7 @@ namespace Intercom\Types; use Intercom\Core\Json\JsonSerializableType; +use Intercom\Traits\ContactReference; use Intercom\Core\Json\JsonProperty; /** @@ -10,110 +11,43 @@ */ class ContactArchived extends JsonSerializableType { - /** - * @var 'contact' $type always contact - */ - #[JsonProperty('type')] - private string $type; - - /** - * @var string $id The unique identifier for the contact which is given by Intercom. - */ - #[JsonProperty('id')] - private string $id; + use ContactReference; /** - * @var ?string $externalId The unique identifier for the contact which is provided by the Client. - */ - #[JsonProperty('external_id')] - private ?string $externalId; - - /** - * @var bool $archived Whether the contact is archived or not. + * @var ?bool $archived Whether the contact is archived or not. */ #[JsonProperty('archived')] - private bool $archived; + private ?bool $archived; /** * @param array{ - * type: 'contact', - * id: string, - * archived: bool, + * type?: ?'contact', + * id?: ?string, * externalId?: ?string, + * archived?: ?bool, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->id = $values['id']; + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; $this->externalId = $values['externalId'] ?? null; - $this->archived = $values['archived']; - } - - /** - * @return 'contact' - */ - public function getType(): string - { - return $this->type; - } - - /** - * @param 'contact' $value - */ - public function setType(string $value): self - { - $this->type = $value; - return $this; - } - - /** - * @return string - */ - public function getId(): string - { - return $this->id; - } - - /** - * @param string $value - */ - public function setId(string $value): self - { - $this->id = $value; - return $this; - } - - /** - * @return ?string - */ - public function getExternalId(): ?string - { - return $this->externalId; - } - - /** - * @param ?string $value - */ - public function setExternalId(?string $value = null): self - { - $this->externalId = $value; - return $this; + $this->archived = $values['archived'] ?? null; } /** - * @return bool + * @return ?bool */ - public function getArchived(): bool + public function getArchived(): ?bool { return $this->archived; } /** - * @param bool $value + * @param ?bool $value */ - public function setArchived(bool $value): self + public function setArchived(?bool $value = null): self { $this->archived = $value; return $this; diff --git a/src/Types/ContactAttachedCompanies.php b/src/Types/ContactAttachedCompanies.php index f4de347..913eb5a 100644 --- a/src/Types/ContactAttachedCompanies.php +++ b/src/Types/ContactAttachedCompanies.php @@ -13,22 +13,22 @@ class ContactAttachedCompanies extends JsonSerializableType { /** - * @var 'list' $type The type of object + * @var ?'list' $type The type of object */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var array $companies An array containing Company Objects + * @var ?array $companies An array containing Company Objects */ #[JsonProperty('companies'), ArrayType([Company::class])] - private array $companies; + private ?array $companies; /** - * @var int $totalCount The total number of companies associated to this contact + * @var ?int $totalCount The total number of companies associated to this contact */ #[JsonProperty('total_count')] - private int $totalCount; + private ?int $totalCount; /** * @var ?PagesLink $pages @@ -38,67 +38,67 @@ class ContactAttachedCompanies extends JsonSerializableType /** * @param array{ - * type: 'list', - * companies: array, - * totalCount: int, + * type?: ?'list', + * companies?: ?array, + * totalCount?: ?int, * pages?: ?PagesLink, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->companies = $values['companies']; - $this->totalCount = $values['totalCount']; + $this->type = $values['type'] ?? null; + $this->companies = $values['companies'] ?? null; + $this->totalCount = $values['totalCount'] ?? null; $this->pages = $values['pages'] ?? null; } /** - * @return 'list' + * @return ?'list' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'list' $value + * @param ?'list' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return array + * @return ?array */ - public function getCompanies(): array + public function getCompanies(): ?array { return $this->companies; } /** - * @param array $value + * @param ?array $value */ - public function setCompanies(array $value): self + public function setCompanies(?array $value = null): self { $this->companies = $value; return $this; } /** - * @return int + * @return ?int */ - public function getTotalCount(): int + public function getTotalCount(): ?int { return $this->totalCount; } /** - * @param int $value + * @param ?int $value */ - public function setTotalCount(int $value): self + public function setTotalCount(?int $value = null): self { $this->totalCount = $value; return $this; diff --git a/src/Types/ContactBlocked.php b/src/Types/ContactBlocked.php new file mode 100644 index 0000000..f362170 --- /dev/null +++ b/src/Types/ContactBlocked.php @@ -0,0 +1,63 @@ +type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->externalId = $values['externalId'] ?? null; + $this->blocked = $values['blocked'] ?? null; + } + + /** + * @return ?bool + */ + public function getBlocked(): ?bool + { + return $this->blocked; + } + + /** + * @param ?bool $value + */ + public function setBlocked(?bool $value = null): self + { + $this->blocked = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/ContactCompanies.php b/src/Types/ContactCompanies.php index e70b4cd..683bb06 100644 --- a/src/Types/ContactCompanies.php +++ b/src/Types/ContactCompanies.php @@ -7,78 +7,53 @@ use Intercom\Core\Types\ArrayType; /** - * An object containing companies meta data about the companies that a contact has. Up to 10 will be displayed here. Use the url to get more. + * An object with metadata about companies attached to a contact . Up to 10 will be displayed here. Use the url to get more. */ class ContactCompanies extends JsonSerializableType { /** - * @var ?'list' $type The type of object + * @var ?array $data An array of company data objects attached to the contact. */ - #[JsonProperty('type')] - private ?string $type; - - /** - * @var ?array $data An array containing Company Objects - */ - #[JsonProperty('data'), ArrayType([ContactCompany::class])] + #[JsonProperty('data'), ArrayType([CompanyData::class])] private ?array $data; /** - * @var string $url Url to get more company resources for this contact + * @var ?string $url Url to get more company resources for this contact */ #[JsonProperty('url')] - private string $url; + private ?string $url; /** - * @var int $totalCount Int representing the total number of companyies attached to this contact + * @var ?int $totalCount Integer representing the total number of companies attached to this contact */ #[JsonProperty('total_count')] - private int $totalCount; + private ?int $totalCount; /** - * @var bool $hasMore Whether there's more Addressable Objects to be viewed. If true, use the url to view all + * @var ?bool $hasMore Whether there's more Addressable Objects to be viewed. If true, use the url to view all */ #[JsonProperty('has_more')] - private bool $hasMore; + private ?bool $hasMore; /** * @param array{ - * url: string, - * totalCount: int, - * hasMore: bool, - * type?: ?'list', - * data?: ?array, + * data?: ?array, + * url?: ?string, + * totalCount?: ?int, + * hasMore?: ?bool, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type'] ?? null; $this->data = $values['data'] ?? null; - $this->url = $values['url']; - $this->totalCount = $values['totalCount']; - $this->hasMore = $values['hasMore']; - } - - /** - * @return ?'list' - */ - public function getType(): ?string - { - return $this->type; + $this->url = $values['url'] ?? null; + $this->totalCount = $values['totalCount'] ?? null; + $this->hasMore = $values['hasMore'] ?? null; } /** - * @param ?'list' $value - */ - public function setType(?string $value = null): self - { - $this->type = $value; - return $this; - } - - /** - * @return ?array + * @return ?array */ public function getData(): ?array { @@ -86,7 +61,7 @@ public function getData(): ?array } /** - * @param ?array $value + * @param ?array $value */ public function setData(?array $value = null): self { @@ -95,51 +70,51 @@ public function setData(?array $value = null): self } /** - * @return string + * @return ?string */ - public function getUrl(): string + public function getUrl(): ?string { return $this->url; } /** - * @param string $value + * @param ?string $value */ - public function setUrl(string $value): self + public function setUrl(?string $value = null): self { $this->url = $value; return $this; } /** - * @return int + * @return ?int */ - public function getTotalCount(): int + public function getTotalCount(): ?int { return $this->totalCount; } /** - * @param int $value + * @param ?int $value */ - public function setTotalCount(int $value): self + public function setTotalCount(?int $value = null): self { $this->totalCount = $value; return $this; } /** - * @return bool + * @return ?bool */ - public function getHasMore(): bool + public function getHasMore(): ?bool { return $this->hasMore; } /** - * @param bool $value + * @param ?bool $value */ - public function setHasMore(bool $value): self + public function setHasMore(?bool $value = null): self { $this->hasMore = $value; return $this; diff --git a/src/Types/ContactDeleted.php b/src/Types/ContactDeleted.php index f9750ce..d87c3de 100644 --- a/src/Types/ContactDeleted.php +++ b/src/Types/ContactDeleted.php @@ -3,6 +3,7 @@ namespace Intercom\Types; use Intercom\Core\Json\JsonSerializableType; +use Intercom\Traits\ContactReference; use Intercom\Core\Json\JsonProperty; /** @@ -10,110 +11,43 @@ */ class ContactDeleted extends JsonSerializableType { - /** - * @var 'contact' $type always contact - */ - #[JsonProperty('type')] - private string $type; - - /** - * @var string $id The unique identifier for the contact which is given by Intercom. - */ - #[JsonProperty('id')] - private string $id; + use ContactReference; /** - * @var ?string $externalId The unique identifier for the contact which is provided by the Client. - */ - #[JsonProperty('external_id')] - private ?string $externalId; - - /** - * @var bool $deleted Whether the contact is deleted or not. + * @var ?bool $deleted Whether the contact is deleted or not. */ #[JsonProperty('deleted')] - private bool $deleted; + private ?bool $deleted; /** * @param array{ - * type: 'contact', - * id: string, - * deleted: bool, + * type?: ?'contact', + * id?: ?string, * externalId?: ?string, + * deleted?: ?bool, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->id = $values['id']; + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; $this->externalId = $values['externalId'] ?? null; - $this->deleted = $values['deleted']; - } - - /** - * @return 'contact' - */ - public function getType(): string - { - return $this->type; - } - - /** - * @param 'contact' $value - */ - public function setType(string $value): self - { - $this->type = $value; - return $this; - } - - /** - * @return string - */ - public function getId(): string - { - return $this->id; - } - - /** - * @param string $value - */ - public function setId(string $value): self - { - $this->id = $value; - return $this; - } - - /** - * @return ?string - */ - public function getExternalId(): ?string - { - return $this->externalId; - } - - /** - * @param ?string $value - */ - public function setExternalId(?string $value = null): self - { - $this->externalId = $value; - return $this; + $this->deleted = $values['deleted'] ?? null; } /** - * @return bool + * @return ?bool */ - public function getDeleted(): bool + public function getDeleted(): ?bool { return $this->deleted; } /** - * @param bool $value + * @param ?bool $value */ - public function setDeleted(bool $value): self + public function setDeleted(?bool $value = null): self { $this->deleted = $value; return $this; diff --git a/src/Types/ContactList.php b/src/Types/ContactList.php index 0484f4e..4e70fc7 100644 --- a/src/Types/ContactList.php +++ b/src/Types/ContactList.php @@ -13,22 +13,22 @@ class ContactList extends JsonSerializableType { /** - * @var 'list' $type Always list + * @var ?'list' $type Always list */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var array $data The list of contact objects + * @var ?array $data The list of contact objects */ #[JsonProperty('data'), ArrayType([Contact::class])] - private array $data; + private ?array $data; /** - * @var int $totalCount A count of the total number of objects. + * @var ?int $totalCount A count of the total number of objects. */ #[JsonProperty('total_count')] - private int $totalCount; + private ?int $totalCount; /** * @var ?CursorPages $pages @@ -38,67 +38,67 @@ class ContactList extends JsonSerializableType /** * @param array{ - * type: 'list', - * data: array, - * totalCount: int, + * type?: ?'list', + * data?: ?array, + * totalCount?: ?int, * pages?: ?CursorPages, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->data = $values['data']; - $this->totalCount = $values['totalCount']; + $this->type = $values['type'] ?? null; + $this->data = $values['data'] ?? null; + $this->totalCount = $values['totalCount'] ?? null; $this->pages = $values['pages'] ?? null; } /** - * @return 'list' + * @return ?'list' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'list' $value + * @param ?'list' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return array + * @return ?array */ - public function getData(): array + public function getData(): ?array { return $this->data; } /** - * @param array $value + * @param ?array $value */ - public function setData(array $value): self + public function setData(?array $value = null): self { $this->data = $value; return $this; } /** - * @return int + * @return ?int */ - public function getTotalCount(): int + public function getTotalCount(): ?int { return $this->totalCount; } /** - * @param int $value + * @param ?int $value */ - public function setTotalCount(int $value): self + public function setTotalCount(?int $value = null): self { $this->totalCount = $value; return $this; diff --git a/src/Types/ContactLocation.php b/src/Types/ContactLocation.php index f7ababe..d980da5 100644 --- a/src/Types/ContactLocation.php +++ b/src/Types/ContactLocation.php @@ -11,10 +11,10 @@ class ContactLocation extends JsonSerializableType { /** - * @var 'location' $type Always location + * @var ?string $type Always location */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** * @var ?string $country The country that the contact is located in @@ -36,33 +36,33 @@ class ContactLocation extends JsonSerializableType /** * @param array{ - * type: 'location', + * type?: ?string, * country?: ?string, * region?: ?string, * city?: ?string, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; + $this->type = $values['type'] ?? null; $this->country = $values['country'] ?? null; $this->region = $values['region'] ?? null; $this->city = $values['city'] ?? null; } /** - * @return 'location' + * @return ?string */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'location' $value + * @param ?string $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; diff --git a/src/Types/ContactNotes.php b/src/Types/ContactNotes.php index 18fb28c..4f56017 100644 --- a/src/Types/ContactNotes.php +++ b/src/Types/ContactNotes.php @@ -12,109 +12,109 @@ class ContactNotes extends JsonSerializableType { /** - * @var array $data This object represents the notes attached to a contact. + * @var ?array $data This object represents the notes attached to a contact. */ #[JsonProperty('data'), ArrayType([AddressableList::class])] - private array $data; + private ?array $data; /** - * @var string $url Url to get more company resources for this contact + * @var ?string $url Url to get more company resources for this contact */ #[JsonProperty('url')] - private string $url; + private ?string $url; /** - * @var int $totalCount Int representing the total number of companyies attached to this contact + * @var ?int $totalCount Int representing the total number of companyies attached to this contact */ #[JsonProperty('total_count')] - private int $totalCount; + private ?int $totalCount; /** - * @var bool $hasMore Whether there's more Addressable Objects to be viewed. If true, use the url to view all + * @var ?bool $hasMore Whether there's more Addressable Objects to be viewed. If true, use the url to view all */ #[JsonProperty('has_more')] - private bool $hasMore; + private ?bool $hasMore; /** * @param array{ - * data: array, - * url: string, - * totalCount: int, - * hasMore: bool, + * data?: ?array, + * url?: ?string, + * totalCount?: ?int, + * hasMore?: ?bool, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->data = $values['data']; - $this->url = $values['url']; - $this->totalCount = $values['totalCount']; - $this->hasMore = $values['hasMore']; + $this->data = $values['data'] ?? null; + $this->url = $values['url'] ?? null; + $this->totalCount = $values['totalCount'] ?? null; + $this->hasMore = $values['hasMore'] ?? null; } /** - * @return array + * @return ?array */ - public function getData(): array + public function getData(): ?array { return $this->data; } /** - * @param array $value + * @param ?array $value */ - public function setData(array $value): self + public function setData(?array $value = null): self { $this->data = $value; return $this; } /** - * @return string + * @return ?string */ - public function getUrl(): string + public function getUrl(): ?string { return $this->url; } /** - * @param string $value + * @param ?string $value */ - public function setUrl(string $value): self + public function setUrl(?string $value = null): self { $this->url = $value; return $this; } /** - * @return int + * @return ?int */ - public function getTotalCount(): int + public function getTotalCount(): ?int { return $this->totalCount; } /** - * @param int $value + * @param ?int $value */ - public function setTotalCount(int $value): self + public function setTotalCount(?int $value = null): self { $this->totalCount = $value; return $this; } /** - * @return bool + * @return ?bool */ - public function getHasMore(): bool + public function getHasMore(): ?bool { return $this->hasMore; } /** - * @param bool $value + * @param ?bool $value */ - public function setHasMore(bool $value): self + public function setHasMore(?bool $value = null): self { $this->hasMore = $value; return $this; diff --git a/src/Types/ContactReference.php b/src/Types/ContactReference.php index 2c40ec2..8cea288 100644 --- a/src/Types/ContactReference.php +++ b/src/Types/ContactReference.php @@ -11,16 +11,16 @@ class ContactReference extends JsonSerializableType { /** - * @var 'contact' $type always contact + * @var ?'contact' $type always contact */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var string $id The unique identifier for the contact which is given by Intercom. + * @var ?string $id The unique identifier for the contact which is given by Intercom. */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** * @var ?string $externalId The unique identifier for the contact which is provided by the Client. @@ -30,48 +30,48 @@ class ContactReference extends JsonSerializableType /** * @param array{ - * type: 'contact', - * id: string, + * type?: ?'contact', + * id?: ?string, * externalId?: ?string, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->id = $values['id']; + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; $this->externalId = $values['externalId'] ?? null; } /** - * @return 'contact' + * @return ?'contact' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'contact' $value + * @param ?'contact' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; diff --git a/src/Types/ContactReplyBaseRequest.php b/src/Types/ContactReplyBaseRequest.php index f297810..c37b351 100644 --- a/src/Types/ContactReplyBaseRequest.php +++ b/src/Types/ContactReplyBaseRequest.php @@ -38,6 +38,12 @@ class ContactReplyBaseRequest extends JsonSerializableType #[JsonProperty('attachment_urls'), ArrayType(['string'])] private ?array $attachmentUrls; + /** + * @var ?array $replyOptions The quick reply selection the contact wishes to respond with. These map to buttons displayed in the Messenger UI if sent by a bot, or the reply options sent by an Admin via the API. + */ + #[JsonProperty('reply_options'), ArrayType([ContactReplyBaseRequestReplyOptionsItem::class])] + private ?array $replyOptions; + /** * @param array{ * messageType: 'comment', @@ -45,6 +51,7 @@ class ContactReplyBaseRequest extends JsonSerializableType * body: string, * createdAt?: ?int, * attachmentUrls?: ?array, + * replyOptions?: ?array, * } $values */ public function __construct( @@ -55,6 +62,7 @@ public function __construct( $this->body = $values['body']; $this->createdAt = $values['createdAt'] ?? null; $this->attachmentUrls = $values['attachmentUrls'] ?? null; + $this->replyOptions = $values['replyOptions'] ?? null; } /** @@ -142,6 +150,23 @@ public function setAttachmentUrls(?array $value = null): self return $this; } + /** + * @return ?array + */ + public function getReplyOptions(): ?array + { + return $this->replyOptions; + } + + /** + * @param ?array $value + */ + public function setReplyOptions(?array $value = null): self + { + $this->replyOptions = $value; + return $this; + } + /** * @return string */ diff --git a/src/Types/ContactReplyBaseRequestReplyOptionsItem.php b/src/Types/ContactReplyBaseRequestReplyOptionsItem.php new file mode 100644 index 0000000..50c1f58 --- /dev/null +++ b/src/Types/ContactReplyBaseRequestReplyOptionsItem.php @@ -0,0 +1,76 @@ +text = $values['text']; + $this->uuid = $values['uuid']; + } + + /** + * @return string + */ + public function getText(): string + { + return $this->text; + } + + /** + * @param string $value + */ + public function setText(string $value): self + { + $this->text = $value; + return $this; + } + + /** + * @return string + */ + public function getUuid(): string + { + return $this->uuid; + } + + /** + * @param string $value + */ + public function setUuid(string $value): self + { + $this->uuid = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/ContactReplyEmailRequest.php b/src/Types/ContactReplyEmailRequest.php index c31921a..ab3d6fe 100644 --- a/src/Types/ContactReplyEmailRequest.php +++ b/src/Types/ContactReplyEmailRequest.php @@ -34,6 +34,7 @@ class ContactReplyEmailRequest extends JsonSerializableType * email: string, * createdAt?: ?int, * attachmentUrls?: ?array, + * replyOptions?: ?array, * attachmentFiles?: ?array, * } $values */ @@ -45,6 +46,7 @@ public function __construct( $this->body = $values['body']; $this->createdAt = $values['createdAt'] ?? null; $this->attachmentUrls = $values['attachmentUrls'] ?? null; + $this->replyOptions = $values['replyOptions'] ?? null; $this->email = $values['email']; $this->attachmentFiles = $values['attachmentFiles'] ?? null; } diff --git a/src/Types/ContactReplyIntercomUserIdRequest.php b/src/Types/ContactReplyIntercomUserIdRequest.php index fc1dc44..6045ad3 100644 --- a/src/Types/ContactReplyIntercomUserIdRequest.php +++ b/src/Types/ContactReplyIntercomUserIdRequest.php @@ -34,6 +34,7 @@ class ContactReplyIntercomUserIdRequest extends JsonSerializableType * intercomUserId: string, * createdAt?: ?int, * attachmentUrls?: ?array, + * replyOptions?: ?array, * attachmentFiles?: ?array, * } $values */ @@ -45,6 +46,7 @@ public function __construct( $this->body = $values['body']; $this->createdAt = $values['createdAt'] ?? null; $this->attachmentUrls = $values['attachmentUrls'] ?? null; + $this->replyOptions = $values['replyOptions'] ?? null; $this->intercomUserId = $values['intercomUserId']; $this->attachmentFiles = $values['attachmentFiles'] ?? null; } diff --git a/src/Types/ContactReplyTicketEmailRequest.php b/src/Types/ContactReplyTicketEmailRequest.php index b5769fa..eb1e682 100644 --- a/src/Types/ContactReplyTicketEmailRequest.php +++ b/src/Types/ContactReplyTicketEmailRequest.php @@ -27,6 +27,7 @@ class ContactReplyTicketEmailRequest extends JsonSerializableType * email: string, * createdAt?: ?int, * attachmentUrls?: ?array, + * replyOptions?: ?array, * } $values */ public function __construct( @@ -37,6 +38,7 @@ public function __construct( $this->body = $values['body']; $this->createdAt = $values['createdAt'] ?? null; $this->attachmentUrls = $values['attachmentUrls'] ?? null; + $this->replyOptions = $values['replyOptions'] ?? null; $this->email = $values['email']; } diff --git a/src/Types/ContactReplyTicketIntercomUserIdRequest.php b/src/Types/ContactReplyTicketIntercomUserIdRequest.php index 7e70b8c..10eb570 100644 --- a/src/Types/ContactReplyTicketIntercomUserIdRequest.php +++ b/src/Types/ContactReplyTicketIntercomUserIdRequest.php @@ -27,6 +27,7 @@ class ContactReplyTicketIntercomUserIdRequest extends JsonSerializableType * intercomUserId: string, * createdAt?: ?int, * attachmentUrls?: ?array, + * replyOptions?: ?array, * } $values */ public function __construct( @@ -37,6 +38,7 @@ public function __construct( $this->body = $values['body']; $this->createdAt = $values['createdAt'] ?? null; $this->attachmentUrls = $values['attachmentUrls'] ?? null; + $this->replyOptions = $values['replyOptions'] ?? null; $this->intercomUserId = $values['intercomUserId']; } diff --git a/src/Types/ContactReplyTicketUserIdRequest.php b/src/Types/ContactReplyTicketUserIdRequest.php index 0a3e7c5..d04729d 100644 --- a/src/Types/ContactReplyTicketUserIdRequest.php +++ b/src/Types/ContactReplyTicketUserIdRequest.php @@ -27,6 +27,7 @@ class ContactReplyTicketUserIdRequest extends JsonSerializableType * userId: string, * createdAt?: ?int, * attachmentUrls?: ?array, + * replyOptions?: ?array, * } $values */ public function __construct( @@ -37,6 +38,7 @@ public function __construct( $this->body = $values['body']; $this->createdAt = $values['createdAt'] ?? null; $this->attachmentUrls = $values['attachmentUrls'] ?? null; + $this->replyOptions = $values['replyOptions'] ?? null; $this->userId = $values['userId']; } diff --git a/src/Types/ContactReplyUserIdRequest.php b/src/Types/ContactReplyUserIdRequest.php index 8eef1da..d66f280 100644 --- a/src/Types/ContactReplyUserIdRequest.php +++ b/src/Types/ContactReplyUserIdRequest.php @@ -34,6 +34,7 @@ class ContactReplyUserIdRequest extends JsonSerializableType * userId: string, * createdAt?: ?int, * attachmentUrls?: ?array, + * replyOptions?: ?array, * attachmentFiles?: ?array, * } $values */ @@ -45,6 +46,7 @@ public function __construct( $this->body = $values['body']; $this->createdAt = $values['createdAt'] ?? null; $this->attachmentUrls = $values['attachmentUrls'] ?? null; + $this->replyOptions = $values['replyOptions'] ?? null; $this->userId = $values['userId']; $this->attachmentFiles = $values['attachmentFiles'] ?? null; } diff --git a/src/Types/ContactSegments.php b/src/Types/ContactSegments.php index 987ed4f..51d57d8 100644 --- a/src/Types/ContactSegments.php +++ b/src/Types/ContactSegments.php @@ -13,59 +13,59 @@ class ContactSegments extends JsonSerializableType { /** - * @var 'list' $type The type of the object + * @var ?'list' $type The type of the object */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var array $data Segment objects associated with the contact. + * @var ?array $data Segment objects associated with the contact. */ #[JsonProperty('data'), ArrayType([Segment::class])] - private array $data; + private ?array $data; /** * @param array{ - * type: 'list', - * data: array, + * type?: ?'list', + * data?: ?array, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->data = $values['data']; + $this->type = $values['type'] ?? null; + $this->data = $values['data'] ?? null; } /** - * @return 'list' + * @return ?'list' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'list' $value + * @param ?'list' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return array + * @return ?array */ - public function getData(): array + public function getData(): ?array { return $this->data; } /** - * @param array $value + * @param ?array $value */ - public function setData(array $value): self + public function setData(?array $value = null): self { $this->data = $value; return $this; diff --git a/src/Types/ContactSocialProfiles.php b/src/Types/ContactSocialProfiles.php index 61645e0..593605b 100644 --- a/src/Types/ContactSocialProfiles.php +++ b/src/Types/ContactSocialProfiles.php @@ -12,34 +12,34 @@ class ContactSocialProfiles extends JsonSerializableType { /** - * @var array $data A list of social profiles objects associated with the contact. + * @var ?array $data A list of social profiles objects associated with the contact. */ #[JsonProperty('data'), ArrayType([SocialProfile::class])] - private array $data; + private ?array $data; /** * @param array{ - * data: array, + * data?: ?array, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->data = $values['data']; + $this->data = $values['data'] ?? null; } /** - * @return array + * @return ?array */ - public function getData(): array + public function getData(): ?array { return $this->data; } /** - * @param array $value + * @param ?array $value */ - public function setData(array $value): self + public function setData(?array $value = null): self { $this->data = $value; return $this; diff --git a/src/Types/ContactSubscriptionTypes.php b/src/Types/ContactSubscriptionTypes.php index 9458596..f95750f 100644 --- a/src/Types/ContactSubscriptionTypes.php +++ b/src/Types/ContactSubscriptionTypes.php @@ -12,109 +12,109 @@ class ContactSubscriptionTypes extends JsonSerializableType { /** - * @var array $data This object represents the subscriptions attached to a contact. + * @var ?array $data This object represents the subscriptions attached to a contact. */ #[JsonProperty('data'), ArrayType([AddressableList::class])] - private array $data; + private ?array $data; /** - * @var string $url Url to get more subscription type resources for this contact + * @var ?string $url Url to get more subscription type resources for this contact */ #[JsonProperty('url')] - private string $url; + private ?string $url; /** - * @var int $totalCount Int representing the total number of subscription types attached to this contact + * @var ?int $totalCount Int representing the total number of subscription types attached to this contact */ #[JsonProperty('total_count')] - private int $totalCount; + private ?int $totalCount; /** - * @var bool $hasMore Whether there's more Addressable Objects to be viewed. If true, use the url to view all + * @var ?bool $hasMore Whether there's more Addressable Objects to be viewed. If true, use the url to view all */ #[JsonProperty('has_more')] - private bool $hasMore; + private ?bool $hasMore; /** * @param array{ - * data: array, - * url: string, - * totalCount: int, - * hasMore: bool, + * data?: ?array, + * url?: ?string, + * totalCount?: ?int, + * hasMore?: ?bool, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->data = $values['data']; - $this->url = $values['url']; - $this->totalCount = $values['totalCount']; - $this->hasMore = $values['hasMore']; + $this->data = $values['data'] ?? null; + $this->url = $values['url'] ?? null; + $this->totalCount = $values['totalCount'] ?? null; + $this->hasMore = $values['hasMore'] ?? null; } /** - * @return array + * @return ?array */ - public function getData(): array + public function getData(): ?array { return $this->data; } /** - * @param array $value + * @param ?array $value */ - public function setData(array $value): self + public function setData(?array $value = null): self { $this->data = $value; return $this; } /** - * @return string + * @return ?string */ - public function getUrl(): string + public function getUrl(): ?string { return $this->url; } /** - * @param string $value + * @param ?string $value */ - public function setUrl(string $value): self + public function setUrl(?string $value = null): self { $this->url = $value; return $this; } /** - * @return int + * @return ?int */ - public function getTotalCount(): int + public function getTotalCount(): ?int { return $this->totalCount; } /** - * @param int $value + * @param ?int $value */ - public function setTotalCount(int $value): self + public function setTotalCount(?int $value = null): self { $this->totalCount = $value; return $this; } /** - * @return bool + * @return ?bool */ - public function getHasMore(): bool + public function getHasMore(): ?bool { return $this->hasMore; } /** - * @param bool $value + * @param ?bool $value */ - public function setHasMore(bool $value): self + public function setHasMore(?bool $value = null): self { $this->hasMore = $value; return $this; diff --git a/src/Types/ContactTags.php b/src/Types/ContactTags.php index 4810b9b..8f26723 100644 --- a/src/Types/ContactTags.php +++ b/src/Types/ContactTags.php @@ -12,109 +12,109 @@ class ContactTags extends JsonSerializableType { /** - * @var array $data This object represents the tags attached to a contact. + * @var ?array $data This object represents the tags attached to a contact. */ #[JsonProperty('data'), ArrayType([AddressableList::class])] - private array $data; + private ?array $data; /** - * @var string $url url to get more tag resources for this contact + * @var ?string $url url to get more tag resources for this contact */ #[JsonProperty('url')] - private string $url; + private ?string $url; /** - * @var int $totalCount Int representing the total number of tags attached to this contact + * @var ?int $totalCount Int representing the total number of tags attached to this contact */ #[JsonProperty('total_count')] - private int $totalCount; + private ?int $totalCount; /** - * @var bool $hasMore Whether there's more Addressable Objects to be viewed. If true, use the url to view all + * @var ?bool $hasMore Whether there's more Addressable Objects to be viewed. If true, use the url to view all */ #[JsonProperty('has_more')] - private bool $hasMore; + private ?bool $hasMore; /** * @param array{ - * data: array, - * url: string, - * totalCount: int, - * hasMore: bool, + * data?: ?array, + * url?: ?string, + * totalCount?: ?int, + * hasMore?: ?bool, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->data = $values['data']; - $this->url = $values['url']; - $this->totalCount = $values['totalCount']; - $this->hasMore = $values['hasMore']; + $this->data = $values['data'] ?? null; + $this->url = $values['url'] ?? null; + $this->totalCount = $values['totalCount'] ?? null; + $this->hasMore = $values['hasMore'] ?? null; } /** - * @return array + * @return ?array */ - public function getData(): array + public function getData(): ?array { return $this->data; } /** - * @param array $value + * @param ?array $value */ - public function setData(array $value): self + public function setData(?array $value = null): self { $this->data = $value; return $this; } /** - * @return string + * @return ?string */ - public function getUrl(): string + public function getUrl(): ?string { return $this->url; } /** - * @param string $value + * @param ?string $value */ - public function setUrl(string $value): self + public function setUrl(?string $value = null): self { $this->url = $value; return $this; } /** - * @return int + * @return ?int */ - public function getTotalCount(): int + public function getTotalCount(): ?int { return $this->totalCount; } /** - * @param int $value + * @param ?int $value */ - public function setTotalCount(int $value): self + public function setTotalCount(?int $value = null): self { $this->totalCount = $value; return $this; } /** - * @return bool + * @return ?bool */ - public function getHasMore(): bool + public function getHasMore(): ?bool { return $this->hasMore; } /** - * @param bool $value + * @param ?bool $value */ - public function setHasMore(bool $value): self + public function setHasMore(?bool $value = null): self { $this->hasMore = $value; return $this; diff --git a/src/Types/ContactUnarchived.php b/src/Types/ContactUnarchived.php index ff0df08..99b1f1a 100644 --- a/src/Types/ContactUnarchived.php +++ b/src/Types/ContactUnarchived.php @@ -3,6 +3,7 @@ namespace Intercom\Types; use Intercom\Core\Json\JsonSerializableType; +use Intercom\Traits\ContactReference; use Intercom\Core\Json\JsonProperty; /** @@ -10,110 +11,43 @@ */ class ContactUnarchived extends JsonSerializableType { - /** - * @var 'contact' $type always contact - */ - #[JsonProperty('type')] - private string $type; - - /** - * @var string $id The unique identifier for the contact which is given by Intercom. - */ - #[JsonProperty('id')] - private string $id; + use ContactReference; /** - * @var ?string $externalId The unique identifier for the contact which is provided by the Client. - */ - #[JsonProperty('external_id')] - private ?string $externalId; - - /** - * @var bool $archived Whether the contact is archived or not. + * @var ?bool $archived Whether the contact is archived or not. */ #[JsonProperty('archived')] - private bool $archived; + private ?bool $archived; /** * @param array{ - * type: 'contact', - * id: string, - * archived: bool, + * type?: ?'contact', + * id?: ?string, * externalId?: ?string, + * archived?: ?bool, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->id = $values['id']; + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; $this->externalId = $values['externalId'] ?? null; - $this->archived = $values['archived']; - } - - /** - * @return 'contact' - */ - public function getType(): string - { - return $this->type; - } - - /** - * @param 'contact' $value - */ - public function setType(string $value): self - { - $this->type = $value; - return $this; - } - - /** - * @return string - */ - public function getId(): string - { - return $this->id; - } - - /** - * @param string $value - */ - public function setId(string $value): self - { - $this->id = $value; - return $this; - } - - /** - * @return ?string - */ - public function getExternalId(): ?string - { - return $this->externalId; - } - - /** - * @param ?string $value - */ - public function setExternalId(?string $value = null): self - { - $this->externalId = $value; - return $this; + $this->archived = $values['archived'] ?? null; } /** - * @return bool + * @return ?bool */ - public function getArchived(): bool + public function getArchived(): ?bool { return $this->archived; } /** - * @param bool $value + * @param ?bool $value */ - public function setArchived(bool $value): self + public function setArchived(?bool $value = null): self { $this->archived = $value; return $this; diff --git a/src/Types/ContentObject.php b/src/Types/ContentObject.php deleted file mode 100644 index 449307c..0000000 --- a/src/Types/ContentObject.php +++ /dev/null @@ -1,57 +0,0 @@ - $components The list of components to be rendered. - */ - #[JsonProperty('components'), ArrayType([Component::class])] - private array $components; - - /** - * @param array{ - * components: array, - * } $values - */ - public function __construct( - array $values, - ) { - $this->components = $values['components']; - } - - /** - * @return array - */ - public function getComponents(): array - { - return $this->components; - } - - /** - * @param array $value - */ - public function setComponents(array $value): self - { - $this->components = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/ContentSourcesList.php b/src/Types/ContentSourcesList.php index dd72fda..4932ae0 100644 --- a/src/Types/ContentSourcesList.php +++ b/src/Types/ContentSourcesList.php @@ -10,84 +10,84 @@ class ContentSourcesList extends JsonSerializableType { /** - * @var 'content_source.list' $type + * @var ?'content_source.list' $type */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var int $totalCount The total number of content sources used by AI Agent in the conversation. + * @var ?int $totalCount The total number of content sources used by AI Agent in the conversation. */ #[JsonProperty('total_count')] - private int $totalCount; + private ?int $totalCount; /** - * @var array $contentSources The content sources used by AI Agent in the conversation. + * @var ?array $contentSources The content sources used by AI Agent in the conversation. */ #[JsonProperty('content_sources'), ArrayType([ContentSource::class])] - private array $contentSources; + private ?array $contentSources; /** * @param array{ - * type: 'content_source.list', - * totalCount: int, - * contentSources: array, + * type?: ?'content_source.list', + * totalCount?: ?int, + * contentSources?: ?array, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->totalCount = $values['totalCount']; - $this->contentSources = $values['contentSources']; + $this->type = $values['type'] ?? null; + $this->totalCount = $values['totalCount'] ?? null; + $this->contentSources = $values['contentSources'] ?? null; } /** - * @return 'content_source.list' + * @return ?'content_source.list' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'content_source.list' $value + * @param ?'content_source.list' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return int + * @return ?int */ - public function getTotalCount(): int + public function getTotalCount(): ?int { return $this->totalCount; } /** - * @param int $value + * @param ?int $value */ - public function setTotalCount(int $value): self + public function setTotalCount(?int $value = null): self { $this->totalCount = $value; return $this; } /** - * @return array + * @return ?array */ - public function getContentSources(): array + public function getContentSources(): ?array { return $this->contentSources; } /** - * @param array $value + * @param ?array $value */ - public function setContentSources(array $value): self + public function setContentSources(?array $value = null): self { $this->contentSources = $value; return $this; diff --git a/src/Types/Context.php b/src/Types/Context.php deleted file mode 100644 index 7b884aa..0000000 --- a/src/Types/Context.php +++ /dev/null @@ -1,181 +0,0 @@ - $location Where the app is added or the action took place. Can be either 'conversation', 'home', 'message', or 'operator'. - */ - #[JsonProperty('location')] - private ?string $location; - - /** - * @var ?string $locale The default end-user language of the Messenger. Use to localise Messenger App content. - */ - #[JsonProperty('locale')] - private ?string $locale; - - /** - * @var ?string $messengerActionColour The messengers action colour. Use in Sheets and Icons to make a Messenger App experience feel part of the host Messenger. - */ - #[JsonProperty('messenger_action_colour')] - private ?string $messengerActionColour; - - /** - * @var ?string $messengerBackgroundColour The messengers background colour. Use in Sheets and Icons to make a Messenger App experience feel part of the host Messenger. - */ - #[JsonProperty('messenger_background_colour')] - private ?string $messengerBackgroundColour; - - /** - * @var ?string $referrer The current page URL where the app is being used. - */ - #[JsonProperty('referrer')] - private ?string $referrer; - - /** - * @param array{ - * conversationId?: ?int, - * location?: ?value-of, - * locale?: ?string, - * messengerActionColour?: ?string, - * messengerBackgroundColour?: ?string, - * referrer?: ?string, - * } $values - */ - public function __construct( - array $values = [], - ) { - $this->conversationId = $values['conversationId'] ?? null; - $this->location = $values['location'] ?? null; - $this->locale = $values['locale'] ?? null; - $this->messengerActionColour = $values['messengerActionColour'] ?? null; - $this->messengerBackgroundColour = $values['messengerBackgroundColour'] ?? null; - $this->referrer = $values['referrer'] ?? null; - } - - /** - * @return ?int - */ - public function getConversationId(): ?int - { - return $this->conversationId; - } - - /** - * @param ?int $value - */ - public function setConversationId(?int $value = null): self - { - $this->conversationId = $value; - return $this; - } - - /** - * @return ?value-of - */ - public function getLocation(): ?string - { - return $this->location; - } - - /** - * @param ?value-of $value - */ - public function setLocation(?string $value = null): self - { - $this->location = $value; - return $this; - } - - /** - * @return ?string - */ - public function getLocale(): ?string - { - return $this->locale; - } - - /** - * @param ?string $value - */ - public function setLocale(?string $value = null): self - { - $this->locale = $value; - return $this; - } - - /** - * @return ?string - */ - public function getMessengerActionColour(): ?string - { - return $this->messengerActionColour; - } - - /** - * @param ?string $value - */ - public function setMessengerActionColour(?string $value = null): self - { - $this->messengerActionColour = $value; - return $this; - } - - /** - * @return ?string - */ - public function getMessengerBackgroundColour(): ?string - { - return $this->messengerBackgroundColour; - } - - /** - * @param ?string $value - */ - public function setMessengerBackgroundColour(?string $value = null): self - { - $this->messengerBackgroundColour = $value; - return $this; - } - - /** - * @return ?string - */ - public function getReferrer(): ?string - { - return $this->referrer; - } - - /** - * @param ?string $value - */ - public function setReferrer(?string $value = null): self - { - $this->referrer = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/ContextLocation.php b/src/Types/ContextLocation.php deleted file mode 100644 index f0aa92d..0000000 --- a/src/Types/ContextLocation.php +++ /dev/null @@ -1,11 +0,0 @@ -contentType = $values['contentType']; - $this->data = $values['data']; - $this->name = $values['name']; + $this->contentType = $values['contentType'] ?? null; + $this->data = $values['data'] ?? null; + $this->name = $values['name'] ?? null; } /** - * @return string + * @return ?string */ - public function getContentType(): string + public function getContentType(): ?string { return $this->contentType; } /** - * @param string $value + * @param ?string $value */ - public function setContentType(string $value): self + public function setContentType(?string $value = null): self { $this->contentType = $value; return $this; } /** - * @return string + * @return ?string */ - public function getData(): string + public function getData(): ?string { return $this->data; } /** - * @param string $value + * @param ?string $value */ - public function setData(string $value): self + public function setData(?string $value = null): self { $this->data = $value; return $this; } /** - * @return string + * @return ?string */ - public function getName(): string + public function getName(): ?string { return $this->name; } /** - * @param string $value + * @param ?string $value */ - public function setName(string $value): self + public function setName(?string $value = null): self { $this->name = $value; return $this; diff --git a/src/Types/ConversationAttributeUpdatedByAdmin.php b/src/Types/ConversationAttributeUpdatedByAdmin.php new file mode 100644 index 0000000..d0036fa --- /dev/null +++ b/src/Types/ConversationAttributeUpdatedByAdmin.php @@ -0,0 +1,79 @@ +conversation_attribute_updated_by_admin. + */ +class ConversationAttributeUpdatedByAdmin extends JsonSerializableType +{ + /** + * @var ?ConversationAttributeUpdatedByAdminAttribute $attribute + */ + #[JsonProperty('attribute')] + private ?ConversationAttributeUpdatedByAdminAttribute $attribute; + + /** + * @var ?ConversationAttributeUpdatedByAdminValue $value + */ + #[JsonProperty('value')] + private ?ConversationAttributeUpdatedByAdminValue $value; + + /** + * @param array{ + * attribute?: ?ConversationAttributeUpdatedByAdminAttribute, + * value?: ?ConversationAttributeUpdatedByAdminValue, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->attribute = $values['attribute'] ?? null; + $this->value = $values['value'] ?? null; + } + + /** + * @return ?ConversationAttributeUpdatedByAdminAttribute + */ + public function getAttribute(): ?ConversationAttributeUpdatedByAdminAttribute + { + return $this->attribute; + } + + /** + * @param ?ConversationAttributeUpdatedByAdminAttribute $value + */ + public function setAttribute(?ConversationAttributeUpdatedByAdminAttribute $value = null): self + { + $this->attribute = $value; + return $this; + } + + /** + * @return ?ConversationAttributeUpdatedByAdminValue + */ + public function getValue(): ?ConversationAttributeUpdatedByAdminValue + { + return $this->value; + } + + /** + * @param ?ConversationAttributeUpdatedByAdminValue $value + */ + public function setValue(?ConversationAttributeUpdatedByAdminValue $value = null): self + { + $this->value = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/ConversationAttributeUpdatedByAdminAttribute.php b/src/Types/ConversationAttributeUpdatedByAdminAttribute.php new file mode 100644 index 0000000..7c2cd2a --- /dev/null +++ b/src/Types/ConversationAttributeUpdatedByAdminAttribute.php @@ -0,0 +1,51 @@ +name = $values['name'] ?? null; + } + + /** + * @return ?string + */ + public function getName(): ?string + { + return $this->name; + } + + /** + * @param ?string $value + */ + public function setName(?string $value = null): self + { + $this->name = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/ConversationAttributeUpdatedByAdminValue.php b/src/Types/ConversationAttributeUpdatedByAdminValue.php new file mode 100644 index 0000000..28adf73 --- /dev/null +++ b/src/Types/ConversationAttributeUpdatedByAdminValue.php @@ -0,0 +1,51 @@ +name = $values['name'] ?? null; + } + + /** + * @return ?string + */ + public function getName(): ?string + { + return $this->name; + } + + /** + * @param ?string $value + */ + public function setName(?string $value = null): self + { + $this->name = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/ConversationAttributeUpdatedByWorkflow.php b/src/Types/ConversationAttributeUpdatedByWorkflow.php new file mode 100644 index 0000000..02582d5 --- /dev/null +++ b/src/Types/ConversationAttributeUpdatedByWorkflow.php @@ -0,0 +1,104 @@ +conversation_attribute_updated_by_workflow. + */ +class ConversationAttributeUpdatedByWorkflow extends JsonSerializableType +{ + /** + * @var ?ConversationAttributeUpdatedByWorkflowWorkflow $workflow + */ + #[JsonProperty('workflow')] + private ?ConversationAttributeUpdatedByWorkflowWorkflow $workflow; + + /** + * @var ?ConversationAttributeUpdatedByWorkflowAttribute $attribute + */ + #[JsonProperty('attribute')] + private ?ConversationAttributeUpdatedByWorkflowAttribute $attribute; + + /** + * @var ?ConversationAttributeUpdatedByWorkflowValue $value + */ + #[JsonProperty('value')] + private ?ConversationAttributeUpdatedByWorkflowValue $value; + + /** + * @param array{ + * workflow?: ?ConversationAttributeUpdatedByWorkflowWorkflow, + * attribute?: ?ConversationAttributeUpdatedByWorkflowAttribute, + * value?: ?ConversationAttributeUpdatedByWorkflowValue, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->workflow = $values['workflow'] ?? null; + $this->attribute = $values['attribute'] ?? null; + $this->value = $values['value'] ?? null; + } + + /** + * @return ?ConversationAttributeUpdatedByWorkflowWorkflow + */ + public function getWorkflow(): ?ConversationAttributeUpdatedByWorkflowWorkflow + { + return $this->workflow; + } + + /** + * @param ?ConversationAttributeUpdatedByWorkflowWorkflow $value + */ + public function setWorkflow(?ConversationAttributeUpdatedByWorkflowWorkflow $value = null): self + { + $this->workflow = $value; + return $this; + } + + /** + * @return ?ConversationAttributeUpdatedByWorkflowAttribute + */ + public function getAttribute(): ?ConversationAttributeUpdatedByWorkflowAttribute + { + return $this->attribute; + } + + /** + * @param ?ConversationAttributeUpdatedByWorkflowAttribute $value + */ + public function setAttribute(?ConversationAttributeUpdatedByWorkflowAttribute $value = null): self + { + $this->attribute = $value; + return $this; + } + + /** + * @return ?ConversationAttributeUpdatedByWorkflowValue + */ + public function getValue(): ?ConversationAttributeUpdatedByWorkflowValue + { + return $this->value; + } + + /** + * @param ?ConversationAttributeUpdatedByWorkflowValue $value + */ + public function setValue(?ConversationAttributeUpdatedByWorkflowValue $value = null): self + { + $this->value = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/ConversationAttributeUpdatedByWorkflowAttribute.php b/src/Types/ConversationAttributeUpdatedByWorkflowAttribute.php new file mode 100644 index 0000000..307a4aa --- /dev/null +++ b/src/Types/ConversationAttributeUpdatedByWorkflowAttribute.php @@ -0,0 +1,51 @@ +name = $values['name'] ?? null; + } + + /** + * @return ?string + */ + public function getName(): ?string + { + return $this->name; + } + + /** + * @param ?string $value + */ + public function setName(?string $value = null): self + { + $this->name = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/ConversationAttributeUpdatedByWorkflowValue.php b/src/Types/ConversationAttributeUpdatedByWorkflowValue.php new file mode 100644 index 0000000..670b424 --- /dev/null +++ b/src/Types/ConversationAttributeUpdatedByWorkflowValue.php @@ -0,0 +1,51 @@ +name = $values['name'] ?? null; + } + + /** + * @return ?string + */ + public function getName(): ?string + { + return $this->name; + } + + /** + * @param ?string $value + */ + public function setName(?string $value = null): self + { + $this->name = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/ConversationAttributeUpdatedByWorkflowWorkflow.php b/src/Types/ConversationAttributeUpdatedByWorkflowWorkflow.php new file mode 100644 index 0000000..52e410e --- /dev/null +++ b/src/Types/ConversationAttributeUpdatedByWorkflowWorkflow.php @@ -0,0 +1,51 @@ +name = $values['name'] ?? null; + } + + /** + * @return ?string + */ + public function getName(): ?string + { + return $this->name; + } + + /** + * @param ?string $value + */ + public function setName(?string $value = null): self + { + $this->name = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/ConversationContacts.php b/src/Types/ConversationContacts.php index 8989ef9..881660e 100644 --- a/src/Types/ConversationContacts.php +++ b/src/Types/ConversationContacts.php @@ -12,59 +12,59 @@ class ConversationContacts extends JsonSerializableType { /** - * @var 'contact.list' $type + * @var ?'contact.list' $type */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var array $contacts The list of contacts (users or leads) involved in this conversation. This will only contain one customer unless more were added via the group conversation feature. + * @var ?array $contacts The list of contacts (users or leads) involved in this conversation. This will only contain one customer unless more were added via the group conversation feature. */ #[JsonProperty('contacts'), ArrayType([ContactReference::class])] - private array $contacts; + private ?array $contacts; /** * @param array{ - * type: 'contact.list', - * contacts: array, + * type?: ?'contact.list', + * contacts?: ?array, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->contacts = $values['contacts']; + $this->type = $values['type'] ?? null; + $this->contacts = $values['contacts'] ?? null; } /** - * @return 'contact.list' + * @return ?'contact.list' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'contact.list' $value + * @param ?'contact.list' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return array + * @return ?array */ - public function getContacts(): array + public function getContacts(): ?array { return $this->contacts; } /** - * @param array $value + * @param ?array $value */ - public function setContacts(array $value): self + public function setContacts(?array $value = null): self { $this->contacts = $value; return $this; diff --git a/src/Types/ConversationDeleted.php b/src/Types/ConversationDeleted.php new file mode 100644 index 0000000..eb399ac --- /dev/null +++ b/src/Types/ConversationDeleted.php @@ -0,0 +1,104 @@ +id = $values['id'] ?? null; + $this->object = $values['object'] ?? null; + $this->deleted = $values['deleted'] ?? null; + } + + /** + * @return ?string + */ + public function getId(): ?string + { + return $this->id; + } + + /** + * @param ?string $value + */ + public function setId(?string $value = null): self + { + $this->id = $value; + return $this; + } + + /** + * @return ?'conversation' + */ + public function getObject(): ?string + { + return $this->object; + } + + /** + * @param ?'conversation' $value + */ + public function setObject(?string $value = null): self + { + $this->object = $value; + return $this; + } + + /** + * @return ?bool + */ + public function getDeleted(): ?bool + { + return $this->deleted; + } + + /** + * @param ?bool $value + */ + public function setDeleted(?bool $value = null): self + { + $this->deleted = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/ConversationFirstContactReply.php b/src/Types/ConversationFirstContactReply.php index 247e44b..7309364 100644 --- a/src/Types/ConversationFirstContactReply.php +++ b/src/Types/ConversationFirstContactReply.php @@ -11,16 +11,16 @@ class ConversationFirstContactReply extends JsonSerializableType { /** - * @var int $createdAt + * @var ?int $createdAt */ #[JsonProperty('created_at')] - private int $createdAt; + private ?int $createdAt; /** - * @var string $type + * @var ?string $type */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** * @var ?string $url @@ -30,48 +30,48 @@ class ConversationFirstContactReply extends JsonSerializableType /** * @param array{ - * createdAt: int, - * type: string, + * createdAt?: ?int, + * type?: ?string, * url?: ?string, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->createdAt = $values['createdAt']; - $this->type = $values['type']; + $this->createdAt = $values['createdAt'] ?? null; + $this->type = $values['type'] ?? null; $this->url = $values['url'] ?? null; } /** - * @return int + * @return ?int */ - public function getCreatedAt(): int + public function getCreatedAt(): ?int { return $this->createdAt; } /** - * @param int $value + * @param ?int $value */ - public function setCreatedAt(int $value): self + public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; return $this; } /** - * @return string + * @return ?string */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param string $value + * @param ?string $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; diff --git a/src/Types/PaginatedConversationResponse.php b/src/Types/ConversationList.php similarity index 59% rename from src/Types/PaginatedConversationResponse.php rename to src/Types/ConversationList.php index 1380250..fc879e2 100644 --- a/src/Types/PaginatedConversationResponse.php +++ b/src/Types/ConversationList.php @@ -10,25 +10,25 @@ /** * Conversations are how you can communicate with users in Intercom. They are created when a contact replies to an outbound message, or when one admin directly sends a message to a single contact. */ -class PaginatedConversationResponse extends JsonSerializableType +class ConversationList extends JsonSerializableType { /** - * @var 'conversation.list' $type Always conversation.list + * @var ?'conversation.list' $type Always conversation.list */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var array $conversations The list of conversation objects + * @var ?array $conversations The list of conversation objects */ #[JsonProperty('conversations'), ArrayType([Conversation::class])] - private array $conversations; + private ?array $conversations; /** - * @var int $totalCount A count of the total number of objects. + * @var ?int $totalCount A count of the total number of objects. */ #[JsonProperty('total_count')] - private int $totalCount; + private ?int $totalCount; /** * @var ?CursorPages $pages @@ -38,67 +38,67 @@ class PaginatedConversationResponse extends JsonSerializableType /** * @param array{ - * type: 'conversation.list', - * conversations: array, - * totalCount: int, + * type?: ?'conversation.list', + * conversations?: ?array, + * totalCount?: ?int, * pages?: ?CursorPages, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->conversations = $values['conversations']; - $this->totalCount = $values['totalCount']; + $this->type = $values['type'] ?? null; + $this->conversations = $values['conversations'] ?? null; + $this->totalCount = $values['totalCount'] ?? null; $this->pages = $values['pages'] ?? null; } /** - * @return 'conversation.list' + * @return ?'conversation.list' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'conversation.list' $value + * @param ?'conversation.list' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return array + * @return ?array */ - public function getConversations(): array + public function getConversations(): ?array { return $this->conversations; } /** - * @param array $value + * @param ?array $value */ - public function setConversations(array $value): self + public function setConversations(?array $value = null): self { $this->conversations = $value; return $this; } /** - * @return int + * @return ?int */ - public function getTotalCount(): int + public function getTotalCount(): ?int { return $this->totalCount; } /** - * @param int $value + * @param ?int $value */ - public function setTotalCount(int $value): self + public function setTotalCount(?int $value = null): self { $this->totalCount = $value; return $this; diff --git a/src/Types/ConversationPart.php b/src/Types/ConversationPart.php index 815e12f..9483e8b 100644 --- a/src/Types/ConversationPart.php +++ b/src/Types/ConversationPart.php @@ -5,6 +5,8 @@ use Intercom\Core\Json\JsonSerializableType; use Intercom\Core\Json\JsonProperty; use Intercom\Core\Types\ArrayType; +use Intercom\Tags\Types\TagBasic; +use Intercom\Core\Types\Union; /** * A Conversation Part represents a message in the conversation. @@ -12,22 +14,22 @@ class ConversationPart extends JsonSerializableType { /** - * @var 'conversation_part' $type Always conversation_part + * @var ?string $type Always conversation_part */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var string $id The id representing the conversation part. + * @var ?string $id The id representing the conversation part. */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** - * @var string $partType The type of conversation part. + * @var ?string $partType The type of conversation part. */ #[JsonProperty('part_type')] - private string $partType; + private ?string $partType; /** * @var ?string $body The message body, which may contain HTML. For Twitter, this will show a generic message regarding why the body is obscured. @@ -36,10 +38,10 @@ class ConversationPart extends JsonSerializableType private ?string $body; /** - * @var int $createdAt The time the conversation part was created. + * @var ?int $createdAt The time the conversation part was created. */ #[JsonProperty('created_at')] - private int $createdAt; + private ?int $createdAt; /** * @var ?int $updatedAt The last time the conversation part was updated. @@ -48,10 +50,10 @@ class ConversationPart extends JsonSerializableType private ?int $updatedAt; /** - * @var int $notifiedAt The time the user was notified with the conversation part. + * @var ?int $notifiedAt The time the user was notified with the conversation part. */ #[JsonProperty('notified_at')] - private int $notifiedAt; + private ?int $notifiedAt; /** * @var ?Reference $assignedTo The id of the admin that was assigned the conversation by this conversation_part (null if there has been no change in assignment.) @@ -60,10 +62,10 @@ class ConversationPart extends JsonSerializableType private ?Reference $assignedTo; /** - * @var ConversationPartAuthor $author + * @var ?ConversationPartAuthor $author */ #[JsonProperty('author')] - private ConversationPartAuthor $author; + private ?ConversationPartAuthor $author; /** * @var ?array $attachments A list of attachments for the part. @@ -78,90 +80,150 @@ class ConversationPart extends JsonSerializableType private ?string $externalId; /** - * @var bool $redacted Whether or not the conversation part has been redacted. + * @var ?bool $redacted Whether or not the conversation part has been redacted. */ #[JsonProperty('redacted')] - private bool $redacted; + private ?bool $redacted; + + /** + * @var ?EmailMessageMetadata $emailMessageMetadata + */ + #[JsonProperty('email_message_metadata')] + private ?EmailMessageMetadata $emailMessageMetadata; + + /** + * @var ?ConversationPartMetadata $metadata + */ + #[JsonProperty('metadata')] + private ?ConversationPartMetadata $metadata; + + /** + * @var ?value-of $state Indicates the current state of conversation when the conversation part was created. + */ + #[JsonProperty('state')] + private ?string $state; + + /** + * @var ?array $tags A list of tags objects associated with the conversation part. + */ + #[JsonProperty('tags'), ArrayType([TagBasic::class])] + private ?array $tags; + + /** + * @var ( + * ConversationAttributeUpdatedByWorkflow + * |ConversationAttributeUpdatedByAdmin + * |CustomActionStarted + * |CustomActionFinished + * |OperatorWorkflowEvent + * )|null $eventDetails + */ + #[JsonProperty('event_details'), Union(ConversationAttributeUpdatedByWorkflow::class, ConversationAttributeUpdatedByAdmin::class, CustomActionStarted::class, CustomActionFinished::class, OperatorWorkflowEvent::class, 'null')] + private ConversationAttributeUpdatedByWorkflow|ConversationAttributeUpdatedByAdmin|CustomActionStarted|CustomActionFinished|OperatorWorkflowEvent|null $eventDetails; + + /** + * @var ?string $appPackageCode The app package code if this part was created via API. null if the part was not created via API. + */ + #[JsonProperty('app_package_code')] + private ?string $appPackageCode; /** * @param array{ - * type: 'conversation_part', - * id: string, - * partType: string, - * createdAt: int, - * notifiedAt: int, - * author: ConversationPartAuthor, - * redacted: bool, + * type?: ?string, + * id?: ?string, + * partType?: ?string, * body?: ?string, + * createdAt?: ?int, * updatedAt?: ?int, + * notifiedAt?: ?int, * assignedTo?: ?Reference, + * author?: ?ConversationPartAuthor, * attachments?: ?array, * externalId?: ?string, + * redacted?: ?bool, + * emailMessageMetadata?: ?EmailMessageMetadata, + * metadata?: ?ConversationPartMetadata, + * state?: ?value-of, + * tags?: ?array, + * eventDetails?: ( + * ConversationAttributeUpdatedByWorkflow + * |ConversationAttributeUpdatedByAdmin + * |CustomActionStarted + * |CustomActionFinished + * |OperatorWorkflowEvent + * )|null, + * appPackageCode?: ?string, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->id = $values['id']; - $this->partType = $values['partType']; + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->partType = $values['partType'] ?? null; $this->body = $values['body'] ?? null; - $this->createdAt = $values['createdAt']; + $this->createdAt = $values['createdAt'] ?? null; $this->updatedAt = $values['updatedAt'] ?? null; - $this->notifiedAt = $values['notifiedAt']; + $this->notifiedAt = $values['notifiedAt'] ?? null; $this->assignedTo = $values['assignedTo'] ?? null; - $this->author = $values['author']; + $this->author = $values['author'] ?? null; $this->attachments = $values['attachments'] ?? null; $this->externalId = $values['externalId'] ?? null; - $this->redacted = $values['redacted']; + $this->redacted = $values['redacted'] ?? null; + $this->emailMessageMetadata = $values['emailMessageMetadata'] ?? null; + $this->metadata = $values['metadata'] ?? null; + $this->state = $values['state'] ?? null; + $this->tags = $values['tags'] ?? null; + $this->eventDetails = $values['eventDetails'] ?? null; + $this->appPackageCode = $values['appPackageCode'] ?? null; } /** - * @return 'conversation_part' + * @return ?string */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'conversation_part' $value + * @param ?string $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; } /** - * @return string + * @return ?string */ - public function getPartType(): string + public function getPartType(): ?string { return $this->partType; } /** - * @param string $value + * @param ?string $value */ - public function setPartType(string $value): self + public function setPartType(?string $value = null): self { $this->partType = $value; return $this; @@ -185,17 +247,17 @@ public function setBody(?string $value = null): self } /** - * @return int + * @return ?int */ - public function getCreatedAt(): int + public function getCreatedAt(): ?int { return $this->createdAt; } /** - * @param int $value + * @param ?int $value */ - public function setCreatedAt(int $value): self + public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; return $this; @@ -219,17 +281,17 @@ public function setUpdatedAt(?int $value = null): self } /** - * @return int + * @return ?int */ - public function getNotifiedAt(): int + public function getNotifiedAt(): ?int { return $this->notifiedAt; } /** - * @param int $value + * @param ?int $value */ - public function setNotifiedAt(int $value): self + public function setNotifiedAt(?int $value = null): self { $this->notifiedAt = $value; return $this; @@ -253,17 +315,17 @@ public function setAssignedTo(?Reference $value = null): self } /** - * @return ConversationPartAuthor + * @return ?ConversationPartAuthor */ - public function getAuthor(): ConversationPartAuthor + public function getAuthor(): ?ConversationPartAuthor { return $this->author; } /** - * @param ConversationPartAuthor $value + * @param ?ConversationPartAuthor $value */ - public function setAuthor(ConversationPartAuthor $value): self + public function setAuthor(?ConversationPartAuthor $value = null): self { $this->author = $value; return $this; @@ -304,22 +366,136 @@ public function setExternalId(?string $value = null): self } /** - * @return bool + * @return ?bool */ - public function getRedacted(): bool + public function getRedacted(): ?bool { return $this->redacted; } /** - * @param bool $value + * @param ?bool $value */ - public function setRedacted(bool $value): self + public function setRedacted(?bool $value = null): self { $this->redacted = $value; return $this; } + /** + * @return ?EmailMessageMetadata + */ + public function getEmailMessageMetadata(): ?EmailMessageMetadata + { + return $this->emailMessageMetadata; + } + + /** + * @param ?EmailMessageMetadata $value + */ + public function setEmailMessageMetadata(?EmailMessageMetadata $value = null): self + { + $this->emailMessageMetadata = $value; + return $this; + } + + /** + * @return ?ConversationPartMetadata + */ + public function getMetadata(): ?ConversationPartMetadata + { + return $this->metadata; + } + + /** + * @param ?ConversationPartMetadata $value + */ + public function setMetadata(?ConversationPartMetadata $value = null): self + { + $this->metadata = $value; + return $this; + } + + /** + * @return ?value-of + */ + public function getState(): ?string + { + return $this->state; + } + + /** + * @param ?value-of $value + */ + public function setState(?string $value = null): self + { + $this->state = $value; + return $this; + } + + /** + * @return ?array + */ + public function getTags(): ?array + { + return $this->tags; + } + + /** + * @param ?array $value + */ + public function setTags(?array $value = null): self + { + $this->tags = $value; + return $this; + } + + /** + * @return ( + * ConversationAttributeUpdatedByWorkflow + * |ConversationAttributeUpdatedByAdmin + * |CustomActionStarted + * |CustomActionFinished + * |OperatorWorkflowEvent + * )|null + */ + public function getEventDetails(): ConversationAttributeUpdatedByWorkflow|ConversationAttributeUpdatedByAdmin|CustomActionStarted|CustomActionFinished|OperatorWorkflowEvent|null + { + return $this->eventDetails; + } + + /** + * @param ( + * ConversationAttributeUpdatedByWorkflow + * |ConversationAttributeUpdatedByAdmin + * |CustomActionStarted + * |CustomActionFinished + * |OperatorWorkflowEvent + * )|null $value + */ + public function setEventDetails(ConversationAttributeUpdatedByWorkflow|ConversationAttributeUpdatedByAdmin|CustomActionStarted|CustomActionFinished|OperatorWorkflowEvent|null $value = null): self + { + $this->eventDetails = $value; + return $this; + } + + /** + * @return ?string + */ + public function getAppPackageCode(): ?string + { + return $this->appPackageCode; + } + + /** + * @param ?string $value + */ + public function setAppPackageCode(?string $value = null): self + { + $this->appPackageCode = $value; + return $this; + } + /** * @return string */ diff --git a/src/Types/ConversationPartAuthor.php b/src/Types/ConversationPartAuthor.php index 8bb3fa9..74391d6 100644 --- a/src/Types/ConversationPartAuthor.php +++ b/src/Types/ConversationPartAuthor.php @@ -11,114 +11,164 @@ class ConversationPartAuthor extends JsonSerializableType { /** - * @var string $type The type of the author + * @var ?string $type The type of the author */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var string $id The id of the author + * @var ?string $id The id of the author */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** - * @var string $name The name of the author + * @var ?string $name The name of the author */ #[JsonProperty('name')] - private string $name; + private ?string $name; /** - * @var string $email The email of the author + * @var ?string $email The email of the author */ #[JsonProperty('email')] - private string $email; + private ?string $email; + + /** + * @var ?bool $fromAiAgent If this conversation part was sent by the AI Agent + */ + #[JsonProperty('from_ai_agent')] + private ?bool $fromAiAgent; + + /** + * @var ?bool $isAiAnswer If this conversation part body was generated by the AI Agent + */ + #[JsonProperty('is_ai_answer')] + private ?bool $isAiAnswer; /** * @param array{ - * type: string, - * id: string, - * name: string, - * email: string, + * type?: ?string, + * id?: ?string, + * name?: ?string, + * email?: ?string, + * fromAiAgent?: ?bool, + * isAiAnswer?: ?bool, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->id = $values['id']; - $this->name = $values['name']; - $this->email = $values['email']; + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->name = $values['name'] ?? null; + $this->email = $values['email'] ?? null; + $this->fromAiAgent = $values['fromAiAgent'] ?? null; + $this->isAiAnswer = $values['isAiAnswer'] ?? null; } /** - * @return string + * @return ?string */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param string $value + * @param ?string $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; } /** - * @return string + * @return ?string */ - public function getName(): string + public function getName(): ?string { return $this->name; } /** - * @param string $value + * @param ?string $value */ - public function setName(string $value): self + public function setName(?string $value = null): self { $this->name = $value; return $this; } /** - * @return string + * @return ?string */ - public function getEmail(): string + public function getEmail(): ?string { return $this->email; } /** - * @param string $value + * @param ?string $value */ - public function setEmail(string $value): self + public function setEmail(?string $value = null): self { $this->email = $value; return $this; } + /** + * @return ?bool + */ + public function getFromAiAgent(): ?bool + { + return $this->fromAiAgent; + } + + /** + * @param ?bool $value + */ + public function setFromAiAgent(?bool $value = null): self + { + $this->fromAiAgent = $value; + return $this; + } + + /** + * @return ?bool + */ + public function getIsAiAnswer(): ?bool + { + return $this->isAiAnswer; + } + + /** + * @param ?bool $value + */ + public function setIsAiAnswer(?bool $value = null): self + { + $this->isAiAnswer = $value; + return $this; + } + /** * @return string */ diff --git a/src/Types/ConversationPartMetadata.php b/src/Types/ConversationPartMetadata.php new file mode 100644 index 0000000..3b98dc0 --- /dev/null +++ b/src/Types/ConversationPartMetadata.php @@ -0,0 +1,80 @@ + $quickReplyOptions The quick reply options sent by the Admin or bot, presented in this conversation part. + */ + #[JsonProperty('quick_reply_options'), ArrayType([ConversationPartMetadataQuickReplyOptionsItem::class])] + private ?array $quickReplyOptions; + + /** + * @var ?string $quickReplyUuid The unique identifier for the quick reply option that was clicked by the end user. + */ + #[JsonProperty('quick_reply_uuid')] + private ?string $quickReplyUuid; + + /** + * @param array{ + * quickReplyOptions?: ?array, + * quickReplyUuid?: ?string, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->quickReplyOptions = $values['quickReplyOptions'] ?? null; + $this->quickReplyUuid = $values['quickReplyUuid'] ?? null; + } + + /** + * @return ?array + */ + public function getQuickReplyOptions(): ?array + { + return $this->quickReplyOptions; + } + + /** + * @param ?array $value + */ + public function setQuickReplyOptions(?array $value = null): self + { + $this->quickReplyOptions = $value; + return $this; + } + + /** + * @return ?string + */ + public function getQuickReplyUuid(): ?string + { + return $this->quickReplyUuid; + } + + /** + * @param ?string $value + */ + public function setQuickReplyUuid(?string $value = null): self + { + $this->quickReplyUuid = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/ConversationPartMetadataQuickReplyOptionsItem.php b/src/Types/ConversationPartMetadataQuickReplyOptionsItem.php new file mode 100644 index 0000000..50580eb --- /dev/null +++ b/src/Types/ConversationPartMetadataQuickReplyOptionsItem.php @@ -0,0 +1,59 @@ + $translations The translations for the quick reply option. + */ + #[JsonProperty('translations'), ArrayType(['string' => 'mixed'])] + private ?array $translations; + + /** + * @param array{ + * text: string, + * uuid: string, + * translations?: ?array, + * } $values + */ + public function __construct( + array $values, + ) { + $this->text = $values['text']; + $this->uuid = $values['uuid']; + $this->translations = $values['translations'] ?? null; + } + + /** + * @return ?array + */ + public function getTranslations(): ?array + { + return $this->translations; + } + + /** + * @param ?array $value + */ + public function setTranslations(?array $value = null): self + { + $this->translations = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/ConversationPartState.php b/src/Types/ConversationPartState.php new file mode 100644 index 0000000..5c2a429 --- /dev/null +++ b/src/Types/ConversationPartState.php @@ -0,0 +1,10 @@ + $conversationParts A list of Conversation Part objects for each part message in the conversation. This is only returned when Retrieving a Conversation, and ignored when Listing all Conversations. There is a limit of 500 parts. + * @var ?array $conversationParts A list of Conversation Part objects for each part message in the conversation. This is only returned when Retrieving a Conversation, and ignored when Listing all Conversations. There is a limit of 500 parts. */ #[JsonProperty('conversation_parts'), ArrayType([ConversationPart::class])] - private array $conversationParts; + private ?array $conversationParts; /** - * @var int $totalCount + * @var ?int $totalCount */ #[JsonProperty('total_count')] - private int $totalCount; + private ?int $totalCount; /** * @param array{ - * type: 'conversation_part.list', - * conversationParts: array, - * totalCount: int, + * type?: ?'conversation_part.list', + * conversationParts?: ?array, + * totalCount?: ?int, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->conversationParts = $values['conversationParts']; - $this->totalCount = $values['totalCount']; + $this->type = $values['type'] ?? null; + $this->conversationParts = $values['conversationParts'] ?? null; + $this->totalCount = $values['totalCount'] ?? null; } /** - * @return 'conversation_part.list' + * @return ?'conversation_part.list' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'conversation_part.list' $value + * @param ?'conversation_part.list' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return array + * @return ?array */ - public function getConversationParts(): array + public function getConversationParts(): ?array { return $this->conversationParts; } /** - * @param array $value + * @param ?array $value */ - public function setConversationParts(array $value): self + public function setConversationParts(?array $value = null): self { $this->conversationParts = $value; return $this; } /** - * @return int + * @return ?int */ - public function getTotalCount(): int + public function getTotalCount(): ?int { return $this->totalCount; } /** - * @param int $value + * @param ?int $value */ - public function setTotalCount(int $value): self + public function setTotalCount(?int $value = null): self { $this->totalCount = $value; return $this; diff --git a/src/Types/ConversationRating.php b/src/Types/ConversationRating.php index 41619f8..21084bc 100644 --- a/src/Types/ConversationRating.php +++ b/src/Types/ConversationRating.php @@ -11,134 +11,159 @@ class ConversationRating extends JsonSerializableType { /** - * @var int $rating The rating, between 1 and 5, for the conversation. + * @var ?int $rating The rating, between 1 and 5, for the conversation. */ #[JsonProperty('rating')] - private int $rating; + private ?int $rating; /** - * @var string $remark An optional field to add a remark to correspond to the number rating + * @var ?string $remark An optional field to add a remark to correspond to the number rating */ #[JsonProperty('remark')] - private string $remark; + private ?string $remark; /** - * @var int $createdAt The time the rating was requested in the conversation being rated. + * @var ?int $createdAt The time the rating was requested in the conversation being rated. */ #[JsonProperty('created_at')] - private int $createdAt; + private ?int $createdAt; /** - * @var ContactReference $contact + * @var ?int $updatedAt The time the rating was last updated. + */ + #[JsonProperty('updated_at')] + private ?int $updatedAt; + + /** + * @var ?ContactReference $contact */ #[JsonProperty('contact')] - private ContactReference $contact; + private ?ContactReference $contact; /** - * @var Reference $teammate + * @var ?Reference $teammate */ #[JsonProperty('teammate')] - private Reference $teammate; + private ?Reference $teammate; /** * @param array{ - * rating: int, - * remark: string, - * createdAt: int, - * contact: ContactReference, - * teammate: Reference, + * rating?: ?int, + * remark?: ?string, + * createdAt?: ?int, + * updatedAt?: ?int, + * contact?: ?ContactReference, + * teammate?: ?Reference, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->rating = $values['rating']; - $this->remark = $values['remark']; - $this->createdAt = $values['createdAt']; - $this->contact = $values['contact']; - $this->teammate = $values['teammate']; + $this->rating = $values['rating'] ?? null; + $this->remark = $values['remark'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; + $this->updatedAt = $values['updatedAt'] ?? null; + $this->contact = $values['contact'] ?? null; + $this->teammate = $values['teammate'] ?? null; } /** - * @return int + * @return ?int */ - public function getRating(): int + public function getRating(): ?int { return $this->rating; } /** - * @param int $value + * @param ?int $value */ - public function setRating(int $value): self + public function setRating(?int $value = null): self { $this->rating = $value; return $this; } /** - * @return string + * @return ?string */ - public function getRemark(): string + public function getRemark(): ?string { return $this->remark; } /** - * @param string $value + * @param ?string $value */ - public function setRemark(string $value): self + public function setRemark(?string $value = null): self { $this->remark = $value; return $this; } /** - * @return int + * @return ?int */ - public function getCreatedAt(): int + public function getCreatedAt(): ?int { return $this->createdAt; } /** - * @param int $value + * @param ?int $value */ - public function setCreatedAt(int $value): self + public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; return $this; } /** - * @return ContactReference + * @return ?int + */ + public function getUpdatedAt(): ?int + { + return $this->updatedAt; + } + + /** + * @param ?int $value + */ + public function setUpdatedAt(?int $value = null): self + { + $this->updatedAt = $value; + return $this; + } + + /** + * @return ?ContactReference */ - public function getContact(): ContactReference + public function getContact(): ?ContactReference { return $this->contact; } /** - * @param ContactReference $value + * @param ?ContactReference $value */ - public function setContact(ContactReference $value): self + public function setContact(?ContactReference $value = null): self { $this->contact = $value; return $this; } /** - * @return Reference + * @return ?Reference */ - public function getTeammate(): Reference + public function getTeammate(): ?Reference { return $this->teammate; } /** - * @param Reference $value + * @param ?Reference $value */ - public function setTeammate(Reference $value): self + public function setTeammate(?Reference $value = null): self { $this->teammate = $value; return $this; diff --git a/src/Types/ConversationResponseTime.php b/src/Types/ConversationResponseTime.php new file mode 100644 index 0000000..ee5a9a6 --- /dev/null +++ b/src/Types/ConversationResponseTime.php @@ -0,0 +1,104 @@ +teamId = $values['teamId'] ?? null; + $this->teamName = $values['teamName'] ?? null; + $this->responseTime = $values['responseTime'] ?? null; + } + + /** + * @return ?int + */ + public function getTeamId(): ?int + { + return $this->teamId; + } + + /** + * @param ?int $value + */ + public function setTeamId(?int $value = null): self + { + $this->teamId = $value; + return $this; + } + + /** + * @return ?string + */ + public function getTeamName(): ?string + { + return $this->teamName; + } + + /** + * @param ?string $value + */ + public function setTeamName(?string $value = null): self + { + $this->teamName = $value; + return $this; + } + + /** + * @return ?int + */ + public function getResponseTime(): ?int + { + return $this->responseTime; + } + + /** + * @param ?int $value + */ + public function setResponseTime(?int $value = null): self + { + $this->responseTime = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/ConversationSource.php b/src/Types/ConversationSource.php index a2506ee..9c82734 100644 --- a/src/Types/ConversationSource.php +++ b/src/Types/ConversationSource.php @@ -7,33 +7,33 @@ use Intercom\Core\Types\ArrayType; /** - * The Conversation Part that originated this conversation, which can be Contact, Admin, Campaign, Automated or Operator initiated. + * The type of the conversation part that started this conversation. Can be Contact, Admin, Campaign, Automated or Operator initiated. */ class ConversationSource extends JsonSerializableType { /** - * @var value-of $type This includes conversation, email, facebook, instagram, phone_call, phone_switch, push, sms, twitter and whatsapp. + * @var ?value-of $type This includes conversation, email, facebook, instagram, phone_call, phone_switch, push, sms, twitter and whatsapp. */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var string $id The id representing the message. + * @var ?string $id The id representing the message. */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** - * @var string $deliveredAs The conversation's initiation type. Possible values are customer_initiated, campaigns_initiated (legacy campaigns), operator_initiated (Custom bot), automated (Series and other outbounds with dynamic audience message) and admin_initiated (fixed audience message, ticket initiated by an admin, group email). + * @var ?string $deliveredAs The conversation's initiation type. Possible values are customer_initiated, campaigns_initiated (legacy campaigns), operator_initiated (Custom bot), automated (Series and other outbounds with dynamic audience message) and admin_initiated (fixed audience message, ticket initiated by an admin, group email). */ #[JsonProperty('delivered_as')] - private string $deliveredAs; + private ?string $deliveredAs; /** - * @var string $subject Optional. The message subject. For Twitter, this will show a generic message regarding why the subject is obscured. + * @var ?string $subject Optional. The message subject. For Twitter, this will show a generic message regarding why the subject is obscured. */ #[JsonProperty('subject')] - private string $subject; + private ?string $subject; /** * @var ?string $body The message body, which may contain HTML. For Twitter, this will show a generic message regarding why the body is obscured. @@ -42,10 +42,10 @@ class ConversationSource extends JsonSerializableType private ?string $body; /** - * @var ConversationPartAuthor $author + * @var ?ConversationPartAuthor $author */ #[JsonProperty('author')] - private ConversationPartAuthor $author; + private ?ConversationPartAuthor $author; /** * @var ?array $attachments A list of attachments for the part. @@ -60,101 +60,101 @@ class ConversationSource extends JsonSerializableType private ?string $url; /** - * @var bool $redacted Whether or not the source message has been redacted. Only applicable for contact initiated messages. + * @var ?bool $redacted Whether or not the source message has been redacted. Only applicable for contact initiated messages. */ #[JsonProperty('redacted')] - private bool $redacted; + private ?bool $redacted; /** * @param array{ - * type: value-of, - * id: string, - * deliveredAs: string, - * subject: string, - * author: ConversationPartAuthor, - * redacted: bool, + * type?: ?value-of, + * id?: ?string, + * deliveredAs?: ?string, + * subject?: ?string, * body?: ?string, + * author?: ?ConversationPartAuthor, * attachments?: ?array, * url?: ?string, + * redacted?: ?bool, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->id = $values['id']; - $this->deliveredAs = $values['deliveredAs']; - $this->subject = $values['subject']; + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->deliveredAs = $values['deliveredAs'] ?? null; + $this->subject = $values['subject'] ?? null; $this->body = $values['body'] ?? null; - $this->author = $values['author']; + $this->author = $values['author'] ?? null; $this->attachments = $values['attachments'] ?? null; $this->url = $values['url'] ?? null; - $this->redacted = $values['redacted']; + $this->redacted = $values['redacted'] ?? null; } /** - * @return value-of + * @return ?value-of */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param value-of $value + * @param ?value-of $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; } /** - * @return string + * @return ?string */ - public function getDeliveredAs(): string + public function getDeliveredAs(): ?string { return $this->deliveredAs; } /** - * @param string $value + * @param ?string $value */ - public function setDeliveredAs(string $value): self + public function setDeliveredAs(?string $value = null): self { $this->deliveredAs = $value; return $this; } /** - * @return string + * @return ?string */ - public function getSubject(): string + public function getSubject(): ?string { return $this->subject; } /** - * @param string $value + * @param ?string $value */ - public function setSubject(string $value): self + public function setSubject(?string $value = null): self { $this->subject = $value; return $this; @@ -178,17 +178,17 @@ public function setBody(?string $value = null): self } /** - * @return ConversationPartAuthor + * @return ?ConversationPartAuthor */ - public function getAuthor(): ConversationPartAuthor + public function getAuthor(): ?ConversationPartAuthor { return $this->author; } /** - * @param ConversationPartAuthor $value + * @param ?ConversationPartAuthor $value */ - public function setAuthor(ConversationPartAuthor $value): self + public function setAuthor(?ConversationPartAuthor $value = null): self { $this->author = $value; return $this; @@ -229,17 +229,17 @@ public function setUrl(?string $value = null): self } /** - * @return bool + * @return ?bool */ - public function getRedacted(): bool + public function getRedacted(): ?bool { return $this->redacted; } /** - * @param bool $value + * @param ?bool $value */ - public function setRedacted(bool $value): self + public function setRedacted(?bool $value = null): self { $this->redacted = $value; return $this; diff --git a/src/Types/ConversationStatistics.php b/src/Types/ConversationStatistics.php index d7b844e..7b38155 100644 --- a/src/Types/ConversationStatistics.php +++ b/src/Types/ConversationStatistics.php @@ -4,6 +4,7 @@ use Intercom\Core\Json\JsonSerializableType; use Intercom\Core\Json\JsonProperty; +use Intercom\Core\Types\ArrayType; /** * A Statistics object containing all information required for reporting, with timestamps and calculated metrics. @@ -11,10 +12,10 @@ class ConversationStatistics extends JsonSerializableType { /** - * @var 'conversation_statistics' $type + * @var ?string $type */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** * @var ?int $timeToAssignment Duration until last assignment before first admin reply. In seconds. @@ -124,9 +125,33 @@ class ConversationStatistics extends JsonSerializableType #[JsonProperty('count_conversation_parts')] private ?int $countConversationParts; + /** + * @var ?array $assignedTeamFirstResponseTimeByTeam An array of conversation response time objects + */ + #[JsonProperty('assigned_team_first_response_time_by_team'), ArrayType([ConversationResponseTime::class])] + private ?array $assignedTeamFirstResponseTimeByTeam; + + /** + * @var ?array $assignedTeamFirstResponseTimeInOfficeHours An array of conversation response time objects within office hours + */ + #[JsonProperty('assigned_team_first_response_time_in_office_hours'), ArrayType([ConversationResponseTime::class])] + private ?array $assignedTeamFirstResponseTimeInOfficeHours; + + /** + * @var ?int $handlingTime Time from conversation assignment to conversation close in seconds. + */ + #[JsonProperty('handling_time')] + private ?int $handlingTime; + + /** + * @var ?int $adjustedHandlingTime Adjusted handling time for conversation in seconds. This is the active handling time excluding idle periods when teammates are not actively working on the conversation. + */ + #[JsonProperty('adjusted_handling_time')] + private ?int $adjustedHandlingTime; + /** * @param array{ - * type: 'conversation_statistics', + * type?: ?string, * timeToAssignment?: ?int, * timeToAdminReply?: ?int, * timeToFirstClose?: ?int, @@ -145,12 +170,16 @@ class ConversationStatistics extends JsonSerializableType * countReopens?: ?int, * countAssignments?: ?int, * countConversationParts?: ?int, + * assignedTeamFirstResponseTimeByTeam?: ?array, + * assignedTeamFirstResponseTimeInOfficeHours?: ?array, + * handlingTime?: ?int, + * adjustedHandlingTime?: ?int, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; + $this->type = $values['type'] ?? null; $this->timeToAssignment = $values['timeToAssignment'] ?? null; $this->timeToAdminReply = $values['timeToAdminReply'] ?? null; $this->timeToFirstClose = $values['timeToFirstClose'] ?? null; @@ -169,20 +198,24 @@ public function __construct( $this->countReopens = $values['countReopens'] ?? null; $this->countAssignments = $values['countAssignments'] ?? null; $this->countConversationParts = $values['countConversationParts'] ?? null; + $this->assignedTeamFirstResponseTimeByTeam = $values['assignedTeamFirstResponseTimeByTeam'] ?? null; + $this->assignedTeamFirstResponseTimeInOfficeHours = $values['assignedTeamFirstResponseTimeInOfficeHours'] ?? null; + $this->handlingTime = $values['handlingTime'] ?? null; + $this->adjustedHandlingTime = $values['adjustedHandlingTime'] ?? null; } /** - * @return 'conversation_statistics' + * @return ?string */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'conversation_statistics' $value + * @param ?string $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; @@ -494,6 +527,74 @@ public function setCountConversationParts(?int $value = null): self return $this; } + /** + * @return ?array + */ + public function getAssignedTeamFirstResponseTimeByTeam(): ?array + { + return $this->assignedTeamFirstResponseTimeByTeam; + } + + /** + * @param ?array $value + */ + public function setAssignedTeamFirstResponseTimeByTeam(?array $value = null): self + { + $this->assignedTeamFirstResponseTimeByTeam = $value; + return $this; + } + + /** + * @return ?array + */ + public function getAssignedTeamFirstResponseTimeInOfficeHours(): ?array + { + return $this->assignedTeamFirstResponseTimeInOfficeHours; + } + + /** + * @param ?array $value + */ + public function setAssignedTeamFirstResponseTimeInOfficeHours(?array $value = null): self + { + $this->assignedTeamFirstResponseTimeInOfficeHours = $value; + return $this; + } + + /** + * @return ?int + */ + public function getHandlingTime(): ?int + { + return $this->handlingTime; + } + + /** + * @param ?int $value + */ + public function setHandlingTime(?int $value = null): self + { + $this->handlingTime = $value; + return $this; + } + + /** + * @return ?int + */ + public function getAdjustedHandlingTime(): ?int + { + return $this->adjustedHandlingTime; + } + + /** + * @param ?int $value + */ + public function setAdjustedHandlingTime(?int $value = null): self + { + $this->adjustedHandlingTime = $value; + return $this; + } + /** * @return string */ diff --git a/src/Articles/Requests/CreateArticleRequest.php b/src/Types/CreateArticleRequest.php similarity index 96% rename from src/Articles/Requests/CreateArticleRequest.php rename to src/Types/CreateArticleRequest.php index c38aee4..961087e 100644 --- a/src/Articles/Requests/CreateArticleRequest.php +++ b/src/Types/CreateArticleRequest.php @@ -1,13 +1,13 @@ translatedContent = $value; return $this; } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } } diff --git a/src/Articles/Types/CreateArticleRequestParentType.php b/src/Types/CreateArticleRequestParentType.php similarity index 77% rename from src/Articles/Types/CreateArticleRequestParentType.php rename to src/Types/CreateArticleRequestParentType.php index 55ae37f..8ed8dcf 100644 --- a/src/Articles/Types/CreateArticleRequestParentType.php +++ b/src/Types/CreateArticleRequestParentType.php @@ -1,6 +1,6 @@ $dataType + */ + #[JsonProperty('data_type')] + private ?string $dataType; + + /** + * @param array{ + * dataType?: ?value-of, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->dataType = $values['dataType'] ?? null; + } + + /** + * @return ?value-of + */ + public function getDataType(): ?string + { + return $this->dataType; + } + + /** + * @param ?value-of $value + */ + public function setDataType(?string $value = null): self + { + $this->dataType = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/DataAttributes/Types/CreateDataAttributeRequestDataType.php b/src/Types/CreateDataAttributeRequestOneDataType.php similarity index 67% rename from src/DataAttributes/Types/CreateDataAttributeRequestDataType.php rename to src/Types/CreateDataAttributeRequestOneDataType.php index ed7177c..af7f8ea 100644 --- a/src/DataAttributes/Types/CreateDataAttributeRequestDataType.php +++ b/src/Types/CreateDataAttributeRequestOneDataType.php @@ -1,8 +1,8 @@ $options Array of objects representing the options of the list, with `value` as the key and the option as the value. At least two options are required. + */ + #[JsonProperty('options'), ArrayType([CreateDataAttributeRequestOptionsOptionsItem::class])] + private array $options; + + /** + * @param array{ + * options: array, + * dataType?: ?'options', + * } $values + */ + public function __construct( + array $values, + ) { + $this->dataType = $values['dataType'] ?? null; + $this->options = $values['options']; + } + + /** + * @return ?'options' + */ + public function getDataType(): ?string + { + return $this->dataType; + } + + /** + * @param ?'options' $value + */ + public function setDataType(?string $value = null): self + { + $this->dataType = $value; + return $this; + } + + /** + * @return array + */ + public function getOptions(): array + { + return $this->options; + } + + /** + * @param array $value + */ + public function setOptions(array $value): self + { + $this->options = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/CreateDataAttributeRequestOptionsOptionsItem.php b/src/Types/CreateDataAttributeRequestOptionsOptionsItem.php new file mode 100644 index 0000000..3d04ffb --- /dev/null +++ b/src/Types/CreateDataAttributeRequestOptionsOptionsItem.php @@ -0,0 +1,51 @@ +value = $values['value'] ?? null; + } + + /** + * @return ?string + */ + public function getValue(): ?string + { + return $this->value; + } + + /** + * @param ?string $value + */ + public function setValue(?string $value = null): self + { + $this->value = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/CreateInternalArticleRequest.php b/src/Types/CreateInternalArticleRequest.php new file mode 100644 index 0000000..7bf82db --- /dev/null +++ b/src/Types/CreateInternalArticleRequest.php @@ -0,0 +1,129 @@ +title = $values['title']; + $this->body = $values['body'] ?? null; + $this->authorId = $values['authorId']; + $this->ownerId = $values['ownerId']; + } + + /** + * @return string + */ + public function getTitle(): string + { + return $this->title; + } + + /** + * @param string $value + */ + public function setTitle(string $value): self + { + $this->title = $value; + return $this; + } + + /** + * @return ?string + */ + public function getBody(): ?string + { + return $this->body; + } + + /** + * @param ?string $value + */ + public function setBody(?string $value = null): self + { + $this->body = $value; + return $this; + } + + /** + * @return int + */ + public function getAuthorId(): int + { + return $this->authorId; + } + + /** + * @param int $value + */ + public function setAuthorId(int $value): self + { + $this->authorId = $value; + return $this; + } + + /** + * @return int + */ + public function getOwnerId(): int + { + return $this->ownerId; + } + + /** + * @param int $value + */ + public function setOwnerId(int $value): self + { + $this->ownerId = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Companies/Requests/CreateOrUpdateCompanyRequest.php b/src/Types/CreateOrUpdateCompanyRequest.php similarity index 96% rename from src/Companies/Requests/CreateOrUpdateCompanyRequest.php rename to src/Types/CreateOrUpdateCompanyRequest.php index ad18998..c7674a1 100644 --- a/src/Companies/Requests/CreateOrUpdateCompanyRequest.php +++ b/src/Types/CreateOrUpdateCompanyRequest.php @@ -1,11 +1,14 @@ monthlySpend = $value; return $this; } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } } diff --git a/src/PhoneCallRedirects/Requests/CreatePhoneCallRedirectRequest.php b/src/Types/CreatePhoneSwitchRequest.php similarity index 58% rename from src/PhoneCallRedirects/Requests/CreatePhoneCallRedirectRequest.php rename to src/Types/CreatePhoneSwitchRequest.php index 2225282..7c09f24 100644 --- a/src/PhoneCallRedirects/Requests/CreatePhoneCallRedirectRequest.php +++ b/src/Types/CreatePhoneSwitchRequest.php @@ -1,12 +1,17 @@ $customAttributes + * @var ?array $customAttributes */ - #[JsonProperty('custom_attributes'), ArrayType(['string' => 'mixed'])] + #[JsonProperty('custom_attributes'), ArrayType(['string' => new Union('string', 'integer', 'datetime', CustomObjectInstanceList::class)])] private ?array $customAttributes; /** * @param array{ * phone: string, - * customAttributes?: ?array, + * customAttributes?: ?array, * } $values */ public function __construct( @@ -51,7 +66,12 @@ public function setPhone(string $value): self } /** - * @return ?array + * @return ?array */ public function getCustomAttributes(): ?array { @@ -59,11 +79,24 @@ public function getCustomAttributes(): ?array } /** - * @param ?array $value + * @param ?array $value */ public function setCustomAttributes(?array $value = null): self { $this->customAttributes = $value; return $this; } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } } diff --git a/src/Types/CreateTicketRequestAssignment.php b/src/Types/CreateTicketRequestAssignment.php new file mode 100644 index 0000000..05ab972 --- /dev/null +++ b/src/Types/CreateTicketRequestAssignment.php @@ -0,0 +1,76 @@ +adminAssigneeId = $values['adminAssigneeId'] ?? null; + $this->teamAssigneeId = $values['teamAssigneeId'] ?? null; + } + + /** + * @return ?string + */ + public function getAdminAssigneeId(): ?string + { + return $this->adminAssigneeId; + } + + /** + * @param ?string $value + */ + public function setAdminAssigneeId(?string $value = null): self + { + $this->adminAssigneeId = $value; + return $this; + } + + /** + * @return ?string + */ + public function getTeamAssigneeId(): ?string + { + return $this->teamAssigneeId; + } + + /** + * @param ?string $value + */ + public function setTeamAssigneeId(?string $value = null): self + { + $this->teamAssigneeId = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/CreateTicketRequest.php b/src/Types/CreateTicketRequestBody.php similarity index 68% rename from src/Types/CreateTicketRequest.php rename to src/Types/CreateTicketRequestBody.php index a0bb8d5..5096f35 100644 --- a/src/Types/CreateTicketRequest.php +++ b/src/Types/CreateTicketRequestBody.php @@ -10,7 +10,7 @@ /** * You can create a Ticket */ -class CreateTicketRequest extends JsonSerializableType +class CreateTicketRequestBody extends JsonSerializableType { /** * @var string $ticketTypeId The ID of the type of ticket you want to create @@ -29,7 +29,19 @@ class CreateTicketRequest extends JsonSerializableType private array $contacts; /** - * @var ?string $companyId The ID of the company that the ticket is associated with. The ID that you set upon company creation. + * The ID of the conversation you want to link to the ticket. Here are the valid ways of linking two tickets: + * - conversation | back-office ticket + * - customer tickets | non-shared back-office ticket + * - conversation | tracker ticket + * - customer ticket | tracker ticket + * + * @var ?string $conversationToLinkId + */ + #[JsonProperty('conversation_to_link_id')] + private ?string $conversationToLinkId; + + /** + * @var ?string $companyId The ID of the company that the ticket is associated with. The unique identifier for the company which is given by Intercom */ #[JsonProperty('company_id')] private ?string $companyId; @@ -41,10 +53,10 @@ class CreateTicketRequest extends JsonSerializableType private ?int $createdAt; /** - * @var ?array $ticketAttributes + * @var ?CreateTicketRequestAssignment $assignment */ - #[JsonProperty('ticket_attributes'), ArrayType(['string' => 'mixed'])] - private ?array $ticketAttributes; + #[JsonProperty('assignment')] + private ?CreateTicketRequestAssignment $assignment; /** * @param array{ @@ -54,9 +66,10 @@ class CreateTicketRequest extends JsonSerializableType * |CreateTicketRequestContactsItemExternalId * |CreateTicketRequestContactsItemEmail * )>, + * conversationToLinkId?: ?string, * companyId?: ?string, * createdAt?: ?int, - * ticketAttributes?: ?array, + * assignment?: ?CreateTicketRequestAssignment, * } $values */ public function __construct( @@ -64,9 +77,10 @@ public function __construct( ) { $this->ticketTypeId = $values['ticketTypeId']; $this->contacts = $values['contacts']; + $this->conversationToLinkId = $values['conversationToLinkId'] ?? null; $this->companyId = $values['companyId'] ?? null; $this->createdAt = $values['createdAt'] ?? null; - $this->ticketAttributes = $values['ticketAttributes'] ?? null; + $this->assignment = $values['assignment'] ?? null; } /** @@ -111,6 +125,23 @@ public function setContacts(array $value): self return $this; } + /** + * @return ?string + */ + public function getConversationToLinkId(): ?string + { + return $this->conversationToLinkId; + } + + /** + * @param ?string $value + */ + public function setConversationToLinkId(?string $value = null): self + { + $this->conversationToLinkId = $value; + return $this; + } + /** * @return ?string */ @@ -146,19 +177,19 @@ public function setCreatedAt(?int $value = null): self } /** - * @return ?array + * @return ?CreateTicketRequestAssignment */ - public function getTicketAttributes(): ?array + public function getAssignment(): ?CreateTicketRequestAssignment { - return $this->ticketAttributes; + return $this->assignment; } /** - * @param ?array $value + * @param ?CreateTicketRequestAssignment $value */ - public function setTicketAttributes(?array $value = null): self + public function setAssignment(?CreateTicketRequestAssignment $value = null): self { - $this->ticketAttributes = $value; + $this->assignment = $value; return $this; } diff --git a/src/TicketTypes/Requests/CreateTicketTypeRequest.php b/src/Types/CreateTicketTypeRequest.php similarity index 90% rename from src/TicketTypes/Requests/CreateTicketTypeRequest.php rename to src/Types/CreateTicketTypeRequest.php index 0c97806..361103d 100644 --- a/src/TicketTypes/Requests/CreateTicketTypeRequest.php +++ b/src/Types/CreateTicketTypeRequest.php @@ -1,11 +1,14 @@ isInternal = $value; return $this; } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } } diff --git a/src/TicketTypes/Types/CreateTicketTypeRequestCategory.php b/src/Types/CreateTicketTypeRequestCategory.php similarity index 80% rename from src/TicketTypes/Types/CreateTicketTypeRequestCategory.php rename to src/Types/CreateTicketTypeRequestCategory.php index d5c8159..42f026c 100644 --- a/src/TicketTypes/Types/CreateTicketTypeRequestCategory.php +++ b/src/Types/CreateTicketTypeRequestCategory.php @@ -1,6 +1,6 @@ currentCanvas = $values['currentCanvas']; - } - - /** - * @return CanvasObject - */ - public function getCurrentCanvas(): CanvasObject - { - return $this->currentCanvas; - } - - /** - * @param CanvasObject $value - */ - public function setCurrentCanvas(CanvasObject $value): self - { - $this->currentCanvas = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/CursorPages.php b/src/Types/CursorPages.php index eafc215..d045236 100644 --- a/src/Types/CursorPages.php +++ b/src/Types/CursorPages.php @@ -12,10 +12,10 @@ class CursorPages extends JsonSerializableType { /** - * @var 'pages' $type the type of object `pages`. + * @var ?'pages' $type the type of object `pages`. */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** * @var ?int $page The current page @@ -43,7 +43,7 @@ class CursorPages extends JsonSerializableType /** * @param array{ - * type: 'pages', + * type?: ?'pages', * page?: ?int, * next?: ?StartingAfterPaging, * perPage?: ?int, @@ -51,9 +51,9 @@ class CursorPages extends JsonSerializableType * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; + $this->type = $values['type'] ?? null; $this->page = $values['page'] ?? null; $this->next = $values['next'] ?? null; $this->perPage = $values['perPage'] ?? null; @@ -61,17 +61,17 @@ public function __construct( } /** - * @return 'pages' + * @return ?'pages' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'pages' $value + * @param ?'pages' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; diff --git a/src/Types/CustomActionFinished.php b/src/Types/CustomActionFinished.php new file mode 100644 index 0000000..ae6bb94 --- /dev/null +++ b/src/Types/CustomActionFinished.php @@ -0,0 +1,54 @@ +custom_action_finished. + */ +class CustomActionFinished extends JsonSerializableType +{ + /** + * @var ?CustomActionFinishedAction $action + */ + #[JsonProperty('action')] + private ?CustomActionFinishedAction $action; + + /** + * @param array{ + * action?: ?CustomActionFinishedAction, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->action = $values['action'] ?? null; + } + + /** + * @return ?CustomActionFinishedAction + */ + public function getAction(): ?CustomActionFinishedAction + { + return $this->action; + } + + /** + * @param ?CustomActionFinishedAction $value + */ + public function setAction(?CustomActionFinishedAction $value = null): self + { + $this->action = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/CustomActionFinishedAction.php b/src/Types/CustomActionFinishedAction.php new file mode 100644 index 0000000..ed04712 --- /dev/null +++ b/src/Types/CustomActionFinishedAction.php @@ -0,0 +1,76 @@ + $result Status of the action + */ + #[JsonProperty('result')] + private ?string $result; + + /** + * @param array{ + * name?: ?string, + * result?: ?value-of, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->name = $values['name'] ?? null; + $this->result = $values['result'] ?? null; + } + + /** + * @return ?string + */ + public function getName(): ?string + { + return $this->name; + } + + /** + * @param ?string $value + */ + public function setName(?string $value = null): self + { + $this->name = $value; + return $this; + } + + /** + * @return ?value-of + */ + public function getResult(): ?string + { + return $this->result; + } + + /** + * @param ?value-of $value + */ + public function setResult(?string $value = null): self + { + $this->result = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/CustomActionFinishedActionResult.php b/src/Types/CustomActionFinishedActionResult.php new file mode 100644 index 0000000..ac6f488 --- /dev/null +++ b/src/Types/CustomActionFinishedActionResult.php @@ -0,0 +1,9 @@ +custom_action_started. + */ +class CustomActionStarted extends JsonSerializableType +{ + /** + * @var ?CustomActionStartedAction $action + */ + #[JsonProperty('action')] + private ?CustomActionStartedAction $action; + + /** + * @param array{ + * action?: ?CustomActionStartedAction, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->action = $values['action'] ?? null; + } + + /** + * @return ?CustomActionStartedAction + */ + public function getAction(): ?CustomActionStartedAction + { + return $this->action; + } + + /** + * @param ?CustomActionStartedAction $value + */ + public function setAction(?CustomActionStartedAction $value = null): self + { + $this->action = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/CustomActionStartedAction.php b/src/Types/CustomActionStartedAction.php new file mode 100644 index 0000000..024b4e0 --- /dev/null +++ b/src/Types/CustomActionStartedAction.php @@ -0,0 +1,51 @@ +name = $values['name'] ?? null; + } + + /** + * @return ?string + */ + public function getName(): ?string + { + return $this->name; + } + + /** + * @param ?string $value + */ + public function setName(?string $value = null): self + { + $this->name = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/DataAttributes/Types/UpdateDataAttributeRequestOptionsItem.php b/src/Types/CustomChannelAttribute.php similarity index 55% rename from src/DataAttributes/Types/UpdateDataAttributeRequestOptionsItem.php rename to src/Types/CustomChannelAttribute.php index f37b59e..3376c63 100644 --- a/src/DataAttributes/Types/UpdateDataAttributeRequestOptionsItem.php +++ b/src/Types/CustomChannelAttribute.php @@ -1,29 +1,54 @@ id = $values['id']; $this->value = $values['value']; } + /** + * @return string + */ + public function getId(): string + { + return $this->id; + } + + /** + * @param string $value + */ + public function setId(string $value): self + { + $this->id = $value; + return $this; + } + /** * @return string */ diff --git a/src/Types/CustomChannelBaseEvent.php b/src/Types/CustomChannelBaseEvent.php new file mode 100644 index 0000000..c1eed94 --- /dev/null +++ b/src/Types/CustomChannelBaseEvent.php @@ -0,0 +1,101 @@ +eventId = $values['eventId']; + $this->externalConversationId = $values['externalConversationId']; + $this->contact = $values['contact']; + } + + /** + * @return string + */ + public function getEventId(): string + { + return $this->eventId; + } + + /** + * @param string $value + */ + public function setEventId(string $value): self + { + $this->eventId = $value; + return $this; + } + + /** + * @return string + */ + public function getExternalConversationId(): string + { + return $this->externalConversationId; + } + + /** + * @param string $value + */ + public function setExternalConversationId(string $value): self + { + $this->externalConversationId = $value; + return $this; + } + + /** + * @return CustomChannelContact + */ + public function getContact(): CustomChannelContact + { + return $this->contact; + } + + /** + * @param CustomChannelContact $value + */ + public function setContact(CustomChannelContact $value): self + { + $this->contact = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/CustomChannelContact.php b/src/Types/CustomChannelContact.php new file mode 100644 index 0000000..35cc727 --- /dev/null +++ b/src/Types/CustomChannelContact.php @@ -0,0 +1,126 @@ + $type Type of contact, must be "user" or "lead". + */ + #[JsonProperty('type')] + private string $type; + + /** + * @var string $externalId External identifier for the contact. Intercom will take care of the mapping of your external_id with our internal ones so you don't have to worry about it. + */ + #[JsonProperty('external_id')] + private string $externalId; + + /** + * @var ?string $name Name of the contact. Required for user type. + */ + #[JsonProperty('name')] + private ?string $name; + + /** + * @var ?string $email Email address of the contact. Required for user type. + */ + #[JsonProperty('email')] + private ?string $email; + + /** + * @param array{ + * type: value-of, + * externalId: string, + * name?: ?string, + * email?: ?string, + * } $values + */ + public function __construct( + array $values, + ) { + $this->type = $values['type']; + $this->externalId = $values['externalId']; + $this->name = $values['name'] ?? null; + $this->email = $values['email'] ?? null; + } + + /** + * @return value-of + */ + public function getType(): string + { + return $this->type; + } + + /** + * @param value-of $value + */ + public function setType(string $value): self + { + $this->type = $value; + return $this; + } + + /** + * @return string + */ + public function getExternalId(): string + { + return $this->externalId; + } + + /** + * @param string $value + */ + public function setExternalId(string $value): self + { + $this->externalId = $value; + return $this; + } + + /** + * @return ?string + */ + public function getName(): ?string + { + return $this->name; + } + + /** + * @param ?string $value + */ + public function setName(?string $value = null): self + { + $this->name = $value; + return $this; + } + + /** + * @return ?string + */ + public function getEmail(): ?string + { + return $this->email; + } + + /** + * @param ?string $value + */ + public function setEmail(?string $value = null): self + { + $this->email = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/CustomChannelContactType.php b/src/Types/CustomChannelContactType.php new file mode 100644 index 0000000..08876cb --- /dev/null +++ b/src/Types/CustomChannelContactType.php @@ -0,0 +1,9 @@ +externalConversationId = $values['externalConversationId']; + $this->conversationId = $values['conversationId']; + $this->externalContactId = $values['externalContactId']; + $this->contactId = $values['contactId']; + } + + /** + * @return string + */ + public function getExternalConversationId(): string + { + return $this->externalConversationId; + } + + /** + * @param string $value + */ + public function setExternalConversationId(string $value): self + { + $this->externalConversationId = $value; + return $this; + } + + /** + * @return string + */ + public function getConversationId(): string + { + return $this->conversationId; + } + + /** + * @param string $value + */ + public function setConversationId(string $value): self + { + $this->conversationId = $value; + return $this; + } + + /** + * @return string + */ + public function getExternalContactId(): string + { + return $this->externalContactId; + } + + /** + * @param string $value + */ + public function setExternalContactId(string $value): self + { + $this->externalContactId = $value; + return $this; + } + + /** + * @return string + */ + public function getContactId(): string + { + return $this->contactId; + } + + /** + * @param string $value + */ + public function setContactId(string $value): self + { + $this->contactId = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/CustomObjectInstanceDeleted.php b/src/Types/CustomObjectInstanceDeleted.php new file mode 100644 index 0000000..1554f21 --- /dev/null +++ b/src/Types/CustomObjectInstanceDeleted.php @@ -0,0 +1,104 @@ +object = $values['object'] ?? null; + $this->id = $values['id'] ?? null; + $this->deleted = $values['deleted'] ?? null; + } + + /** + * @return ?string + */ + public function getObject(): ?string + { + return $this->object; + } + + /** + * @param ?string $value + */ + public function setObject(?string $value = null): self + { + $this->object = $value; + return $this; + } + + /** + * @return ?string + */ + public function getId(): ?string + { + return $this->id; + } + + /** + * @param ?string $value + */ + public function setId(?string $value = null): self + { + $this->id = $value; + return $this; + } + + /** + * @return ?bool + */ + public function getDeleted(): ?bool + { + return $this->deleted; + } + + /** + * @param ?bool $value + */ + public function setDeleted(?bool $value = null): self + { + $this->deleted = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/CustomObjectInstanceList.php b/src/Types/CustomObjectInstanceList.php new file mode 100644 index 0000000..c4d6958 --- /dev/null +++ b/src/Types/CustomObjectInstanceList.php @@ -0,0 +1,82 @@ + $instances The list of associated custom object instances for a given reference attribute on the parent object. + */ + #[JsonProperty('instances'), ArrayType([new Union(CustomObjectInstance::class, 'null')])] + private ?array $instances; + + /** + * @param array{ + * type?: ?string, + * instances?: ?array, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->type = $values['type'] ?? null; + $this->instances = $values['instances'] ?? null; + } + + /** + * @return ?string + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?string $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?array + */ + public function getInstances(): ?array + { + return $this->instances; + } + + /** + * @param ?array $value + */ + public function setInstances(?array $value = null): self + { + $this->instances = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/DataAttributeList.php b/src/Types/DataAttributeList.php index 47b9e8c..8169b21 100644 --- a/src/Types/DataAttributeList.php +++ b/src/Types/DataAttributeList.php @@ -13,59 +13,59 @@ class DataAttributeList extends JsonSerializableType { /** - * @var 'list' $type The type of the object + * @var ?'list' $type The type of the object */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var array $data A list of data attributes + * @var ?array $data A list of data attributes */ #[JsonProperty('data'), ArrayType([DataAttribute::class])] - private array $data; + private ?array $data; /** * @param array{ - * type: 'list', - * data: array, + * type?: ?'list', + * data?: ?array, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->data = $values['data']; + $this->type = $values['type'] ?? null; + $this->data = $values['data'] ?? null; } /** - * @return 'list' + * @return ?'list' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'list' $value + * @param ?'list' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return array + * @return ?array */ - public function getData(): array + public function getData(): ?array { return $this->data; } /** - * @param array $value + * @param ?array $value */ - public function setData(array $value): self + public function setData(?array $value = null): self { $this->data = $value; return $this; diff --git a/src/Types/DataEventList.php b/src/Types/DataEventList.php index 47cbb0a..6e1202e 100644 --- a/src/Types/DataEventList.php +++ b/src/Types/DataEventList.php @@ -13,16 +13,16 @@ class DataEventList extends JsonSerializableType { /** - * @var 'event.list' $type The type of the object + * @var ?'event.list' $type The type of the object */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var array $events A list of data events + * @var ?array $events A list of data events */ #[JsonProperty('events'), ArrayType([DataEvent::class])] - private array $events; + private ?array $events; /** * @var ?DataEventListPages $pages Pagination @@ -32,48 +32,48 @@ class DataEventList extends JsonSerializableType /** * @param array{ - * type: 'event.list', - * events: array, + * type?: ?'event.list', + * events?: ?array, * pages?: ?DataEventListPages, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->events = $values['events']; + $this->type = $values['type'] ?? null; + $this->events = $values['events'] ?? null; $this->pages = $values['pages'] ?? null; } /** - * @return 'event.list' + * @return ?'event.list' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'event.list' $value + * @param ?'event.list' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return array + * @return ?array */ - public function getEvents(): array + public function getEvents(): ?array { return $this->events; } /** - * @param array $value + * @param ?array $value */ - public function setEvents(array $value): self + public function setEvents(?array $value = null): self { $this->events = $value; return $this; diff --git a/src/Types/DataEventSummary.php b/src/Types/DataEventSummary.php index 46cf0a3..9923e70 100644 --- a/src/Types/DataEventSummary.php +++ b/src/Types/DataEventSummary.php @@ -5,6 +5,7 @@ use Intercom\Core\Json\JsonSerializableType; use Intercom\Core\Json\JsonProperty; use Intercom\Core\Types\ArrayType; +use Intercom\Core\Types\Union; /** * This will return a summary of data events for the App. @@ -36,14 +37,14 @@ class DataEventSummary extends JsonSerializableType private ?string $userId; /** - * @var array $events A summary of data events + * @var array $events A summary of data events */ - #[JsonProperty('events'), ArrayType([DataEventSummaryItem::class])] + #[JsonProperty('events'), ArrayType([new Union(DataEventSummaryItem::class, 'null')])] private array $events; /** * @param array{ - * events: array, + * events: array, * type?: ?'event.summary', * email?: ?string, * intercomUserId?: ?string, @@ -129,7 +130,7 @@ public function setUserId(?string $value = null): self } /** - * @return array + * @return array */ public function getEvents(): array { @@ -137,7 +138,7 @@ public function getEvents(): array } /** - * @param array $value + * @param array $value */ public function setEvents(array $value): self { diff --git a/src/Types/DataEventSummaryItem.php b/src/Types/DataEventSummaryItem.php index 472855c..6cc3ce2 100644 --- a/src/Types/DataEventSummaryItem.php +++ b/src/Types/DataEventSummaryItem.php @@ -11,28 +11,28 @@ class DataEventSummaryItem extends JsonSerializableType { /** - * @var string $name The name of the event + * @var ?string $name The name of the event */ #[JsonProperty('name')] - private string $name; + private ?string $name; /** - * @var string $first The first time the event was sent + * @var ?string $first The first time the event was sent */ #[JsonProperty('first')] - private string $first; + private ?string $first; /** - * @var string $last The last time the event was sent + * @var ?string $last The last time the event was sent */ #[JsonProperty('last')] - private string $last; + private ?string $last; /** - * @var int $count The number of times the event was sent + * @var ?int $count The number of times the event was sent */ #[JsonProperty('count')] - private int $count; + private ?int $count; /** * @var ?string $description The description of the event @@ -42,86 +42,86 @@ class DataEventSummaryItem extends JsonSerializableType /** * @param array{ - * name: string, - * first: string, - * last: string, - * count: int, + * name?: ?string, + * first?: ?string, + * last?: ?string, + * count?: ?int, * description?: ?string, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->name = $values['name']; - $this->first = $values['first']; - $this->last = $values['last']; - $this->count = $values['count']; + $this->name = $values['name'] ?? null; + $this->first = $values['first'] ?? null; + $this->last = $values['last'] ?? null; + $this->count = $values['count'] ?? null; $this->description = $values['description'] ?? null; } /** - * @return string + * @return ?string */ - public function getName(): string + public function getName(): ?string { return $this->name; } /** - * @param string $value + * @param ?string $value */ - public function setName(string $value): self + public function setName(?string $value = null): self { $this->name = $value; return $this; } /** - * @return string + * @return ?string */ - public function getFirst(): string + public function getFirst(): ?string { return $this->first; } /** - * @param string $value + * @param ?string $value */ - public function setFirst(string $value): self + public function setFirst(?string $value = null): self { $this->first = $value; return $this; } /** - * @return string + * @return ?string */ - public function getLast(): string + public function getLast(): ?string { return $this->last; } /** - * @param string $value + * @param ?string $value */ - public function setLast(string $value): self + public function setLast(?string $value = null): self { $this->last = $value; return $this; } /** - * @return int + * @return ?int */ - public function getCount(): int + public function getCount(): ?int { return $this->count; } /** - * @param int $value + * @param ?int $value */ - public function setCount(int $value): self + public function setCount(?int $value = null): self { $this->count = $value; return $this; diff --git a/src/Types/DataExportCsv.php b/src/Types/DataExportCsv.php index 8edf656..a424c1e 100644 --- a/src/Types/DataExportCsv.php +++ b/src/Types/DataExportCsv.php @@ -11,10 +11,10 @@ class DataExportCsv extends JsonSerializableType { /** - * @var string $userId The user_id of the user who was sent the message. + * @var ?string $userId The user_id of the user who was sent the message. */ #[JsonProperty('user_id')] - private string $userId; + private ?string $userId; /** * @var ?string $userExternalId The external_user_id of the user who was sent the message @@ -23,46 +23,46 @@ class DataExportCsv extends JsonSerializableType private ?string $userExternalId; /** - * @var string $companyId The company ID of the user in relation to the message that was sent. Will return -1 if no company is present. + * @var ?string $companyId The company ID of the user in relation to the message that was sent. Will return -1 if no company is present. */ #[JsonProperty('company_id')] - private string $companyId; + private ?string $companyId; /** - * @var string $email The users email who was sent the message. + * @var ?string $email The users email who was sent the message. */ #[JsonProperty('email')] - private string $email; + private ?string $email; /** - * @var string $name The full name of the user receiving the message + * @var ?string $name The full name of the user receiving the message */ #[JsonProperty('name')] - private string $name; + private ?string $name; /** - * @var string $rulesetId The id of the message. + * @var ?string $rulesetId The id of the message. */ #[JsonProperty('ruleset_id')] - private string $rulesetId; + private ?string $rulesetId; /** - * @var string $contentId The specific content that was received. In an A/B test each version has its own Content ID. + * @var ?string $contentId The specific content that was received. In an A/B test each version has its own Content ID. */ #[JsonProperty('content_id')] - private string $contentId; + private ?string $contentId; /** - * @var string $contentType Email, Chat, Post etc. + * @var ?string $contentType Email, Chat, Post etc. */ #[JsonProperty('content_type')] - private string $contentType; + private ?string $contentType; /** - * @var string $contentTitle The title of the content you see in your Intercom workspace. + * @var ?string $contentTitle The title of the content you see in your Intercom workspace. */ #[JsonProperty('content_title')] - private string $contentTitle; + private ?string $contentTitle; /** * @var ?string $rulesetVersionId As you edit content we record new versions. This ID can help you determine which version of a piece of content that was received. @@ -168,15 +168,15 @@ class DataExportCsv extends JsonSerializableType /** * @param array{ - * userId: string, - * companyId: string, - * email: string, - * name: string, - * rulesetId: string, - * contentId: string, - * contentType: string, - * contentTitle: string, + * userId?: ?string, * userExternalId?: ?string, + * companyId?: ?string, + * email?: ?string, + * name?: ?string, + * rulesetId?: ?string, + * contentId?: ?string, + * contentType?: ?string, + * contentTitle?: ?string, * rulesetVersionId?: ?string, * receiptId?: ?string, * receivedAt?: ?int, @@ -197,17 +197,17 @@ class DataExportCsv extends JsonSerializableType * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->userId = $values['userId']; + $this->userId = $values['userId'] ?? null; $this->userExternalId = $values['userExternalId'] ?? null; - $this->companyId = $values['companyId']; - $this->email = $values['email']; - $this->name = $values['name']; - $this->rulesetId = $values['rulesetId']; - $this->contentId = $values['contentId']; - $this->contentType = $values['contentType']; - $this->contentTitle = $values['contentTitle']; + $this->companyId = $values['companyId'] ?? null; + $this->email = $values['email'] ?? null; + $this->name = $values['name'] ?? null; + $this->rulesetId = $values['rulesetId'] ?? null; + $this->contentId = $values['contentId'] ?? null; + $this->contentType = $values['contentType'] ?? null; + $this->contentTitle = $values['contentTitle'] ?? null; $this->rulesetVersionId = $values['rulesetVersionId'] ?? null; $this->receiptId = $values['receiptId'] ?? null; $this->receivedAt = $values['receivedAt'] ?? null; @@ -228,17 +228,17 @@ public function __construct( } /** - * @return string + * @return ?string */ - public function getUserId(): string + public function getUserId(): ?string { return $this->userId; } /** - * @param string $value + * @param ?string $value */ - public function setUserId(string $value): self + public function setUserId(?string $value = null): self { $this->userId = $value; return $this; @@ -262,119 +262,119 @@ public function setUserExternalId(?string $value = null): self } /** - * @return string + * @return ?string */ - public function getCompanyId(): string + public function getCompanyId(): ?string { return $this->companyId; } /** - * @param string $value + * @param ?string $value */ - public function setCompanyId(string $value): self + public function setCompanyId(?string $value = null): self { $this->companyId = $value; return $this; } /** - * @return string + * @return ?string */ - public function getEmail(): string + public function getEmail(): ?string { return $this->email; } /** - * @param string $value + * @param ?string $value */ - public function setEmail(string $value): self + public function setEmail(?string $value = null): self { $this->email = $value; return $this; } /** - * @return string + * @return ?string */ - public function getName(): string + public function getName(): ?string { return $this->name; } /** - * @param string $value + * @param ?string $value */ - public function setName(string $value): self + public function setName(?string $value = null): self { $this->name = $value; return $this; } /** - * @return string + * @return ?string */ - public function getRulesetId(): string + public function getRulesetId(): ?string { return $this->rulesetId; } /** - * @param string $value + * @param ?string $value */ - public function setRulesetId(string $value): self + public function setRulesetId(?string $value = null): self { $this->rulesetId = $value; return $this; } /** - * @return string + * @return ?string */ - public function getContentId(): string + public function getContentId(): ?string { return $this->contentId; } /** - * @param string $value + * @param ?string $value */ - public function setContentId(string $value): self + public function setContentId(?string $value = null): self { $this->contentId = $value; return $this; } /** - * @return string + * @return ?string */ - public function getContentType(): string + public function getContentType(): ?string { return $this->contentType; } /** - * @param string $value + * @param ?string $value */ - public function setContentType(string $value): self + public function setContentType(?string $value = null): self { $this->contentType = $value; return $this; } /** - * @return string + * @return ?string */ - public function getContentTitle(): string + public function getContentTitle(): ?string { return $this->contentTitle; } /** - * @param string $value + * @param ?string $value */ - public function setContentTitle(string $value): self + public function setContentTitle(?string $value = null): self { $this->contentTitle = $value; return $this; diff --git a/src/Types/DataTableComponent.php b/src/Types/DataTableComponent.php deleted file mode 100644 index 6fc1244..0000000 --- a/src/Types/DataTableComponent.php +++ /dev/null @@ -1,55 +0,0 @@ - $items The items that will be rendered in the data-table. - */ - #[JsonProperty('items'), ArrayType([DataTableItem::class])] - private array $items; - - /** - * @param array{ - * items: array, - * } $values - */ - public function __construct( - array $values, - ) { - $this->items = $values['items']; - } - - /** - * @return array - */ - public function getItems(): array - { - return $this->items; - } - - /** - * @param array $value - */ - public function setItems(array $value): self - { - $this->items = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/DataTableItem.php b/src/Types/DataTableItem.php deleted file mode 100644 index 1b5221c..0000000 --- a/src/Types/DataTableItem.php +++ /dev/null @@ -1,104 +0,0 @@ -type = $values['type']; - $this->field = $values['field']; - $this->value = $values['value']; - } - - /** - * @return 'field-value' - */ - public function getType(): string - { - return $this->type; - } - - /** - * @param 'field-value' $value - */ - public function setType(string $value): self - { - $this->type = $value; - return $this; - } - - /** - * @return string - */ - public function getField(): string - { - return $this->field; - } - - /** - * @param string $value - */ - public function setField(string $value): self - { - $this->field = $value; - return $this; - } - - /** - * @return string - */ - public function getValue(): string - { - return $this->value; - } - - /** - * @param string $value - */ - public function setValue(string $value): self - { - $this->value = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/DeletedArticleObject.php b/src/Types/DeletedArticleObject.php index c0e896d..e0eaac4 100644 --- a/src/Types/DeletedArticleObject.php +++ b/src/Types/DeletedArticleObject.php @@ -11,84 +11,84 @@ class DeletedArticleObject extends JsonSerializableType { /** - * @var string $id The unique identifier for the article which you provided in the URL. + * @var ?string $id The unique identifier for the article which you provided in the URL. */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** - * @var 'article' $object The type of object which was deleted. - article + * @var ?'article' $object The type of object which was deleted. - article */ #[JsonProperty('object')] - private string $object; + private ?string $object; /** - * @var bool $deleted Whether the article was deleted successfully or not. + * @var ?bool $deleted Whether the article was deleted successfully or not. */ #[JsonProperty('deleted')] - private bool $deleted; + private ?bool $deleted; /** * @param array{ - * id: string, - * object: 'article', - * deleted: bool, + * id?: ?string, + * object?: ?'article', + * deleted?: ?bool, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->id = $values['id']; - $this->object = $values['object']; - $this->deleted = $values['deleted']; + $this->id = $values['id'] ?? null; + $this->object = $values['object'] ?? null; + $this->deleted = $values['deleted'] ?? null; } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; } /** - * @return 'article' + * @return ?'article' */ - public function getObject(): string + public function getObject(): ?string { return $this->object; } /** - * @param 'article' $value + * @param ?'article' $value */ - public function setObject(string $value): self + public function setObject(?string $value = null): self { $this->object = $value; return $this; } /** - * @return bool + * @return ?bool */ - public function getDeleted(): bool + public function getDeleted(): ?bool { return $this->deleted; } /** - * @param bool $value + * @param ?bool $value */ - public function setDeleted(bool $value): self + public function setDeleted(?bool $value = null): self { $this->deleted = $value; return $this; diff --git a/src/Types/DeletedCollectionObject.php b/src/Types/DeletedCollectionObject.php index 7dd2b84..2c538a7 100644 --- a/src/Types/DeletedCollectionObject.php +++ b/src/Types/DeletedCollectionObject.php @@ -11,84 +11,84 @@ class DeletedCollectionObject extends JsonSerializableType { /** - * @var string $id The unique identifier for the collection which you provided in the URL. + * @var ?string $id The unique identifier for the collection which you provided in the URL. */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** - * @var 'collection' $object The type of object which was deleted. - `collection` + * @var ?'collection' $object The type of object which was deleted. - `collection` */ #[JsonProperty('object')] - private string $object; + private ?string $object; /** - * @var bool $deleted Whether the collection was deleted successfully or not. + * @var ?bool $deleted Whether the collection was deleted successfully or not. */ #[JsonProperty('deleted')] - private bool $deleted; + private ?bool $deleted; /** * @param array{ - * id: string, - * object: 'collection', - * deleted: bool, + * id?: ?string, + * object?: ?'collection', + * deleted?: ?bool, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->id = $values['id']; - $this->object = $values['object']; - $this->deleted = $values['deleted']; + $this->id = $values['id'] ?? null; + $this->object = $values['object'] ?? null; + $this->deleted = $values['deleted'] ?? null; } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; } /** - * @return 'collection' + * @return ?'collection' */ - public function getObject(): string + public function getObject(): ?string { return $this->object; } /** - * @param 'collection' $value + * @param ?'collection' $value */ - public function setObject(string $value): self + public function setObject(?string $value = null): self { $this->object = $value; return $this; } /** - * @return bool + * @return ?bool */ - public function getDeleted(): bool + public function getDeleted(): ?bool { return $this->deleted; } /** - * @param bool $value + * @param ?bool $value */ - public function setDeleted(bool $value): self + public function setDeleted(?bool $value = null): self { $this->deleted = $value; return $this; diff --git a/src/Types/DeletedCompanyObject.php b/src/Types/DeletedCompanyObject.php index b22524d..adfc262 100644 --- a/src/Types/DeletedCompanyObject.php +++ b/src/Types/DeletedCompanyObject.php @@ -11,84 +11,84 @@ class DeletedCompanyObject extends JsonSerializableType { /** - * @var string $id The unique identifier for the company which is given by Intercom. + * @var ?string $id The unique identifier for the company which is given by Intercom. */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** - * @var 'company' $object The type of object which was deleted. - `company` + * @var ?'company' $object The type of object which was deleted. - `company` */ #[JsonProperty('object')] - private string $object; + private ?string $object; /** - * @var bool $deleted Whether the company was deleted successfully or not. + * @var ?bool $deleted Whether the company was deleted successfully or not. */ #[JsonProperty('deleted')] - private bool $deleted; + private ?bool $deleted; /** * @param array{ - * id: string, - * object: 'company', - * deleted: bool, + * id?: ?string, + * object?: ?'company', + * deleted?: ?bool, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->id = $values['id']; - $this->object = $values['object']; - $this->deleted = $values['deleted']; + $this->id = $values['id'] ?? null; + $this->object = $values['object'] ?? null; + $this->deleted = $values['deleted'] ?? null; } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; } /** - * @return 'company' + * @return ?'company' */ - public function getObject(): string + public function getObject(): ?string { return $this->object; } /** - * @param 'company' $value + * @param ?'company' $value */ - public function setObject(string $value): self + public function setObject(?string $value = null): self { $this->object = $value; return $this; } /** - * @return bool + * @return ?bool */ - public function getDeleted(): bool + public function getDeleted(): ?bool { return $this->deleted; } /** - * @param bool $value + * @param ?bool $value */ - public function setDeleted(bool $value): self + public function setDeleted(?bool $value = null): self { $this->deleted = $value; return $this; diff --git a/src/Types/DeletedInternalArticleObject.php b/src/Types/DeletedInternalArticleObject.php new file mode 100644 index 0000000..18e0cf2 --- /dev/null +++ b/src/Types/DeletedInternalArticleObject.php @@ -0,0 +1,104 @@ +id = $values['id'] ?? null; + $this->object = $values['object'] ?? null; + $this->deleted = $values['deleted'] ?? null; + } + + /** + * @return ?string + */ + public function getId(): ?string + { + return $this->id; + } + + /** + * @param ?string $value + */ + public function setId(?string $value = null): self + { + $this->id = $value; + return $this; + } + + /** + * @return ?'internal_article' + */ + public function getObject(): ?string + { + return $this->object; + } + + /** + * @param ?'internal_article' $value + */ + public function setObject(?string $value = null): self + { + $this->object = $value; + return $this; + } + + /** + * @return ?bool + */ + public function getDeleted(): ?bool + { + return $this->deleted; + } + + /** + * @param ?bool $value + */ + public function setDeleted(?bool $value = null): self + { + $this->deleted = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/DeletedObject.php b/src/Types/DeletedObject.php index 1faa504..7e69b70 100644 --- a/src/Types/DeletedObject.php +++ b/src/Types/DeletedObject.php @@ -11,84 +11,84 @@ class DeletedObject extends JsonSerializableType { /** - * @var string $id The unique identifier for the news item which you provided in the URL. + * @var ?string $id The unique identifier for the news item which you provided in the URL. */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** - * @var 'news-item' $object The type of object which was deleted - news-item. + * @var ?'news-item' $object The type of object which was deleted - news-item. */ #[JsonProperty('object')] - private string $object; + private ?string $object; /** - * @var bool $deleted Whether the news item was deleted successfully or not. + * @var ?bool $deleted Whether the news item was deleted successfully or not. */ #[JsonProperty('deleted')] - private bool $deleted; + private ?bool $deleted; /** * @param array{ - * id: string, - * object: 'news-item', - * deleted: bool, + * id?: ?string, + * object?: ?'news-item', + * deleted?: ?bool, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->id = $values['id']; - $this->object = $values['object']; - $this->deleted = $values['deleted']; + $this->id = $values['id'] ?? null; + $this->object = $values['object'] ?? null; + $this->deleted = $values['deleted'] ?? null; } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; } /** - * @return 'news-item' + * @return ?'news-item' */ - public function getObject(): string + public function getObject(): ?string { return $this->object; } /** - * @param 'news-item' $value + * @param ?'news-item' $value */ - public function setObject(string $value): self + public function setObject(?string $value = null): self { $this->object = $value; return $this; } /** - * @return bool + * @return ?bool */ - public function getDeleted(): bool + public function getDeleted(): ?bool { return $this->deleted; } /** - * @param bool $value + * @param ?bool $value */ - public function setDeleted(bool $value): self + public function setDeleted(?bool $value = null): self { $this->deleted = $value; return $this; diff --git a/src/Types/DropdownComponent.php b/src/Types/DropdownComponent.php deleted file mode 100644 index 061c327..0000000 --- a/src/Types/DropdownComponent.php +++ /dev/null @@ -1,182 +0,0 @@ - $options The list of options. Can provide 2 to 10. - */ - #[JsonProperty('options'), ArrayType([DropdownOption::class])] - private array $options; - - /** - * @var ?string $label The text shown above the dropdown. - */ - #[JsonProperty('label')] - private ?string $label; - - /** - * @var ?string $value The option that is selected by default. - */ - #[JsonProperty('value')] - private ?string $value; - - /** - * @var ?value-of $saveState Styles all options and prevents the action. Default is `unsaved`. Will be overridden if `save_state` is `saved`. - */ - #[JsonProperty('save_state')] - private ?string $saveState; - - /** - * @var ?bool $disabled Styles all options and prevents the action. Default is false. Will be overridden if save_state is saved. - */ - #[JsonProperty('disabled')] - private ?bool $disabled; - - /** - * @param array{ - * id: string, - * options: array, - * label?: ?string, - * value?: ?string, - * saveState?: ?value-of, - * disabled?: ?bool, - * } $values - */ - public function __construct( - array $values, - ) { - $this->id = $values['id']; - $this->options = $values['options']; - $this->label = $values['label'] ?? null; - $this->value = $values['value'] ?? null; - $this->saveState = $values['saveState'] ?? null; - $this->disabled = $values['disabled'] ?? null; - } - - /** - * @return string - */ - public function getId(): string - { - return $this->id; - } - - /** - * @param string $value - */ - public function setId(string $value): self - { - $this->id = $value; - return $this; - } - - /** - * @return array - */ - public function getOptions(): array - { - return $this->options; - } - - /** - * @param array $value - */ - public function setOptions(array $value): self - { - $this->options = $value; - return $this; - } - - /** - * @return ?string - */ - public function getLabel(): ?string - { - return $this->label; - } - - /** - * @param ?string $value - */ - public function setLabel(?string $value = null): self - { - $this->label = $value; - return $this; - } - - /** - * @return ?string - */ - public function getValue(): ?string - { - return $this->value; - } - - /** - * @param ?string $value - */ - public function setValue(?string $value = null): self - { - $this->value = $value; - return $this; - } - - /** - * @return ?value-of - */ - public function getSaveState(): ?string - { - return $this->saveState; - } - - /** - * @param ?value-of $value - */ - public function setSaveState(?string $value = null): self - { - $this->saveState = $value; - return $this; - } - - /** - * @return ?bool - */ - public function getDisabled(): ?bool - { - return $this->disabled; - } - - /** - * @param ?bool $value - */ - public function setDisabled(?bool $value = null): self - { - $this->disabled = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/DropdownComponentSaveState.php b/src/Types/DropdownComponentSaveState.php deleted file mode 100644 index 542de8d..0000000 --- a/src/Types/DropdownComponentSaveState.php +++ /dev/null @@ -1,10 +0,0 @@ -type = $values['type']; - $this->id = $values['id']; - $this->text = $values['text']; - $this->disabled = $values['disabled'] ?? null; - } - - /** - * @return 'option' - */ - public function getType(): string - { - return $this->type; - } - - /** - * @param 'option' $value - */ - public function setType(string $value): self - { - $this->type = $value; - return $this; - } - - /** - * @return string - */ - public function getId(): string - { - return $this->id; - } - - /** - * @param string $value - */ - public function setId(string $value): self - { - $this->id = $value; - return $this; - } - - /** - * @return string - */ - public function getText(): string - { - return $this->text; - } - - /** - * @param string $value - */ - public function setText(string $value): self - { - $this->text = $value; - return $this; - } - - /** - * @return ?bool - */ - public function getDisabled(): ?bool - { - return $this->disabled; - } - - /** - * @param ?bool $value - */ - public function setDisabled(?bool $value = null): self - { - $this->disabled = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/EmailAddressHeader.php b/src/Types/EmailAddressHeader.php new file mode 100644 index 0000000..935375b --- /dev/null +++ b/src/Types/EmailAddressHeader.php @@ -0,0 +1,104 @@ +type = $values['type'] ?? null; + $this->emailAddress = $values['emailAddress'] ?? null; + $this->name = $values['name'] ?? null; + } + + /** + * @return ?string + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?string $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?string + */ + public function getEmailAddress(): ?string + { + return $this->emailAddress; + } + + /** + * @param ?string $value + */ + public function setEmailAddress(?string $value = null): self + { + $this->emailAddress = $value; + return $this; + } + + /** + * @return ?string + */ + public function getName(): ?string + { + return $this->name; + } + + /** + * @param ?string $value + */ + public function setName(?string $value = null): self + { + $this->name = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/EmailMessageMetadata.php b/src/Types/EmailMessageMetadata.php new file mode 100644 index 0000000..3db79e5 --- /dev/null +++ b/src/Types/EmailMessageMetadata.php @@ -0,0 +1,80 @@ + $emailAddressHeaders A list of an email address headers. + */ + #[JsonProperty('email_address_headers'), ArrayType([EmailAddressHeader::class])] + private ?array $emailAddressHeaders; + + /** + * @param array{ + * subject?: ?string, + * emailAddressHeaders?: ?array, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->subject = $values['subject'] ?? null; + $this->emailAddressHeaders = $values['emailAddressHeaders'] ?? null; + } + + /** + * @return ?string + */ + public function getSubject(): ?string + { + return $this->subject; + } + + /** + * @param ?string $value + */ + public function setSubject(?string $value = null): self + { + $this->subject = $value; + return $this; + } + + /** + * @return ?array + */ + public function getEmailAddressHeaders(): ?array + { + return $this->emailAddressHeaders; + } + + /** + * @param ?array $value + */ + public function setEmailAddressHeaders(?array $value = null): self + { + $this->emailAddressHeaders = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/Event.php b/src/Types/Event.php deleted file mode 100644 index e9b90fa..0000000 --- a/src/Types/Event.php +++ /dev/null @@ -1,54 +0,0 @@ -type = $values['type']; - } - - /** - * @return 'completed' - */ - public function getType(): string - { - return $this->type; - } - - /** - * @param 'completed' $value - */ - public function setType(string $value): self - { - $this->type = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/FileAttribute.php b/src/Types/FileAttribute.php index 60ed961..7886256 100644 --- a/src/Types/FileAttribute.php +++ b/src/Types/FileAttribute.php @@ -11,184 +11,184 @@ class FileAttribute extends JsonSerializableType { /** - * @var string $type + * @var ?string $type */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var string $name The name of the file + * @var ?string $name The name of the file */ #[JsonProperty('name')] - private string $name; + private ?string $name; /** - * @var string $url The url of the file. This is a temporary URL and will expire after 30 minutes. + * @var ?string $url The url of the file. This is a temporary URL and will expire after 30 minutes. */ #[JsonProperty('url')] - private string $url; + private ?string $url; /** - * @var string $contentType The type of file + * @var ?string $contentType The type of file */ #[JsonProperty('content_type')] - private string $contentType; + private ?string $contentType; /** - * @var int $filesize The size of the file in bytes + * @var ?int $filesize The size of the file in bytes */ #[JsonProperty('filesize')] - private int $filesize; + private ?int $filesize; /** - * @var int $width The width of the file in pixels, if applicable + * @var ?int $width The width of the file in pixels, if applicable */ #[JsonProperty('width')] - private int $width; + private ?int $width; /** - * @var int $height The height of the file in pixels, if applicable + * @var ?int $height The height of the file in pixels, if applicable */ #[JsonProperty('height')] - private int $height; + private ?int $height; /** * @param array{ - * type: string, - * name: string, - * url: string, - * contentType: string, - * filesize: int, - * width: int, - * height: int, + * type?: ?string, + * name?: ?string, + * url?: ?string, + * contentType?: ?string, + * filesize?: ?int, + * width?: ?int, + * height?: ?int, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->name = $values['name']; - $this->url = $values['url']; - $this->contentType = $values['contentType']; - $this->filesize = $values['filesize']; - $this->width = $values['width']; - $this->height = $values['height']; + $this->type = $values['type'] ?? null; + $this->name = $values['name'] ?? null; + $this->url = $values['url'] ?? null; + $this->contentType = $values['contentType'] ?? null; + $this->filesize = $values['filesize'] ?? null; + $this->width = $values['width'] ?? null; + $this->height = $values['height'] ?? null; } /** - * @return string + * @return ?string */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param string $value + * @param ?string $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return string + * @return ?string */ - public function getName(): string + public function getName(): ?string { return $this->name; } /** - * @param string $value + * @param ?string $value */ - public function setName(string $value): self + public function setName(?string $value = null): self { $this->name = $value; return $this; } /** - * @return string + * @return ?string */ - public function getUrl(): string + public function getUrl(): ?string { return $this->url; } /** - * @param string $value + * @param ?string $value */ - public function setUrl(string $value): self + public function setUrl(?string $value = null): self { $this->url = $value; return $this; } /** - * @return string + * @return ?string */ - public function getContentType(): string + public function getContentType(): ?string { return $this->contentType; } /** - * @param string $value + * @param ?string $value */ - public function setContentType(string $value): self + public function setContentType(?string $value = null): self { $this->contentType = $value; return $this; } /** - * @return int + * @return ?int */ - public function getFilesize(): int + public function getFilesize(): ?int { return $this->filesize; } /** - * @param int $value + * @param ?int $value */ - public function setFilesize(int $value): self + public function setFilesize(?int $value = null): self { $this->filesize = $value; return $this; } /** - * @return int + * @return ?int */ - public function getWidth(): int + public function getWidth(): ?int { return $this->width; } /** - * @param int $value + * @param ?int $value */ - public function setWidth(int $value): self + public function setWidth(?int $value = null): self { $this->width = $value; return $this; } /** - * @return int + * @return ?int */ - public function getHeight(): int + public function getHeight(): ?int { return $this->height; } /** - * @param int $value + * @param ?int $value */ - public function setHeight(int $value): self + public function setHeight(?int $value = null): self { $this->height = $value; return $this; diff --git a/src/Types/GroupContent.php b/src/Types/GroupContent.php index 52f43d6..9e3bcc4 100644 --- a/src/Types/GroupContent.php +++ b/src/Types/GroupContent.php @@ -11,84 +11,84 @@ class GroupContent extends JsonSerializableType { /** - * @var 'group_content' $type The type of object - `group_content` . + * @var ?'group_content' $type The type of object - `group_content` . */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var string $name The name of the collection or section. + * @var ?string $name The name of the collection or section. */ #[JsonProperty('name')] - private string $name; + private ?string $name; /** - * @var string $description The description of the collection. Only available for collections. + * @var ?string $description The description of the collection. Only available for collections. */ #[JsonProperty('description')] - private string $description; + private ?string $description; /** * @param array{ - * type: 'group_content', - * name: string, - * description: string, + * type?: ?'group_content', + * name?: ?string, + * description?: ?string, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->name = $values['name']; - $this->description = $values['description']; + $this->type = $values['type'] ?? null; + $this->name = $values['name'] ?? null; + $this->description = $values['description'] ?? null; } /** - * @return 'group_content' + * @return ?'group_content' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'group_content' $value + * @param ?'group_content' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return string + * @return ?string */ - public function getName(): string + public function getName(): ?string { return $this->name; } /** - * @param string $value + * @param ?string $value */ - public function setName(string $value): self + public function setName(?string $value = null): self { $this->name = $value; return $this; } /** - * @return string + * @return ?string */ - public function getDescription(): string + public function getDescription(): ?string { return $this->description; } /** - * @param string $value + * @param ?string $value */ - public function setDescription(string $value): self + public function setDescription(?string $value = null): self { $this->description = $value; return $this; diff --git a/src/Types/GroupTranslatedContent.php b/src/Types/GroupTranslatedContent.php index 77b3be4..7e212a4 100644 --- a/src/Types/GroupTranslatedContent.php +++ b/src/Types/GroupTranslatedContent.php @@ -11,10 +11,10 @@ class GroupTranslatedContent extends JsonSerializableType { /** - * @var 'group_translated_content' $type The type of object - group_translated_content. + * @var ?'group_translated_content' $type The type of object - group_translated_content. */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** * @var ?GroupContent $ar The content of the group in Arabic @@ -240,7 +240,7 @@ class GroupTranslatedContent extends JsonSerializableType /** * @param array{ - * type: 'group_translated_content', + * type?: ?'group_translated_content', * ar?: ?GroupContent, * bg?: ?GroupContent, * bs?: ?GroupContent, @@ -281,9 +281,9 @@ class GroupTranslatedContent extends JsonSerializableType * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; + $this->type = $values['type'] ?? null; $this->ar = $values['ar'] ?? null; $this->bg = $values['bg'] ?? null; $this->bs = $values['bs'] ?? null; @@ -324,17 +324,17 @@ public function __construct( } /** - * @return 'group_translated_content' + * @return ?'group_translated_content' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'group_translated_content' $value + * @param ?'group_translated_content' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; diff --git a/src/Types/ImageComponent.php b/src/Types/ImageComponent.php deleted file mode 100644 index 49b6470..0000000 --- a/src/Types/ImageComponent.php +++ /dev/null @@ -1,232 +0,0 @@ - $align Aligns the image inside the component. Default is `left`. - */ - #[JsonProperty('align')] - private ?string $align; - - /** - * @var int $width The exact width of the image in pixels. - */ - #[JsonProperty('width')] - private int $width; - - /** - * @var int $height The exact height of the image in pixels. - */ - #[JsonProperty('height')] - private int $height; - - /** - * @var ?bool $rounded Rounds the corners of the image. Default is `false`. - */ - #[JsonProperty('rounded')] - private ?bool $rounded; - - /** - * @var ?'none' $bottomMargin Disables a component's margin-bottom of 10px. - */ - #[JsonProperty('bottom_margin')] - private ?string $bottomMargin; - - /** - * @var ?UrlActionComponent $action This can be a URL Action only. - */ - #[JsonProperty('action')] - private ?UrlActionComponent $action; - - /** - * @param array{ - * url: string, - * width: int, - * height: int, - * id?: ?string, - * align?: ?value-of, - * rounded?: ?bool, - * bottomMargin?: ?'none', - * action?: ?UrlActionComponent, - * } $values - */ - public function __construct( - array $values, - ) { - $this->id = $values['id'] ?? null; - $this->url = $values['url']; - $this->align = $values['align'] ?? null; - $this->width = $values['width']; - $this->height = $values['height']; - $this->rounded = $values['rounded'] ?? null; - $this->bottomMargin = $values['bottomMargin'] ?? null; - $this->action = $values['action'] ?? null; - } - - /** - * @return ?string - */ - public function getId(): ?string - { - return $this->id; - } - - /** - * @param ?string $value - */ - public function setId(?string $value = null): self - { - $this->id = $value; - return $this; - } - - /** - * @return string - */ - public function getUrl(): string - { - return $this->url; - } - - /** - * @param string $value - */ - public function setUrl(string $value): self - { - $this->url = $value; - return $this; - } - - /** - * @return ?value-of - */ - public function getAlign(): ?string - { - return $this->align; - } - - /** - * @param ?value-of $value - */ - public function setAlign(?string $value = null): self - { - $this->align = $value; - return $this; - } - - /** - * @return int - */ - public function getWidth(): int - { - return $this->width; - } - - /** - * @param int $value - */ - public function setWidth(int $value): self - { - $this->width = $value; - return $this; - } - - /** - * @return int - */ - public function getHeight(): int - { - return $this->height; - } - - /** - * @param int $value - */ - public function setHeight(int $value): self - { - $this->height = $value; - return $this; - } - - /** - * @return ?bool - */ - public function getRounded(): ?bool - { - return $this->rounded; - } - - /** - * @param ?bool $value - */ - public function setRounded(?bool $value = null): self - { - $this->rounded = $value; - return $this; - } - - /** - * @return ?'none' - */ - public function getBottomMargin(): ?string - { - return $this->bottomMargin; - } - - /** - * @param ?'none' $value - */ - public function setBottomMargin(?string $value = null): self - { - $this->bottomMargin = $value; - return $this; - } - - /** - * @return ?UrlActionComponent - */ - public function getAction(): ?UrlActionComponent - { - return $this->action; - } - - /** - * @param ?UrlActionComponent $value - */ - public function setAction(?UrlActionComponent $value = null): self - { - $this->action = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/ImageComponentAlign.php b/src/Types/ImageComponentAlign.php deleted file mode 100644 index 359ca12..0000000 --- a/src/Types/ImageComponentAlign.php +++ /dev/null @@ -1,11 +0,0 @@ - $cardCreationOptions Key-value pairs which were given as results in response to the Configure request. - */ - #[JsonProperty('card_creation_options'), ArrayType(['string' => 'mixed'])] - private array $cardCreationOptions; - - /** - * @var Context $context The context of where the app is added, where the user last visited, and information on the Messenger settings. - */ - #[JsonProperty('context')] - private Context $context; - - /** - * @var Conversation $conversation The conversation your app is being shown for. - */ - #[JsonProperty('conversation')] - private Conversation $conversation; - - /** - * @var Contact $contact The contact which is currently being viewed by the teammate in the conversation details panel. We send an individual initialize request for each customer when it's a group conversation. - */ - #[JsonProperty('contact')] - private Contact $contact; - - /** - * @param array{ - * workspaceId: string, - * workspaceRegion: string, - * admin: Admin, - * cardCreationOptions: array, - * context: Context, - * conversation: Conversation, - * contact: Contact, - * } $values - */ - public function __construct( - array $values, - ) { - $this->workspaceId = $values['workspaceId']; - $this->workspaceRegion = $values['workspaceRegion']; - $this->admin = $values['admin']; - $this->cardCreationOptions = $values['cardCreationOptions']; - $this->context = $values['context']; - $this->conversation = $values['conversation']; - $this->contact = $values['contact']; - } - - /** - * @return string - */ - public function getWorkspaceId(): string - { - return $this->workspaceId; - } - - /** - * @param string $value - */ - public function setWorkspaceId(string $value): self - { - $this->workspaceId = $value; - return $this; - } - - /** - * @return string - */ - public function getWorkspaceRegion(): string - { - return $this->workspaceRegion; - } - - /** - * @param string $value - */ - public function setWorkspaceRegion(string $value): self - { - $this->workspaceRegion = $value; - return $this; - } - - /** - * @return Admin - */ - public function getAdmin(): Admin - { - return $this->admin; - } - - /** - * @param Admin $value - */ - public function setAdmin(Admin $value): self - { - $this->admin = $value; - return $this; - } - - /** - * @return array - */ - public function getCardCreationOptions(): array - { - return $this->cardCreationOptions; - } - - /** - * @param array $value - */ - public function setCardCreationOptions(array $value): self - { - $this->cardCreationOptions = $value; - return $this; - } - - /** - * @return Context - */ - public function getContext(): Context - { - return $this->context; - } - - /** - * @param Context $value - */ - public function setContext(Context $value): self - { - $this->context = $value; - return $this; - } - - /** - * @return Conversation - */ - public function getConversation(): Conversation - { - return $this->conversation; - } - - /** - * @param Conversation $value - */ - public function setConversation(Conversation $value): self - { - $this->conversation = $value; - return $this; - } - - /** - * @return Contact - */ - public function getContact(): Contact - { - return $this->contact; - } - - /** - * @param Contact $value - */ - public function setContact(Contact $value): self - { - $this->contact = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/InitializeResponse.php b/src/Types/InitializeResponse.php deleted file mode 100644 index 51be89a..0000000 --- a/src/Types/InitializeResponse.php +++ /dev/null @@ -1,54 +0,0 @@ -canvas = $values['canvas']; - } - - /** - * @return CanvasObject - */ - public function getCanvas(): CanvasObject - { - return $this->canvas; - } - - /** - * @param CanvasObject $value - */ - public function setCanvas(CanvasObject $value): self - { - $this->canvas = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/InputComponent.php b/src/Types/InputComponent.php deleted file mode 100644 index 3559951..0000000 --- a/src/Types/InputComponent.php +++ /dev/null @@ -1,207 +0,0 @@ - $saveState Styles the input. Default is `unsaved`. Prevent action with `saved`. - */ - #[JsonProperty('save_state')] - private ?string $saveState; - - /** - * @var ?bool $disabled Styles the input and prevents the action. Default is false. Will be overridden if save_state is saved. - */ - #[JsonProperty('disabled')] - private ?bool $disabled; - - /** - * @param array{ - * id: string, - * label?: ?string, - * placeholder?: ?string, - * value?: ?string, - * action?: ?ActionComponent, - * saveState?: ?value-of, - * disabled?: ?bool, - * } $values - */ - public function __construct( - array $values, - ) { - $this->id = $values['id']; - $this->label = $values['label'] ?? null; - $this->placeholder = $values['placeholder'] ?? null; - $this->value = $values['value'] ?? null; - $this->action = $values['action'] ?? null; - $this->saveState = $values['saveState'] ?? null; - $this->disabled = $values['disabled'] ?? null; - } - - /** - * @return string - */ - public function getId(): string - { - return $this->id; - } - - /** - * @param string $value - */ - public function setId(string $value): self - { - $this->id = $value; - return $this; - } - - /** - * @return ?string - */ - public function getLabel(): ?string - { - return $this->label; - } - - /** - * @param ?string $value - */ - public function setLabel(?string $value = null): self - { - $this->label = $value; - return $this; - } - - /** - * @return ?string - */ - public function getPlaceholder(): ?string - { - return $this->placeholder; - } - - /** - * @param ?string $value - */ - public function setPlaceholder(?string $value = null): self - { - $this->placeholder = $value; - return $this; - } - - /** - * @return ?string - */ - public function getValue(): ?string - { - return $this->value; - } - - /** - * @param ?string $value - */ - public function setValue(?string $value = null): self - { - $this->value = $value; - return $this; - } - - /** - * @return ?ActionComponent - */ - public function getAction(): ?ActionComponent - { - return $this->action; - } - - /** - * @param ?ActionComponent $value - */ - public function setAction(?ActionComponent $value = null): self - { - $this->action = $value; - return $this; - } - - /** - * @return ?value-of - */ - public function getSaveState(): ?string - { - return $this->saveState; - } - - /** - * @param ?value-of $value - */ - public function setSaveState(?string $value = null): self - { - $this->saveState = $value; - return $this; - } - - /** - * @return ?bool - */ - public function getDisabled(): ?bool - { - return $this->disabled; - } - - /** - * @param ?bool $value - */ - public function setDisabled(?bool $value = null): self - { - $this->disabled = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/InputComponentSaveState.php b/src/Types/InputComponentSaveState.php deleted file mode 100644 index c1075be..0000000 --- a/src/Types/InputComponentSaveState.php +++ /dev/null @@ -1,10 +0,0 @@ - $data An array of Internal Article objects + */ + #[JsonProperty('data'), ArrayType([InternalArticleListItem::class])] + private ?array $data; + + /** + * @param array{ + * type?: ?'list', + * pages?: ?CursorPages, + * totalCount?: ?int, + * data?: ?array, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->type = $values['type'] ?? null; + $this->pages = $values['pages'] ?? null; + $this->totalCount = $values['totalCount'] ?? null; + $this->data = $values['data'] ?? null; + } + + /** + * @return ?'list' + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?'list' $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?CursorPages + */ + public function getPages(): ?CursorPages + { + return $this->pages; + } + + /** + * @param ?CursorPages $value + */ + public function setPages(?CursorPages $value = null): self + { + $this->pages = $value; + return $this; + } + + /** + * @return ?int + */ + public function getTotalCount(): ?int + { + return $this->totalCount; + } + + /** + * @param ?int $value + */ + public function setTotalCount(?int $value = null): self + { + $this->totalCount = $value; + return $this; + } + + /** + * @return ?array + */ + public function getData(): ?array + { + return $this->data; + } + + /** + * @param ?array $value + */ + public function setData(?array $value = null): self + { + $this->data = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/LinkedObject.php b/src/Types/LinkedObject.php index 2d491f0..07b06f7 100644 --- a/src/Types/LinkedObject.php +++ b/src/Types/LinkedObject.php @@ -11,74 +11,74 @@ class LinkedObject extends JsonSerializableType { /** - * @var value-of $type ticket or conversation + * @var ?value-of $type ticket or conversation */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var string $id The ID of the linked object + * @var ?string $id The ID of the linked object */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** - * @var ?string $category Category of the Linked Ticket Object. + * @var ?value-of $category Category of the Linked Ticket Object. */ #[JsonProperty('category')] private ?string $category; /** * @param array{ - * type: value-of, - * id: string, - * category?: ?string, + * type?: ?value-of, + * id?: ?string, + * category?: ?value-of, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->id = $values['id']; + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; $this->category = $values['category'] ?? null; } /** - * @return value-of + * @return ?value-of */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param value-of $value + * @param ?value-of $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; } /** - * @return ?string + * @return ?value-of */ public function getCategory(): ?string { @@ -86,7 +86,7 @@ public function getCategory(): ?string } /** - * @param ?string $value + * @param ?value-of $value */ public function setCategory(?string $value = null): self { diff --git a/src/TicketTypes/Types/UpdateTicketTypeRequestBodyCategory.php b/src/Types/LinkedObjectCategory.php similarity index 56% rename from src/TicketTypes/Types/UpdateTicketTypeRequestBodyCategory.php rename to src/Types/LinkedObjectCategory.php index 26981fb..665399d 100644 --- a/src/TicketTypes/Types/UpdateTicketTypeRequestBodyCategory.php +++ b/src/Types/LinkedObjectCategory.php @@ -1,8 +1,8 @@ $data An array containing the linked conversations and linked tickets. + * @var ?array $data An array containing the linked conversations and linked tickets. */ #[JsonProperty('data'), ArrayType([LinkedObject::class])] - private array $data; + private ?array $data; /** * @param array{ - * type: 'list', - * totalCount: int, - * hasMore: bool, - * data: array, + * type?: ?'list', + * totalCount?: ?int, + * hasMore?: ?bool, + * data?: ?array, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->totalCount = $values['totalCount']; - $this->hasMore = $values['hasMore']; - $this->data = $values['data']; + $this->type = $values['type'] ?? null; + $this->totalCount = $values['totalCount'] ?? null; + $this->hasMore = $values['hasMore'] ?? null; + $this->data = $values['data'] ?? null; } /** - * @return 'list' + * @return ?'list' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'list' $value + * @param ?'list' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return int + * @return ?int */ - public function getTotalCount(): int + public function getTotalCount(): ?int { return $this->totalCount; } /** - * @param int $value + * @param ?int $value */ - public function setTotalCount(int $value): self + public function setTotalCount(?int $value = null): self { $this->totalCount = $value; return $this; } /** - * @return bool + * @return ?bool */ - public function getHasMore(): bool + public function getHasMore(): ?bool { return $this->hasMore; } /** - * @param bool $value + * @param ?bool $value */ - public function setHasMore(bool $value): self + public function setHasMore(?bool $value = null): self { $this->hasMore = $value; return $this; } /** - * @return array + * @return ?array */ - public function getData(): array + public function getData(): ?array { return $this->data; } /** - * @param array $value + * @param ?array $value */ - public function setData(array $value): self + public function setData(?array $value = null): self { $this->data = $value; return $this; diff --git a/src/Types/ListComponent.php b/src/Types/ListComponent.php deleted file mode 100644 index 66bb35d..0000000 --- a/src/Types/ListComponent.php +++ /dev/null @@ -1,97 +0,0 @@ - $items The items that will be rendered in the list. - */ - #[JsonProperty('items'), ArrayType([new Union(ListItemWithImage::class, ListItemWithoutImage::class)])] - private array $items; - - /** - * @var ?bool $disabled Styles all list items and prevents the action. Default is `false`. - */ - #[JsonProperty('disabled')] - private ?bool $disabled; - - /** - * @param array{ - * items: array<( - * ListItemWithImage - * |ListItemWithoutImage - * )>, - * disabled?: ?bool, - * } $values - */ - public function __construct( - array $values, - ) { - $this->items = $values['items']; - $this->disabled = $values['disabled'] ?? null; - } - - /** - * @return array<( - * ListItemWithImage - * |ListItemWithoutImage - * )> - */ - public function getItems(): array - { - return $this->items; - } - - /** - * @param array<( - * ListItemWithImage - * |ListItemWithoutImage - * )> $value - */ - public function setItems(array $value): self - { - $this->items = $value; - return $this; - } - - /** - * @return ?bool - */ - public function getDisabled(): ?bool - { - return $this->disabled; - } - - /** - * @param ?bool $value - */ - public function setDisabled(?bool $value = null): self - { - $this->disabled = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/ListItem.php b/src/Types/ListItem.php deleted file mode 100644 index e3e9d8f..0000000 --- a/src/Types/ListItem.php +++ /dev/null @@ -1,229 +0,0 @@ -type = $values['type']; - $this->id = $values['id']; - $this->title = $values['title']; - $this->subtitle = $values['subtitle'] ?? null; - $this->tertiaryText = $values['tertiaryText'] ?? null; - $this->roundedImage = $values['roundedImage'] ?? null; - $this->disabled = $values['disabled'] ?? null; - $this->action = $values['action'] ?? null; - } - - /** - * @return 'item' - */ - public function getType(): string - { - return $this->type; - } - - /** - * @param 'item' $value - */ - public function setType(string $value): self - { - $this->type = $value; - return $this; - } - - /** - * @return string - */ - public function getId(): string - { - return $this->id; - } - - /** - * @param string $value - */ - public function setId(string $value): self - { - $this->id = $value; - return $this; - } - - /** - * @return string - */ - public function getTitle(): string - { - return $this->title; - } - - /** - * @param string $value - */ - public function setTitle(string $value): self - { - $this->title = $value; - return $this; - } - - /** - * @return ?string - */ - public function getSubtitle(): ?string - { - return $this->subtitle; - } - - /** - * @param ?string $value - */ - public function setSubtitle(?string $value = null): self - { - $this->subtitle = $value; - return $this; - } - - /** - * @return ?string - */ - public function getTertiaryText(): ?string - { - return $this->tertiaryText; - } - - /** - * @param ?string $value - */ - public function setTertiaryText(?string $value = null): self - { - $this->tertiaryText = $value; - return $this; - } - - /** - * @return ?bool - */ - public function getRoundedImage(): ?bool - { - return $this->roundedImage; - } - - /** - * @param ?bool $value - */ - public function setRoundedImage(?bool $value = null): self - { - $this->roundedImage = $value; - return $this; - } - - /** - * @return ?bool - */ - public function getDisabled(): ?bool - { - return $this->disabled; - } - - /** - * @param ?bool $value - */ - public function setDisabled(?bool $value = null): self - { - $this->disabled = $value; - return $this; - } - - /** - * @return ?ActionComponent - */ - public function getAction(): ?ActionComponent - { - return $this->action; - } - - /** - * @param ?ActionComponent $value - */ - public function setAction(?ActionComponent $value = null): self - { - $this->action = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/ListItemWithImage.php b/src/Types/ListItemWithImage.php deleted file mode 100644 index 09e4a26..0000000 --- a/src/Types/ListItemWithImage.php +++ /dev/null @@ -1,120 +0,0 @@ -type = $values['type']; - $this->id = $values['id']; - $this->title = $values['title']; - $this->subtitle = $values['subtitle'] ?? null; - $this->tertiaryText = $values['tertiaryText'] ?? null; - $this->roundedImage = $values['roundedImage'] ?? null; - $this->disabled = $values['disabled'] ?? null; - $this->action = $values['action'] ?? null; - $this->image = $values['image']; - $this->imageWidth = $values['imageWidth']; - $this->imageHeight = $values['imageHeight']; - } - - /** - * @return string - */ - public function getImage(): string - { - return $this->image; - } - - /** - * @param string $value - */ - public function setImage(string $value): self - { - $this->image = $value; - return $this; - } - - /** - * @return int - */ - public function getImageWidth(): int - { - return $this->imageWidth; - } - - /** - * @param int $value - */ - public function setImageWidth(int $value): self - { - $this->imageWidth = $value; - return $this; - } - - /** - * @return int - */ - public function getImageHeight(): int - { - return $this->imageHeight; - } - - /** - * @param int $value - */ - public function setImageHeight(int $value): self - { - $this->imageHeight = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/ListItemWithoutImage.php b/src/Types/ListItemWithoutImage.php deleted file mode 100644 index 5d65475..0000000 --- a/src/Types/ListItemWithoutImage.php +++ /dev/null @@ -1,120 +0,0 @@ -type = $values['type']; - $this->id = $values['id']; - $this->title = $values['title']; - $this->subtitle = $values['subtitle'] ?? null; - $this->tertiaryText = $values['tertiaryText'] ?? null; - $this->roundedImage = $values['roundedImage'] ?? null; - $this->disabled = $values['disabled'] ?? null; - $this->action = $values['action'] ?? null; - $this->image = $values['image'] ?? null; - $this->imageWidth = $values['imageWidth'] ?? null; - $this->imageHeight = $values['imageHeight'] ?? null; - } - - /** - * @return ?string - */ - public function getImage(): ?string - { - return $this->image; - } - - /** - * @param ?string $value - */ - public function setImage(?string $value = null): self - { - $this->image = $value; - return $this; - } - - /** - * @return ?int - */ - public function getImageWidth(): ?int - { - return $this->imageWidth; - } - - /** - * @param ?int $value - */ - public function setImageWidth(?int $value = null): self - { - $this->imageWidth = $value; - return $this; - } - - /** - * @return ?int - */ - public function getImageHeight(): ?int - { - return $this->imageHeight; - } - - /** - * @param ?int $value - */ - public function setImageHeight(?int $value = null): self - { - $this->imageHeight = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/LiveCanvasRequest.php b/src/Types/LiveCanvasRequest.php deleted file mode 100644 index 62b66ca..0000000 --- a/src/Types/LiveCanvasRequest.php +++ /dev/null @@ -1,157 +0,0 @@ -workspaceId = $values['workspaceId']; - $this->workspaceRegion = $values['workspaceRegion']; - $this->canvas = $values['canvas']; - $this->context = $values['context']; - $this->contact = $values['contact']; - } - - /** - * @return string - */ - public function getWorkspaceId(): string - { - return $this->workspaceId; - } - - /** - * @param string $value - */ - public function setWorkspaceId(string $value): self - { - $this->workspaceId = $value; - return $this; - } - - /** - * @return string - */ - public function getWorkspaceRegion(): string - { - return $this->workspaceRegion; - } - - /** - * @param string $value - */ - public function setWorkspaceRegion(string $value): self - { - $this->workspaceRegion = $value; - return $this; - } - - /** - * @return CanvasObject - */ - public function getCanvas(): CanvasObject - { - return $this->canvas; - } - - /** - * @param CanvasObject $value - */ - public function setCanvas(CanvasObject $value): self - { - $this->canvas = $value; - return $this; - } - - /** - * @return Context - */ - public function getContext(): Context - { - return $this->context; - } - - /** - * @param Context $value - */ - public function setContext(Context $value): self - { - $this->context = $value; - return $this; - } - - /** - * @return Contact - */ - public function getContact(): Contact - { - return $this->contact; - } - - /** - * @param Contact $value - */ - public function setContact(Contact $value): self - { - $this->contact = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/LiveCanvasResponse.php b/src/Types/LiveCanvasResponse.php deleted file mode 100644 index 8f4ed3c..0000000 --- a/src/Types/LiveCanvasResponse.php +++ /dev/null @@ -1,54 +0,0 @@ -content = $values['content']; - } - - /** - * @return ContentObject - */ - public function getContent(): ContentObject - { - return $this->content; - } - - /** - * @param ContentObject $value - */ - public function setContent(ContentObject $value): self - { - $this->content = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/MultipleFilterSearchRequest.php b/src/Types/MultipleFilterSearchRequest.php index 371a458..c215c38 100644 --- a/src/Types/MultipleFilterSearchRequest.php +++ b/src/Types/MultipleFilterSearchRequest.php @@ -4,7 +4,6 @@ use Intercom\Core\Json\JsonSerializableType; use Intercom\Core\Json\JsonProperty; -use Intercom\Core\Types\ArrayType; use Intercom\Core\Types\Union; /** @@ -19,21 +18,21 @@ class MultipleFilterSearchRequest extends JsonSerializableType private ?string $operator; /** - * @var ?array<( - * MultipleFilterSearchRequest - * |SingleFilterSearchRequest - * )> $value + * @var ( + * array + * |array + * )|null $value */ - #[JsonProperty('value'), ArrayType([new Union(MultipleFilterSearchRequest::class, SingleFilterSearchRequest::class)])] - private ?array $value; + #[JsonProperty('value'), Union([MultipleFilterSearchRequest::class], [SingleFilterSearchRequest::class], 'null')] + private array|null $value; /** * @param array{ * operator?: ?value-of, - * value?: ?array<( - * MultipleFilterSearchRequest - * |SingleFilterSearchRequest - * )>, + * value?: ( + * array + * |array + * )|null, * } $values */ public function __construct( @@ -61,23 +60,23 @@ public function setOperator(?string $value = null): self } /** - * @return ?array<( - * MultipleFilterSearchRequest - * |SingleFilterSearchRequest - * )> + * @return ( + * array + * |array + * )|null */ - public function getValue(): ?array + public function getValue(): array|null { return $this->value; } /** - * @param ?array<( - * MultipleFilterSearchRequest - * |SingleFilterSearchRequest - * )> $value + * @param ( + * array + * |array + * )|null $value */ - public function setValue(?array $value = null): self + public function setValue(array|null $value = null): self { $this->value = $value; return $this; diff --git a/src/Types/NotFoundErrorBody.php b/src/Types/NotFoundErrorBody.php new file mode 100644 index 0000000..ebf251b --- /dev/null +++ b/src/Types/NotFoundErrorBody.php @@ -0,0 +1,102 @@ + $errors An array of one or more error objects + */ + #[JsonProperty('errors'), ArrayType([NotFoundErrorBodyErrorsItem::class])] + private array $errors; + + /** + * @param array{ + * type: string, + * errors: array, + * requestId?: ?string, + * } $values + */ + public function __construct( + array $values, + ) { + $this->type = $values['type']; + $this->requestId = $values['requestId'] ?? null; + $this->errors = $values['errors']; + } + + /** + * @return string + */ + public function getType(): string + { + return $this->type; + } + + /** + * @param string $value + */ + public function setType(string $value): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?string + */ + public function getRequestId(): ?string + { + return $this->requestId; + } + + /** + * @param ?string $value + */ + public function setRequestId(?string $value = null): self + { + $this->requestId = $value; + return $this; + } + + /** + * @return array + */ + public function getErrors(): array + { + return $this->errors; + } + + /** + * @param array $value + */ + public function setErrors(array $value): self + { + $this->errors = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/NotFoundErrorBodyErrorsItem.php b/src/Types/NotFoundErrorBodyErrorsItem.php new file mode 100644 index 0000000..d5b0c5e --- /dev/null +++ b/src/Types/NotFoundErrorBodyErrorsItem.php @@ -0,0 +1,76 @@ +code = $values['code']; + $this->message = $values['message'] ?? null; + } + + /** + * @return string + */ + public function getCode(): string + { + return $this->code; + } + + /** + * @param string $value + */ + public function setCode(string $value): self + { + $this->code = $value; + return $this; + } + + /** + * @return ?string + */ + public function getMessage(): ?string + { + return $this->message; + } + + /** + * @param ?string $value + */ + public function setMessage(?string $value = null): self + { + $this->message = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/NoteList.php b/src/Types/NoteList.php index cd3456c..4f76b39 100644 --- a/src/Types/NoteList.php +++ b/src/Types/NoteList.php @@ -13,84 +13,84 @@ class NoteList extends JsonSerializableType { /** - * @var 'list' $type String representing the object's type. Always has the value `list`. + * @var ?string $type String representing the object's type. Always has the value `list`. */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var array $data An array of notes. + * @var ?array $data An array of notes. */ #[JsonProperty('data'), ArrayType([Note::class])] - private array $data; + private ?array $data; /** - * @var int $totalCount A count of the total number of notes. + * @var ?int $totalCount A count of the total number of notes. */ #[JsonProperty('total_count')] - private int $totalCount; + private ?int $totalCount; /** * @param array{ - * type: 'list', - * data: array, - * totalCount: int, + * type?: ?string, + * data?: ?array, + * totalCount?: ?int, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->data = $values['data']; - $this->totalCount = $values['totalCount']; + $this->type = $values['type'] ?? null; + $this->data = $values['data'] ?? null; + $this->totalCount = $values['totalCount'] ?? null; } /** - * @return 'list' + * @return ?string */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'list' $value + * @param ?string $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return array + * @return ?array */ - public function getData(): array + public function getData(): ?array { return $this->data; } /** - * @param array $value + * @param ?array $value */ - public function setData(array $value): self + public function setData(?array $value = null): self { $this->data = $value; return $this; } /** - * @return int + * @return ?int */ - public function getTotalCount(): int + public function getTotalCount(): ?int { return $this->totalCount; } /** - * @param int $value + * @param ?int $value */ - public function setTotalCount(int $value): self + public function setTotalCount(?int $value = null): self { $this->totalCount = $value; return $this; diff --git a/src/Types/OperatorWorkflowEvent.php b/src/Types/OperatorWorkflowEvent.php new file mode 100644 index 0000000..8590d2c --- /dev/null +++ b/src/Types/OperatorWorkflowEvent.php @@ -0,0 +1,79 @@ +operator_workflow_event. + */ +class OperatorWorkflowEvent extends JsonSerializableType +{ + /** + * @var ?OperatorWorkflowEventWorkflow $workflow + */ + #[JsonProperty('workflow')] + private ?OperatorWorkflowEventWorkflow $workflow; + + /** + * @var ?OperatorWorkflowEventEvent $event + */ + #[JsonProperty('event')] + private ?OperatorWorkflowEventEvent $event; + + /** + * @param array{ + * workflow?: ?OperatorWorkflowEventWorkflow, + * event?: ?OperatorWorkflowEventEvent, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->workflow = $values['workflow'] ?? null; + $this->event = $values['event'] ?? null; + } + + /** + * @return ?OperatorWorkflowEventWorkflow + */ + public function getWorkflow(): ?OperatorWorkflowEventWorkflow + { + return $this->workflow; + } + + /** + * @param ?OperatorWorkflowEventWorkflow $value + */ + public function setWorkflow(?OperatorWorkflowEventWorkflow $value = null): self + { + $this->workflow = $value; + return $this; + } + + /** + * @return ?OperatorWorkflowEventEvent + */ + public function getEvent(): ?OperatorWorkflowEventEvent + { + return $this->event; + } + + /** + * @param ?OperatorWorkflowEventEvent $value + */ + public function setEvent(?OperatorWorkflowEventEvent $value = null): self + { + $this->event = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/OperatorWorkflowEventEvent.php b/src/Types/OperatorWorkflowEventEvent.php new file mode 100644 index 0000000..4ebdfa2 --- /dev/null +++ b/src/Types/OperatorWorkflowEventEvent.php @@ -0,0 +1,76 @@ +type = $values['type'] ?? null; + $this->result = $values['result'] ?? null; + } + + /** + * @return ?string + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?string $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?string + */ + public function getResult(): ?string + { + return $this->result; + } + + /** + * @param ?string $value + */ + public function setResult(?string $value = null): self + { + $this->result = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/OperatorWorkflowEventWorkflow.php b/src/Types/OperatorWorkflowEventWorkflow.php new file mode 100644 index 0000000..080b2a2 --- /dev/null +++ b/src/Types/OperatorWorkflowEventWorkflow.php @@ -0,0 +1,51 @@ +name = $values['name'] ?? null; + } + + /** + * @return ?string + */ + public function getName(): ?string + { + return $this->name; + } + + /** + * @param ?string $value + */ + public function setName(?string $value = null): self + { + $this->name = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/PagesLink.php b/src/Types/PagesLink.php index 8a5519c..e14e065 100644 --- a/src/Types/PagesLink.php +++ b/src/Types/PagesLink.php @@ -13,16 +13,16 @@ class PagesLink extends JsonSerializableType { /** - * @var 'pages' $type + * @var ?'pages' $type */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var int $page + * @var ?int $page */ #[JsonProperty('page')] - private int $page; + private ?int $page; /** * @var ?string $next A link to the next page of results. A response that does not contain a next link does not have further data to fetch. @@ -31,65 +31,65 @@ class PagesLink extends JsonSerializableType private ?string $next; /** - * @var int $perPage + * @var ?int $perPage */ #[JsonProperty('per_page')] - private int $perPage; + private ?int $perPage; /** - * @var int $totalPages + * @var ?int $totalPages */ #[JsonProperty('total_pages')] - private int $totalPages; + private ?int $totalPages; /** * @param array{ - * type: 'pages', - * page: int, - * perPage: int, - * totalPages: int, + * type?: ?'pages', + * page?: ?int, * next?: ?string, + * perPage?: ?int, + * totalPages?: ?int, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->page = $values['page']; + $this->type = $values['type'] ?? null; + $this->page = $values['page'] ?? null; $this->next = $values['next'] ?? null; - $this->perPage = $values['perPage']; - $this->totalPages = $values['totalPages']; + $this->perPage = $values['perPage'] ?? null; + $this->totalPages = $values['totalPages'] ?? null; } /** - * @return 'pages' + * @return ?'pages' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'pages' $value + * @param ?'pages' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return int + * @return ?int */ - public function getPage(): int + public function getPage(): ?int { return $this->page; } /** - * @param int $value + * @param ?int $value */ - public function setPage(int $value): self + public function setPage(?int $value = null): self { $this->page = $value; return $this; @@ -113,34 +113,34 @@ public function setNext(?string $value = null): self } /** - * @return int + * @return ?int */ - public function getPerPage(): int + public function getPerPage(): ?int { return $this->perPage; } /** - * @param int $value + * @param ?int $value */ - public function setPerPage(int $value): self + public function setPerPage(?int $value = null): self { $this->perPage = $value; return $this; } /** - * @return int + * @return ?int */ - public function getTotalPages(): int + public function getTotalPages(): ?int { return $this->totalPages; } /** - * @param int $value + * @param ?int $value */ - public function setTotalPages(int $value): self + public function setTotalPages(?int $value = null): self { $this->totalPages = $value; return $this; diff --git a/src/Types/PaginatedResponse.php b/src/Types/PaginatedResponse.php new file mode 100644 index 0000000..35fe68a --- /dev/null +++ b/src/Types/PaginatedResponse.php @@ -0,0 +1,130 @@ + $type The type of object + */ + #[JsonProperty('type')] + private ?string $type; + + /** + * @var ?CursorPages $pages + */ + #[JsonProperty('pages')] + private ?CursorPages $pages; + + /** + * @var ?int $totalCount A count of the total number of objects. + */ + #[JsonProperty('total_count')] + private ?int $totalCount; + + /** + * @var ?array $data An array of Objects + */ + #[JsonProperty('data'), ArrayType([PaginatedResponseDataItem::class])] + private ?array $data; + + /** + * @param array{ + * type?: ?value-of, + * pages?: ?CursorPages, + * totalCount?: ?int, + * data?: ?array, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->type = $values['type'] ?? null; + $this->pages = $values['pages'] ?? null; + $this->totalCount = $values['totalCount'] ?? null; + $this->data = $values['data'] ?? null; + } + + /** + * @return ?value-of + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?value-of $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?CursorPages + */ + public function getPages(): ?CursorPages + { + return $this->pages; + } + + /** + * @param ?CursorPages $value + */ + public function setPages(?CursorPages $value = null): self + { + $this->pages = $value; + return $this; + } + + /** + * @return ?int + */ + public function getTotalCount(): ?int + { + return $this->totalCount; + } + + /** + * @param ?int $value + */ + public function setTotalCount(?int $value = null): self + { + $this->totalCount = $value; + return $this; + } + + /** + * @return ?array + */ + public function getData(): ?array + { + return $this->data; + } + + /** + * @param ?array $value + */ + public function setData(?array $value = null): self + { + $this->data = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/ActionComponent.php b/src/Types/PaginatedResponseDataItem.php similarity index 52% rename from src/Types/ActionComponent.php rename to src/Types/PaginatedResponseDataItem.php index 9a587df..389a8a4 100644 --- a/src/Types/ActionComponent.php +++ b/src/Types/PaginatedResponseDataItem.php @@ -3,16 +3,17 @@ namespace Intercom\Types; use Intercom\Core\Json\JsonSerializableType; +use Intercom\News\Types\NewsItem; +use Intercom\News\Types\Newsfeed; use Exception; use Intercom\Core\Json\JsonDecoder; -class ActionComponent extends JsonSerializableType +class PaginatedResponseDataItem extends JsonSerializableType { /** * @var ( - * 'sheet' - * |'url' - * |'submit' + * 'news-item' + * |'newsfeed' * |'_unknown' * ) $type */ @@ -20,9 +21,8 @@ class ActionComponent extends JsonSerializableType /** * @var ( - * SheetActionComponent - * |UrlActionComponent - * |SubmitActionComponent + * NewsItem + * |Newsfeed * |mixed * ) $value */ @@ -31,15 +31,13 @@ class ActionComponent extends JsonSerializableType /** * @param array{ * type: ( - * 'sheet' - * |'url' - * |'submit' + * 'news-item' + * |'newsfeed' * |'_unknown' * ), * value: ( - * SheetActionComponent - * |UrlActionComponent - * |SubmitActionComponent + * NewsItem + * |Newsfeed * |mixed * ), * } $values @@ -53,9 +51,8 @@ private function __construct( /** * @return ( - * 'sheet' - * |'url' - * |'submit' + * 'news-item' + * |'newsfeed' * |'_unknown' * ) */ @@ -66,9 +63,8 @@ public function getType(): string /** * @return ( - * SheetActionComponent - * |UrlActionComponent - * |SubmitActionComponent + * NewsItem + * |Newsfeed * |mixed * ) */ @@ -78,57 +74,45 @@ public function getValue(): mixed } /** - * @param SheetActionComponent $sheet - * @return ActionComponent + * @param NewsItem $newsItem + * @return PaginatedResponseDataItem */ - public static function sheet(SheetActionComponent $sheet): ActionComponent + public static function newsItem(NewsItem $newsItem): PaginatedResponseDataItem { - return new ActionComponent([ - 'type' => 'sheet', - 'value' => $sheet, + return new PaginatedResponseDataItem([ + 'type' => 'news-item', + 'value' => $newsItem, ]); } /** - * @param UrlActionComponent $url - * @return ActionComponent + * @param Newsfeed $newsfeed + * @return PaginatedResponseDataItem */ - public static function url(UrlActionComponent $url): ActionComponent + public static function newsfeed(Newsfeed $newsfeed): PaginatedResponseDataItem { - return new ActionComponent([ - 'type' => 'url', - 'value' => $url, - ]); - } - - /** - * @param SubmitActionComponent $submit - * @return ActionComponent - */ - public static function submit(SubmitActionComponent $submit): ActionComponent - { - return new ActionComponent([ - 'type' => 'submit', - 'value' => $submit, + return new PaginatedResponseDataItem([ + 'type' => 'newsfeed', + 'value' => $newsfeed, ]); } /** * @return bool */ - public function isSheet(): bool + public function isNewsItem(): bool { - return $this->value instanceof SheetActionComponent && $this->type === 'sheet'; + return $this->value instanceof NewsItem && $this->type === 'news-item'; } /** - * @return SheetActionComponent + * @return NewsItem */ - public function asSheet(): SheetActionComponent + public function asNewsItem(): NewsItem { - if (!($this->value instanceof SheetActionComponent && $this->type === 'sheet')) { + if (!($this->value instanceof NewsItem && $this->type === 'news-item')) { throw new Exception( - "Expected sheet; got " . $this->type . " with value of type " . get_debug_type($this->value), + "Expected news-item; got " . $this->type . " with value of type " . get_debug_type($this->value), ); } @@ -138,41 +122,19 @@ public function asSheet(): SheetActionComponent /** * @return bool */ - public function isUrl(): bool + public function isNewsfeed(): bool { - return $this->value instanceof UrlActionComponent && $this->type === 'url'; + return $this->value instanceof Newsfeed && $this->type === 'newsfeed'; } /** - * @return UrlActionComponent + * @return Newsfeed */ - public function asUrl(): UrlActionComponent + public function asNewsfeed(): Newsfeed { - if (!($this->value instanceof UrlActionComponent && $this->type === 'url')) { + if (!($this->value instanceof Newsfeed && $this->type === 'newsfeed')) { throw new Exception( - "Expected url; got " . $this->type . " with value of type " . get_debug_type($this->value), - ); - } - - return $this->value; - } - - /** - * @return bool - */ - public function isSubmit(): bool - { - return $this->value instanceof SubmitActionComponent && $this->type === 'submit'; - } - - /** - * @return SubmitActionComponent - */ - public function asSubmit(): SubmitActionComponent - { - if (!($this->value instanceof SubmitActionComponent && $this->type === 'submit')) { - throw new Exception( - "Expected submit; got " . $this->type . " with value of type " . get_debug_type($this->value), + "Expected newsfeed; got " . $this->type . " with value of type " . get_debug_type($this->value), ); } @@ -199,16 +161,12 @@ public function jsonSerialize(): array $result = array_merge($base, $result); switch ($this->type) { - case 'sheet': - $value = $this->asSheet()->jsonSerialize(); + case 'news-item': + $value = $this->asNewsItem()->jsonSerialize(); $result = array_merge($value, $result); break; - case 'url': - $value = $this->asUrl()->jsonSerialize(); - $result = array_merge($value, $result); - break; - case 'submit': - $value = $this->asSubmit()->jsonSerialize(); + case 'newsfeed': + $value = $this->asNewsfeed()->jsonSerialize(); $result = array_merge($value, $result); break; case '_unknown': @@ -259,14 +217,11 @@ public static function jsonDeserialize(array $data): static $args['type'] = $type; switch ($type) { - case 'sheet': - $args['value'] = SheetActionComponent::jsonDeserialize($data); - break; - case 'url': - $args['value'] = UrlActionComponent::jsonDeserialize($data); + case 'news-item': + $args['value'] = NewsItem::jsonDeserialize($data); break; - case 'submit': - $args['value'] = SubmitActionComponent::jsonDeserialize($data); + case 'newsfeed': + $args['value'] = Newsfeed::jsonDeserialize($data); break; case '_unknown': default: diff --git a/src/Types/PaginatedResponseType.php b/src/Types/PaginatedResponseType.php new file mode 100644 index 0000000..fb2ef73 --- /dev/null +++ b/src/Types/PaginatedResponseType.php @@ -0,0 +1,9 @@ +type = $values['type']; - $this->name = $values['name']; - $this->url = $values['url']; - $this->contentType = $values['contentType']; - $this->filesize = $values['filesize']; - $this->width = $values['width']; - $this->height = $values['height']; + $this->type = $values['type'] ?? null; + $this->name = $values['name'] ?? null; + $this->url = $values['url'] ?? null; + $this->contentType = $values['contentType'] ?? null; + $this->filesize = $values['filesize'] ?? null; + $this->width = $values['width'] ?? null; + $this->height = $values['height'] ?? null; } /** - * @return string + * @return ?string */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param string $value + * @param ?string $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return string + * @return ?string */ - public function getName(): string + public function getName(): ?string { return $this->name; } /** - * @param string $value + * @param ?string $value */ - public function setName(string $value): self + public function setName(?string $value = null): self { $this->name = $value; return $this; } /** - * @return string + * @return ?string */ - public function getUrl(): string + public function getUrl(): ?string { return $this->url; } /** - * @param string $value + * @param ?string $value */ - public function setUrl(string $value): self + public function setUrl(?string $value = null): self { $this->url = $value; return $this; } /** - * @return string + * @return ?string */ - public function getContentType(): string + public function getContentType(): ?string { return $this->contentType; } /** - * @param string $value + * @param ?string $value */ - public function setContentType(string $value): self + public function setContentType(?string $value = null): self { $this->contentType = $value; return $this; } /** - * @return int + * @return ?int */ - public function getFilesize(): int + public function getFilesize(): ?int { return $this->filesize; } /** - * @param int $value + * @param ?int $value */ - public function setFilesize(int $value): self + public function setFilesize(?int $value = null): self { $this->filesize = $value; return $this; } /** - * @return int + * @return ?int */ - public function getWidth(): int + public function getWidth(): ?int { return $this->width; } /** - * @param int $value + * @param ?int $value */ - public function setWidth(int $value): self + public function setWidth(?int $value = null): self { $this->width = $value; return $this; } /** - * @return int + * @return ?int */ - public function getHeight(): int + public function getHeight(): ?int { return $this->height; } /** - * @param int $value + * @param ?int $value */ - public function setHeight(int $value): self + public function setHeight(?int $value = null): self { $this->height = $value; return $this; diff --git a/src/Types/PhoneSwitch.php b/src/Types/PhoneSwitch.php index 62f991b..b0618cc 100644 --- a/src/Types/PhoneSwitch.php +++ b/src/Types/PhoneSwitch.php @@ -11,59 +11,59 @@ class PhoneSwitch extends JsonSerializableType { /** - * @var 'phone_call_redirect' $type + * @var ?'phone_call_redirect' $type */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var string $phone Phone number in E.164 format, that has received the SMS to continue the conversation in the Messenger. + * @var ?string $phone Phone number in E.164 format, that has received the SMS to continue the conversation in the Messenger. */ #[JsonProperty('phone')] - private string $phone; + private ?string $phone; /** * @param array{ - * type: 'phone_call_redirect', - * phone: string, + * type?: ?'phone_call_redirect', + * phone?: ?string, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->phone = $values['phone']; + $this->type = $values['type'] ?? null; + $this->phone = $values['phone'] ?? null; } /** - * @return 'phone_call_redirect' + * @return ?'phone_call_redirect' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'phone_call_redirect' $value + * @param ?'phone_call_redirect' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return string + * @return ?string */ - public function getPhone(): string + public function getPhone(): ?string { return $this->phone; } /** - * @param string $value + * @param ?string $value */ - public function setPhone(string $value): self + public function setPhone(?string $value = null): self { $this->phone = $value; return $this; diff --git a/src/Types/QuickReplyOption.php b/src/Types/QuickReplyOption.php new file mode 100644 index 0000000..47d006a --- /dev/null +++ b/src/Types/QuickReplyOption.php @@ -0,0 +1,76 @@ +text = $values['text']; + $this->uuid = $values['uuid']; + } + + /** + * @return string + */ + public function getText(): string + { + return $this->text; + } + + /** + * @param string $value + */ + public function setText(string $value): self + { + $this->text = $value; + return $this; + } + + /** + * @return string + */ + public function getUuid(): string + { + return $this->uuid; + } + + /** + * @param string $value + */ + public function setUuid(string $value): self + { + $this->uuid = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/Recipient.php b/src/Types/Recipient.php new file mode 100644 index 0000000..275d596 --- /dev/null +++ b/src/Types/Recipient.php @@ -0,0 +1,79 @@ + $type The role associated to the contact - `user` or `lead`. + */ + #[JsonProperty('type')] + private string $type; + + /** + * @var string $id The identifier for the contact which is given by Intercom. + */ + #[JsonProperty('id')] + private string $id; + + /** + * @param array{ + * type: value-of, + * id: string, + * } $values + */ + public function __construct( + array $values, + ) { + $this->type = $values['type']; + $this->id = $values['id']; + } + + /** + * @return value-of + */ + public function getType(): string + { + return $this->type; + } + + /** + * @param value-of $value + */ + public function setType(string $value): self + { + $this->type = $value; + return $this; + } + + /** + * @return string + */ + public function getId(): string + { + return $this->id; + } + + /** + * @param string $value + */ + public function setId(string $value): self + { + $this->id = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/RecipientType.php b/src/Types/RecipientType.php new file mode 100644 index 0000000..1a929da --- /dev/null +++ b/src/Types/RecipientType.php @@ -0,0 +1,9 @@ +type = $values['type']; + $this->type = $values['type'] ?? null; $this->id = $values['id'] ?? null; } /** - * @return string + * @return ?string */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param string $value + * @param ?string $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; diff --git a/src/Types/ResultsResponse.php b/src/Types/ResultsResponse.php deleted file mode 100644 index d0df17d..0000000 --- a/src/Types/ResultsResponse.php +++ /dev/null @@ -1,55 +0,0 @@ - $results Key-value pairs of data you want access to in the Initialize request - */ - #[JsonProperty('results'), ArrayType(['string' => 'mixed'])] - private array $results; - - /** - * @param array{ - * results: array, - * } $values - */ - public function __construct( - array $values, - ) { - $this->results = $values['results']; - } - - /** - * @return array - */ - public function getResults(): array - { - return $this->results; - } - - /** - * @param array $value - */ - public function setResults(array $value): self - { - $this->results = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/SegmentList.php b/src/Types/SegmentList.php index 52cbc4d..08ebfdc 100644 --- a/src/Types/SegmentList.php +++ b/src/Types/SegmentList.php @@ -13,16 +13,16 @@ class SegmentList extends JsonSerializableType { /** - * @var 'segment.list' $type The type of the object + * @var ?'segment.list' $type The type of the object */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var array $segments A list of Segment objects + * @var ?array $segments A list of Segment objects */ #[JsonProperty('segments'), ArrayType([Segment::class])] - private array $segments; + private ?array $segments; /** * @var ?array $pages A pagination object, which may be empty, indicating no further pages to fetch. @@ -32,48 +32,48 @@ class SegmentList extends JsonSerializableType /** * @param array{ - * type: 'segment.list', - * segments: array, + * type?: ?'segment.list', + * segments?: ?array, * pages?: ?array, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->segments = $values['segments']; + $this->type = $values['type'] ?? null; + $this->segments = $values['segments'] ?? null; $this->pages = $values['pages'] ?? null; } /** - * @return 'segment.list' + * @return ?'segment.list' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'segment.list' $value + * @param ?'segment.list' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return array + * @return ?array */ - public function getSegments(): array + public function getSegments(): ?array { return $this->segments; } /** - * @param array $value + * @param ?array $value */ - public function setSegments(array $value): self + public function setSegments(?array $value = null): self { $this->segments = $value; return $this; diff --git a/src/Types/SheetActionComponent.php b/src/Types/SheetActionComponent.php deleted file mode 100644 index 5b4b0d7..0000000 --- a/src/Types/SheetActionComponent.php +++ /dev/null @@ -1,56 +0,0 @@ -url = $values['url']; - } - - /** - * @return string - */ - public function getUrl(): string - { - return $this->url; - } - - /** - * @param string $value - */ - public function setUrl(string $value): self - { - $this->url = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/SingleFilterSearchRequest.php b/src/Types/SingleFilterSearchRequest.php index e3f39d4..17f721e 100644 --- a/src/Types/SingleFilterSearchRequest.php +++ b/src/Types/SingleFilterSearchRequest.php @@ -27,11 +27,13 @@ class SingleFilterSearchRequest extends JsonSerializableType * @var ( * string * |int - * |array - * |array + * |array<( + * string + * |int + * )> * )|null $value The value that you want to search on. */ - #[JsonProperty('value'), Union('string', 'integer', ['string'], ['integer'], 'null')] + #[JsonProperty('value'), Union('string', 'integer', [new Union('string', 'integer')], 'null')] private string|int|array|null $value; /** @@ -41,8 +43,10 @@ class SingleFilterSearchRequest extends JsonSerializableType * value?: ( * string * |int - * |array - * |array + * |array<( + * string + * |int + * )> * )|null, * } $values */ @@ -92,8 +96,10 @@ public function setOperator(?string $value = null): self * @return ( * string * |int - * |array - * |array + * |array<( + * string + * |int + * )> * )|null */ public function getValue(): string|int|array|null @@ -105,8 +111,10 @@ public function getValue(): string|int|array|null * @param ( * string * |int - * |array - * |array + * |array<( + * string + * |int + * )> * )|null $value */ public function setValue(string|int|array|null $value = null): self diff --git a/src/Types/SingleFilterSearchRequestOperator.php b/src/Types/SingleFilterSearchRequestOperator.php index 6fa00dd..0015297 100644 --- a/src/Types/SingleFilterSearchRequestOperator.php +++ b/src/Types/SingleFilterSearchRequestOperator.php @@ -13,5 +13,5 @@ enum SingleFilterSearchRequestOperator: string case Contains = "~"; case DoesNotContain = "!~"; case StartsWith = "^"; - case EndsWith = "$"; + case EndsWith = "\$"; } diff --git a/src/Types/SingleSelectComponent.php b/src/Types/SingleSelectComponent.php deleted file mode 100644 index ee3fc45..0000000 --- a/src/Types/SingleSelectComponent.php +++ /dev/null @@ -1,210 +0,0 @@ - $options The list of options. Can provide 2 to 10. - */ - #[JsonProperty('options'), ArrayType([SingleSelectOption::class])] - private array $options; - - /** - * @var ?string $label The text shown above the options. - */ - #[JsonProperty('label')] - private ?string $label; - - /** - * @var ?string $value The option that is selected by default. - */ - #[JsonProperty('value')] - private ?string $value; - - /** - * @var ?value-of $saveState Styles the input. Default is `unsaved`. Prevent action with `saved`. - */ - #[JsonProperty('save_state')] - private ?string $saveState; - - /** - * @var ?bool $disabled Styles all options and prevents the action. Default is false. Will be overridden if save_state is saved. - */ - #[JsonProperty('disabled')] - private ?bool $disabled; - - /** - * @var ?ActionComponent $action This can be a Submit Action, URL Action, or Sheets Action. - */ - #[JsonProperty('action')] - private ?ActionComponent $action; - - /** - * @param array{ - * id: string, - * options: array, - * label?: ?string, - * value?: ?string, - * saveState?: ?value-of, - * disabled?: ?bool, - * action?: ?ActionComponent, - * } $values - */ - public function __construct( - array $values, - ) { - $this->id = $values['id']; - $this->options = $values['options']; - $this->label = $values['label'] ?? null; - $this->value = $values['value'] ?? null; - $this->saveState = $values['saveState'] ?? null; - $this->disabled = $values['disabled'] ?? null; - $this->action = $values['action'] ?? null; - } - - /** - * @return string - */ - public function getId(): string - { - return $this->id; - } - - /** - * @param string $value - */ - public function setId(string $value): self - { - $this->id = $value; - return $this; - } - - /** - * @return array - */ - public function getOptions(): array - { - return $this->options; - } - - /** - * @param array $value - */ - public function setOptions(array $value): self - { - $this->options = $value; - return $this; - } - - /** - * @return ?string - */ - public function getLabel(): ?string - { - return $this->label; - } - - /** - * @param ?string $value - */ - public function setLabel(?string $value = null): self - { - $this->label = $value; - return $this; - } - - /** - * @return ?string - */ - public function getValue(): ?string - { - return $this->value; - } - - /** - * @param ?string $value - */ - public function setValue(?string $value = null): self - { - $this->value = $value; - return $this; - } - - /** - * @return ?value-of - */ - public function getSaveState(): ?string - { - return $this->saveState; - } - - /** - * @param ?value-of $value - */ - public function setSaveState(?string $value = null): self - { - $this->saveState = $value; - return $this; - } - - /** - * @return ?bool - */ - public function getDisabled(): ?bool - { - return $this->disabled; - } - - /** - * @param ?bool $value - */ - public function setDisabled(?bool $value = null): self - { - $this->disabled = $value; - return $this; - } - - /** - * @return ?ActionComponent - */ - public function getAction(): ?ActionComponent - { - return $this->action; - } - - /** - * @param ?ActionComponent $value - */ - public function setAction(?ActionComponent $value = null): self - { - $this->action = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/SingleSelectComponentSaveState.php b/src/Types/SingleSelectComponentSaveState.php deleted file mode 100644 index 3776c6a..0000000 --- a/src/Types/SingleSelectComponentSaveState.php +++ /dev/null @@ -1,10 +0,0 @@ -type = $values['type']; - $this->id = $values['id']; - $this->text = $values['text']; - $this->disabled = $values['disabled'] ?? null; - } - - /** - * @return 'option' - */ - public function getType(): string - { - return $this->type; - } - - /** - * @param 'option' $value - */ - public function setType(string $value): self - { - $this->type = $value; - return $this; - } - - /** - * @return string - */ - public function getId(): string - { - return $this->id; - } - - /** - * @param string $value - */ - public function setId(string $value): self - { - $this->id = $value; - return $this; - } - - /** - * @return string - */ - public function getText(): string - { - return $this->text; - } - - /** - * @param string $value - */ - public function setText(string $value): self - { - $this->text = $value; - return $this; - } - - /** - * @return ?bool - */ - public function getDisabled(): ?bool - { - return $this->disabled; - } - - /** - * @param ?bool $value - */ - public function setDisabled(?bool $value = null): self - { - $this->disabled = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/SlaApplied.php b/src/Types/SlaApplied.php index 79ced80..6587038 100644 --- a/src/Types/SlaApplied.php +++ b/src/Types/SlaApplied.php @@ -12,16 +12,16 @@ class SlaApplied extends JsonSerializableType { /** - * @var string $type object type + * @var ?string $type object type */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var string $slaName The name of the SLA as given by the teammate when it was created. + * @var ?string $slaName The name of the SLA as given by the teammate when it was created. */ #[JsonProperty('sla_name')] - private string $slaName; + private ?string $slaName; /** * SLA statuses: @@ -29,72 +29,72 @@ class SlaApplied extends JsonSerializableType * - `missed`: If there are any missed sla_events for the conversation and no canceled events. If there’s even a single missed sla event, the status will always be missed. A missed status is not applied when the SLA expires, only the next time a teammate replies. * - `active`: An SLA has been applied to a conversation, but has not yet been fulfilled. SLA status is active only if there are no “hit, “missed”, or “canceled” events. * - * @var value-of $slaStatus + * @var ?value-of $slaStatus */ #[JsonProperty('sla_status')] - private string $slaStatus; + private ?string $slaStatus; /** * @param array{ - * type: string, - * slaName: string, - * slaStatus: value-of, + * type?: ?string, + * slaName?: ?string, + * slaStatus?: ?value-of, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->slaName = $values['slaName']; - $this->slaStatus = $values['slaStatus']; + $this->type = $values['type'] ?? null; + $this->slaName = $values['slaName'] ?? null; + $this->slaStatus = $values['slaStatus'] ?? null; } /** - * @return string + * @return ?string */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param string $value + * @param ?string $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return string + * @return ?string */ - public function getSlaName(): string + public function getSlaName(): ?string { return $this->slaName; } /** - * @param string $value + * @param ?string $value */ - public function setSlaName(string $value): self + public function setSlaName(?string $value = null): self { $this->slaName = $value; return $this; } /** - * @return value-of + * @return ?value-of */ - public function getSlaStatus(): string + public function getSlaStatus(): ?string { return $this->slaStatus; } /** - * @param value-of $value + * @param ?value-of $value */ - public function setSlaStatus(string $value): self + public function setSlaStatus(?string $value = null): self { $this->slaStatus = $value; return $this; diff --git a/src/Types/SocialProfile.php b/src/Types/SocialProfile.php index ac99d03..0ae1f48 100644 --- a/src/Types/SocialProfile.php +++ b/src/Types/SocialProfile.php @@ -11,84 +11,84 @@ class SocialProfile extends JsonSerializableType { /** - * @var 'social_profile' $type value is "social_profile" + * @var ?'social_profile' $type value is "social_profile" */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var string $name The name of the Social media profile + * @var ?string $name The name of the Social media profile */ #[JsonProperty('name')] - private string $name; + private ?string $name; /** - * @var string $url The name of the Social media profile + * @var ?string $url The name of the Social media profile */ #[JsonProperty('url')] - private string $url; + private ?string $url; /** * @param array{ - * type: 'social_profile', - * name: string, - * url: string, + * type?: ?'social_profile', + * name?: ?string, + * url?: ?string, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->name = $values['name']; - $this->url = $values['url']; + $this->type = $values['type'] ?? null; + $this->name = $values['name'] ?? null; + $this->url = $values['url'] ?? null; } /** - * @return 'social_profile' + * @return ?'social_profile' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'social_profile' $value + * @param ?'social_profile' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return string + * @return ?string */ - public function getName(): string + public function getName(): ?string { return $this->name; } /** - * @param string $value + * @param ?string $value */ - public function setName(string $value): self + public function setName(?string $value = null): self { $this->name = $value; return $this; } /** - * @return string + * @return ?string */ - public function getUrl(): string + public function getUrl(): ?string { return $this->url; } /** - * @param string $value + * @param ?string $value */ - public function setUrl(string $value): self + public function setUrl(?string $value = null): self { $this->url = $value; return $this; diff --git a/src/Types/SpacerComponentSize.php b/src/Types/SpacerComponentSize.php deleted file mode 100644 index 57b3d99..0000000 --- a/src/Types/SpacerComponentSize.php +++ /dev/null @@ -1,12 +0,0 @@ -perPage = $values['perPage']; + $this->perPage = $values['perPage'] ?? null; $this->startingAfter = $values['startingAfter'] ?? null; } /** - * @return int + * @return ?int */ - public function getPerPage(): int + public function getPerPage(): ?int { return $this->perPage; } /** - * @param int $value + * @param ?int $value */ - public function setPerPage(int $value): self + public function setPerPage(?int $value = null): self { $this->perPage = $value; return $this; diff --git a/src/Types/SubmitActionComponent.php b/src/Types/SubmitActionComponent.php deleted file mode 100644 index 6b4d2c9..0000000 --- a/src/Types/SubmitActionComponent.php +++ /dev/null @@ -1,19 +0,0 @@ -toJson(); - } -} diff --git a/src/Types/SubmitRequest.php b/src/Types/SubmitRequest.php deleted file mode 100644 index f88fe7a..0000000 --- a/src/Types/SubmitRequest.php +++ /dev/null @@ -1,283 +0,0 @@ - $inputValues A list of key/value pairs of data, inputted by the teammate on the current canvas. - */ - #[JsonProperty('input_values'), ArrayType(['string' => 'mixed'])] - private array $inputValues; - - /** - * @var Contact $user The user who took the action. - */ - #[JsonProperty('user')] - private Contact $user; - - /** - * @param array{ - * workspaceId: string, - * workspaceRegion: string, - * admin: Admin, - * componentId: string, - * context: Context, - * conversation: Conversation, - * currentCanvas: CurrentCanvas, - * contact: Contact, - * inputValues: array, - * user: Contact, - * } $values - */ - public function __construct( - array $values, - ) { - $this->workspaceId = $values['workspaceId']; - $this->workspaceRegion = $values['workspaceRegion']; - $this->admin = $values['admin']; - $this->componentId = $values['componentId']; - $this->context = $values['context']; - $this->conversation = $values['conversation']; - $this->currentCanvas = $values['currentCanvas']; - $this->contact = $values['contact']; - $this->inputValues = $values['inputValues']; - $this->user = $values['user']; - } - - /** - * @return string - */ - public function getWorkspaceId(): string - { - return $this->workspaceId; - } - - /** - * @param string $value - */ - public function setWorkspaceId(string $value): self - { - $this->workspaceId = $value; - return $this; - } - - /** - * @return string - */ - public function getWorkspaceRegion(): string - { - return $this->workspaceRegion; - } - - /** - * @param string $value - */ - public function setWorkspaceRegion(string $value): self - { - $this->workspaceRegion = $value; - return $this; - } - - /** - * @return Admin - */ - public function getAdmin(): Admin - { - return $this->admin; - } - - /** - * @param Admin $value - */ - public function setAdmin(Admin $value): self - { - $this->admin = $value; - return $this; - } - - /** - * @return string - */ - public function getComponentId(): string - { - return $this->componentId; - } - - /** - * @param string $value - */ - public function setComponentId(string $value): self - { - $this->componentId = $value; - return $this; - } - - /** - * @return Context - */ - public function getContext(): Context - { - return $this->context; - } - - /** - * @param Context $value - */ - public function setContext(Context $value): self - { - $this->context = $value; - return $this; - } - - /** - * @return Conversation - */ - public function getConversation(): Conversation - { - return $this->conversation; - } - - /** - * @param Conversation $value - */ - public function setConversation(Conversation $value): self - { - $this->conversation = $value; - return $this; - } - - /** - * @return CurrentCanvas - */ - public function getCurrentCanvas(): CurrentCanvas - { - return $this->currentCanvas; - } - - /** - * @param CurrentCanvas $value - */ - public function setCurrentCanvas(CurrentCanvas $value): self - { - $this->currentCanvas = $value; - return $this; - } - - /** - * @return Contact - */ - public function getContact(): Contact - { - return $this->contact; - } - - /** - * @param Contact $value - */ - public function setContact(Contact $value): self - { - $this->contact = $value; - return $this; - } - - /** - * @return array - */ - public function getInputValues(): array - { - return $this->inputValues; - } - - /** - * @param array $value - */ - public function setInputValues(array $value): self - { - $this->inputValues = $value; - return $this; - } - - /** - * @return Contact - */ - public function getUser(): Contact - { - return $this->user; - } - - /** - * @param Contact $value - */ - public function setUser(Contact $value): self - { - $this->user = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/SubmitResponse.php b/src/Types/SubmitResponse.php deleted file mode 100644 index b4fb3a8..0000000 --- a/src/Types/SubmitResponse.php +++ /dev/null @@ -1,113 +0,0 @@ - $cardCreationOptions Optional. Key-value pairs that will be sent in the initialize request to insert an app into the conversation reply. - */ - #[JsonProperty('card_creation_options'), ArrayType(['string' => 'mixed'])] - private ?array $cardCreationOptions; - - /** - * @var ?Event $event Optional. Indicates if the app has completed its purpose. - */ - #[JsonProperty('event')] - private ?Event $event; - - /** - * @param array{ - * canvas: CanvasObject, - * cardCreationOptions?: ?array, - * event?: ?Event, - * } $values - */ - public function __construct( - array $values, - ) { - $this->canvas = $values['canvas']; - $this->cardCreationOptions = $values['cardCreationOptions'] ?? null; - $this->event = $values['event'] ?? null; - } - - /** - * @return CanvasObject - */ - public function getCanvas(): CanvasObject - { - return $this->canvas; - } - - /** - * @param CanvasObject $value - */ - public function setCanvas(CanvasObject $value): self - { - $this->canvas = $value; - return $this; - } - - /** - * @return ?array - */ - public function getCardCreationOptions(): ?array - { - return $this->cardCreationOptions; - } - - /** - * @param ?array $value - */ - public function setCardCreationOptions(?array $value = null): self - { - $this->cardCreationOptions = $value; - return $this; - } - - /** - * @return ?Event - */ - public function getEvent(): ?Event - { - return $this->event; - } - - /** - * @param ?Event $value - */ - public function setEvent(?Event $value = null): self - { - $this->event = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/SubscriptionTypeList.php b/src/Types/SubscriptionTypeList.php index 7c292dd..9526ff2 100644 --- a/src/Types/SubscriptionTypeList.php +++ b/src/Types/SubscriptionTypeList.php @@ -13,59 +13,59 @@ class SubscriptionTypeList extends JsonSerializableType { /** - * @var 'list' $type The type of the object + * @var ?'list' $type The type of the object */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var array $data A list of subscription type objects associated with the workspace . + * @var ?array $data A list of subscription type objects associated with the workspace . */ #[JsonProperty('data'), ArrayType([SubscriptionType::class])] - private array $data; + private ?array $data; /** * @param array{ - * type: 'list', - * data: array, + * type?: ?'list', + * data?: ?array, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->data = $values['data']; + $this->type = $values['type'] ?? null; + $this->data = $values['data'] ?? null; } /** - * @return 'list' + * @return ?'list' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'list' $value + * @param ?'list' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return array + * @return ?array */ - public function getData(): array + public function getData(): ?array { return $this->data; } /** - * @param array $value + * @param ?array $value */ - public function setData(array $value): self + public function setData(?array $value = null): self { $this->data = $value; return $this; diff --git a/src/Types/TagList.php b/src/Types/TagList.php index c9a3e64..105a2c7 100644 --- a/src/Types/TagList.php +++ b/src/Types/TagList.php @@ -13,59 +13,59 @@ class TagList extends JsonSerializableType { /** - * @var 'list' $type The type of the object + * @var ?'list' $type The type of the object */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var array $data A list of tags objects associated with the workspace . + * @var ?array $data A list of tags objects associated with the workspace . */ #[JsonProperty('data'), ArrayType([Tag::class])] - private array $data; + private ?array $data; /** * @param array{ - * type: 'list', - * data: array, + * type?: ?'list', + * data?: ?array, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->data = $values['data']; + $this->type = $values['type'] ?? null; + $this->data = $values['data'] ?? null; } /** - * @return 'list' + * @return ?'list' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'list' $value + * @param ?'list' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return array + * @return ?array */ - public function getData(): array + public function getData(): ?array { return $this->data; } /** - * @param array $value + * @param ?array $value */ - public function setData(array $value): self + public function setData(?array $value = null): self { $this->data = $value; return $this; diff --git a/src/Types/Tags.php b/src/Types/Tags.php index 598c543..a09e730 100644 --- a/src/Types/Tags.php +++ b/src/Types/Tags.php @@ -13,59 +13,59 @@ class Tags extends JsonSerializableType { /** - * @var 'tag.list' $type The type of the object + * @var ?'tag.list' $type The type of the object */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var array $tags A list of tags objects associated with the conversation. + * @var ?array $tags A list of tags objects associated with the conversation. */ #[JsonProperty('tags'), ArrayType([Tag::class])] - private array $tags; + private ?array $tags; /** * @param array{ - * type: 'tag.list', - * tags: array, + * type?: ?'tag.list', + * tags?: ?array, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->tags = $values['tags']; + $this->type = $values['type'] ?? null; + $this->tags = $values['tags'] ?? null; } /** - * @return 'tag.list' + * @return ?'tag.list' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'tag.list' $value + * @param ?'tag.list' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return array + * @return ?array */ - public function getTags(): array + public function getTags(): ?array { return $this->tags; } /** - * @param array $value + * @param ?array $value */ - public function setTags(array $value): self + public function setTags(?array $value = null): self { $this->tags = $value; return $this; diff --git a/src/Types/TeamList.php b/src/Types/TeamList.php index 8670875..a7912da 100644 --- a/src/Types/TeamList.php +++ b/src/Types/TeamList.php @@ -13,59 +13,59 @@ class TeamList extends JsonSerializableType { /** - * @var 'team.list' $type The type of the object + * @var ?'team.list' $type The type of the object */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var array $teams A list of team objects + * @var ?array $teams A list of team objects */ #[JsonProperty('teams'), ArrayType([Team::class])] - private array $teams; + private ?array $teams; /** * @param array{ - * type: 'team.list', - * teams: array, + * type?: ?'team.list', + * teams?: ?array, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->teams = $values['teams']; + $this->type = $values['type'] ?? null; + $this->teams = $values['teams'] ?? null; } /** - * @return 'team.list' + * @return ?'team.list' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'team.list' $value + * @param ?'team.list' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return array + * @return ?array */ - public function getTeams(): array + public function getTeams(): ?array { return $this->teams; } /** - * @param array $value + * @param ?array $value */ - public function setTeams(array $value): self + public function setTeams(?array $value = null): self { $this->teams = $value; return $this; diff --git a/src/Types/TextAreaComponent.php b/src/Types/TextAreaComponent.php deleted file mode 100644 index 7d8ac7f..0000000 --- a/src/Types/TextAreaComponent.php +++ /dev/null @@ -1,181 +0,0 @@ -id = $values['id']; - $this->label = $values['label'] ?? null; - $this->placeholder = $values['placeholder'] ?? null; - $this->value = $values['value'] ?? null; - $this->error = $values['error'] ?? null; - $this->disabled = $values['disabled'] ?? null; - } - - /** - * @return string - */ - public function getId(): string - { - return $this->id; - } - - /** - * @param string $value - */ - public function setId(string $value): self - { - $this->id = $value; - return $this; - } - - /** - * @return ?string - */ - public function getLabel(): ?string - { - return $this->label; - } - - /** - * @param ?string $value - */ - public function setLabel(?string $value = null): self - { - $this->label = $value; - return $this; - } - - /** - * @return ?string - */ - public function getPlaceholder(): ?string - { - return $this->placeholder; - } - - /** - * @param ?string $value - */ - public function setPlaceholder(?string $value = null): self - { - $this->placeholder = $value; - return $this; - } - - /** - * @return ?string - */ - public function getValue(): ?string - { - return $this->value; - } - - /** - * @param ?string $value - */ - public function setValue(?string $value = null): self - { - $this->value = $value; - return $this; - } - - /** - * @return ?bool - */ - public function getError(): ?bool - { - return $this->error; - } - - /** - * @param ?bool $value - */ - public function setError(?bool $value = null): self - { - $this->error = $value; - return $this; - } - - /** - * @return ?bool - */ - public function getDisabled(): ?bool - { - return $this->disabled; - } - - /** - * @param ?bool $value - */ - public function setDisabled(?bool $value = null): self - { - $this->disabled = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/TextComponent.php b/src/Types/TextComponent.php deleted file mode 100644 index df32229..0000000 --- a/src/Types/TextComponent.php +++ /dev/null @@ -1,154 +0,0 @@ - $align Aligns the text. Default is `left`. - */ - #[JsonProperty('align')] - private ?string $align; - - /** - * @var ?value-of $style Styles the text. Default is `paragraph`. - */ - #[JsonProperty('style')] - private ?string $style; - - /** - * @var ?'none' $bottomMargin Disables a component's margin-bottom of 10px. - */ - #[JsonProperty('bottom_margin')] - private ?string $bottomMargin; - - /** - * @param array{ - * text: string, - * id?: ?string, - * align?: ?value-of, - * style?: ?value-of, - * bottomMargin?: ?'none', - * } $values - */ - public function __construct( - array $values, - ) { - $this->id = $values['id'] ?? null; - $this->text = $values['text']; - $this->align = $values['align'] ?? null; - $this->style = $values['style'] ?? null; - $this->bottomMargin = $values['bottomMargin'] ?? null; - } - - /** - * @return ?string - */ - public function getId(): ?string - { - return $this->id; - } - - /** - * @param ?string $value - */ - public function setId(?string $value = null): self - { - $this->id = $value; - return $this; - } - - /** - * @return string - */ - public function getText(): string - { - return $this->text; - } - - /** - * @param string $value - */ - public function setText(string $value): self - { - $this->text = $value; - return $this; - } - - /** - * @return ?value-of - */ - public function getAlign(): ?string - { - return $this->align; - } - - /** - * @param ?value-of $value - */ - public function setAlign(?string $value = null): self - { - $this->align = $value; - return $this; - } - - /** - * @return ?value-of - */ - public function getStyle(): ?string - { - return $this->style; - } - - /** - * @param ?value-of $value - */ - public function setStyle(?string $value = null): self - { - $this->style = $value; - return $this; - } - - /** - * @return ?'none' - */ - public function getBottomMargin(): ?string - { - return $this->bottomMargin; - } - - /** - * @param ?'none' $value - */ - public function setBottomMargin(?string $value = null): self - { - $this->bottomMargin = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/TextComponentAlign.php b/src/Types/TextComponentAlign.php deleted file mode 100644 index ab4576a..0000000 --- a/src/Types/TextComponentAlign.php +++ /dev/null @@ -1,10 +0,0 @@ - $tickets The list of ticket objects + * @var ?array $tickets The list of ticket objects */ - #[JsonProperty('tickets'), ArrayType([Ticket::class])] - private array $tickets; + #[JsonProperty('tickets'), ArrayType([new Union(Ticket::class, 'null')])] + private ?array $tickets; /** - * @var int $totalCount A count of the total number of objects. + * @var ?int $totalCount A count of the total number of objects. */ #[JsonProperty('total_count')] - private int $totalCount; + private ?int $totalCount; /** * @var ?CursorPages $pages @@ -38,67 +39,67 @@ class TicketList extends JsonSerializableType /** * @param array{ - * type: 'ticket.list', - * tickets: array, - * totalCount: int, + * type?: ?'ticket.list', + * tickets?: ?array, + * totalCount?: ?int, * pages?: ?CursorPages, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->tickets = $values['tickets']; - $this->totalCount = $values['totalCount']; + $this->type = $values['type'] ?? null; + $this->tickets = $values['tickets'] ?? null; + $this->totalCount = $values['totalCount'] ?? null; $this->pages = $values['pages'] ?? null; } /** - * @return 'ticket.list' + * @return ?'ticket.list' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'ticket.list' $value + * @param ?'ticket.list' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return array + * @return ?array */ - public function getTickets(): array + public function getTickets(): ?array { return $this->tickets; } /** - * @param array $value + * @param ?array $value */ - public function setTickets(array $value): self + public function setTickets(?array $value = null): self { $this->tickets = $value; return $this; } /** - * @return int + * @return ?int */ - public function getTotalCount(): int + public function getTotalCount(): ?int { return $this->totalCount; } /** - * @param int $value + * @param ?int $value */ - public function setTotalCount(int $value): self + public function setTotalCount(?int $value = null): self { $this->totalCount = $value; return $this; diff --git a/src/Types/TicketPartAuthor.php b/src/Types/TicketPartAuthor.php index 2f3e292..faadb61 100644 --- a/src/Types/TicketPartAuthor.php +++ b/src/Types/TicketPartAuthor.php @@ -11,16 +11,16 @@ class TicketPartAuthor extends JsonSerializableType { /** - * @var value-of $type The type of the author + * @var ?value-of $type The type of the author */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var string $id The id of the author + * @var ?string $id The id of the author */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** * @var ?string $name The name of the author @@ -29,57 +29,57 @@ class TicketPartAuthor extends JsonSerializableType private ?string $name; /** - * @var string $email The email of the author + * @var ?string $email The email of the author */ #[JsonProperty('email')] - private string $email; + private ?string $email; /** * @param array{ - * type: value-of, - * id: string, - * email: string, + * type?: ?value-of, + * id?: ?string, * name?: ?string, + * email?: ?string, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->id = $values['id']; + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; $this->name = $values['name'] ?? null; - $this->email = $values['email']; + $this->email = $values['email'] ?? null; } /** - * @return value-of + * @return ?value-of */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param value-of $value + * @param ?value-of $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; @@ -103,17 +103,17 @@ public function setName(?string $value = null): self } /** - * @return string + * @return ?string */ - public function getEmail(): string + public function getEmail(): ?string { return $this->email; } /** - * @param string $value + * @param ?string $value */ - public function setEmail(string $value): self + public function setEmail(?string $value = null): self { $this->email = $value; return $this; diff --git a/src/Types/TicketParts.php b/src/Types/TicketParts.php index 7abbb00..2dea032 100644 --- a/src/Types/TicketParts.php +++ b/src/Types/TicketParts.php @@ -13,84 +13,84 @@ class TicketParts extends JsonSerializableType { /** - * @var 'ticket_part.list' $type + * @var ?'ticket_part.list' $type */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var array $ticketParts A list of Ticket Part objects for each ticket. There is a limit of 500 parts. + * @var ?array $ticketParts A list of Ticket Part objects for each ticket. There is a limit of 500 parts. */ #[JsonProperty('ticket_parts'), ArrayType([TicketPart::class])] - private array $ticketParts; + private ?array $ticketParts; /** - * @var int $totalCount + * @var ?int $totalCount */ #[JsonProperty('total_count')] - private int $totalCount; + private ?int $totalCount; /** * @param array{ - * type: 'ticket_part.list', - * ticketParts: array, - * totalCount: int, + * type?: ?'ticket_part.list', + * ticketParts?: ?array, + * totalCount?: ?int, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->ticketParts = $values['ticketParts']; - $this->totalCount = $values['totalCount']; + $this->type = $values['type'] ?? null; + $this->ticketParts = $values['ticketParts'] ?? null; + $this->totalCount = $values['totalCount'] ?? null; } /** - * @return 'ticket_part.list' + * @return ?'ticket_part.list' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'ticket_part.list' $value + * @param ?'ticket_part.list' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return array + * @return ?array */ - public function getTicketParts(): array + public function getTicketParts(): ?array { return $this->ticketParts; } /** - * @param array $value + * @param ?array $value */ - public function setTicketParts(array $value): self + public function setTicketParts(?array $value = null): self { $this->ticketParts = $value; return $this; } /** - * @return int + * @return ?int */ - public function getTotalCount(): int + public function getTotalCount(): ?int { return $this->totalCount; } /** - * @param int $value + * @param ?int $value */ - public function setTotalCount(int $value): self + public function setTotalCount(?int $value = null): self { $this->totalCount = $value; return $this; diff --git a/src/Types/TicketReply.php b/src/Types/TicketReply.php index c2439b7..96bc10e 100644 --- a/src/Types/TicketReply.php +++ b/src/Types/TicketReply.php @@ -12,22 +12,22 @@ class TicketReply extends JsonSerializableType { /** - * @var 'ticket_part' $type Always ticket_part + * @var ?'ticket_part' $type Always ticket_part */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var string $id The id representing the part. + * @var ?string $id The id representing the part. */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** - * @var value-of $partType Type of the part + * @var ?value-of $partType Type of the part */ #[JsonProperty('part_type')] - private string $partType; + private ?string $partType; /** * @var ?string $body The message body, which may contain HTML. @@ -36,10 +36,10 @@ class TicketReply extends JsonSerializableType private ?string $body; /** - * @var int $createdAt The time the note was created. + * @var ?int $createdAt The time the note was created. */ #[JsonProperty('created_at')] - private int $createdAt; + private ?int $createdAt; /** * @var ?int $updatedAt The last time the note was updated. @@ -67,11 +67,11 @@ class TicketReply extends JsonSerializableType /** * @param array{ - * type: 'ticket_part', - * id: string, - * partType: value-of, - * createdAt: int, + * type?: ?'ticket_part', + * id?: ?string, + * partType?: ?value-of, * body?: ?string, + * createdAt?: ?int, * updatedAt?: ?int, * author?: ?TicketPartAuthor, * attachments?: ?array, @@ -79,13 +79,13 @@ class TicketReply extends JsonSerializableType * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->id = $values['id']; - $this->partType = $values['partType']; + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->partType = $values['partType'] ?? null; $this->body = $values['body'] ?? null; - $this->createdAt = $values['createdAt']; + $this->createdAt = $values['createdAt'] ?? null; $this->updatedAt = $values['updatedAt'] ?? null; $this->author = $values['author'] ?? null; $this->attachments = $values['attachments'] ?? null; @@ -93,51 +93,51 @@ public function __construct( } /** - * @return 'ticket_part' + * @return ?'ticket_part' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'ticket_part' $value + * @param ?'ticket_part' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; } /** - * @return value-of + * @return ?value-of */ - public function getPartType(): string + public function getPartType(): ?string { return $this->partType; } /** - * @param value-of $value + * @param ?value-of $value */ - public function setPartType(string $value): self + public function setPartType(?string $value = null): self { $this->partType = $value; return $this; @@ -161,17 +161,17 @@ public function setBody(?string $value = null): self } /** - * @return int + * @return ?int */ - public function getCreatedAt(): int + public function getCreatedAt(): ?int { return $this->createdAt; } /** - * @param int $value + * @param ?int $value */ - public function setCreatedAt(int $value): self + public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; return $this; diff --git a/src/Types/TicketStateList.php b/src/Types/TicketStateList.php new file mode 100644 index 0000000..7e42c02 --- /dev/null +++ b/src/Types/TicketStateList.php @@ -0,0 +1,82 @@ + $data A list of ticket states associated with a given ticket type. + */ + #[JsonProperty('data'), ArrayType([new Union(TicketStateDetailed::class, 'null')])] + private ?array $data; + + /** + * @param array{ + * type?: ?string, + * data?: ?array, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->type = $values['type'] ?? null; + $this->data = $values['data'] ?? null; + } + + /** + * @return ?string + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?string $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?array + */ + public function getData(): ?array + { + return $this->data; + } + + /** + * @param ?array $value + */ + public function setData(?array $value = null): self + { + $this->data = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/TicketTypeAttribute.php b/src/Types/TicketTypeAttribute.php index 0920322..757aa5f 100644 --- a/src/Types/TicketTypeAttribute.php +++ b/src/Types/TicketTypeAttribute.php @@ -12,100 +12,100 @@ class TicketTypeAttribute extends JsonSerializableType { /** - * @var 'ticket_type_attribute' $type String representing the object's type. Always has the value `ticket_type_attribute`. + * @var ?string $type String representing the object's type. Always has the value `ticket_type_attribute`. */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var string $id The id representing the ticket type attribute. + * @var ?string $id The id representing the ticket type attribute. */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** - * @var string $workspaceId The id of the workspace that the ticket type attribute belongs to. + * @var ?string $workspaceId The id of the workspace that the ticket type attribute belongs to. */ #[JsonProperty('workspace_id')] - private string $workspaceId; + private ?string $workspaceId; /** - * @var string $name The name of the ticket type attribute + * @var ?string $name The name of the ticket type attribute */ #[JsonProperty('name')] - private string $name; + private ?string $name; /** - * @var string $description The description of the ticket type attribute + * @var ?string $description The description of the ticket type attribute */ #[JsonProperty('description')] - private string $description; + private ?string $description; /** - * @var value-of $dataType The type of the data attribute (allowed values: "string list integer decimal boolean datetime files") + * @var ?value-of $dataType The type of the data attribute (allowed values: "string list integer decimal boolean datetime files") */ #[JsonProperty('data_type')] - private string $dataType; + private ?string $dataType; /** - * @var array $inputOptions Input options for the attribute + * @var ?array $inputOptions Input options for the attribute */ #[JsonProperty('input_options'), ArrayType(['string' => 'mixed'])] - private array $inputOptions; + private ?array $inputOptions; /** - * @var int $order The order of the attribute against other attributes + * @var ?int $order The order of the attribute against other attributes */ #[JsonProperty('order')] - private int $order; + private ?int $order; /** - * @var bool $requiredToCreate Whether the attribute is required or not for teammates. + * @var ?bool $requiredToCreate Whether the attribute is required or not for teammates. */ #[JsonProperty('required_to_create')] - private bool $requiredToCreate; + private ?bool $requiredToCreate; /** - * @var bool $requiredToCreateForContacts Whether the attribute is required or not for contacts. + * @var ?bool $requiredToCreateForContacts Whether the attribute is required or not for contacts. */ #[JsonProperty('required_to_create_for_contacts')] - private bool $requiredToCreateForContacts; + private ?bool $requiredToCreateForContacts; /** - * @var bool $visibleOnCreate Whether the attribute is visible or not to teammates. + * @var ?bool $visibleOnCreate Whether the attribute is visible or not to teammates. */ #[JsonProperty('visible_on_create')] - private bool $visibleOnCreate; + private ?bool $visibleOnCreate; /** - * @var bool $visibleToContacts Whether the attribute is visible or not to contacts. + * @var ?bool $visibleToContacts Whether the attribute is visible or not to contacts. */ #[JsonProperty('visible_to_contacts')] - private bool $visibleToContacts; + private ?bool $visibleToContacts; /** - * @var bool $default Whether the attribute is built in or not. + * @var ?bool $default Whether the attribute is built in or not. */ #[JsonProperty('default')] - private bool $default; + private ?bool $default; /** - * @var int $ticketTypeId The id of the ticket type that the attribute belongs to. + * @var ?int $ticketTypeId The id of the ticket type that the attribute belongs to. */ #[JsonProperty('ticket_type_id')] - private int $ticketTypeId; + private ?int $ticketTypeId; /** - * @var bool $archived Whether the ticket type attribute is archived or not. + * @var ?bool $archived Whether the ticket type attribute is archived or not. */ #[JsonProperty('archived')] - private bool $archived; + private ?bool $archived; /** - * @var int $createdAt The date and time the ticket type attribute was created. + * @var ?int $createdAt The date and time the ticket type attribute was created. */ #[JsonProperty('created_at')] - private int $createdAt; + private ?int $createdAt; /** * @var ?int $updatedAt The date and time the ticket type attribute was last updated. @@ -115,314 +115,314 @@ class TicketTypeAttribute extends JsonSerializableType /** * @param array{ - * type: 'ticket_type_attribute', - * id: string, - * workspaceId: string, - * name: string, - * description: string, - * dataType: value-of, - * inputOptions: array, - * order: int, - * requiredToCreate: bool, - * requiredToCreateForContacts: bool, - * visibleOnCreate: bool, - * visibleToContacts: bool, - * default: bool, - * ticketTypeId: int, - * archived: bool, - * createdAt: int, + * type?: ?string, + * id?: ?string, + * workspaceId?: ?string, + * name?: ?string, + * description?: ?string, + * dataType?: ?value-of, + * inputOptions?: ?array, + * order?: ?int, + * requiredToCreate?: ?bool, + * requiredToCreateForContacts?: ?bool, + * visibleOnCreate?: ?bool, + * visibleToContacts?: ?bool, + * default?: ?bool, + * ticketTypeId?: ?int, + * archived?: ?bool, + * createdAt?: ?int, * updatedAt?: ?int, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->id = $values['id']; - $this->workspaceId = $values['workspaceId']; - $this->name = $values['name']; - $this->description = $values['description']; - $this->dataType = $values['dataType']; - $this->inputOptions = $values['inputOptions']; - $this->order = $values['order']; - $this->requiredToCreate = $values['requiredToCreate']; - $this->requiredToCreateForContacts = $values['requiredToCreateForContacts']; - $this->visibleOnCreate = $values['visibleOnCreate']; - $this->visibleToContacts = $values['visibleToContacts']; - $this->default = $values['default']; - $this->ticketTypeId = $values['ticketTypeId']; - $this->archived = $values['archived']; - $this->createdAt = $values['createdAt']; + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->workspaceId = $values['workspaceId'] ?? null; + $this->name = $values['name'] ?? null; + $this->description = $values['description'] ?? null; + $this->dataType = $values['dataType'] ?? null; + $this->inputOptions = $values['inputOptions'] ?? null; + $this->order = $values['order'] ?? null; + $this->requiredToCreate = $values['requiredToCreate'] ?? null; + $this->requiredToCreateForContacts = $values['requiredToCreateForContacts'] ?? null; + $this->visibleOnCreate = $values['visibleOnCreate'] ?? null; + $this->visibleToContacts = $values['visibleToContacts'] ?? null; + $this->default = $values['default'] ?? null; + $this->ticketTypeId = $values['ticketTypeId'] ?? null; + $this->archived = $values['archived'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; $this->updatedAt = $values['updatedAt'] ?? null; } /** - * @return 'ticket_type_attribute' + * @return ?string */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'ticket_type_attribute' $value + * @param ?string $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; } /** - * @return string + * @return ?string */ - public function getWorkspaceId(): string + public function getWorkspaceId(): ?string { return $this->workspaceId; } /** - * @param string $value + * @param ?string $value */ - public function setWorkspaceId(string $value): self + public function setWorkspaceId(?string $value = null): self { $this->workspaceId = $value; return $this; } /** - * @return string + * @return ?string */ - public function getName(): string + public function getName(): ?string { return $this->name; } /** - * @param string $value + * @param ?string $value */ - public function setName(string $value): self + public function setName(?string $value = null): self { $this->name = $value; return $this; } /** - * @return string + * @return ?string */ - public function getDescription(): string + public function getDescription(): ?string { return $this->description; } /** - * @param string $value + * @param ?string $value */ - public function setDescription(string $value): self + public function setDescription(?string $value = null): self { $this->description = $value; return $this; } /** - * @return value-of + * @return ?value-of */ - public function getDataType(): string + public function getDataType(): ?string { return $this->dataType; } /** - * @param value-of $value + * @param ?value-of $value */ - public function setDataType(string $value): self + public function setDataType(?string $value = null): self { $this->dataType = $value; return $this; } /** - * @return array + * @return ?array */ - public function getInputOptions(): array + public function getInputOptions(): ?array { return $this->inputOptions; } /** - * @param array $value + * @param ?array $value */ - public function setInputOptions(array $value): self + public function setInputOptions(?array $value = null): self { $this->inputOptions = $value; return $this; } /** - * @return int + * @return ?int */ - public function getOrder(): int + public function getOrder(): ?int { return $this->order; } /** - * @param int $value + * @param ?int $value */ - public function setOrder(int $value): self + public function setOrder(?int $value = null): self { $this->order = $value; return $this; } /** - * @return bool + * @return ?bool */ - public function getRequiredToCreate(): bool + public function getRequiredToCreate(): ?bool { return $this->requiredToCreate; } /** - * @param bool $value + * @param ?bool $value */ - public function setRequiredToCreate(bool $value): self + public function setRequiredToCreate(?bool $value = null): self { $this->requiredToCreate = $value; return $this; } /** - * @return bool + * @return ?bool */ - public function getRequiredToCreateForContacts(): bool + public function getRequiredToCreateForContacts(): ?bool { return $this->requiredToCreateForContacts; } /** - * @param bool $value + * @param ?bool $value */ - public function setRequiredToCreateForContacts(bool $value): self + public function setRequiredToCreateForContacts(?bool $value = null): self { $this->requiredToCreateForContacts = $value; return $this; } /** - * @return bool + * @return ?bool */ - public function getVisibleOnCreate(): bool + public function getVisibleOnCreate(): ?bool { return $this->visibleOnCreate; } /** - * @param bool $value + * @param ?bool $value */ - public function setVisibleOnCreate(bool $value): self + public function setVisibleOnCreate(?bool $value = null): self { $this->visibleOnCreate = $value; return $this; } /** - * @return bool + * @return ?bool */ - public function getVisibleToContacts(): bool + public function getVisibleToContacts(): ?bool { return $this->visibleToContacts; } /** - * @param bool $value + * @param ?bool $value */ - public function setVisibleToContacts(bool $value): self + public function setVisibleToContacts(?bool $value = null): self { $this->visibleToContacts = $value; return $this; } /** - * @return bool + * @return ?bool */ - public function getDefault(): bool + public function getDefault(): ?bool { return $this->default; } /** - * @param bool $value + * @param ?bool $value */ - public function setDefault(bool $value): self + public function setDefault(?bool $value = null): self { $this->default = $value; return $this; } /** - * @return int + * @return ?int */ - public function getTicketTypeId(): int + public function getTicketTypeId(): ?int { return $this->ticketTypeId; } /** - * @param int $value + * @param ?int $value */ - public function setTicketTypeId(int $value): self + public function setTicketTypeId(?int $value = null): self { $this->ticketTypeId = $value; return $this; } /** - * @return bool + * @return ?bool */ - public function getArchived(): bool + public function getArchived(): ?bool { return $this->archived; } /** - * @param bool $value + * @param ?bool $value */ - public function setArchived(bool $value): self + public function setArchived(?bool $value = null): self { $this->archived = $value; return $this; } /** - * @return int + * @return ?int */ - public function getCreatedAt(): int + public function getCreatedAt(): ?int { return $this->createdAt; } /** - * @param int $value + * @param ?int $value */ - public function setCreatedAt(int $value): self + public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; return $this; diff --git a/src/Types/TicketTypeAttributeList.php b/src/Types/TicketTypeAttributeList.php index 7e23379..e153db8 100644 --- a/src/Types/TicketTypeAttributeList.php +++ b/src/Types/TicketTypeAttributeList.php @@ -5,6 +5,7 @@ use Intercom\Core\Json\JsonSerializableType; use Intercom\Core\Json\JsonProperty; use Intercom\Core\Types\ArrayType; +use Intercom\Core\Types\Union; /** * A list of attributes associated with a given ticket type. @@ -12,59 +13,59 @@ class TicketTypeAttributeList extends JsonSerializableType { /** - * @var 'ticket_type_attributes.list' $type String representing the object's type. Always has the value `ticket_type_attributes.list`. + * @var ?string $type String representing the object's type. Always has the value `ticket_type_attributes.list`. */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var array $ticketTypeAttributes A list of ticket type attributes associated with a given ticket type. + * @var ?array $ticketTypeAttributes A list of ticket type attributes associated with a given ticket type. */ - #[JsonProperty('ticket_type_attributes'), ArrayType([TicketTypeAttribute::class])] - private array $ticketTypeAttributes; + #[JsonProperty('ticket_type_attributes'), ArrayType([new Union(TicketTypeAttribute::class, 'null')])] + private ?array $ticketTypeAttributes; /** * @param array{ - * type: 'ticket_type_attributes.list', - * ticketTypeAttributes: array, + * type?: ?string, + * ticketTypeAttributes?: ?array, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->ticketTypeAttributes = $values['ticketTypeAttributes']; + $this->type = $values['type'] ?? null; + $this->ticketTypeAttributes = $values['ticketTypeAttributes'] ?? null; } /** - * @return 'ticket_type_attributes.list' + * @return ?string */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'ticket_type_attributes.list' $value + * @param ?string $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return array + * @return ?array */ - public function getTicketTypeAttributes(): array + public function getTicketTypeAttributes(): ?array { return $this->ticketTypeAttributes; } /** - * @param array $value + * @param ?array $value */ - public function setTicketTypeAttributes(array $value): self + public function setTicketTypeAttributes(?array $value = null): self { $this->ticketTypeAttributes = $value; return $this; diff --git a/src/Types/TicketTypeList.php b/src/Types/TicketTypeList.php index 53612bb..15f57f4 100644 --- a/src/Types/TicketTypeList.php +++ b/src/Types/TicketTypeList.php @@ -6,6 +6,7 @@ use Intercom\Core\Json\JsonProperty; use Intercom\Tickets\Types\TicketType; use Intercom\Core\Types\ArrayType; +use Intercom\Core\Types\Union; /** * A list of ticket types associated with a given workspace. @@ -13,61 +14,61 @@ class TicketTypeList extends JsonSerializableType { /** - * @var 'ticket_type_attributes.list' $type String representing the object's type. Always has the value `ticket_type.list`. + * @var ?string $type String representing the object's type. Always has the value `list`. */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var array $ticketTypes A list of ticket_types associated with a given workspace. + * @var ?array $data A list of ticket_types associated with a given workspace. */ - #[JsonProperty('ticket_types'), ArrayType([TicketType::class])] - private array $ticketTypes; + #[JsonProperty('data'), ArrayType([new Union(TicketType::class, 'null')])] + private ?array $data; /** * @param array{ - * type: 'ticket_type_attributes.list', - * ticketTypes: array, + * type?: ?string, + * data?: ?array, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->ticketTypes = $values['ticketTypes']; + $this->type = $values['type'] ?? null; + $this->data = $values['data'] ?? null; } /** - * @return 'ticket_type_attributes.list' + * @return ?string */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'ticket_type_attributes.list' $value + * @param ?string $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return array + * @return ?array */ - public function getTicketTypes(): array + public function getData(): ?array { - return $this->ticketTypes; + return $this->data; } /** - * @param array $value + * @param ?array $value */ - public function setTicketTypes(array $value): self + public function setData(?array $value = null): self { - $this->ticketTypes = $value; + $this->data = $value; return $this; } diff --git a/src/Types/Translation.php b/src/Types/Translation.php index 8be582a..7b98448 100644 --- a/src/Types/Translation.php +++ b/src/Types/Translation.php @@ -11,84 +11,84 @@ class Translation extends JsonSerializableType { /** - * @var string $name The localised name of the subscription type. + * @var ?string $name The localised name of the subscription type. */ #[JsonProperty('name')] - private string $name; + private ?string $name; /** - * @var string $description The localised description of the subscription type. + * @var ?string $description The localised description of the subscription type. */ #[JsonProperty('description')] - private string $description; + private ?string $description; /** - * @var string $locale The two character identifier for the language of the translation object. + * @var ?string $locale The two character identifier for the language of the translation object. */ #[JsonProperty('locale')] - private string $locale; + private ?string $locale; /** * @param array{ - * name: string, - * description: string, - * locale: string, + * name?: ?string, + * description?: ?string, + * locale?: ?string, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->name = $values['name']; - $this->description = $values['description']; - $this->locale = $values['locale']; + $this->name = $values['name'] ?? null; + $this->description = $values['description'] ?? null; + $this->locale = $values['locale'] ?? null; } /** - * @return string + * @return ?string */ - public function getName(): string + public function getName(): ?string { return $this->name; } /** - * @param string $value + * @param ?string $value */ - public function setName(string $value): self + public function setName(?string $value = null): self { $this->name = $value; return $this; } /** - * @return string + * @return ?string */ - public function getDescription(): string + public function getDescription(): ?string { return $this->description; } /** - * @param string $value + * @param ?string $value */ - public function setDescription(string $value): self + public function setDescription(?string $value = null): self { $this->description = $value; return $this; } /** - * @return string + * @return ?string */ - public function getLocale(): string + public function getLocale(): ?string { return $this->locale; } /** - * @param string $value + * @param ?string $value */ - public function setLocale(string $value): self + public function setLocale(?string $value = null): self { $this->locale = $value; return $this; diff --git a/src/Types/UntagCompanyRequestCompaniesItem.php b/src/Types/UntagCompanyRequestCompaniesItem.php index badf1b7..7f12d76 100644 --- a/src/Types/UntagCompanyRequestCompaniesItem.php +++ b/src/Types/UntagCompanyRequestCompaniesItem.php @@ -8,84 +8,84 @@ class UntagCompanyRequestCompaniesItem extends JsonSerializableType { /** - * @var string $id The Intercom defined id representing the company. + * @var ?string $id The Intercom defined id representing the company. */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** - * @var string $companyId The company id you have defined for the company. + * @var ?string $companyId The company id you have defined for the company. */ #[JsonProperty('company_id')] - private string $companyId; + private ?string $companyId; /** - * @var true $untag Always set to true + * @var ?bool $untag Always set to true */ #[JsonProperty('untag')] - private bool $untag; + private ?bool $untag; /** * @param array{ - * id: string, - * companyId: string, - * untag: true, + * id?: ?string, + * companyId?: ?string, + * untag?: ?bool, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->id = $values['id']; - $this->companyId = $values['companyId']; - $this->untag = $values['untag']; + $this->id = $values['id'] ?? null; + $this->companyId = $values['companyId'] ?? null; + $this->untag = $values['untag'] ?? null; } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; } /** - * @return string + * @return ?string */ - public function getCompanyId(): string + public function getCompanyId(): ?string { return $this->companyId; } /** - * @param string $value + * @param ?string $value */ - public function setCompanyId(string $value): self + public function setCompanyId(?string $value = null): self { $this->companyId = $value; return $this; } /** - * @return true + * @return ?bool */ - public function getUntag(): bool + public function getUntag(): ?bool { return $this->untag; } /** - * @param true $value + * @param ?bool $value */ - public function setUntag(bool $value): self + public function setUntag(?bool $value = null): self { $this->untag = $value; return $this; diff --git a/src/Types/UpdateArticleRequestBody.php b/src/Types/UpdateArticleRequestBody.php new file mode 100644 index 0000000..f22bdf0 --- /dev/null +++ b/src/Types/UpdateArticleRequestBody.php @@ -0,0 +1,51 @@ + $parentType + */ + #[JsonProperty('parent_type')] + private ?string $parentType; + + /** + * @param array{ + * parentType?: ?value-of, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->parentType = $values['parentType'] ?? null; + } + + /** + * @return ?value-of + */ + public function getParentType(): ?string + { + return $this->parentType; + } + + /** + * @param ?value-of $value + */ + public function setParentType(?string $value = null): self + { + $this->parentType = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Articles/Types/UpdateArticleRequestBodyParentType.php b/src/Types/UpdateArticleRequestBodyParentType.php similarity index 78% rename from src/Articles/Types/UpdateArticleRequestBodyParentType.php rename to src/Types/UpdateArticleRequestBodyParentType.php index 374f62b..116289c 100644 --- a/src/Articles/Types/UpdateArticleRequestBodyParentType.php +++ b/src/Types/UpdateArticleRequestBodyParentType.php @@ -1,6 +1,6 @@ $customAttributes A hash of key/value pairs containing any other data about the company you want Intercom to store. + */ + #[JsonProperty('custom_attributes'), ArrayType(['string' => 'string'])] + private ?array $customAttributes; + + /** + * @var ?int $monthlySpend 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')] + private ?int $monthlySpend; + + /** + * @param array{ + * name?: ?string, + * plan?: ?string, + * size?: ?int, + * website?: ?string, + * industry?: ?string, + * customAttributes?: ?array, + * monthlySpend?: ?int, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->name = $values['name'] ?? null; + $this->plan = $values['plan'] ?? null; + $this->size = $values['size'] ?? null; + $this->website = $values['website'] ?? null; + $this->industry = $values['industry'] ?? null; + $this->customAttributes = $values['customAttributes'] ?? null; + $this->monthlySpend = $values['monthlySpend'] ?? null; + } + + /** + * @return ?string + */ + public function getName(): ?string + { + return $this->name; + } + + /** + * @param ?string $value + */ + public function setName(?string $value = null): self + { + $this->name = $value; + return $this; + } + + /** + * @return ?string + */ + public function getPlan(): ?string + { + return $this->plan; + } + + /** + * @param ?string $value + */ + public function setPlan(?string $value = null): self + { + $this->plan = $value; + return $this; + } + + /** + * @return ?int + */ + public function getSize(): ?int + { + return $this->size; + } + + /** + * @param ?int $value + */ + public function setSize(?int $value = null): self + { + $this->size = $value; + return $this; + } + + /** + * @return ?string + */ + public function getWebsite(): ?string + { + return $this->website; + } + + /** + * @param ?string $value + */ + public function setWebsite(?string $value = null): self + { + $this->website = $value; + return $this; + } + + /** + * @return ?string + */ + public function getIndustry(): ?string + { + return $this->industry; + } + + /** + * @param ?string $value + */ + public function setIndustry(?string $value = null): self + { + $this->industry = $value; + return $this; + } + + /** + * @return ?array + */ + public function getCustomAttributes(): ?array + { + return $this->customAttributes; + } + + /** + * @param ?array $value + */ + public function setCustomAttributes(?array $value = null): self + { + $this->customAttributes = $value; + return $this; + } + + /** + * @return ?int + */ + public function getMonthlySpend(): ?int + { + return $this->monthlySpend; + } + + /** + * @param ?int $value + */ + public function setMonthlySpend(?int $value = null): self + { + $this->monthlySpend = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/UpdateDataAttributeRequestOptions.php b/src/Types/UpdateDataAttributeRequestOptions.php new file mode 100644 index 0000000..fa5e0b2 --- /dev/null +++ b/src/Types/UpdateDataAttributeRequestOptions.php @@ -0,0 +1,52 @@ + $options Array of objects representing the options of the list, with `value` as the key and the option as the value. At least two options are required. + */ + #[JsonProperty('options'), ArrayType([UpdateDataAttributeRequestOptionsOptionsItem::class])] + private array $options; + + /** + * @param array{ + * options: array, + * } $values + */ + public function __construct( + array $values, + ) { + $this->options = $values['options']; + } + + /** + * @return array + */ + public function getOptions(): array + { + return $this->options; + } + + /** + * @param array $value + */ + public function setOptions(array $value): self + { + $this->options = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/UpdateDataAttributeRequestOptionsOptionsItem.php b/src/Types/UpdateDataAttributeRequestOptionsOptionsItem.php new file mode 100644 index 0000000..cd8485d --- /dev/null +++ b/src/Types/UpdateDataAttributeRequestOptionsOptionsItem.php @@ -0,0 +1,51 @@ +value = $values['value'] ?? null; + } + + /** + * @return ?string + */ + public function getValue(): ?string + { + return $this->value; + } + + /** + * @param ?string $value + */ + public function setValue(?string $value = null): self + { + $this->value = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/UrlActionComponent.php b/src/Types/UrlActionComponent.php deleted file mode 100644 index fcac878..0000000 --- a/src/Types/UrlActionComponent.php +++ /dev/null @@ -1,54 +0,0 @@ -url = $values['url']; - } - - /** - * @return string - */ - public function getUrl(): string - { - return $this->url; - } - - /** - * @param string $value - */ - public function setUrl(string $value): self - { - $this->url = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/Visitor.php b/src/Types/Visitor.php index 05a9dd9..8ebfa5a 100644 --- a/src/Types/Visitor.php +++ b/src/Types/Visitor.php @@ -12,34 +12,34 @@ class Visitor extends JsonSerializableType { /** - * @var 'visitor' $type Value is 'visitor' + * @var ?'visitor' $type Value is 'visitor' */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var string $id The Intercom defined id representing the Visitor. + * @var ?string $id The Intercom defined id representing the Visitor. */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** - * @var string $userId Automatically generated identifier for the Visitor. + * @var ?string $userId Automatically generated identifier for the Visitor. */ #[JsonProperty('user_id')] - private string $userId; + private ?string $userId; /** - * @var bool $anonymous Identifies if this visitor is anonymous. + * @var ?bool $anonymous Identifies if this visitor is anonymous. */ #[JsonProperty('anonymous')] - private bool $anonymous; + private ?bool $anonymous; /** - * @var string $email The email of the visitor. + * @var ?string $email The email of the visitor. */ #[JsonProperty('email')] - private string $email; + private ?string $email; /** * @var ?string $phone The phone number of the visitor. @@ -66,10 +66,10 @@ class Visitor extends JsonSerializableType private ?VisitorAvatar $avatar; /** - * @var string $appId The id of the app the visitor is associated with. + * @var ?string $appId The id of the app the visitor is associated with. */ #[JsonProperty('app_id')] - private string $appId; + private ?string $appId; /** * @var ?VisitorCompanies $companies @@ -90,10 +90,10 @@ class Visitor extends JsonSerializableType private ?int $lasRequestAt; /** - * @var int $createdAt The time the Visitor was added to Intercom. + * @var ?int $createdAt The time the Visitor was added to Intercom. */ #[JsonProperty('created_at')] - private int $createdAt; + private ?int $createdAt; /** * @var ?int $remoteCreatedAt The time the Visitor was added to Intercom. @@ -102,10 +102,10 @@ class Visitor extends JsonSerializableType private ?int $remoteCreatedAt; /** - * @var int $signedUpAt The time the Visitor signed up for your product. + * @var ?int $signedUpAt The time the Visitor signed up for your product. */ #[JsonProperty('signed_up_at')] - private int $signedUpAt; + private ?int $signedUpAt; /** * @var ?int $updatedAt The last time the Visitor was updated. @@ -211,22 +211,22 @@ class Visitor extends JsonSerializableType /** * @param array{ - * type: 'visitor', - * id: string, - * userId: string, - * anonymous: bool, - * email: string, - * appId: string, - * createdAt: int, - * signedUpAt: int, + * type?: ?'visitor', + * id?: ?string, + * userId?: ?string, + * anonymous?: ?bool, + * email?: ?string, * phone?: ?string, * name?: ?string, * pseudonym?: ?string, * avatar?: ?VisitorAvatar, + * appId?: ?string, * companies?: ?VisitorCompanies, * locationData?: ?VisitorLocationData, * lasRequestAt?: ?int, + * createdAt?: ?int, * remoteCreatedAt?: ?int, + * signedUpAt?: ?int, * updatedAt?: ?int, * sessionCount?: ?int, * socialProfiles?: ?VisitorSocialProfiles, @@ -247,24 +247,24 @@ class Visitor extends JsonSerializableType * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->id = $values['id']; - $this->userId = $values['userId']; - $this->anonymous = $values['anonymous']; - $this->email = $values['email']; + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->userId = $values['userId'] ?? null; + $this->anonymous = $values['anonymous'] ?? null; + $this->email = $values['email'] ?? null; $this->phone = $values['phone'] ?? null; $this->name = $values['name'] ?? null; $this->pseudonym = $values['pseudonym'] ?? null; $this->avatar = $values['avatar'] ?? null; - $this->appId = $values['appId']; + $this->appId = $values['appId'] ?? null; $this->companies = $values['companies'] ?? null; $this->locationData = $values['locationData'] ?? null; $this->lasRequestAt = $values['lasRequestAt'] ?? null; - $this->createdAt = $values['createdAt']; + $this->createdAt = $values['createdAt'] ?? null; $this->remoteCreatedAt = $values['remoteCreatedAt'] ?? null; - $this->signedUpAt = $values['signedUpAt']; + $this->signedUpAt = $values['signedUpAt'] ?? null; $this->updatedAt = $values['updatedAt'] ?? null; $this->sessionCount = $values['sessionCount'] ?? null; $this->socialProfiles = $values['socialProfiles'] ?? null; @@ -285,85 +285,85 @@ public function __construct( } /** - * @return 'visitor' + * @return ?'visitor' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'visitor' $value + * @param ?'visitor' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; } /** - * @return string + * @return ?string */ - public function getUserId(): string + public function getUserId(): ?string { return $this->userId; } /** - * @param string $value + * @param ?string $value */ - public function setUserId(string $value): self + public function setUserId(?string $value = null): self { $this->userId = $value; return $this; } /** - * @return bool + * @return ?bool */ - public function getAnonymous(): bool + public function getAnonymous(): ?bool { return $this->anonymous; } /** - * @param bool $value + * @param ?bool $value */ - public function setAnonymous(bool $value): self + public function setAnonymous(?bool $value = null): self { $this->anonymous = $value; return $this; } /** - * @return string + * @return ?string */ - public function getEmail(): string + public function getEmail(): ?string { return $this->email; } /** - * @param string $value + * @param ?string $value */ - public function setEmail(string $value): self + public function setEmail(?string $value = null): self { $this->email = $value; return $this; @@ -438,17 +438,17 @@ public function setAvatar(?VisitorAvatar $value = null): self } /** - * @return string + * @return ?string */ - public function getAppId(): string + public function getAppId(): ?string { return $this->appId; } /** - * @param string $value + * @param ?string $value */ - public function setAppId(string $value): self + public function setAppId(?string $value = null): self { $this->appId = $value; return $this; @@ -506,17 +506,17 @@ public function setLasRequestAt(?int $value = null): self } /** - * @return int + * @return ?int */ - public function getCreatedAt(): int + public function getCreatedAt(): ?int { return $this->createdAt; } /** - * @param int $value + * @param ?int $value */ - public function setCreatedAt(int $value): self + public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; return $this; @@ -540,17 +540,17 @@ public function setRemoteCreatedAt(?int $value = null): self } /** - * @return int + * @return ?int */ - public function getSignedUpAt(): int + public function getSignedUpAt(): ?int { return $this->signedUpAt; } /** - * @param int $value + * @param ?int $value */ - public function setSignedUpAt(int $value): self + public function setSignedUpAt(?int $value = null): self { $this->signedUpAt = $value; return $this; diff --git a/src/Types/VisitorDeletedObject.php b/src/Types/VisitorDeletedObject.php index 4b9d586..b90fc8f 100644 --- a/src/Types/VisitorDeletedObject.php +++ b/src/Types/VisitorDeletedObject.php @@ -11,84 +11,84 @@ class VisitorDeletedObject extends JsonSerializableType { /** - * @var string $id The unique identifier for the visitor which is given by Intercom. + * @var ?string $id The unique identifier for the visitor which is given by Intercom. */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** - * @var 'visitor' $type The type of object which was deleted + * @var ?'visitor' $type The type of object which was deleted */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var string $userId Automatically generated identifier for the Visitor. + * @var ?string $userId Automatically generated identifier for the Visitor. */ #[JsonProperty('user_id')] - private string $userId; + private ?string $userId; /** * @param array{ - * id: string, - * type: 'visitor', - * userId: string, + * id?: ?string, + * type?: ?'visitor', + * userId?: ?string, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->id = $values['id']; - $this->type = $values['type']; - $this->userId = $values['userId']; + $this->id = $values['id'] ?? null; + $this->type = $values['type'] ?? null; + $this->userId = $values['userId'] ?? null; } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; } /** - * @return 'visitor' + * @return ?'visitor' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'visitor' $value + * @param ?'visitor' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return string + * @return ?string */ - public function getUserId(): string + public function getUserId(): ?string { return $this->userId; } /** - * @param string $value + * @param ?string $value */ - public function setUserId(string $value): self + public function setUserId(?string $value = null): self { $this->userId = $value; return $this; diff --git a/src/Types/WhatsappMessageStatusList.php b/src/Types/WhatsappMessageStatusList.php new file mode 100644 index 0000000..8ff477a --- /dev/null +++ b/src/Types/WhatsappMessageStatusList.php @@ -0,0 +1,152 @@ + $events + */ + #[JsonProperty('events'), ArrayType([WhatsappMessageStatusListEventsItem::class])] + private array $events; + + /** + * @param array{ + * type: 'list', + * rulesetId: string, + * pages: WhatsappMessageStatusListPages, + * totalCount: int, + * events: array, + * } $values + */ + public function __construct( + array $values, + ) { + $this->type = $values['type']; + $this->rulesetId = $values['rulesetId']; + $this->pages = $values['pages']; + $this->totalCount = $values['totalCount']; + $this->events = $values['events']; + } + + /** + * @return 'list' + */ + public function getType(): string + { + return $this->type; + } + + /** + * @param 'list' $value + */ + public function setType(string $value): self + { + $this->type = $value; + return $this; + } + + /** + * @return string + */ + public function getRulesetId(): string + { + return $this->rulesetId; + } + + /** + * @param string $value + */ + public function setRulesetId(string $value): self + { + $this->rulesetId = $value; + return $this; + } + + /** + * @return WhatsappMessageStatusListPages + */ + public function getPages(): WhatsappMessageStatusListPages + { + return $this->pages; + } + + /** + * @param WhatsappMessageStatusListPages $value + */ + public function setPages(WhatsappMessageStatusListPages $value): self + { + $this->pages = $value; + return $this; + } + + /** + * @return int + */ + public function getTotalCount(): int + { + return $this->totalCount; + } + + /** + * @param int $value + */ + public function setTotalCount(int $value): self + { + $this->totalCount = $value; + return $this; + } + + /** + * @return array + */ + public function getEvents(): array + { + return $this->events; + } + + /** + * @param array $value + */ + public function setEvents(array $value): self + { + $this->events = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/WhatsappMessageStatusListEventsItem.php b/src/Types/WhatsappMessageStatusListEventsItem.php new file mode 100644 index 0000000..9eb3715 --- /dev/null +++ b/src/Types/WhatsappMessageStatusListEventsItem.php @@ -0,0 +1,226 @@ + $status Current status of the message + */ + #[JsonProperty('status')] + private string $status; + + /** + * @var 'broadcast_outbound' $type Event type + */ + #[JsonProperty('type')] + private string $type; + + /** + * @var int $createdAt Creation timestamp + */ + #[JsonProperty('created_at')] + private int $createdAt; + + /** + * @var int $updatedAt Last update timestamp + */ + #[JsonProperty('updated_at')] + private int $updatedAt; + + /** + * @var string $whatsappMessageId WhatsApp's message identifier + */ + #[JsonProperty('whatsapp_message_id')] + private string $whatsappMessageId; + + /** + * @var ?string $templateName Name of the WhatsApp template used + */ + #[JsonProperty('template_name')] + private ?string $templateName; + + /** + * @param array{ + * id: string, + * conversationId: string, + * status: value-of, + * type: 'broadcast_outbound', + * createdAt: int, + * updatedAt: int, + * whatsappMessageId: string, + * templateName?: ?string, + * } $values + */ + public function __construct( + array $values, + ) { + $this->id = $values['id']; + $this->conversationId = $values['conversationId']; + $this->status = $values['status']; + $this->type = $values['type']; + $this->createdAt = $values['createdAt']; + $this->updatedAt = $values['updatedAt']; + $this->whatsappMessageId = $values['whatsappMessageId']; + $this->templateName = $values['templateName'] ?? null; + } + + /** + * @return string + */ + public function getId(): string + { + return $this->id; + } + + /** + * @param string $value + */ + public function setId(string $value): self + { + $this->id = $value; + return $this; + } + + /** + * @return string + */ + public function getConversationId(): string + { + return $this->conversationId; + } + + /** + * @param string $value + */ + public function setConversationId(string $value): self + { + $this->conversationId = $value; + return $this; + } + + /** + * @return value-of + */ + public function getStatus(): string + { + return $this->status; + } + + /** + * @param value-of $value + */ + public function setStatus(string $value): self + { + $this->status = $value; + return $this; + } + + /** + * @return 'broadcast_outbound' + */ + public function getType(): string + { + return $this->type; + } + + /** + * @param 'broadcast_outbound' $value + */ + public function setType(string $value): self + { + $this->type = $value; + return $this; + } + + /** + * @return int + */ + public function getCreatedAt(): int + { + return $this->createdAt; + } + + /** + * @param int $value + */ + public function setCreatedAt(int $value): self + { + $this->createdAt = $value; + return $this; + } + + /** + * @return int + */ + public function getUpdatedAt(): int + { + return $this->updatedAt; + } + + /** + * @param int $value + */ + public function setUpdatedAt(int $value): self + { + $this->updatedAt = $value; + return $this; + } + + /** + * @return string + */ + public function getWhatsappMessageId(): string + { + return $this->whatsappMessageId; + } + + /** + * @param string $value + */ + public function setWhatsappMessageId(string $value): self + { + $this->whatsappMessageId = $value; + return $this; + } + + /** + * @return ?string + */ + public function getTemplateName(): ?string + { + return $this->templateName; + } + + /** + * @param ?string $value + */ + public function setTemplateName(?string $value = null): self + { + $this->templateName = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/WhatsappMessageStatusListEventsItemStatus.php b/src/Types/WhatsappMessageStatusListEventsItemStatus.php new file mode 100644 index 0000000..d97b01e --- /dev/null +++ b/src/Types/WhatsappMessageStatusListEventsItemStatus.php @@ -0,0 +1,11 @@ +type = $values['type']; + $this->perPage = $values['perPage']; + $this->totalPages = $values['totalPages']; + $this->next = $values['next'] ?? null; + } + + /** + * @return 'pages' + */ + public function getType(): string + { + return $this->type; + } + + /** + * @param 'pages' $value + */ + public function setType(string $value): self + { + $this->type = $value; + return $this; + } + + /** + * @return int + */ + public function getPerPage(): int + { + return $this->perPage; + } + + /** + * @param int $value + */ + public function setPerPage(int $value): self + { + $this->perPage = $value; + return $this; + } + + /** + * @return int + */ + public function getTotalPages(): int + { + return $this->totalPages; + } + + /** + * @param int $value + */ + public function setTotalPages(int $value): self + { + $this->totalPages = $value; + return $this; + } + + /** + * @return ?WhatsappMessageStatusListPagesNext + */ + public function getNext(): ?WhatsappMessageStatusListPagesNext + { + return $this->next; + } + + /** + * @param ?WhatsappMessageStatusListPagesNext $value + */ + public function setNext(?WhatsappMessageStatusListPagesNext $value = null): self + { + $this->next = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/WhatsappMessageStatusListPagesNext.php b/src/Types/WhatsappMessageStatusListPagesNext.php new file mode 100644 index 0000000..1b112f4 --- /dev/null +++ b/src/Types/WhatsappMessageStatusListPagesNext.php @@ -0,0 +1,54 @@ +startingAfter = $values['startingAfter'] ?? null; + } + + /** + * @return ?string + */ + public function getStartingAfter(): ?string + { + return $this->startingAfter; + } + + /** + * @param ?string $value + */ + public function setStartingAfter(?string $value = null): self + { + $this->startingAfter = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Unstable/Admins/AdminsClient.php b/src/Unstable/Admins/AdminsClient.php index f0e6361..27ee2c5 100644 --- a/src/Unstable/Admins/AdminsClient.php +++ b/src/Unstable/Admins/AdminsClient.php @@ -29,7 +29,7 @@ class AdminsClient * maxRetries?: int, * timeout?: float, * headers?: array, - * } $options + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator */ private array $options; diff --git a/src/Unstable/AiAgent/Types/AiAgent.php b/src/Unstable/AiAgent/Types/AiAgent.php index d2a66c1..635bd82 100644 --- a/src/Unstable/AiAgent/Types/AiAgent.php +++ b/src/Unstable/AiAgent/Types/AiAgent.php @@ -24,13 +24,13 @@ class AiAgent extends JsonSerializableType private ?string $sourceTitle; /** - * @var ?string $lastAnswerType The type of the last answer delivered by AI Agent. If no answer was delivered then this will return `null` + * @var ?value-of $lastAnswerType The type of the last answer delivered by AI Agent. If no answer was delivered then this will return `null` */ #[JsonProperty('last_answer_type')] private ?string $lastAnswerType; /** - * @var ?string $resolutionState The resolution state of AI Agent. If no AI or custom answer has been delivered then this will return `null`. + * @var ?value-of $resolutionState The resolution state of AI Agent. If no AI or custom answer has been delivered then this will return `null`. */ #[JsonProperty('resolution_state')] private ?string $resolutionState; @@ -47,6 +47,18 @@ class AiAgent extends JsonSerializableType #[JsonProperty('rating_remark')] private ?string $ratingRemark; + /** + * @var ?int $createdAt The time when the AI agent rating was created. + */ + #[JsonProperty('created_at')] + private ?int $createdAt; + + /** + * @var ?int $updatedAt The time when the AI agent rating was last updated. + */ + #[JsonProperty('updated_at')] + private ?int $updatedAt; + /** * @var ?ContentSourcesList $contentSources */ @@ -57,10 +69,12 @@ class AiAgent extends JsonSerializableType * @param array{ * sourceType?: ?value-of, * sourceTitle?: ?string, - * lastAnswerType?: ?string, - * resolutionState?: ?string, + * lastAnswerType?: ?value-of, + * resolutionState?: ?value-of, * rating?: ?int, * ratingRemark?: ?string, + * createdAt?: ?int, + * updatedAt?: ?int, * contentSources?: ?ContentSourcesList, * } $values */ @@ -73,6 +87,8 @@ public function __construct( $this->resolutionState = $values['resolutionState'] ?? null; $this->rating = $values['rating'] ?? null; $this->ratingRemark = $values['ratingRemark'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; + $this->updatedAt = $values['updatedAt'] ?? null; $this->contentSources = $values['contentSources'] ?? null; } @@ -111,7 +127,7 @@ public function setSourceTitle(?string $value = null): self } /** - * @return ?string + * @return ?value-of */ public function getLastAnswerType(): ?string { @@ -119,7 +135,7 @@ public function getLastAnswerType(): ?string } /** - * @param ?string $value + * @param ?value-of $value */ public function setLastAnswerType(?string $value = null): self { @@ -128,7 +144,7 @@ public function setLastAnswerType(?string $value = null): self } /** - * @return ?string + * @return ?value-of */ public function getResolutionState(): ?string { @@ -136,7 +152,7 @@ public function getResolutionState(): ?string } /** - * @param ?string $value + * @param ?value-of $value */ public function setResolutionState(?string $value = null): self { @@ -178,6 +194,40 @@ public function setRatingRemark(?string $value = null): self return $this; } + /** + * @return ?int + */ + public function getCreatedAt(): ?int + { + return $this->createdAt; + } + + /** + * @param ?int $value + */ + public function setCreatedAt(?int $value = null): self + { + $this->createdAt = $value; + return $this; + } + + /** + * @return ?int + */ + public function getUpdatedAt(): ?int + { + return $this->updatedAt; + } + + /** + * @param ?int $value + */ + public function setUpdatedAt(?int $value = null): self + { + $this->updatedAt = $value; + return $this; + } + /** * @return ?ContentSourcesList */ diff --git a/src/Unstable/AiAgent/Types/AiAgentLastAnswerType.php b/src/Unstable/AiAgent/Types/AiAgentLastAnswerType.php new file mode 100644 index 0000000..6260a82 --- /dev/null +++ b/src/Unstable/AiAgent/Types/AiAgentLastAnswerType.php @@ -0,0 +1,9 @@ +, - * } $options + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator */ private array $options; diff --git a/src/Unstable/Articles/ArticlesClient.php b/src/Unstable/Articles/ArticlesClient.php index 51b95d1..7afaeec 100644 --- a/src/Unstable/Articles/ArticlesClient.php +++ b/src/Unstable/Articles/ArticlesClient.php @@ -29,7 +29,7 @@ class ArticlesClient * maxRetries?: int, * timeout?: float, * headers?: array, - * } $options + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator */ private array $options; diff --git a/src/Unstable/AwayStatusReasons/AwayStatusReasonsClient.php b/src/Unstable/AwayStatusReasons/AwayStatusReasonsClient.php index fd5466c..01c1bf6 100644 --- a/src/Unstable/AwayStatusReasons/AwayStatusReasonsClient.php +++ b/src/Unstable/AwayStatusReasons/AwayStatusReasonsClient.php @@ -24,7 +24,7 @@ class AwayStatusReasonsClient * maxRetries?: int, * timeout?: float, * headers?: array, - * } $options + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator */ private array $options; diff --git a/src/Unstable/Brands/BrandsClient.php b/src/Unstable/Brands/BrandsClient.php new file mode 100644 index 0000000..0143e8c --- /dev/null +++ b/src/Unstable/Brands/BrandsClient.php @@ -0,0 +1,164 @@ +, + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator + */ + private array $options; + + /** + * @var RawClient $client + */ + private RawClient $client; + + /** + * @param RawClient $client + * @param ?array{ + * baseUrl?: string, + * client?: ClientInterface, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * } $options + */ + public function __construct( + RawClient $client, + ?array $options = null, + ) { + $this->client = $client; + $this->options = $options ?? []; + } + + /** + * Retrieves all brands for the workspace, including the default brand. + * The default brand id always matches the workspace + * + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return BrandList + * @throws IntercomException + * @throws IntercomApiException + */ + public function listBrands(?array $options = null): BrandList + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "brands", + method: HttpMethod::GET, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return BrandList::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * Fetches a specific brand by its unique identifier + * + * @param RetrieveBrandRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return Brand + * @throws IntercomException + * @throws IntercomApiException + */ + public function retrieveBrand(RetrieveBrandRequest $request, ?array $options = null): Brand + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "brands/{$request->getId()}", + method: HttpMethod::GET, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return Brand::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } +} diff --git a/src/Unstable/Brands/Requests/RetrieveBrandRequest.php b/src/Unstable/Brands/Requests/RetrieveBrandRequest.php new file mode 100644 index 0000000..4341267 --- /dev/null +++ b/src/Unstable/Brands/Requests/RetrieveBrandRequest.php @@ -0,0 +1,41 @@ +id = $values['id']; + } + + /** + * @return string + */ + public function getId(): string + { + return $this->id; + } + + /** + * @param string $value + */ + public function setId(string $value): self + { + $this->id = $value; + return $this; + } +} diff --git a/src/Unstable/Brands/Types/Brand.php b/src/Unstable/Brands/Types/Brand.php new file mode 100644 index 0000000..e1206d2 --- /dev/null +++ b/src/Unstable/Brands/Types/Brand.php @@ -0,0 +1,229 @@ +type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->name = $values['name'] ?? null; + $this->isDefault = $values['isDefault'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; + $this->updatedAt = $values['updatedAt'] ?? null; + $this->helpCenterId = $values['helpCenterId'] ?? null; + $this->defaultAddressSettingsId = $values['defaultAddressSettingsId'] ?? null; + } + + /** + * @return ?string + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?string $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?string + */ + public function getId(): ?string + { + return $this->id; + } + + /** + * @param ?string $value + */ + public function setId(?string $value = null): self + { + $this->id = $value; + return $this; + } + + /** + * @return ?string + */ + public function getName(): ?string + { + return $this->name; + } + + /** + * @param ?string $value + */ + public function setName(?string $value = null): self + { + $this->name = $value; + return $this; + } + + /** + * @return ?bool + */ + public function getIsDefault(): ?bool + { + return $this->isDefault; + } + + /** + * @param ?bool $value + */ + public function setIsDefault(?bool $value = null): self + { + $this->isDefault = $value; + return $this; + } + + /** + * @return ?int + */ + public function getCreatedAt(): ?int + { + return $this->createdAt; + } + + /** + * @param ?int $value + */ + public function setCreatedAt(?int $value = null): self + { + $this->createdAt = $value; + return $this; + } + + /** + * @return ?int + */ + public function getUpdatedAt(): ?int + { + return $this->updatedAt; + } + + /** + * @param ?int $value + */ + public function setUpdatedAt(?int $value = null): self + { + $this->updatedAt = $value; + return $this; + } + + /** + * @return ?string + */ + public function getHelpCenterId(): ?string + { + return $this->helpCenterId; + } + + /** + * @param ?string $value + */ + public function setHelpCenterId(?string $value = null): self + { + $this->helpCenterId = $value; + return $this; + } + + /** + * @return ?string + */ + public function getDefaultAddressSettingsId(): ?string + { + return $this->defaultAddressSettingsId; + } + + /** + * @param ?string $value + */ + public function setDefaultAddressSettingsId(?string $value = null): self + { + $this->defaultAddressSettingsId = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Unstable/Brands/Types/BrandList.php b/src/Unstable/Brands/Types/BrandList.php new file mode 100644 index 0000000..90cade1 --- /dev/null +++ b/src/Unstable/Brands/Types/BrandList.php @@ -0,0 +1,80 @@ + $data + */ + #[JsonProperty('data'), ArrayType([Brand::class])] + private ?array $data; + + /** + * @param array{ + * type?: ?string, + * data?: ?array, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->type = $values['type'] ?? null; + $this->data = $values['data'] ?? null; + } + + /** + * @return ?string + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?string $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?array + */ + public function getData(): ?array + { + return $this->data; + } + + /** + * @param ?array $value + */ + public function setData(?array $value = null): self + { + $this->data = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Unstable/Calls/CallsClient.php b/src/Unstable/Calls/CallsClient.php new file mode 100644 index 0000000..6f857f8 --- /dev/null +++ b/src/Unstable/Calls/CallsClient.php @@ -0,0 +1,572 @@ +, + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator + */ + private array $options; + + /** + * @var RawClient $client + */ + private RawClient $client; + + /** + * @param RawClient $client + * @param ?array{ + * baseUrl?: string, + * client?: ClientInterface, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * } $options + */ + public function __construct( + RawClient $client, + ?array $options = null, + ) { + $this->client = $client; + $this->options = $options ?? []; + } + + /** + * Retrieve a paginated list of calls. + * + * @param ListCallsRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return CallList + * @throws IntercomException + * @throws IntercomApiException + */ + public function listCalls(ListCallsRequest $request = new ListCallsRequest(), ?array $options = null): CallList + { + $options = array_merge($this->options, $options ?? []); + $query = []; + if ($request->getPage() != null) { + $query['page'] = $request->getPage(); + } + if ($request->getPerPage() != null) { + $query['per_page'] = $request->getPerPage(); + } + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "calls", + method: HttpMethod::GET, + query: $query, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return CallList::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * Retrieve a single call by id. + * + * @param ShowCallRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return Call + * @throws IntercomException + * @throws IntercomApiException + */ + public function showCall(ShowCallRequest $request, ?array $options = null): Call + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "calls/{$request->getId()}", + method: HttpMethod::GET, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return Call::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * Redirects to a signed URL for the call's recording if it exists. + * + * @param ShowCallRecordingRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @throws IntercomException + * @throws IntercomApiException + */ + public function showCallRecording(ShowCallRecordingRequest $request, ?array $options = null): void + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "calls/{$request->getId()}/recording", + method: HttpMethod::GET, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + return; + } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * Returns the transcript for the specified call as a downloadable text file. + * + * @param ShowCallTranscriptRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return string + * @throws IntercomException + * @throws IntercomApiException + */ + public function showCallTranscript(ShowCallTranscriptRequest $request, ?array $options = null): string + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "calls/{$request->getId()}/transcript", + method: HttpMethod::GET, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + return $response->getBody()->getContents(); + } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * Retrieve calls by a list of conversation ids and include transcripts when available. + * A maximum of 20 `conversation_ids` can be provided. If none are provided or more than 20 are provided, a 400 error is returned. + * + * @param ListCallsWithTranscriptsRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return ListCallsWithTranscriptsResponse + * @throws IntercomException + * @throws IntercomApiException + */ + public function listCallsWithTranscripts(ListCallsWithTranscriptsRequest $request, ?array $options = null): ListCallsWithTranscriptsResponse + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "calls/search", + method: HttpMethod::POST, + body: $request, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return ListCallsWithTranscriptsResponse::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * Register a Fin Voice call with Intercom. This endpoint creates an external reference + * that links an external call identifier to an Intercom call and conversation. + * + * The call can be from different sources: + * - AWS Connect (default) + * - Five9 + * - Zoom Phone + * + * @param ?RegisterFinVoiceCallRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return AiCallResponse + * @throws IntercomException + * @throws IntercomApiException + */ + public function registerFinVoiceCall(?RegisterFinVoiceCallRequest $request = null, ?array $options = null): AiCallResponse + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "fin_voice/register", + method: HttpMethod::POST, + body: $request, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return AiCallResponse::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * Retrieve information about a Fin Voice call using the external reference ID. + * + * @param CollectFinVoiceCallByIdRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return AiCallResponse + * @throws IntercomException + * @throws IntercomApiException + */ + public function collectFinVoiceCallById(CollectFinVoiceCallByIdRequest $request, ?array $options = null): AiCallResponse + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "fin_voice/collect/{$request->getId()}", + method: HttpMethod::GET, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return AiCallResponse::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * Retrieve information about a Fin Voice call using the external call identifier. + * + * @param CollectFinVoiceCallByExternalIdRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return AiCallResponse + * @throws IntercomException + * @throws IntercomApiException + */ + public function collectFinVoiceCallByExternalId(CollectFinVoiceCallByExternalIdRequest $request, ?array $options = null): AiCallResponse + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "fin_voice/external_id/{$request->getExternalId()}", + method: HttpMethod::GET, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return AiCallResponse::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * Retrieve information about a Fin Voice call using the phone number. + * + * Returns the most recent matched call for the given phone number, ordered by creation date. + * + * @param CollectFinVoiceCallByPhoneNumberRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return Error + * @throws IntercomException + * @throws IntercomApiException + */ + public function collectFinVoiceCallByPhoneNumber(CollectFinVoiceCallByPhoneNumberRequest $request, ?array $options = null): Error + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "fin_voice/phone_number/{$request->getPhoneNumber()}", + method: HttpMethod::GET, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return Error::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } +} diff --git a/src/Unstable/Calls/Requests/CollectFinVoiceCallByExternalIdRequest.php b/src/Unstable/Calls/Requests/CollectFinVoiceCallByExternalIdRequest.php new file mode 100644 index 0000000..84f9a02 --- /dev/null +++ b/src/Unstable/Calls/Requests/CollectFinVoiceCallByExternalIdRequest.php @@ -0,0 +1,41 @@ +externalId = $values['externalId']; + } + + /** + * @return string + */ + public function getExternalId(): string + { + return $this->externalId; + } + + /** + * @param string $value + */ + public function setExternalId(string $value): self + { + $this->externalId = $value; + return $this; + } +} diff --git a/src/Unstable/Calls/Requests/CollectFinVoiceCallByIdRequest.php b/src/Unstable/Calls/Requests/CollectFinVoiceCallByIdRequest.php new file mode 100644 index 0000000..f2412a6 --- /dev/null +++ b/src/Unstable/Calls/Requests/CollectFinVoiceCallByIdRequest.php @@ -0,0 +1,41 @@ +id = $values['id']; + } + + /** + * @return int + */ + public function getId(): int + { + return $this->id; + } + + /** + * @param int $value + */ + public function setId(int $value): self + { + $this->id = $value; + return $this; + } +} diff --git a/src/Unstable/Calls/Requests/CollectFinVoiceCallByPhoneNumberRequest.php b/src/Unstable/Calls/Requests/CollectFinVoiceCallByPhoneNumberRequest.php new file mode 100644 index 0000000..490d628 --- /dev/null +++ b/src/Unstable/Calls/Requests/CollectFinVoiceCallByPhoneNumberRequest.php @@ -0,0 +1,41 @@ +phoneNumber = $values['phoneNumber']; + } + + /** + * @return string + */ + public function getPhoneNumber(): string + { + return $this->phoneNumber; + } + + /** + * @param string $value + */ + public function setPhoneNumber(string $value): self + { + $this->phoneNumber = $value; + return $this; + } +} diff --git a/src/Unstable/Calls/Requests/ListCallsRequest.php b/src/Unstable/Calls/Requests/ListCallsRequest.php new file mode 100644 index 0000000..69cf13c --- /dev/null +++ b/src/Unstable/Calls/Requests/ListCallsRequest.php @@ -0,0 +1,65 @@ +page = $values['page'] ?? null; + $this->perPage = $values['perPage'] ?? null; + } + + /** + * @return ?int + */ + public function getPage(): ?int + { + return $this->page; + } + + /** + * @param ?int $value + */ + public function setPage(?int $value = null): self + { + $this->page = $value; + return $this; + } + + /** + * @return ?int + */ + public function getPerPage(): ?int + { + return $this->perPage; + } + + /** + * @param ?int $value + */ + public function setPerPage(?int $value = null): self + { + $this->perPage = $value; + return $this; + } +} diff --git a/src/Unstable/Calls/Requests/ListCallsWithTranscriptsRequest.php b/src/Unstable/Calls/Requests/ListCallsWithTranscriptsRequest.php new file mode 100644 index 0000000..58d704a --- /dev/null +++ b/src/Unstable/Calls/Requests/ListCallsWithTranscriptsRequest.php @@ -0,0 +1,44 @@ + $conversationIds A list of conversation ids to fetch calls for. Maximum 20. + */ + #[JsonProperty('conversation_ids'), ArrayType(['string'])] + private array $conversationIds; + + /** + * @param array{ + * conversationIds: array, + * } $values + */ + public function __construct( + array $values, + ) { + $this->conversationIds = $values['conversationIds']; + } + + /** + * @return array + */ + public function getConversationIds(): array + { + return $this->conversationIds; + } + + /** + * @param array $value + */ + public function setConversationIds(array $value): self + { + $this->conversationIds = $value; + return $this; + } +} diff --git a/src/Unstable/Calls/Requests/ShowCallRecordingRequest.php b/src/Unstable/Calls/Requests/ShowCallRecordingRequest.php new file mode 100644 index 0000000..71adbfe --- /dev/null +++ b/src/Unstable/Calls/Requests/ShowCallRecordingRequest.php @@ -0,0 +1,41 @@ +id = $values['id']; + } + + /** + * @return string + */ + public function getId(): string + { + return $this->id; + } + + /** + * @param string $value + */ + public function setId(string $value): self + { + $this->id = $value; + return $this; + } +} diff --git a/src/Unstable/Calls/Requests/ShowCallRequest.php b/src/Unstable/Calls/Requests/ShowCallRequest.php new file mode 100644 index 0000000..f571778 --- /dev/null +++ b/src/Unstable/Calls/Requests/ShowCallRequest.php @@ -0,0 +1,41 @@ +id = $values['id']; + } + + /** + * @return string + */ + public function getId(): string + { + return $this->id; + } + + /** + * @param string $value + */ + public function setId(string $value): self + { + $this->id = $value; + return $this; + } +} diff --git a/src/Unstable/Calls/Requests/ShowCallTranscriptRequest.php b/src/Unstable/Calls/Requests/ShowCallTranscriptRequest.php new file mode 100644 index 0000000..a5b7e88 --- /dev/null +++ b/src/Unstable/Calls/Requests/ShowCallTranscriptRequest.php @@ -0,0 +1,41 @@ +id = $values['id']; + } + + /** + * @return string + */ + public function getId(): string + { + return $this->id; + } + + /** + * @param string $value + */ + public function setId(string $value): self + { + $this->id = $value; + return $this; + } +} diff --git a/src/Unstable/Calls/Traits/Call.php b/src/Unstable/Calls/Traits/Call.php new file mode 100644 index 0000000..f056d4d --- /dev/null +++ b/src/Unstable/Calls/Traits/Call.php @@ -0,0 +1,530 @@ +type; + } + + /** + * @param ?string $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?string + */ + public function getId(): ?string + { + return $this->id; + } + + /** + * @param ?string $value + */ + public function setId(?string $value = null): self + { + $this->id = $value; + return $this; + } + + /** + * @return ?string + */ + public function getConversationId(): ?string + { + return $this->conversationId; + } + + /** + * @param ?string $value + */ + public function setConversationId(?string $value = null): self + { + $this->conversationId = $value; + return $this; + } + + /** + * @return ?string + */ + public function getAdminId(): ?string + { + return $this->adminId; + } + + /** + * @param ?string $value + */ + public function setAdminId(?string $value = null): self + { + $this->adminId = $value; + return $this; + } + + /** + * @return ?string + */ + public function getContactId(): ?string + { + return $this->contactId; + } + + /** + * @param ?string $value + */ + public function setContactId(?string $value = null): self + { + $this->contactId = $value; + return $this; + } + + /** + * @return ?string + */ + public function getState(): ?string + { + return $this->state; + } + + /** + * @param ?string $value + */ + public function setState(?string $value = null): self + { + $this->state = $value; + return $this; + } + + /** + * @return ( + * DateTime + * |int + * )|null + */ + public function getInitiatedAt(): DateTime|int|null + { + return $this->initiatedAt; + } + + /** + * @param ( + * DateTime + * |int + * )|null $value + */ + public function setInitiatedAt(DateTime|int|null $value = null): self + { + $this->initiatedAt = $value; + return $this; + } + + /** + * @return ( + * DateTime + * |int + * )|null + */ + public function getAnsweredAt(): DateTime|int|null + { + return $this->answeredAt; + } + + /** + * @param ( + * DateTime + * |int + * )|null $value + */ + public function setAnsweredAt(DateTime|int|null $value = null): self + { + $this->answeredAt = $value; + return $this; + } + + /** + * @return ( + * DateTime + * |int + * )|null + */ + public function getEndedAt(): DateTime|int|null + { + return $this->endedAt; + } + + /** + * @param ( + * DateTime + * |int + * )|null $value + */ + public function setEndedAt(DateTime|int|null $value = null): self + { + $this->endedAt = $value; + return $this; + } + + /** + * @return ( + * DateTime + * |int + * )|null + */ + public function getCreatedAt(): DateTime|int|null + { + return $this->createdAt; + } + + /** + * @param ( + * DateTime + * |int + * )|null $value + */ + public function setCreatedAt(DateTime|int|null $value = null): self + { + $this->createdAt = $value; + return $this; + } + + /** + * @return ( + * DateTime + * |int + * )|null + */ + public function getUpdatedAt(): DateTime|int|null + { + return $this->updatedAt; + } + + /** + * @param ( + * DateTime + * |int + * )|null $value + */ + public function setUpdatedAt(DateTime|int|null $value = null): self + { + $this->updatedAt = $value; + return $this; + } + + /** + * @return ?string + */ + public function getRecordingUrl(): ?string + { + return $this->recordingUrl; + } + + /** + * @param ?string $value + */ + public function setRecordingUrl(?string $value = null): self + { + $this->recordingUrl = $value; + return $this; + } + + /** + * @return ?string + */ + public function getTranscriptionUrl(): ?string + { + return $this->transcriptionUrl; + } + + /** + * @param ?string $value + */ + public function setTranscriptionUrl(?string $value = null): self + { + $this->transcriptionUrl = $value; + return $this; + } + + /** + * @return ?string + */ + public function getCallType(): ?string + { + return $this->callType; + } + + /** + * @param ?string $value + */ + public function setCallType(?string $value = null): self + { + $this->callType = $value; + return $this; + } + + /** + * @return ?string + */ + public function getDirection(): ?string + { + return $this->direction; + } + + /** + * @param ?string $value + */ + public function setDirection(?string $value = null): self + { + $this->direction = $value; + return $this; + } + + /** + * @return ?string + */ + public function getEndedReason(): ?string + { + return $this->endedReason; + } + + /** + * @param ?string $value + */ + public function setEndedReason(?string $value = null): self + { + $this->endedReason = $value; + return $this; + } + + /** + * @return ?string + */ + public function getPhone(): ?string + { + return $this->phone; + } + + /** + * @param ?string $value + */ + public function setPhone(?string $value = null): self + { + $this->phone = $value; + return $this; + } + + /** + * @return ?string + */ + public function getFinRecordingUrl(): ?string + { + return $this->finRecordingUrl; + } + + /** + * @param ?string $value + */ + public function setFinRecordingUrl(?string $value = null): self + { + $this->finRecordingUrl = $value; + return $this; + } + + /** + * @return ?string + */ + public function getFinTranscriptionUrl(): ?string + { + return $this->finTranscriptionUrl; + } + + /** + * @param ?string $value + */ + public function setFinTranscriptionUrl(?string $value = null): self + { + $this->finTranscriptionUrl = $value; + return $this; + } +} diff --git a/src/Unstable/Calls/Types/Call.php b/src/Unstable/Calls/Types/Call.php new file mode 100644 index 0000000..7c9183b --- /dev/null +++ b/src/Unstable/Calls/Types/Call.php @@ -0,0 +1,566 @@ +type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->conversationId = $values['conversationId'] ?? null; + $this->adminId = $values['adminId'] ?? null; + $this->contactId = $values['contactId'] ?? null; + $this->state = $values['state'] ?? null; + $this->initiatedAt = $values['initiatedAt'] ?? null; + $this->answeredAt = $values['answeredAt'] ?? null; + $this->endedAt = $values['endedAt'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; + $this->updatedAt = $values['updatedAt'] ?? null; + $this->recordingUrl = $values['recordingUrl'] ?? null; + $this->transcriptionUrl = $values['transcriptionUrl'] ?? null; + $this->callType = $values['callType'] ?? null; + $this->direction = $values['direction'] ?? null; + $this->endedReason = $values['endedReason'] ?? null; + $this->phone = $values['phone'] ?? null; + $this->finRecordingUrl = $values['finRecordingUrl'] ?? null; + $this->finTranscriptionUrl = $values['finTranscriptionUrl'] ?? null; + } + + /** + * @return ?string + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?string $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?string + */ + public function getId(): ?string + { + return $this->id; + } + + /** + * @param ?string $value + */ + public function setId(?string $value = null): self + { + $this->id = $value; + return $this; + } + + /** + * @return ?string + */ + public function getConversationId(): ?string + { + return $this->conversationId; + } + + /** + * @param ?string $value + */ + public function setConversationId(?string $value = null): self + { + $this->conversationId = $value; + return $this; + } + + /** + * @return ?string + */ + public function getAdminId(): ?string + { + return $this->adminId; + } + + /** + * @param ?string $value + */ + public function setAdminId(?string $value = null): self + { + $this->adminId = $value; + return $this; + } + + /** + * @return ?string + */ + public function getContactId(): ?string + { + return $this->contactId; + } + + /** + * @param ?string $value + */ + public function setContactId(?string $value = null): self + { + $this->contactId = $value; + return $this; + } + + /** + * @return ?string + */ + public function getState(): ?string + { + return $this->state; + } + + /** + * @param ?string $value + */ + public function setState(?string $value = null): self + { + $this->state = $value; + return $this; + } + + /** + * @return ( + * DateTime + * |int + * )|null + */ + public function getInitiatedAt(): DateTime|int|null + { + return $this->initiatedAt; + } + + /** + * @param ( + * DateTime + * |int + * )|null $value + */ + public function setInitiatedAt(DateTime|int|null $value = null): self + { + $this->initiatedAt = $value; + return $this; + } + + /** + * @return ( + * DateTime + * |int + * )|null + */ + public function getAnsweredAt(): DateTime|int|null + { + return $this->answeredAt; + } + + /** + * @param ( + * DateTime + * |int + * )|null $value + */ + public function setAnsweredAt(DateTime|int|null $value = null): self + { + $this->answeredAt = $value; + return $this; + } + + /** + * @return ( + * DateTime + * |int + * )|null + */ + public function getEndedAt(): DateTime|int|null + { + return $this->endedAt; + } + + /** + * @param ( + * DateTime + * |int + * )|null $value + */ + public function setEndedAt(DateTime|int|null $value = null): self + { + $this->endedAt = $value; + return $this; + } + + /** + * @return ( + * DateTime + * |int + * )|null + */ + public function getCreatedAt(): DateTime|int|null + { + return $this->createdAt; + } + + /** + * @param ( + * DateTime + * |int + * )|null $value + */ + public function setCreatedAt(DateTime|int|null $value = null): self + { + $this->createdAt = $value; + return $this; + } + + /** + * @return ( + * DateTime + * |int + * )|null + */ + public function getUpdatedAt(): DateTime|int|null + { + return $this->updatedAt; + } + + /** + * @param ( + * DateTime + * |int + * )|null $value + */ + public function setUpdatedAt(DateTime|int|null $value = null): self + { + $this->updatedAt = $value; + return $this; + } + + /** + * @return ?string + */ + public function getRecordingUrl(): ?string + { + return $this->recordingUrl; + } + + /** + * @param ?string $value + */ + public function setRecordingUrl(?string $value = null): self + { + $this->recordingUrl = $value; + return $this; + } + + /** + * @return ?string + */ + public function getTranscriptionUrl(): ?string + { + return $this->transcriptionUrl; + } + + /** + * @param ?string $value + */ + public function setTranscriptionUrl(?string $value = null): self + { + $this->transcriptionUrl = $value; + return $this; + } + + /** + * @return ?string + */ + public function getCallType(): ?string + { + return $this->callType; + } + + /** + * @param ?string $value + */ + public function setCallType(?string $value = null): self + { + $this->callType = $value; + return $this; + } + + /** + * @return ?string + */ + public function getDirection(): ?string + { + return $this->direction; + } + + /** + * @param ?string $value + */ + public function setDirection(?string $value = null): self + { + $this->direction = $value; + return $this; + } + + /** + * @return ?string + */ + public function getEndedReason(): ?string + { + return $this->endedReason; + } + + /** + * @param ?string $value + */ + public function setEndedReason(?string $value = null): self + { + $this->endedReason = $value; + return $this; + } + + /** + * @return ?string + */ + public function getPhone(): ?string + { + return $this->phone; + } + + /** + * @param ?string $value + */ + public function setPhone(?string $value = null): self + { + $this->phone = $value; + return $this; + } + + /** + * @return ?string + */ + public function getFinRecordingUrl(): ?string + { + return $this->finRecordingUrl; + } + + /** + * @param ?string $value + */ + public function setFinRecordingUrl(?string $value = null): self + { + $this->finRecordingUrl = $value; + return $this; + } + + /** + * @return ?string + */ + public function getFinTranscriptionUrl(): ?string + { + return $this->finTranscriptionUrl; + } + + /** + * @param ?string $value + */ + public function setFinTranscriptionUrl(?string $value = null): self + { + $this->finTranscriptionUrl = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Unstable/Calls/Types/ListCallsWithTranscriptsResponse.php b/src/Unstable/Calls/Types/ListCallsWithTranscriptsResponse.php new file mode 100644 index 0000000..1852a5c --- /dev/null +++ b/src/Unstable/Calls/Types/ListCallsWithTranscriptsResponse.php @@ -0,0 +1,77 @@ + $data + */ + #[JsonProperty('data'), ArrayType([ListCallsWithTranscriptsResponseDataItem::class])] + private ?array $data; + + /** + * @param array{ + * type?: ?string, + * data?: ?array, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->type = $values['type'] ?? null; + $this->data = $values['data'] ?? null; + } + + /** + * @return ?string + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?string $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?array + */ + public function getData(): ?array + { + return $this->data; + } + + /** + * @param ?array $value + */ + public function setData(?array $value = null): self + { + $this->data = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Unstable/Calls/Types/ListCallsWithTranscriptsResponseDataItem.php b/src/Unstable/Calls/Types/ListCallsWithTranscriptsResponseDataItem.php new file mode 100644 index 0000000..2f1b4f3 --- /dev/null +++ b/src/Unstable/Calls/Types/ListCallsWithTranscriptsResponseDataItem.php @@ -0,0 +1,134 @@ +> $transcript The call transcript if available, otherwise an empty array. + */ + #[JsonProperty('transcript'), ArrayType([['string' => 'mixed']])] + private ?array $transcript; + + /** + * @var ?string $transcriptStatus The status of the transcript if available. + */ + #[JsonProperty('transcript_status')] + private ?string $transcriptStatus; + + /** + * @param array{ + * type?: ?string, + * id?: ?string, + * conversationId?: ?string, + * adminId?: ?string, + * contactId?: ?string, + * state?: ?string, + * initiatedAt?: ( + * DateTime + * |int + * )|null, + * answeredAt?: ( + * DateTime + * |int + * )|null, + * endedAt?: ( + * DateTime + * |int + * )|null, + * createdAt?: ( + * DateTime + * |int + * )|null, + * updatedAt?: ( + * DateTime + * |int + * )|null, + * recordingUrl?: ?string, + * transcriptionUrl?: ?string, + * callType?: ?string, + * direction?: ?string, + * endedReason?: ?string, + * phone?: ?string, + * finRecordingUrl?: ?string, + * finTranscriptionUrl?: ?string, + * transcript?: ?array>, + * transcriptStatus?: ?string, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->conversationId = $values['conversationId'] ?? null; + $this->adminId = $values['adminId'] ?? null; + $this->contactId = $values['contactId'] ?? null; + $this->state = $values['state'] ?? null; + $this->initiatedAt = $values['initiatedAt'] ?? null; + $this->answeredAt = $values['answeredAt'] ?? null; + $this->endedAt = $values['endedAt'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; + $this->updatedAt = $values['updatedAt'] ?? null; + $this->recordingUrl = $values['recordingUrl'] ?? null; + $this->transcriptionUrl = $values['transcriptionUrl'] ?? null; + $this->callType = $values['callType'] ?? null; + $this->direction = $values['direction'] ?? null; + $this->endedReason = $values['endedReason'] ?? null; + $this->phone = $values['phone'] ?? null; + $this->finRecordingUrl = $values['finRecordingUrl'] ?? null; + $this->finTranscriptionUrl = $values['finTranscriptionUrl'] ?? null; + $this->transcript = $values['transcript'] ?? null; + $this->transcriptStatus = $values['transcriptStatus'] ?? null; + } + + /** + * @return ?array> + */ + public function getTranscript(): ?array + { + return $this->transcript; + } + + /** + * @param ?array> $value + */ + public function setTranscript(?array $value = null): self + { + $this->transcript = $value; + return $this; + } + + /** + * @return ?string + */ + public function getTranscriptStatus(): ?string + { + return $this->transcriptStatus; + } + + /** + * @param ?string $value + */ + public function setTranscriptStatus(?string $value = null): self + { + $this->transcriptStatus = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Unstable/Companies/CompaniesClient.php b/src/Unstable/Companies/CompaniesClient.php index e8fa08b..85ddb55 100644 --- a/src/Unstable/Companies/CompaniesClient.php +++ b/src/Unstable/Companies/CompaniesClient.php @@ -38,7 +38,7 @@ class CompaniesClient * maxRetries?: int, * timeout?: float, * headers?: array, - * } $options + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator */ private array $options; diff --git a/src/Unstable/Companies/Types/Company.php b/src/Unstable/Companies/Types/Company.php index d61f9fe..5214eaf 100644 --- a/src/Unstable/Companies/Types/Company.php +++ b/src/Unstable/Companies/Types/Company.php @@ -125,6 +125,12 @@ class Company extends JsonSerializableType #[JsonProperty('segments')] private ?CompanySegments $segments; + /** + * @var ?CompanyNotes $notes The list of notes associated with the company + */ + #[JsonProperty('notes')] + private ?CompanyNotes $notes; + /** * @param array{ * type?: ?'company', @@ -146,6 +152,7 @@ class Company extends JsonSerializableType * customAttributes?: ?array, * tags?: ?CompanyTags, * segments?: ?CompanySegments, + * notes?: ?CompanyNotes, * } $values */ public function __construct( @@ -170,6 +177,7 @@ public function __construct( $this->customAttributes = $values['customAttributes'] ?? null; $this->tags = $values['tags'] ?? null; $this->segments = $values['segments'] ?? null; + $this->notes = $values['notes'] ?? null; } /** @@ -495,6 +503,23 @@ public function setSegments(?CompanySegments $value = null): self return $this; } + /** + * @return ?CompanyNotes + */ + public function getNotes(): ?CompanyNotes + { + return $this->notes; + } + + /** + * @param ?CompanyNotes $value + */ + public function setNotes(?CompanyNotes $value = null): self + { + $this->notes = $value; + return $this; + } + /** * @return string */ diff --git a/src/Unstable/Companies/Types/CompanyNotes.php b/src/Unstable/Companies/Types/CompanyNotes.php new file mode 100644 index 0000000..7c31050 --- /dev/null +++ b/src/Unstable/Companies/Types/CompanyNotes.php @@ -0,0 +1,81 @@ + $notes + */ + #[JsonProperty('notes'), ArrayType([CompanyNote::class])] + private ?array $notes; + + /** + * @param array{ + * type?: ?'note.list', + * notes?: ?array, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->type = $values['type'] ?? null; + $this->notes = $values['notes'] ?? null; + } + + /** + * @return ?'note.list' + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?'note.list' $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?array + */ + public function getNotes(): ?array + { + return $this->notes; + } + + /** + * @param ?array $value + */ + public function setNotes(?array $value = null): self + { + $this->notes = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Unstable/Contacts/ContactsClient.php b/src/Unstable/Contacts/ContactsClient.php index afd3f14..a51577f 100644 --- a/src/Unstable/Contacts/ContactsClient.php +++ b/src/Unstable/Contacts/ContactsClient.php @@ -49,7 +49,7 @@ class ContactsClient * maxRetries?: int, * timeout?: float, * headers?: array, - * } $options + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator */ private array $options; diff --git a/src/Unstable/Conversations/ConversationsClient.php b/src/Unstable/Conversations/ConversationsClient.php index 473ac82..2828890 100644 --- a/src/Unstable/Conversations/ConversationsClient.php +++ b/src/Unstable/Conversations/ConversationsClient.php @@ -39,7 +39,7 @@ class ConversationsClient * maxRetries?: int, * timeout?: float, * headers?: array, - * } $options + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator */ private array $options; @@ -146,6 +146,7 @@ public function listConversations(ListConversationsRequest $request = new ListCo * * This will return the Message model that has been created. * + * * @param CreateConversationRequest $request * @param ?array{ * baseUrl?: string, @@ -231,6 +232,9 @@ public function retrieveConversation(RetrieveConversationRequest $request, ?arra if ($request->getDisplayAs() != null) { $query['display_as'] = $request->getDisplayAs(); } + if ($request->getIncludeTranslations() != null) { + $query['include_translations'] = $request->getIncludeTranslations(); + } try { $response = $this->client->sendRequest( new JsonApiRequest( @@ -282,6 +286,7 @@ public function retrieveConversation(RetrieveConversationRequest $request, ?arra * See _`update a conversation with an association to a custom object instance`_ in the request/response examples to see the custom object association format. * {% /admonition %} * + * * @param UpdateConversationRequest $request * @param ?array{ * baseUrl?: string, @@ -672,6 +677,7 @@ public function manageConversation(ManageConversationRequest $request, ?array $o * If you add a contact via the email parameter and there is no user/lead found on that workspace with he given email, then we will create a new contact with `role` set to `lead`. * {% /admonition %} * + * * @param AttachContactToConversationRequest $request * @param ?array{ * baseUrl?: string, @@ -732,6 +738,7 @@ public function attachContactToConversation(AttachContactToConversationRequest $ * If you add a contact via the email parameter and there is no user/lead found on that workspace with he given email, then we will create a new contact with `role` set to `lead`. * {% /admonition %} * + * * @param DetachContactFromConversationRequest $request * @param ?array{ * baseUrl?: string, @@ -792,6 +799,7 @@ public function detachContactFromConversation(DetachContactFromConversationReque * If you are redacting a conversation part, it must have a `body`. If you are redacting a source message, it must have been created by a contact. We will return a `conversation_part_not_redactable` error if these criteria are not met. * {% /admonition %} * + * * @param RedactConversationRequest $request * @param ?array{ * baseUrl?: string, diff --git a/src/Unstable/Conversations/Requests/RetrieveConversationRequest.php b/src/Unstable/Conversations/Requests/RetrieveConversationRequest.php index b549593..c36da92 100644 --- a/src/Unstable/Conversations/Requests/RetrieveConversationRequest.php +++ b/src/Unstable/Conversations/Requests/RetrieveConversationRequest.php @@ -12,14 +12,20 @@ class RetrieveConversationRequest extends JsonSerializableType private int $id; /** - * @var ?string $displayAs Set to plaintext to retrieve conversation messages in plain text. + * @var ?string $displayAs Set to plaintext to retrieve conversation messages in plain text. This affects both the body and subject fields. */ private ?string $displayAs; + /** + * @var ?bool $includeTranslations If set to true, conversation parts will be translated to the detected language of the conversation. + */ + private ?bool $includeTranslations; + /** * @param array{ * id: int, * displayAs?: ?string, + * includeTranslations?: ?bool, * } $values */ public function __construct( @@ -27,6 +33,7 @@ public function __construct( ) { $this->id = $values['id']; $this->displayAs = $values['displayAs'] ?? null; + $this->includeTranslations = $values['includeTranslations'] ?? null; } /** @@ -62,4 +69,21 @@ public function setDisplayAs(?string $value = null): self $this->displayAs = $value; return $this; } + + /** + * @return ?bool + */ + public function getIncludeTranslations(): ?bool + { + return $this->includeTranslations; + } + + /** + * @param ?bool $value + */ + public function setIncludeTranslations(?bool $value = null): self + { + $this->includeTranslations = $value; + return $this; + } } diff --git a/src/Unstable/Conversations/Requests/UpdateConversationRequest.php b/src/Unstable/Conversations/Requests/UpdateConversationRequest.php index 8532a59..d167286 100644 --- a/src/Unstable/Conversations/Requests/UpdateConversationRequest.php +++ b/src/Unstable/Conversations/Requests/UpdateConversationRequest.php @@ -17,7 +17,7 @@ class UpdateConversationRequest extends JsonSerializableType private int $id; /** - * @var ?string $displayAs Set to plaintext to retrieve conversation messages in plain text. + * @var ?string $displayAs Set to plaintext to retrieve conversation messages in plain text. This affects both the body and subject fields. */ private ?string $displayAs; diff --git a/src/Unstable/CustomChannelEvents/CustomChannelEventsClient.php b/src/Unstable/CustomChannelEvents/CustomChannelEventsClient.php index 30dfdc2..c04a706 100644 --- a/src/Unstable/CustomChannelEvents/CustomChannelEventsClient.php +++ b/src/Unstable/CustomChannelEvents/CustomChannelEventsClient.php @@ -27,7 +27,7 @@ class CustomChannelEventsClient * maxRetries?: int, * timeout?: float, * headers?: array, - * } $options + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator */ private array $options; diff --git a/src/Unstable/CustomObjectInstances/CustomObjectInstancesClient.php b/src/Unstable/CustomObjectInstances/CustomObjectInstancesClient.php index 250331a..9baf82f 100644 --- a/src/Unstable/CustomObjectInstances/CustomObjectInstancesClient.php +++ b/src/Unstable/CustomObjectInstances/CustomObjectInstancesClient.php @@ -29,7 +29,7 @@ class CustomObjectInstancesClient * maxRetries?: int, * timeout?: float, * headers?: array, - * } $options + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator */ private array $options; diff --git a/src/Unstable/DataAttributes/DataAttributesClient.php b/src/Unstable/DataAttributes/DataAttributesClient.php index 0a74aec..13125bb 100644 --- a/src/Unstable/DataAttributes/DataAttributesClient.php +++ b/src/Unstable/DataAttributes/DataAttributesClient.php @@ -14,7 +14,6 @@ use JsonException; use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; -use Intercom\Unstable\DataAttributes\Requests\CreateDataAttributeRequest; use Intercom\Unstable\DataAttributes\Types\DataAttribute; use Intercom\Unstable\DataAttributes\Requests\UpdateDataAttributeRequest; @@ -27,7 +26,7 @@ class DataAttributesClient * maxRetries?: int, * timeout?: float, * headers?: array, - * } $options + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator */ private array $options; @@ -120,7 +119,7 @@ public function lisDataAttributes(LisDataAttributesRequest $request = new LisDat /** * You can create a data attributes for a `contact` or a `company`. * - * @param CreateDataAttributeRequest $request + * @param mixed $request * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -133,7 +132,7 @@ public function lisDataAttributes(LisDataAttributesRequest $request = new LisDat * @throws IntercomException * @throws IntercomApiException */ - public function createDataAttribute(CreateDataAttributeRequest $request, ?array $options = null): DataAttribute + public function createDataAttribute(mixed $request, ?array $options = null): DataAttribute { $options = array_merge($this->options, $options ?? []); try { @@ -203,7 +202,7 @@ public function updateDataAttribute(UpdateDataAttributeRequest $request, ?array baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, path: "data_attributes/{$request->getId()}", method: HttpMethod::PUT, - body: $request, + body: $request->getBody(), ), $options, ); diff --git a/src/Unstable/DataAttributes/Requests/CreateDataAttributeRequest.php b/src/Unstable/DataAttributes/Requests/CreateDataAttributeRequest.php deleted file mode 100644 index 06625dd..0000000 --- a/src/Unstable/DataAttributes/Requests/CreateDataAttributeRequest.php +++ /dev/null @@ -1,171 +0,0 @@ - $model The model that the data attribute belongs to. - */ - #[JsonProperty('model')] - private string $model; - - /** - * @var value-of $dataType The type of data stored for this attribute. - */ - #[JsonProperty('data_type')] - private string $dataType; - - /** - * @var ?string $description The readable description you see in the UI for the attribute. - */ - #[JsonProperty('description')] - private ?string $description; - - /** - * @var ?array $options 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'), ArrayType(['string'])] - private ?array $options; - - /** - * @var ?bool $messengerWritable Can this attribute be updated by the Messenger - */ - #[JsonProperty('messenger_writable')] - private ?bool $messengerWritable; - - /** - * @param array{ - * name: string, - * model: value-of, - * dataType: value-of, - * description?: ?string, - * options?: ?array, - * messengerWritable?: ?bool, - * } $values - */ - public function __construct( - array $values, - ) { - $this->name = $values['name']; - $this->model = $values['model']; - $this->dataType = $values['dataType']; - $this->description = $values['description'] ?? null; - $this->options = $values['options'] ?? null; - $this->messengerWritable = $values['messengerWritable'] ?? null; - } - - /** - * @return string - */ - public function getName(): string - { - return $this->name; - } - - /** - * @param string $value - */ - public function setName(string $value): self - { - $this->name = $value; - return $this; - } - - /** - * @return value-of - */ - public function getModel(): string - { - return $this->model; - } - - /** - * @param value-of $value - */ - public function setModel(string $value): self - { - $this->model = $value; - return $this; - } - - /** - * @return value-of - */ - public function getDataType(): string - { - return $this->dataType; - } - - /** - * @param value-of $value - */ - public function setDataType(string $value): self - { - $this->dataType = $value; - return $this; - } - - /** - * @return ?string - */ - public function getDescription(): ?string - { - return $this->description; - } - - /** - * @param ?string $value - */ - public function setDescription(?string $value = null): self - { - $this->description = $value; - return $this; - } - - /** - * @return ?array - */ - public function getOptions(): ?array - { - return $this->options; - } - - /** - * @param ?array $value - */ - public function setOptions(?array $value = null): self - { - $this->options = $value; - return $this; - } - - /** - * @return ?bool - */ - public function getMessengerWritable(): ?bool - { - return $this->messengerWritable; - } - - /** - * @param ?bool $value - */ - public function setMessengerWritable(?bool $value = null): self - { - $this->messengerWritable = $value; - return $this; - } -} diff --git a/src/Unstable/DataAttributes/Requests/UpdateDataAttributeRequest.php b/src/Unstable/DataAttributes/Requests/UpdateDataAttributeRequest.php index 5036ad4..f25e038 100644 --- a/src/Unstable/DataAttributes/Requests/UpdateDataAttributeRequest.php +++ b/src/Unstable/DataAttributes/Requests/UpdateDataAttributeRequest.php @@ -3,8 +3,6 @@ namespace Intercom\Unstable\DataAttributes\Requests; use Intercom\Core\Json\JsonSerializableType; -use Intercom\Core\Json\JsonProperty; -use Intercom\Core\Types\ArrayType; class UpdateDataAttributeRequest extends JsonSerializableType { @@ -14,46 +12,21 @@ class UpdateDataAttributeRequest extends JsonSerializableType private int $id; /** - * @var ?bool $archived Whether the attribute is to be archived or not. + * @var mixed $body */ - #[JsonProperty('archived')] - private ?bool $archived; - - /** - * @var ?string $description The readable description you see in the UI for the attribute. - */ - #[JsonProperty('description')] - private ?string $description; - - /** - * @var ?array $options 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'), ArrayType(['string'])] - private ?array $options; - - /** - * @var ?bool $messengerWritable Can this attribute be updated by the Messenger - */ - #[JsonProperty('messenger_writable')] - private ?bool $messengerWritable; + private mixed $body; /** * @param array{ * id: int, - * archived?: ?bool, - * description?: ?string, - * options?: ?array, - * messengerWritable?: ?bool, + * body: mixed, * } $values */ public function __construct( array $values, ) { $this->id = $values['id']; - $this->archived = $values['archived'] ?? null; - $this->description = $values['description'] ?? null; - $this->options = $values['options'] ?? null; - $this->messengerWritable = $values['messengerWritable'] ?? null; + $this->body = $values['body']; } /** @@ -74,70 +47,19 @@ public function setId(int $value): self } /** - * @return ?bool - */ - public function getArchived(): ?bool - { - return $this->archived; - } - - /** - * @param ?bool $value - */ - public function setArchived(?bool $value = null): self - { - $this->archived = $value; - return $this; - } - - /** - * @return ?string - */ - public function getDescription(): ?string - { - return $this->description; - } - - /** - * @param ?string $value - */ - public function setDescription(?string $value = null): self - { - $this->description = $value; - return $this; - } - - /** - * @return ?array - */ - public function getOptions(): ?array - { - return $this->options; - } - - /** - * @param ?array $value - */ - public function setOptions(?array $value = null): self - { - $this->options = $value; - return $this; - } - - /** - * @return ?bool + * @return mixed */ - public function getMessengerWritable(): ?bool + public function getBody(): mixed { - return $this->messengerWritable; + return $this->body; } /** - * @param ?bool $value + * @param mixed $value */ - public function setMessengerWritable(?bool $value = null): self + public function setBody(mixed $value): self { - $this->messengerWritable = $value; + $this->body = $value; return $this; } } diff --git a/src/Unstable/DataAttributes/Types/CreateDataAttributeRequestModel.php b/src/Unstable/DataAttributes/Types/CreateDataAttributeRequestModel.php deleted file mode 100644 index 414b329..0000000 --- a/src/Unstable/DataAttributes/Types/CreateDataAttributeRequestModel.php +++ /dev/null @@ -1,9 +0,0 @@ -, - * } $options + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator */ private array $options; @@ -175,6 +175,7 @@ public function lisDataEvents(LisDataEventsRequest $request, ?array $options = n * - Event lists containing duplicate events will have those duplicates ignored. * - Server errors will return a `500` response code and may contain an error message in the body. * + * * @param mixed $request * @param ?array{ * baseUrl?: string, @@ -227,6 +228,7 @@ public function createDataEvent(mixed $request, ?array $options = null): void /** * Create event summaries for a user. Event summaries are used to track the number of times an event has occurred, the first time it occurred and the last time it occurred. * + * * @param CreateDataEventSummariesRequest $request * @param ?array{ * baseUrl?: string, diff --git a/src/Unstable/DataExport/DataExportClient.php b/src/Unstable/DataExport/DataExportClient.php index 4085bce..600a5a3 100644 --- a/src/Unstable/DataExport/DataExportClient.php +++ b/src/Unstable/DataExport/DataExportClient.php @@ -27,7 +27,7 @@ class DataExportClient * maxRetries?: int, * timeout?: float, * headers?: array, - * } $options + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator */ private array $options; diff --git a/src/Unstable/Emails/EmailsClient.php b/src/Unstable/Emails/EmailsClient.php new file mode 100644 index 0000000..c4e3095 --- /dev/null +++ b/src/Unstable/Emails/EmailsClient.php @@ -0,0 +1,163 @@ +, + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator + */ + private array $options; + + /** + * @var RawClient $client + */ + private RawClient $client; + + /** + * @param RawClient $client + * @param ?array{ + * baseUrl?: string, + * client?: ClientInterface, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * } $options + */ + public function __construct( + RawClient $client, + ?array $options = null, + ) { + $this->client = $client; + $this->options = $options ?? []; + } + + /** + * Lists all sender email address settings for the workspace + * + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return EmailList + * @throws IntercomException + * @throws IntercomApiException + */ + public function listEmails(?array $options = null): EmailList + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "emails", + method: HttpMethod::GET, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return EmailList::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * Fetches a specific email setting by its unique identifier + * + * @param RetrieveEmailRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return EmailSetting + * @throws IntercomException + * @throws IntercomApiException + */ + public function retrieveEmail(RetrieveEmailRequest $request, ?array $options = null): EmailSetting + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "emails/{$request->getId()}", + method: HttpMethod::GET, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return EmailSetting::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } +} diff --git a/src/Unstable/Emails/Requests/RetrieveEmailRequest.php b/src/Unstable/Emails/Requests/RetrieveEmailRequest.php new file mode 100644 index 0000000..467a677 --- /dev/null +++ b/src/Unstable/Emails/Requests/RetrieveEmailRequest.php @@ -0,0 +1,41 @@ +id = $values['id']; + } + + /** + * @return string + */ + public function getId(): string + { + return $this->id; + } + + /** + * @param string $value + */ + public function setId(string $value): self + { + $this->id = $value; + return $this; + } +} diff --git a/src/Unstable/Emails/Types/EmailList.php b/src/Unstable/Emails/Types/EmailList.php new file mode 100644 index 0000000..a9e4074 --- /dev/null +++ b/src/Unstable/Emails/Types/EmailList.php @@ -0,0 +1,80 @@ + $data + */ + #[JsonProperty('data'), ArrayType([EmailSetting::class])] + private ?array $data; + + /** + * @param array{ + * type?: ?string, + * data?: ?array, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->type = $values['type'] ?? null; + $this->data = $values['data'] ?? null; + } + + /** + * @return ?string + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?string $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?array + */ + public function getData(): ?array + { + return $this->data; + } + + /** + * @param ?array $value + */ + public function setData(?array $value = null): self + { + $this->data = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Unstable/Emails/Types/EmailSetting.php b/src/Unstable/Emails/Types/EmailSetting.php new file mode 100644 index 0000000..d90b86b --- /dev/null +++ b/src/Unstable/Emails/Types/EmailSetting.php @@ -0,0 +1,279 @@ +type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->email = $values['email'] ?? null; + $this->verified = $values['verified'] ?? null; + $this->domain = $values['domain'] ?? null; + $this->brandId = $values['brandId'] ?? null; + $this->forwardingEnabled = $values['forwardingEnabled'] ?? null; + $this->forwardedEmailLastReceivedAt = $values['forwardedEmailLastReceivedAt'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; + $this->updatedAt = $values['updatedAt'] ?? null; + } + + /** + * @return ?string + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?string $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?string + */ + public function getId(): ?string + { + return $this->id; + } + + /** + * @param ?string $value + */ + public function setId(?string $value = null): self + { + $this->id = $value; + return $this; + } + + /** + * @return ?string + */ + public function getEmail(): ?string + { + return $this->email; + } + + /** + * @param ?string $value + */ + public function setEmail(?string $value = null): self + { + $this->email = $value; + return $this; + } + + /** + * @return ?bool + */ + public function getVerified(): ?bool + { + return $this->verified; + } + + /** + * @param ?bool $value + */ + public function setVerified(?bool $value = null): self + { + $this->verified = $value; + return $this; + } + + /** + * @return ?string + */ + public function getDomain(): ?string + { + return $this->domain; + } + + /** + * @param ?string $value + */ + public function setDomain(?string $value = null): self + { + $this->domain = $value; + return $this; + } + + /** + * @return ?string + */ + public function getBrandId(): ?string + { + return $this->brandId; + } + + /** + * @param ?string $value + */ + public function setBrandId(?string $value = null): self + { + $this->brandId = $value; + return $this; + } + + /** + * @return ?bool + */ + public function getForwardingEnabled(): ?bool + { + return $this->forwardingEnabled; + } + + /** + * @param ?bool $value + */ + public function setForwardingEnabled(?bool $value = null): self + { + $this->forwardingEnabled = $value; + return $this; + } + + /** + * @return ?int + */ + public function getForwardedEmailLastReceivedAt(): ?int + { + return $this->forwardedEmailLastReceivedAt; + } + + /** + * @param ?int $value + */ + public function setForwardedEmailLastReceivedAt(?int $value = null): self + { + $this->forwardedEmailLastReceivedAt = $value; + return $this; + } + + /** + * @return ?int + */ + public function getCreatedAt(): ?int + { + return $this->createdAt; + } + + /** + * @param ?int $value + */ + public function setCreatedAt(?int $value = null): self + { + $this->createdAt = $value; + return $this; + } + + /** + * @return ?int + */ + public function getUpdatedAt(): ?int + { + return $this->updatedAt; + } + + /** + * @param ?int $value + */ + public function setUpdatedAt(?int $value = null): self + { + $this->updatedAt = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Unstable/Export/ExportClient.php b/src/Unstable/Export/ExportClient.php index ce0bd14..f3335ef 100644 --- a/src/Unstable/Export/ExportClient.php +++ b/src/Unstable/Export/ExportClient.php @@ -25,7 +25,7 @@ class ExportClient * maxRetries?: int, * timeout?: float, * headers?: array, - * } $options + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator */ private array $options; diff --git a/src/Unstable/HelpCenter/HelpCenterClient.php b/src/Unstable/HelpCenter/HelpCenterClient.php index 5608aa7..52b8b48 100644 --- a/src/Unstable/HelpCenter/HelpCenterClient.php +++ b/src/Unstable/HelpCenter/HelpCenterClient.php @@ -32,7 +32,7 @@ class HelpCenterClient * maxRetries?: int, * timeout?: float, * headers?: array, - * } $options + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator */ private array $options; diff --git a/src/Unstable/HelpCenter/Types/HelpCenter.php b/src/Unstable/HelpCenter/Types/HelpCenter.php index bafc7ab..2d33002 100644 --- a/src/Unstable/HelpCenter/Types/HelpCenter.php +++ b/src/Unstable/HelpCenter/Types/HelpCenter.php @@ -52,6 +52,18 @@ class HelpCenter extends JsonSerializableType #[JsonProperty('display_name')] private ?string $displayName; + /** + * @var ?string $url The URL for the help center, if you have a custom domain then this will show the URL using the custom domain. + */ + #[JsonProperty('url')] + private ?string $url; + + /** + * @var ?string $customDomain Custom domain configured for the help center + */ + #[JsonProperty('custom_domain')] + private ?string $customDomain; + /** * @param array{ * id?: ?string, @@ -61,6 +73,8 @@ class HelpCenter extends JsonSerializableType * identifier?: ?string, * websiteTurnedOn?: ?bool, * displayName?: ?string, + * url?: ?string, + * customDomain?: ?string, * } $values */ public function __construct( @@ -73,6 +87,8 @@ public function __construct( $this->identifier = $values['identifier'] ?? null; $this->websiteTurnedOn = $values['websiteTurnedOn'] ?? null; $this->displayName = $values['displayName'] ?? null; + $this->url = $values['url'] ?? null; + $this->customDomain = $values['customDomain'] ?? null; } /** @@ -194,6 +210,40 @@ public function setDisplayName(?string $value = null): self return $this; } + /** + * @return ?string + */ + public function getUrl(): ?string + { + return $this->url; + } + + /** + * @param ?string $value + */ + public function setUrl(?string $value = null): self + { + $this->url = $value; + return $this; + } + + /** + * @return ?string + */ + public function getCustomDomain(): ?string + { + return $this->customDomain; + } + + /** + * @param ?string $value + */ + public function setCustomDomain(?string $value = null): self + { + $this->customDomain = $value; + return $this; + } + /** * @return string */ diff --git a/src/Unstable/InternalArticles/InternalArticlesClient.php b/src/Unstable/InternalArticles/InternalArticlesClient.php new file mode 100644 index 0000000..41bc943 --- /dev/null +++ b/src/Unstable/InternalArticles/InternalArticlesClient.php @@ -0,0 +1,396 @@ +, + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator + */ + private array $options; + + /** + * @var RawClient $client + */ + private RawClient $client; + + /** + * @param RawClient $client + * @param ?array{ + * baseUrl?: string, + * client?: ClientInterface, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * } $options + */ + public function __construct( + RawClient $client, + ?array $options = null, + ) { + $this->client = $client; + $this->options = $options ?? []; + } + + /** + * You can fetch a list of all internal articles by making a GET request to `https://api.intercom.io/internal_articles`. + * + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return InternalArticleList + * @throws IntercomException + * @throws IntercomApiException + */ + public function listInternalArticles(?array $options = null): InternalArticleList + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "internal_articles", + method: HttpMethod::GET, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return InternalArticleList::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * You can create a new internal article by making a POST request to `https://api.intercom.io/internal_articles`. + * + * @param ?CreateInternalArticleRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return InternalArticleListItem + * @throws IntercomException + * @throws IntercomApiException + */ + public function createInternalArticle(?CreateInternalArticleRequest $request = null, ?array $options = null): InternalArticleListItem + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "internal_articles", + method: HttpMethod::POST, + body: $request, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return InternalArticleListItem::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * You can fetch the details of a single internal article by making a GET request to `https://api.intercom.io/internal_articles/`. + * + * @param RetrieveInternalArticleRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return InternalArticleListItem + * @throws IntercomException + * @throws IntercomApiException + */ + public function retrieveInternalArticle(RetrieveInternalArticleRequest $request, ?array $options = null): InternalArticleListItem + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "internal_articles/{$request->getId()}", + method: HttpMethod::GET, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return InternalArticleListItem::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * You can update the details of a single internal article by making a PUT request to `https://api.intercom.io/internal_articles/`. + * + * @param UpdateInternalArticleRequestBody $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return InternalArticleListItem + * @throws IntercomException + * @throws IntercomApiException + */ + public function updateInternalArticle(UpdateInternalArticleRequestBody $request, ?array $options = null): InternalArticleListItem + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "internal_articles/{$request->getId()}", + method: HttpMethod::PUT, + body: $request, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return InternalArticleListItem::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * You can delete a single internal article by making a DELETE request to `https://api.intercom.io/internal_articles/`. + * + * @param DeleteInternalArticleRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return DeletedInternalArticleObject + * @throws IntercomException + * @throws IntercomApiException + */ + public function deleteInternalArticle(DeleteInternalArticleRequest $request, ?array $options = null): DeletedInternalArticleObject + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "internal_articles/{$request->getId()}", + method: HttpMethod::DELETE, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return DeletedInternalArticleObject::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * You can search for internal articles by making a GET request to `https://api.intercom.io/internal_articles/search`. + * + * @param SearchInternalArticlesRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return InternalArticleSearchResponse + * @throws IntercomException + * @throws IntercomApiException + */ + public function searchInternalArticles(SearchInternalArticlesRequest $request = new SearchInternalArticlesRequest(), ?array $options = null): InternalArticleSearchResponse + { + $options = array_merge($this->options, $options ?? []); + $query = []; + if ($request->getFolderId() != null) { + $query['folder_id'] = $request->getFolderId(); + } + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "internal_articles/search", + method: HttpMethod::GET, + query: $query, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return InternalArticleSearchResponse::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } +} diff --git a/src/Unstable/InternalArticles/Requests/DeleteInternalArticleRequest.php b/src/Unstable/InternalArticles/Requests/DeleteInternalArticleRequest.php new file mode 100644 index 0000000..50e7744 --- /dev/null +++ b/src/Unstable/InternalArticles/Requests/DeleteInternalArticleRequest.php @@ -0,0 +1,41 @@ +id = $values['id']; + } + + /** + * @return int + */ + public function getId(): int + { + return $this->id; + } + + /** + * @param int $value + */ + public function setId(int $value): self + { + $this->id = $value; + return $this; + } +} diff --git a/src/Unstable/InternalArticles/Requests/RetrieveInternalArticleRequest.php b/src/Unstable/InternalArticles/Requests/RetrieveInternalArticleRequest.php new file mode 100644 index 0000000..e715963 --- /dev/null +++ b/src/Unstable/InternalArticles/Requests/RetrieveInternalArticleRequest.php @@ -0,0 +1,41 @@ +id = $values['id']; + } + + /** + * @return int + */ + public function getId(): int + { + return $this->id; + } + + /** + * @param int $value + */ + public function setId(int $value): self + { + $this->id = $value; + return $this; + } +} diff --git a/src/Unstable/InternalArticles/Requests/SearchInternalArticlesRequest.php b/src/Unstable/InternalArticles/Requests/SearchInternalArticlesRequest.php new file mode 100644 index 0000000..4c5ce06 --- /dev/null +++ b/src/Unstable/InternalArticles/Requests/SearchInternalArticlesRequest.php @@ -0,0 +1,41 @@ +folderId = $values['folderId'] ?? null; + } + + /** + * @return ?string + */ + public function getFolderId(): ?string + { + return $this->folderId; + } + + /** + * @param ?string $value + */ + public function setFolderId(?string $value = null): self + { + $this->folderId = $value; + return $this; + } +} diff --git a/src/Unstable/InternalArticles/Requests/UpdateInternalArticleRequestBody.php b/src/Unstable/InternalArticles/Requests/UpdateInternalArticleRequestBody.php new file mode 100644 index 0000000..76ce544 --- /dev/null +++ b/src/Unstable/InternalArticles/Requests/UpdateInternalArticleRequestBody.php @@ -0,0 +1,142 @@ +id = $values['id']; + $this->title = $values['title'] ?? null; + $this->body = $values['body'] ?? null; + $this->authorId = $values['authorId'] ?? null; + $this->ownerId = $values['ownerId'] ?? null; + } + + /** + * @return int + */ + public function getId(): int + { + return $this->id; + } + + /** + * @param int $value + */ + public function setId(int $value): self + { + $this->id = $value; + return $this; + } + + /** + * @return ?string + */ + public function getTitle(): ?string + { + return $this->title; + } + + /** + * @param ?string $value + */ + public function setTitle(?string $value = null): self + { + $this->title = $value; + return $this; + } + + /** + * @return ?string + */ + public function getBody(): ?string + { + return $this->body; + } + + /** + * @param ?string $value + */ + public function setBody(?string $value = null): self + { + $this->body = $value; + return $this; + } + + /** + * @return ?int + */ + public function getAuthorId(): ?int + { + return $this->authorId; + } + + /** + * @param ?int $value + */ + public function setAuthorId(?int $value = null): self + { + $this->authorId = $value; + return $this; + } + + /** + * @return ?int + */ + public function getOwnerId(): ?int + { + return $this->ownerId; + } + + /** + * @param ?int $value + */ + public function setOwnerId(?int $value = null): self + { + $this->ownerId = $value; + return $this; + } +} diff --git a/src/Unstable/InternalArticles/Types/InternalArticleListItem.php b/src/Unstable/InternalArticles/Types/InternalArticleListItem.php new file mode 100644 index 0000000..4dff4e3 --- /dev/null +++ b/src/Unstable/InternalArticles/Types/InternalArticleListItem.php @@ -0,0 +1,254 @@ +type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->title = $values['title'] ?? null; + $this->body = $values['body'] ?? null; + $this->ownerId = $values['ownerId'] ?? null; + $this->authorId = $values['authorId'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; + $this->updatedAt = $values['updatedAt'] ?? null; + $this->locale = $values['locale'] ?? null; + } + + /** + * @return ?'internal_article' + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?'internal_article' $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?string + */ + public function getId(): ?string + { + return $this->id; + } + + /** + * @param ?string $value + */ + public function setId(?string $value = null): self + { + $this->id = $value; + return $this; + } + + /** + * @return ?string + */ + public function getTitle(): ?string + { + return $this->title; + } + + /** + * @param ?string $value + */ + public function setTitle(?string $value = null): self + { + $this->title = $value; + return $this; + } + + /** + * @return ?string + */ + public function getBody(): ?string + { + return $this->body; + } + + /** + * @param ?string $value + */ + public function setBody(?string $value = null): self + { + $this->body = $value; + return $this; + } + + /** + * @return ?int + */ + public function getOwnerId(): ?int + { + return $this->ownerId; + } + + /** + * @param ?int $value + */ + public function setOwnerId(?int $value = null): self + { + $this->ownerId = $value; + return $this; + } + + /** + * @return ?int + */ + public function getAuthorId(): ?int + { + return $this->authorId; + } + + /** + * @param ?int $value + */ + public function setAuthorId(?int $value = null): self + { + $this->authorId = $value; + return $this; + } + + /** + * @return ?int + */ + public function getCreatedAt(): ?int + { + return $this->createdAt; + } + + /** + * @param ?int $value + */ + public function setCreatedAt(?int $value = null): self + { + $this->createdAt = $value; + return $this; + } + + /** + * @return ?int + */ + public function getUpdatedAt(): ?int + { + return $this->updatedAt; + } + + /** + * @param ?int $value + */ + public function setUpdatedAt(?int $value = null): self + { + $this->updatedAt = $value; + return $this; + } + + /** + * @return ?string + */ + public function getLocale(): ?string + { + return $this->locale; + } + + /** + * @param ?string $value + */ + public function setLocale(?string $value = null): self + { + $this->locale = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Unstable/InternalArticles/Types/InternalArticleSearchResponse.php b/src/Unstable/InternalArticles/Types/InternalArticleSearchResponse.php new file mode 100644 index 0000000..2c61496 --- /dev/null +++ b/src/Unstable/InternalArticles/Types/InternalArticleSearchResponse.php @@ -0,0 +1,130 @@ +type = $values['type'] ?? null; + $this->totalCount = $values['totalCount'] ?? null; + $this->data = $values['data'] ?? null; + $this->pages = $values['pages'] ?? null; + } + + /** + * @return ?'list' + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?'list' $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?int + */ + public function getTotalCount(): ?int + { + return $this->totalCount; + } + + /** + * @param ?int $value + */ + public function setTotalCount(?int $value = null): self + { + $this->totalCount = $value; + return $this; + } + + /** + * @return ?InternalArticleSearchResponseData + */ + public function getData(): ?InternalArticleSearchResponseData + { + return $this->data; + } + + /** + * @param ?InternalArticleSearchResponseData $value + */ + public function setData(?InternalArticleSearchResponseData $value = null): self + { + $this->data = $value; + return $this; + } + + /** + * @return ?CursorPages + */ + public function getPages(): ?CursorPages + { + return $this->pages; + } + + /** + * @param ?CursorPages $value + */ + public function setPages(?CursorPages $value = null): self + { + $this->pages = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Unstable/InternalArticles/Types/InternalArticleSearchResponseData.php b/src/Unstable/InternalArticles/Types/InternalArticleSearchResponseData.php new file mode 100644 index 0000000..f4dd5d2 --- /dev/null +++ b/src/Unstable/InternalArticles/Types/InternalArticleSearchResponseData.php @@ -0,0 +1,55 @@ + $internalArticles An array of Internal Article objects + */ + #[JsonProperty('internal_articles'), ArrayType([InternalArticleListItem::class])] + private ?array $internalArticles; + + /** + * @param array{ + * internalArticles?: ?array, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->internalArticles = $values['internalArticles'] ?? null; + } + + /** + * @return ?array + */ + public function getInternalArticles(): ?array + { + return $this->internalArticles; + } + + /** + * @param ?array $value + */ + public function setInternalArticles(?array $value = null): self + { + $this->internalArticles = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Unstable/Jobs/JobsClient.php b/src/Unstable/Jobs/JobsClient.php index 767e6f5..805c045 100644 --- a/src/Unstable/Jobs/JobsClient.php +++ b/src/Unstable/Jobs/JobsClient.php @@ -24,7 +24,7 @@ class JobsClient * maxRetries?: int, * timeout?: float, * headers?: array, - * } $options + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator */ private array $options; diff --git a/src/Unstable/Macros/MacrosClient.php b/src/Unstable/Macros/MacrosClient.php index fe77951..ed5e868 100644 --- a/src/Unstable/Macros/MacrosClient.php +++ b/src/Unstable/Macros/MacrosClient.php @@ -26,7 +26,7 @@ class MacrosClient * maxRetries?: int, * timeout?: float, * headers?: array, - * } $options + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator */ private array $options; diff --git a/src/Unstable/Messages/MessagesClient.php b/src/Unstable/Messages/MessagesClient.php index fc89e56..7413e3e 100644 --- a/src/Unstable/Messages/MessagesClient.php +++ b/src/Unstable/Messages/MessagesClient.php @@ -25,7 +25,7 @@ class MessagesClient * maxRetries?: int, * timeout?: float, * headers?: array, - * } $options + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator */ private array $options; @@ -78,7 +78,7 @@ public function __construct( * @throws IntercomException * @throws IntercomApiException */ - public function createMessage(mixed $request, ?array $options = null): Message + public function createMessage(mixed $request = null, ?array $options = null): Message { $options = array_merge($this->options, $options ?? []); try { diff --git a/src/Unstable/News/NewsClient.php b/src/Unstable/News/NewsClient.php index 16bdb07..d1411ce 100644 --- a/src/Unstable/News/NewsClient.php +++ b/src/Unstable/News/NewsClient.php @@ -32,7 +32,7 @@ class NewsClient * maxRetries?: int, * timeout?: float, * headers?: array, - * } $options + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator */ private array $options; diff --git a/src/Unstable/News/Types/NewsItem.php b/src/Unstable/News/Types/NewsItem.php index e3686fa..0135982 100644 --- a/src/Unstable/News/Types/NewsItem.php +++ b/src/Unstable/News/Types/NewsItem.php @@ -12,6 +12,12 @@ */ class NewsItem extends JsonSerializableType { + /** + * @var ?'news-item' $type The type of object. + */ + #[JsonProperty('type')] + private ?string $type; + /** * @var ?string $id The unique identifier for the news item which is given by Intercom. */ @@ -92,6 +98,7 @@ class NewsItem extends JsonSerializableType /** * @param array{ + * type?: ?'news-item', * id?: ?string, * workspaceId?: ?string, * title?: ?string, @@ -110,6 +117,7 @@ class NewsItem extends JsonSerializableType public function __construct( array $values = [], ) { + $this->type = $values['type'] ?? null; $this->id = $values['id'] ?? null; $this->workspaceId = $values['workspaceId'] ?? null; $this->title = $values['title'] ?? null; @@ -125,6 +133,23 @@ public function __construct( $this->updatedAt = $values['updatedAt'] ?? null; } + /** + * @return ?'news-item' + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?'news-item' $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + /** * @return ?string */ diff --git a/src/Unstable/News/Types/Newsfeed.php b/src/Unstable/News/Types/Newsfeed.php index 60d262e..3e8db8d 100644 --- a/src/Unstable/News/Types/Newsfeed.php +++ b/src/Unstable/News/Types/Newsfeed.php @@ -18,6 +18,12 @@ class Newsfeed extends JsonSerializableType #[JsonProperty('id')] private ?string $id; + /** + * @var ?'newsfeed' $type The type of object. + */ + #[JsonProperty('type')] + private ?string $type; + /** * @var ?string $name The name of the newsfeed. This name will never be visible to your users. */ @@ -39,6 +45,7 @@ class Newsfeed extends JsonSerializableType /** * @param array{ * id?: ?string, + * type?: ?'newsfeed', * name?: ?string, * createdAt?: ?int, * updatedAt?: ?int, @@ -48,6 +55,7 @@ public function __construct( array $values = [], ) { $this->id = $values['id'] ?? null; + $this->type = $values['type'] ?? null; $this->name = $values['name'] ?? null; $this->createdAt = $values['createdAt'] ?? null; $this->updatedAt = $values['updatedAt'] ?? null; @@ -70,6 +78,23 @@ public function setId(?string $value = null): self return $this; } + /** + * @return ?'newsfeed' + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?'newsfeed' $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + /** * @return ?string */ diff --git a/src/Unstable/Notes/NotesClient.php b/src/Unstable/Notes/NotesClient.php index 062f704..e041692 100644 --- a/src/Unstable/Notes/NotesClient.php +++ b/src/Unstable/Notes/NotesClient.php @@ -4,7 +4,7 @@ use GuzzleHttp\ClientInterface; use Intercom\Core\Client\RawClient; -use Intercom\Unstable\Notes\Requests\ListNotesRequest; +use Intercom\Unstable\Notes\Requests\ListCompanyNotesRequest; use Intercom\Unstable\Types\NoteList; use Intercom\Exceptions\IntercomException; use Intercom\Exceptions\IntercomApiException; @@ -14,6 +14,7 @@ use JsonException; use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; +use Intercom\Unstable\Notes\Requests\ListNotesRequest; use Intercom\Unstable\Notes\Requests\CreateNoteRequest; use Intercom\Unstable\Notes\Types\Note; use Intercom\Unstable\Notes\Requests\RetrieveNoteRequest; @@ -27,7 +28,7 @@ class NotesClient * maxRetries?: int, * timeout?: float, * headers?: array, - * } $options + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator */ private array $options; @@ -54,6 +55,61 @@ public function __construct( $this->options = $options ?? []; } + /** + * You can fetch a list of notes that are associated to a company. + * + * @param ListCompanyNotesRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return NoteList + * @throws IntercomException + * @throws IntercomApiException + */ + public function listCompanyNotes(ListCompanyNotesRequest $request, ?array $options = null): NoteList + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "companies/{$request->getId()}/notes", + method: HttpMethod::GET, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return NoteList::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + /** * You can fetch a list of notes that are associated to a contact. * diff --git a/src/Unstable/Notes/Requests/ListCompanyNotesRequest.php b/src/Unstable/Notes/Requests/ListCompanyNotesRequest.php new file mode 100644 index 0000000..54b001c --- /dev/null +++ b/src/Unstable/Notes/Requests/ListCompanyNotesRequest.php @@ -0,0 +1,41 @@ +id = $values['id']; + } + + /** + * @return string + */ + public function getId(): string + { + return $this->id; + } + + /** + * @param string $value + */ + public function setId(string $value): self + { + $this->id = $value; + return $this; + } +} diff --git a/src/Unstable/Notes/Types/CompanyNote.php b/src/Unstable/Notes/Types/CompanyNote.php new file mode 100644 index 0000000..1eddf57 --- /dev/null +++ b/src/Unstable/Notes/Types/CompanyNote.php @@ -0,0 +1,180 @@ +type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; + $this->company = $values['company'] ?? null; + $this->author = $values['author'] ?? null; + $this->body = $values['body'] ?? null; + } + + /** + * @return ?string + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?string $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?string + */ + public function getId(): ?string + { + return $this->id; + } + + /** + * @param ?string $value + */ + public function setId(?string $value = null): self + { + $this->id = $value; + return $this; + } + + /** + * @return ?int + */ + public function getCreatedAt(): ?int + { + return $this->createdAt; + } + + /** + * @param ?int $value + */ + public function setCreatedAt(?int $value = null): self + { + $this->createdAt = $value; + return $this; + } + + /** + * @return ?CompanyNoteCompany + */ + public function getCompany(): ?CompanyNoteCompany + { + return $this->company; + } + + /** + * @param ?CompanyNoteCompany $value + */ + public function setCompany(?CompanyNoteCompany $value = null): self + { + $this->company = $value; + return $this; + } + + /** + * @return ?Admin + */ + public function getAuthor(): ?Admin + { + return $this->author; + } + + /** + * @param ?Admin $value + */ + public function setAuthor(?Admin $value = null): self + { + $this->author = $value; + return $this; + } + + /** + * @return ?string + */ + public function getBody(): ?string + { + return $this->body; + } + + /** + * @param ?string $value + */ + public function setBody(?string $value = null): self + { + $this->body = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/DividerComponent.php b/src/Unstable/Notes/Types/CompanyNoteCompany.php similarity index 55% rename from src/Types/DividerComponent.php rename to src/Unstable/Notes/Types/CompanyNoteCompany.php index 5423f26..5d2154c 100644 --- a/src/Types/DividerComponent.php +++ b/src/Unstable/Notes/Types/CompanyNoteCompany.php @@ -1,71 +1,71 @@ type = $values['type'] ?? null; $this->id = $values['id'] ?? null; - $this->bottomMargin = $values['bottomMargin'] ?? null; } /** * @return ?string */ - public function getId(): ?string + public function getType(): ?string { - return $this->id; + return $this->type; } /** * @param ?string $value */ - public function setId(?string $value = null): self + public function setType(?string $value = null): self { - $this->id = $value; + $this->type = $value; return $this; } /** - * @return ?'none' + * @return ?string */ - public function getBottomMargin(): ?string + public function getId(): ?string { - return $this->bottomMargin; + return $this->id; } /** - * @param ?'none' $value + * @param ?string $value */ - public function setBottomMargin(?string $value = null): self + public function setId(?string $value = null): self { - $this->bottomMargin = $value; + $this->id = $value; return $this; } diff --git a/src/Unstable/Segments/SegmentsClient.php b/src/Unstable/Segments/SegmentsClient.php index 125b751..fdfae88 100644 --- a/src/Unstable/Segments/SegmentsClient.php +++ b/src/Unstable/Segments/SegmentsClient.php @@ -26,7 +26,7 @@ class SegmentsClient * maxRetries?: int, * timeout?: float, * headers?: array, - * } $options + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator */ private array $options; diff --git a/src/Unstable/SubscriptionTypes/SubscriptionTypesClient.php b/src/Unstable/SubscriptionTypes/SubscriptionTypesClient.php index fd15aa6..62db4ce 100644 --- a/src/Unstable/SubscriptionTypes/SubscriptionTypesClient.php +++ b/src/Unstable/SubscriptionTypes/SubscriptionTypesClient.php @@ -26,7 +26,7 @@ class SubscriptionTypesClient * maxRetries?: int, * timeout?: float, * headers?: array, - * } $options + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator */ private array $options; diff --git a/src/Unstable/Switch_/SwitchClient.php b/src/Unstable/Switch_/SwitchClient.php index bdbe247..f87cecd 100644 --- a/src/Unstable/Switch_/SwitchClient.php +++ b/src/Unstable/Switch_/SwitchClient.php @@ -23,7 +23,7 @@ class SwitchClient * maxRetries?: int, * timeout?: float, * headers?: array, - * } $options + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator */ private array $options; diff --git a/src/Unstable/Tags/TagsClient.php b/src/Unstable/Tags/TagsClient.php index 0edf4fc..5c7d36f 100644 --- a/src/Unstable/Tags/TagsClient.php +++ b/src/Unstable/Tags/TagsClient.php @@ -38,7 +38,7 @@ class TagsClient * maxRetries?: int, * timeout?: float, * headers?: array, - * } $options + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator */ private array $options; @@ -291,6 +291,7 @@ public function detachTagFromConversation(DetachTagFromConversationRequest $requ /** * You can fetch a list of all tags for a given workspace. * + * * @param ?array{ * baseUrl?: string, * maxRetries?: int, diff --git a/src/Unstable/Teams/TeamsClient.php b/src/Unstable/Teams/TeamsClient.php index 61b57d0..74c6c02 100644 --- a/src/Unstable/Teams/TeamsClient.php +++ b/src/Unstable/Teams/TeamsClient.php @@ -25,7 +25,7 @@ class TeamsClient * maxRetries?: int, * timeout?: float, * headers?: array, - * } $options + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator */ private array $options; diff --git a/src/Unstable/TicketStates/TicketStatesClient.php b/src/Unstable/TicketStates/TicketStatesClient.php index ed6272f..209b694 100644 --- a/src/Unstable/TicketStates/TicketStatesClient.php +++ b/src/Unstable/TicketStates/TicketStatesClient.php @@ -23,7 +23,7 @@ class TicketStatesClient * maxRetries?: int, * timeout?: float, * headers?: array, - * } $options + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator */ private array $options; diff --git a/src/Unstable/TicketTypeAttributes/TicketTypeAttributesClient.php b/src/Unstable/TicketTypeAttributes/TicketTypeAttributesClient.php index 70efaf6..a5e6314 100644 --- a/src/Unstable/TicketTypeAttributes/TicketTypeAttributesClient.php +++ b/src/Unstable/TicketTypeAttributes/TicketTypeAttributesClient.php @@ -25,7 +25,7 @@ class TicketTypeAttributesClient * maxRetries?: int, * timeout?: float, * headers?: array, - * } $options + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator */ private array $options; diff --git a/src/Unstable/TicketTypes/TicketTypesClient.php b/src/Unstable/TicketTypes/TicketTypesClient.php index 5a80c2e..1f5e7a6 100644 --- a/src/Unstable/TicketTypes/TicketTypesClient.php +++ b/src/Unstable/TicketTypes/TicketTypesClient.php @@ -25,7 +25,7 @@ class TicketTypesClient * maxRetries?: int, * timeout?: float, * headers?: array, - * } $options + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator */ private array $options; diff --git a/src/Unstable/Tickets/TicketsClient.php b/src/Unstable/Tickets/TicketsClient.php index 24f0f51..7854212 100644 --- a/src/Unstable/Tickets/TicketsClient.php +++ b/src/Unstable/Tickets/TicketsClient.php @@ -33,7 +33,7 @@ class TicketsClient * maxRetries?: int, * timeout?: float, * headers?: array, - * } $options + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator */ private array $options; @@ -374,8 +374,8 @@ public function deleteTicket(DeleteTicketRequest $request, ?array $options = nul * | id | String | * | created_at | Date (UNIX timestamp) | * | updated_at | Date (UNIX timestamp) | - * | _default_title_ | String | - * | _default_description_ | String | + * | title | String | + * | description | String | * | category | String | * | ticket_type_id | String | * | contact_ids | String | diff --git a/src/Unstable/Types/ActivityLogActivityType.php b/src/Unstable/Types/ActivityLogActivityType.php index f8cddd3..c82055a 100644 --- a/src/Unstable/Types/ActivityLogActivityType.php +++ b/src/Unstable/Types/ActivityLogActivityType.php @@ -4,7 +4,8 @@ enum ActivityLogActivityType: string { - case AdminAssignmentLimitChange = "admin_assignment_limit_change"; + case AdminConversationAssignmentLimitChange = "admin_conversation_assignment_limit_change"; + case AdminTicketAssignmentLimitChange = "admin_ticket_assignment_limit_change"; case AdminAwayModeChange = "admin_away_mode_change"; case AdminDeletion = "admin_deletion"; case AdminDeprovisioned = "admin_deprovisioned"; diff --git a/src/Unstable/Types/ActivityLogMetadata.php b/src/Unstable/Types/ActivityLogMetadata.php index c66967d..2d9c6c9 100644 --- a/src/Unstable/Types/ActivityLogMetadata.php +++ b/src/Unstable/Types/ActivityLogMetadata.php @@ -64,6 +64,18 @@ class ActivityLogMetadata extends JsonSerializableType #[JsonProperty('update_by_name')] private ?string $updateByName; + /** + * @var ?int $conversationAssignmentLimit The conversation assignment limit value for an admin. + */ + #[JsonProperty('conversation_assignment_limit')] + private ?int $conversationAssignmentLimit; + + /** + * @var ?int $ticketAssignmentLimit The ticket assignment limit value for an admin. + */ + #[JsonProperty('ticket_assignment_limit')] + private ?int $ticketAssignmentLimit; + /** * @param array{ * signInMethod?: ?string, @@ -75,6 +87,8 @@ class ActivityLogMetadata extends JsonSerializableType * autoChanged?: ?string, * updateBy?: ?int, * updateByName?: ?string, + * conversationAssignmentLimit?: ?int, + * ticketAssignmentLimit?: ?int, * } $values */ public function __construct( @@ -89,6 +103,8 @@ public function __construct( $this->autoChanged = $values['autoChanged'] ?? null; $this->updateBy = $values['updateBy'] ?? null; $this->updateByName = $values['updateByName'] ?? null; + $this->conversationAssignmentLimit = $values['conversationAssignmentLimit'] ?? null; + $this->ticketAssignmentLimit = $values['ticketAssignmentLimit'] ?? null; } /** @@ -244,6 +260,40 @@ public function setUpdateByName(?string $value = null): self return $this; } + /** + * @return ?int + */ + public function getConversationAssignmentLimit(): ?int + { + return $this->conversationAssignmentLimit; + } + + /** + * @param ?int $value + */ + public function setConversationAssignmentLimit(?int $value = null): self + { + $this->conversationAssignmentLimit = $value; + return $this; + } + + /** + * @return ?int + */ + public function getTicketAssignmentLimit(): ?int + { + return $this->ticketAssignmentLimit; + } + + /** + * @param ?int $value + */ + public function setTicketAssignmentLimit(?int $value = null): self + { + $this->ticketAssignmentLimit = $value; + return $this; + } + /** * @return string */ diff --git a/src/Unstable/Types/AiCallResponse.php b/src/Unstable/Types/AiCallResponse.php new file mode 100644 index 0000000..e7eeb3d --- /dev/null +++ b/src/Unstable/Types/AiCallResponse.php @@ -0,0 +1,280 @@ +> $callTranscript Array of transcript entries for the call + */ + #[JsonProperty('call_transcript'), ArrayType([['string' => 'mixed']])] + private ?array $callTranscript; + + /** + * @var ?string $callSummary Summary of the call conversation, truncated to 256 characters. Empty string if no summary available. + */ + #[JsonProperty('call_summary')] + private ?string $callSummary; + + /** + * @var ?array> $intent Array of intent classifications for the call + */ + #[JsonProperty('intent'), ArrayType([['string' => 'mixed']])] + private ?array $intent; + + /** + * @param array{ + * id?: ?int, + * appId?: ?int, + * userPhoneNumber?: ?string, + * status?: ?string, + * intercomCallId?: ?string, + * externalCallId?: ?string, + * intercomConversationId?: ?string, + * callTranscript?: ?array>, + * callSummary?: ?string, + * intent?: ?array>, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->id = $values['id'] ?? null; + $this->appId = $values['appId'] ?? null; + $this->userPhoneNumber = $values['userPhoneNumber'] ?? null; + $this->status = $values['status'] ?? null; + $this->intercomCallId = $values['intercomCallId'] ?? null; + $this->externalCallId = $values['externalCallId'] ?? null; + $this->intercomConversationId = $values['intercomConversationId'] ?? null; + $this->callTranscript = $values['callTranscript'] ?? null; + $this->callSummary = $values['callSummary'] ?? null; + $this->intent = $values['intent'] ?? null; + } + + /** + * @return ?int + */ + public function getId(): ?int + { + return $this->id; + } + + /** + * @param ?int $value + */ + public function setId(?int $value = null): self + { + $this->id = $value; + return $this; + } + + /** + * @return ?int + */ + public function getAppId(): ?int + { + return $this->appId; + } + + /** + * @param ?int $value + */ + public function setAppId(?int $value = null): self + { + $this->appId = $value; + return $this; + } + + /** + * @return ?string + */ + public function getUserPhoneNumber(): ?string + { + return $this->userPhoneNumber; + } + + /** + * @param ?string $value + */ + public function setUserPhoneNumber(?string $value = null): self + { + $this->userPhoneNumber = $value; + return $this; + } + + /** + * @return ?string + */ + public function getStatus(): ?string + { + return $this->status; + } + + /** + * @param ?string $value + */ + public function setStatus(?string $value = null): self + { + $this->status = $value; + return $this; + } + + /** + * @return ?string + */ + public function getIntercomCallId(): ?string + { + return $this->intercomCallId; + } + + /** + * @param ?string $value + */ + public function setIntercomCallId(?string $value = null): self + { + $this->intercomCallId = $value; + return $this; + } + + /** + * @return ?string + */ + public function getExternalCallId(): ?string + { + return $this->externalCallId; + } + + /** + * @param ?string $value + */ + public function setExternalCallId(?string $value = null): self + { + $this->externalCallId = $value; + return $this; + } + + /** + * @return ?string + */ + public function getIntercomConversationId(): ?string + { + return $this->intercomConversationId; + } + + /** + * @param ?string $value + */ + public function setIntercomConversationId(?string $value = null): self + { + $this->intercomConversationId = $value; + return $this; + } + + /** + * @return ?array> + */ + public function getCallTranscript(): ?array + { + return $this->callTranscript; + } + + /** + * @param ?array> $value + */ + public function setCallTranscript(?array $value = null): self + { + $this->callTranscript = $value; + return $this; + } + + /** + * @return ?string + */ + public function getCallSummary(): ?string + { + return $this->callSummary; + } + + /** + * @param ?string $value + */ + public function setCallSummary(?string $value = null): self + { + $this->callSummary = $value; + return $this; + } + + /** + * @return ?array> + */ + public function getIntent(): ?array + { + return $this->intent; + } + + /** + * @param ?array> $value + */ + public function setIntent(?array $value = null): self + { + $this->intent = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Unstable/Types/ArticleContent.php b/src/Unstable/Types/ArticleContent.php index 5a9cd88..5d1b2ff 100644 --- a/src/Unstable/Types/ArticleContent.php +++ b/src/Unstable/Types/ArticleContent.php @@ -11,7 +11,7 @@ class ArticleContent extends JsonSerializableType { /** - * @var ?string $type The type of object - `article_content` . + * @var ?'article_content' $type The type of object - `article_content` . */ #[JsonProperty('type')] private ?string $type; @@ -66,7 +66,7 @@ class ArticleContent extends JsonSerializableType /** * @param array{ - * type?: ?string, + * type?: ?'article_content', * title?: ?string, * description?: ?string, * body?: ?string, @@ -92,7 +92,7 @@ public function __construct( } /** - * @return ?string + * @return ?'article_content' */ public function getType(): ?string { @@ -100,7 +100,7 @@ public function getType(): ?string } /** - * @param ?string $value + * @param ?'article_content' $value */ public function setType(?string $value = null): self { diff --git a/src/Unstable/Types/ArticleTranslatedContent.php b/src/Unstable/Types/ArticleTranslatedContent.php index f0a79fa..27e54b2 100644 --- a/src/Unstable/Types/ArticleTranslatedContent.php +++ b/src/Unstable/Types/ArticleTranslatedContent.php @@ -11,7 +11,7 @@ class ArticleTranslatedContent extends JsonSerializableType { /** - * @var ?string $type The type of object - article_translated_content. + * @var ?'article_translated_content' $type The type of object - article_translated_content. */ #[JsonProperty('type')] private ?string $type; @@ -240,7 +240,7 @@ class ArticleTranslatedContent extends JsonSerializableType /** * @param array{ - * type?: ?string, + * type?: ?'article_translated_content', * ar?: ?ArticleContent, * bg?: ?ArticleContent, * bs?: ?ArticleContent, @@ -324,7 +324,7 @@ public function __construct( } /** - * @return ?string + * @return ?'article_translated_content' */ public function getType(): ?string { @@ -332,7 +332,7 @@ public function getType(): ?string } /** - * @param ?string $value + * @param ?'article_translated_content' $value */ public function setType(?string $value = null): self { diff --git a/src/Types/PaginatedNewsfeedResponse.php b/src/Unstable/Types/CallList.php similarity index 53% rename from src/Types/PaginatedNewsfeedResponse.php rename to src/Unstable/Types/CallList.php index b5bfac7..943a7af 100644 --- a/src/Types/PaginatedNewsfeedResponse.php +++ b/src/Unstable/Types/CallList.php @@ -1,123 +1,123 @@ $data A list of calls. */ - #[JsonProperty('pages')] - private ?CursorPages $pages; + #[JsonProperty('data'), ArrayType([Call::class])] + private ?array $data; /** - * @var int $totalCount A count of the total number of Newsfeeds. + * @var ?int $totalCount Total number of items available. */ #[JsonProperty('total_count')] - private int $totalCount; + private ?int $totalCount; /** - * @var array $data An array of Newsfeeds + * @var ?CursorPages $pages */ - #[JsonProperty('data'), ArrayType([Newsfeed::class])] - private array $data; + #[JsonProperty('pages')] + private ?CursorPages $pages; /** * @param array{ - * type: 'list', - * totalCount: int, - * data: array, + * type?: ?string, + * data?: ?array, + * totalCount?: ?int, * pages?: ?CursorPages, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; + $this->type = $values['type'] ?? null; + $this->data = $values['data'] ?? null; + $this->totalCount = $values['totalCount'] ?? null; $this->pages = $values['pages'] ?? null; - $this->totalCount = $values['totalCount']; - $this->data = $values['data']; } /** - * @return 'list' + * @return ?string */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'list' $value + * @param ?string $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return ?CursorPages + * @return ?array */ - public function getPages(): ?CursorPages + public function getData(): ?array { - return $this->pages; + return $this->data; } /** - * @param ?CursorPages $value + * @param ?array $value */ - public function setPages(?CursorPages $value = null): self + public function setData(?array $value = null): self { - $this->pages = $value; + $this->data = $value; return $this; } /** - * @return int + * @return ?int */ - public function getTotalCount(): int + public function getTotalCount(): ?int { return $this->totalCount; } /** - * @param int $value + * @param ?int $value */ - public function setTotalCount(int $value): self + public function setTotalCount(?int $value = null): self { $this->totalCount = $value; return $this; } /** - * @return array + * @return ?CursorPages */ - public function getData(): array + public function getPages(): ?CursorPages { - return $this->data; + return $this->pages; } /** - * @param array $value + * @param ?CursorPages $value */ - public function setData(array $value): self + public function setPages(?CursorPages $value = null): self { - $this->data = $value; + $this->pages = $value; return $this; } diff --git a/src/Unstable/Types/ConversationRating.php b/src/Unstable/Types/ConversationRating.php index 25352f3..7ad4553 100644 --- a/src/Unstable/Types/ConversationRating.php +++ b/src/Unstable/Types/ConversationRating.php @@ -28,6 +28,12 @@ class ConversationRating extends JsonSerializableType #[JsonProperty('created_at')] private ?int $createdAt; + /** + * @var ?int $updatedAt The time the rating was last updated. + */ + #[JsonProperty('updated_at')] + private ?int $updatedAt; + /** * @var ?ContactReference $contact */ @@ -45,6 +51,7 @@ class ConversationRating extends JsonSerializableType * rating?: ?int, * remark?: ?string, * createdAt?: ?int, + * updatedAt?: ?int, * contact?: ?ContactReference, * teammate?: ?Reference, * } $values @@ -55,6 +62,7 @@ public function __construct( $this->rating = $values['rating'] ?? null; $this->remark = $values['remark'] ?? null; $this->createdAt = $values['createdAt'] ?? null; + $this->updatedAt = $values['updatedAt'] ?? null; $this->contact = $values['contact'] ?? null; $this->teammate = $values['teammate'] ?? null; } @@ -110,6 +118,23 @@ public function setCreatedAt(?int $value = null): self return $this; } + /** + * @return ?int + */ + public function getUpdatedAt(): ?int + { + return $this->updatedAt; + } + + /** + * @param ?int $value + */ + public function setUpdatedAt(?int $value = null): self + { + $this->updatedAt = $value; + return $this; + } + /** * @return ?ContactReference */ diff --git a/src/Unstable/Types/ConversationStatistics.php b/src/Unstable/Types/ConversationStatistics.php index 5915e48..b4d2a19 100644 --- a/src/Unstable/Types/ConversationStatistics.php +++ b/src/Unstable/Types/ConversationStatistics.php @@ -143,6 +143,12 @@ class ConversationStatistics extends JsonSerializableType #[JsonProperty('handling_time')] private ?int $handlingTime; + /** + * @var ?int $adjustedHandlingTime Adjusted handling time for conversation in seconds. This is the active handling time excluding idle periods when teammates are not actively working on the conversation. + */ + #[JsonProperty('adjusted_handling_time')] + private ?int $adjustedHandlingTime; + /** * @param array{ * type?: ?string, @@ -167,6 +173,7 @@ class ConversationStatistics extends JsonSerializableType * assignedTeamFirstResponseTimeByTeam?: ?array, * assignedTeamFirstResponseTimeInOfficeHours?: ?array, * handlingTime?: ?int, + * adjustedHandlingTime?: ?int, * } $values */ public function __construct( @@ -194,6 +201,7 @@ public function __construct( $this->assignedTeamFirstResponseTimeByTeam = $values['assignedTeamFirstResponseTimeByTeam'] ?? null; $this->assignedTeamFirstResponseTimeInOfficeHours = $values['assignedTeamFirstResponseTimeInOfficeHours'] ?? null; $this->handlingTime = $values['handlingTime'] ?? null; + $this->adjustedHandlingTime = $values['adjustedHandlingTime'] ?? null; } /** @@ -570,6 +578,23 @@ public function setHandlingTime(?int $value = null): self return $this; } + /** + * @return ?int + */ + public function getAdjustedHandlingTime(): ?int + { + return $this->adjustedHandlingTime; + } + + /** + * @param ?int $value + */ + public function setAdjustedHandlingTime(?int $value = null): self + { + $this->adjustedHandlingTime = $value; + return $this; + } + /** * @return string */ diff --git a/src/Unstable/Types/UpdateArticleRequestBody.php b/src/Unstable/Types/CreateArticleRequest.php similarity index 73% rename from src/Unstable/Types/UpdateArticleRequestBody.php rename to src/Unstable/Types/CreateArticleRequest.php index 2616367..a14c324 100644 --- a/src/Unstable/Types/UpdateArticleRequestBody.php +++ b/src/Unstable/Types/CreateArticleRequest.php @@ -6,15 +6,15 @@ use Intercom\Core\Json\JsonProperty; /** - * You can Update an Article + * You can create an Article */ -class UpdateArticleRequestBody extends JsonSerializableType +class CreateArticleRequest extends JsonSerializableType { /** - * @var ?string $title The title of the article.For multilingual articles, this will be the title of the default language's content. + * @var string $title The title of the article.For multilingual articles, this will be the title of the default language's content. */ #[JsonProperty('title')] - private ?string $title; + private string $title; /** * @var ?string $description The description of the article. For multilingual articles, this will be the description of the default language's content. @@ -29,22 +29,22 @@ class UpdateArticleRequestBody extends JsonSerializableType private ?string $body; /** - * @var ?int $authorId 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. + * @var int $authorId 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')] - private ?int $authorId; + private int $authorId; /** - * @var ?value-of $state 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. + * @var ?value-of $state 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')] private ?string $state; /** - * @var ?string $parentId The id of the article's parent collection or section. An article without this field stands alone. + * @var ?int $parentId The id of the article's parent collection or section. An article without this field stands alone. */ #[JsonProperty('parent_id')] - private ?string $parentId; + private ?int $parentId; /** * @var ?string $parentType The type of parent, which can either be a `collection` or `section`. @@ -60,23 +60,23 @@ class UpdateArticleRequestBody extends JsonSerializableType /** * @param array{ - * title?: ?string, + * title: string, + * authorId: int, * description?: ?string, * body?: ?string, - * authorId?: ?int, - * state?: ?value-of, - * parentId?: ?string, + * state?: ?value-of, + * parentId?: ?int, * parentType?: ?string, * translatedContent?: ?ArticleTranslatedContent, * } $values */ public function __construct( - array $values = [], + array $values, ) { - $this->title = $values['title'] ?? null; + $this->title = $values['title']; $this->description = $values['description'] ?? null; $this->body = $values['body'] ?? null; - $this->authorId = $values['authorId'] ?? null; + $this->authorId = $values['authorId']; $this->state = $values['state'] ?? null; $this->parentId = $values['parentId'] ?? null; $this->parentType = $values['parentType'] ?? null; @@ -84,17 +84,17 @@ public function __construct( } /** - * @return ?string + * @return string */ - public function getTitle(): ?string + public function getTitle(): string { return $this->title; } /** - * @param ?string $value + * @param string $value */ - public function setTitle(?string $value = null): self + public function setTitle(string $value): self { $this->title = $value; return $this; @@ -135,24 +135,24 @@ public function setBody(?string $value = null): self } /** - * @return ?int + * @return int */ - public function getAuthorId(): ?int + public function getAuthorId(): int { return $this->authorId; } /** - * @param ?int $value + * @param int $value */ - public function setAuthorId(?int $value = null): self + public function setAuthorId(int $value): self { $this->authorId = $value; return $this; } /** - * @return ?value-of + * @return ?value-of */ public function getState(): ?string { @@ -160,7 +160,7 @@ public function getState(): ?string } /** - * @param ?value-of $value + * @param ?value-of $value */ public function setState(?string $value = null): self { @@ -169,17 +169,17 @@ public function setState(?string $value = null): self } /** - * @return ?string + * @return ?int */ - public function getParentId(): ?string + public function getParentId(): ?int { return $this->parentId; } /** - * @param ?string $value + * @param ?int $value */ - public function setParentId(?string $value = null): self + public function setParentId(?int $value = null): self { $this->parentId = $value; return $this; diff --git a/src/Unstable/Types/CreateArticleRequestState.php b/src/Unstable/Types/CreateArticleRequestState.php new file mode 100644 index 0000000..4e41f9f --- /dev/null +++ b/src/Unstable/Types/CreateArticleRequestState.php @@ -0,0 +1,9 @@ + $dataType + */ + #[JsonProperty('data_type')] + private ?string $dataType; + + /** + * @param array{ + * dataType?: ?value-of, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->dataType = $values['dataType'] ?? null; + } + + /** + * @return ?value-of + */ + public function getDataType(): ?string + { + return $this->dataType; + } + + /** + * @param ?value-of $value + */ + public function setDataType(?string $value = null): self + { + $this->dataType = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Unstable/DataAttributes/Types/CreateDataAttributeRequestDataType.php b/src/Unstable/Types/CreateDataAttributeRequestOneDataType.php similarity index 65% rename from src/Unstable/DataAttributes/Types/CreateDataAttributeRequestDataType.php rename to src/Unstable/Types/CreateDataAttributeRequestOneDataType.php index e31d259..b16abca 100644 --- a/src/Unstable/DataAttributes/Types/CreateDataAttributeRequestDataType.php +++ b/src/Unstable/Types/CreateDataAttributeRequestOneDataType.php @@ -1,8 +1,8 @@ $options Array of objects representing the options of the list, with `value` as the key and the option as the value. At least two options are required. + */ + #[JsonProperty('options'), ArrayType([CreateDataAttributeRequestOptionsOptionsItem::class])] + private array $options; + + /** + * @param array{ + * options: array, + * dataType?: ?'options', + * } $values + */ + public function __construct( + array $values, + ) { + $this->dataType = $values['dataType'] ?? null; + $this->options = $values['options']; + } + + /** + * @return ?'options' + */ + public function getDataType(): ?string + { + return $this->dataType; + } + + /** + * @param ?'options' $value + */ + public function setDataType(?string $value = null): self + { + $this->dataType = $value; + return $this; + } + + /** + * @return array + */ + public function getOptions(): array + { + return $this->options; + } + + /** + * @param array $value + */ + public function setOptions(array $value): self + { + $this->options = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Unstable/Types/CreateDataAttributeRequestOptionsOptionsItem.php b/src/Unstable/Types/CreateDataAttributeRequestOptionsOptionsItem.php new file mode 100644 index 0000000..f4f33be --- /dev/null +++ b/src/Unstable/Types/CreateDataAttributeRequestOptionsOptionsItem.php @@ -0,0 +1,51 @@ +value = $values['value'] ?? null; + } + + /** + * @return ?string + */ + public function getValue(): ?string + { + return $this->value; + } + + /** + * @param ?string $value + */ + public function setValue(?string $value = null): self + { + $this->value = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Unstable/Types/CreateInternalArticleRequest.php b/src/Unstable/Types/CreateInternalArticleRequest.php new file mode 100644 index 0000000..5239646 --- /dev/null +++ b/src/Unstable/Types/CreateInternalArticleRequest.php @@ -0,0 +1,129 @@ +title = $values['title']; + $this->body = $values['body'] ?? null; + $this->authorId = $values['authorId']; + $this->ownerId = $values['ownerId']; + } + + /** + * @return string + */ + public function getTitle(): string + { + return $this->title; + } + + /** + * @param string $value + */ + public function setTitle(string $value): self + { + $this->title = $value; + return $this; + } + + /** + * @return ?string + */ + public function getBody(): ?string + { + return $this->body; + } + + /** + * @param ?string $value + */ + public function setBody(?string $value = null): self + { + $this->body = $value; + return $this; + } + + /** + * @return int + */ + public function getAuthorId(): int + { + return $this->authorId; + } + + /** + * @param int $value + */ + public function setAuthorId(int $value): self + { + $this->authorId = $value; + return $this; + } + + /** + * @return int + */ + public function getOwnerId(): int + { + return $this->ownerId; + } + + /** + * @param int $value + */ + public function setOwnerId(int $value): self + { + $this->ownerId = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Unstable/Types/CreateOrUpdateCompanyRequest.php b/src/Unstable/Types/CreateOrUpdateCompanyRequest.php new file mode 100644 index 0000000..614037c --- /dev/null +++ b/src/Unstable/Types/CreateOrUpdateCompanyRequest.php @@ -0,0 +1,255 @@ + $customAttributes A hash of key/value pairs containing any other data about the company you want Intercom to store. + */ + #[JsonProperty('custom_attributes'), ArrayType(['string' => 'string'])] + private ?array $customAttributes; + + /** + * @var ?int $remoteCreatedAt The time the company was created by you. + */ + #[JsonProperty('remote_created_at')] + private ?int $remoteCreatedAt; + + /** + * @var ?int $monthlySpend 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')] + private ?int $monthlySpend; + + /** + * @param array{ + * name?: ?string, + * companyId?: ?string, + * plan?: ?string, + * size?: ?int, + * website?: ?string, + * industry?: ?string, + * customAttributes?: ?array, + * remoteCreatedAt?: ?int, + * monthlySpend?: ?int, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->name = $values['name'] ?? null; + $this->companyId = $values['companyId'] ?? null; + $this->plan = $values['plan'] ?? null; + $this->size = $values['size'] ?? null; + $this->website = $values['website'] ?? null; + $this->industry = $values['industry'] ?? null; + $this->customAttributes = $values['customAttributes'] ?? null; + $this->remoteCreatedAt = $values['remoteCreatedAt'] ?? null; + $this->monthlySpend = $values['monthlySpend'] ?? null; + } + + /** + * @return ?string + */ + public function getName(): ?string + { + return $this->name; + } + + /** + * @param ?string $value + */ + public function setName(?string $value = null): self + { + $this->name = $value; + return $this; + } + + /** + * @return ?string + */ + public function getCompanyId(): ?string + { + return $this->companyId; + } + + /** + * @param ?string $value + */ + public function setCompanyId(?string $value = null): self + { + $this->companyId = $value; + return $this; + } + + /** + * @return ?string + */ + public function getPlan(): ?string + { + return $this->plan; + } + + /** + * @param ?string $value + */ + public function setPlan(?string $value = null): self + { + $this->plan = $value; + return $this; + } + + /** + * @return ?int + */ + public function getSize(): ?int + { + return $this->size; + } + + /** + * @param ?int $value + */ + public function setSize(?int $value = null): self + { + $this->size = $value; + return $this; + } + + /** + * @return ?string + */ + public function getWebsite(): ?string + { + return $this->website; + } + + /** + * @param ?string $value + */ + public function setWebsite(?string $value = null): self + { + $this->website = $value; + return $this; + } + + /** + * @return ?string + */ + public function getIndustry(): ?string + { + return $this->industry; + } + + /** + * @param ?string $value + */ + public function setIndustry(?string $value = null): self + { + $this->industry = $value; + return $this; + } + + /** + * @return ?array + */ + public function getCustomAttributes(): ?array + { + return $this->customAttributes; + } + + /** + * @param ?array $value + */ + public function setCustomAttributes(?array $value = null): self + { + $this->customAttributes = $value; + return $this; + } + + /** + * @return ?int + */ + public function getRemoteCreatedAt(): ?int + { + return $this->remoteCreatedAt; + } + + /** + * @param ?int $value + */ + public function setRemoteCreatedAt(?int $value = null): self + { + $this->remoteCreatedAt = $value; + return $this; + } + + /** + * @return ?int + */ + public function getMonthlySpend(): ?int + { + return $this->monthlySpend; + } + + /** + * @param ?int $value + */ + public function setMonthlySpend(?int $value = null): self + { + $this->monthlySpend = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Unstable/Types/CreatePhoneSwitchRequest.php b/src/Unstable/Types/CreatePhoneSwitchRequest.php new file mode 100644 index 0000000..645f03f --- /dev/null +++ b/src/Unstable/Types/CreatePhoneSwitchRequest.php @@ -0,0 +1,102 @@ + $customAttributes + */ + #[JsonProperty('custom_attributes'), ArrayType(['string' => new Union('string', 'integer', 'datetime', CustomObjectInstanceList::class)])] + private ?array $customAttributes; + + /** + * @param array{ + * phone: string, + * customAttributes?: ?array, + * } $values + */ + public function __construct( + array $values, + ) { + $this->phone = $values['phone']; + $this->customAttributes = $values['customAttributes'] ?? null; + } + + /** + * @return string + */ + public function getPhone(): string + { + return $this->phone; + } + + /** + * @param string $value + */ + public function setPhone(string $value): self + { + $this->phone = $value; + return $this; + } + + /** + * @return ?array + */ + public function getCustomAttributes(): ?array + { + return $this->customAttributes; + } + + /** + * @param ?array $value + */ + public function setCustomAttributes(?array $value = null): self + { + $this->customAttributes = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Unstable/Types/UpdateTicketTypeRequestBody.php b/src/Unstable/Types/CreateTicketTypeRequest.php similarity index 66% rename from src/Unstable/Types/UpdateTicketTypeRequestBody.php rename to src/Unstable/Types/CreateTicketTypeRequest.php index 9011776..03ffc1e 100644 --- a/src/Unstable/Types/UpdateTicketTypeRequestBody.php +++ b/src/Unstable/Types/CreateTicketTypeRequest.php @@ -6,16 +6,16 @@ use Intercom\Core\Json\JsonProperty; /** - * The request payload for updating a ticket type. - * You can copy the `icon` property for your ticket type from [Twemoji Cheatsheet](https://twemoji-cheatsheet.vercel.app/) + * The request payload for creating a ticket type. + * You can copy the `icon` property for your ticket type from [Twemoji Cheatsheet](https://twemoji-cheatsheet.vercel.app/) */ -class UpdateTicketTypeRequestBody extends JsonSerializableType +class CreateTicketTypeRequest extends JsonSerializableType { /** - * @var ?string $name The name of the ticket type. + * @var string $name The name of the ticket type. */ #[JsonProperty('name')] - private ?string $name; + private string $name; /** * @var ?string $description The description of the ticket type. @@ -24,7 +24,7 @@ class UpdateTicketTypeRequestBody extends JsonSerializableType private ?string $description; /** - * @var ?value-of $category Category of the Ticket Type. + * @var ?value-of $category Category of the Ticket Type. */ #[JsonProperty('category')] private ?string $category; @@ -35,12 +35,6 @@ class UpdateTicketTypeRequestBody extends JsonSerializableType #[JsonProperty('icon')] private ?string $icon; - /** - * @var ?bool $archived The archived status of the ticket type. - */ - #[JsonProperty('archived')] - private ?bool $archived; - /** * @var ?bool $isInternal 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. */ @@ -49,37 +43,35 @@ class UpdateTicketTypeRequestBody extends JsonSerializableType /** * @param array{ - * name?: ?string, + * name: string, * description?: ?string, - * category?: ?value-of, + * category?: ?value-of, * icon?: ?string, - * archived?: ?bool, * isInternal?: ?bool, * } $values */ public function __construct( - array $values = [], + array $values, ) { - $this->name = $values['name'] ?? null; + $this->name = $values['name']; $this->description = $values['description'] ?? null; $this->category = $values['category'] ?? null; $this->icon = $values['icon'] ?? null; - $this->archived = $values['archived'] ?? null; $this->isInternal = $values['isInternal'] ?? null; } /** - * @return ?string + * @return string */ - public function getName(): ?string + public function getName(): string { return $this->name; } /** - * @param ?string $value + * @param string $value */ - public function setName(?string $value = null): self + public function setName(string $value): self { $this->name = $value; return $this; @@ -103,7 +95,7 @@ public function setDescription(?string $value = null): self } /** - * @return ?value-of + * @return ?value-of */ public function getCategory(): ?string { @@ -111,7 +103,7 @@ public function getCategory(): ?string } /** - * @param ?value-of $value + * @param ?value-of $value */ public function setCategory(?string $value = null): self { @@ -136,23 +128,6 @@ public function setIcon(?string $value = null): self return $this; } - /** - * @return ?bool - */ - public function getArchived(): ?bool - { - return $this->archived; - } - - /** - * @param ?bool $value - */ - public function setArchived(?bool $value = null): self - { - $this->archived = $value; - return $this; - } - /** * @return ?bool */ diff --git a/src/Unstable/Types/CreateTicketTypeRequestCategory.php b/src/Unstable/Types/CreateTicketTypeRequestCategory.php new file mode 100644 index 0000000..bca229b --- /dev/null +++ b/src/Unstable/Types/CreateTicketTypeRequestCategory.php @@ -0,0 +1,10 @@ +id = $values['id'] ?? null; + $this->object = $values['object'] ?? null; + $this->deleted = $values['deleted'] ?? null; + } + + /** + * @return ?string + */ + public function getId(): ?string + { + return $this->id; + } + + /** + * @param ?string $value + */ + public function setId(?string $value = null): self + { + $this->id = $value; + return $this; + } + + /** + * @return ?'internal_article' + */ + public function getObject(): ?string + { + return $this->object; + } + + /** + * @param ?'internal_article' $value + */ + public function setObject(?string $value = null): self + { + $this->object = $value; + return $this; + } + + /** + * @return ?bool + */ + public function getDeleted(): ?bool + { + return $this->deleted; + } + + /** + * @param ?bool $value + */ + public function setDeleted(?bool $value = null): self + { + $this->deleted = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Unstable/Types/EmailMessageMetadata.php b/src/Unstable/Types/EmailMessageMetadata.php index bd3d457..9fb3f19 100644 --- a/src/Unstable/Types/EmailMessageMetadata.php +++ b/src/Unstable/Types/EmailMessageMetadata.php @@ -23,10 +23,17 @@ class EmailMessageMetadata extends JsonSerializableType #[JsonProperty('email_address_headers'), ArrayType([EmailAddressHeader::class])] private ?array $emailAddressHeaders; + /** + * @var ?string $messageId The unique identifier for the email message as specified in the Message-ID header + */ + #[JsonProperty('message_id')] + private ?string $messageId; + /** * @param array{ * subject?: ?string, * emailAddressHeaders?: ?array, + * messageId?: ?string, * } $values */ public function __construct( @@ -34,6 +41,7 @@ public function __construct( ) { $this->subject = $values['subject'] ?? null; $this->emailAddressHeaders = $values['emailAddressHeaders'] ?? null; + $this->messageId = $values['messageId'] ?? null; } /** @@ -70,6 +78,23 @@ public function setEmailAddressHeaders(?array $value = null): self return $this; } + /** + * @return ?string + */ + public function getMessageId(): ?string + { + return $this->messageId; + } + + /** + * @param ?string $value + */ + public function setMessageId(?string $value = null): self + { + $this->messageId = $value; + return $this; + } + /** * @return string */ diff --git a/src/Unstable/Types/GroupContent.php b/src/Unstable/Types/GroupContent.php index 0de13d1..5088119 100644 --- a/src/Unstable/Types/GroupContent.php +++ b/src/Unstable/Types/GroupContent.php @@ -11,7 +11,7 @@ class GroupContent extends JsonSerializableType { /** - * @var ?string $type The type of object - `group_content` . + * @var ?'group_content' $type The type of object - `group_content` . */ #[JsonProperty('type')] private ?string $type; @@ -30,7 +30,7 @@ class GroupContent extends JsonSerializableType /** * @param array{ - * type?: ?string, + * type?: ?'group_content', * name?: ?string, * description?: ?string, * } $values @@ -44,7 +44,7 @@ public function __construct( } /** - * @return ?string + * @return ?'group_content' */ public function getType(): ?string { @@ -52,7 +52,7 @@ public function getType(): ?string } /** - * @param ?string $value + * @param ?'group_content' $value */ public function setType(?string $value = null): self { diff --git a/src/Unstable/Types/GroupTranslatedContent.php b/src/Unstable/Types/GroupTranslatedContent.php index 3ac4865..dcba90a 100644 --- a/src/Unstable/Types/GroupTranslatedContent.php +++ b/src/Unstable/Types/GroupTranslatedContent.php @@ -11,7 +11,7 @@ class GroupTranslatedContent extends JsonSerializableType { /** - * @var ?string $type The type of object - group_translated_content. + * @var ?'group_translated_content' $type The type of object - group_translated_content. */ #[JsonProperty('type')] private ?string $type; @@ -240,7 +240,7 @@ class GroupTranslatedContent extends JsonSerializableType /** * @param array{ - * type?: ?string, + * type?: ?'group_translated_content', * ar?: ?GroupContent, * bg?: ?GroupContent, * bs?: ?GroupContent, @@ -324,7 +324,7 @@ public function __construct( } /** - * @return ?string + * @return ?'group_translated_content' */ public function getType(): ?string { @@ -332,7 +332,7 @@ public function getType(): ?string } /** - * @param ?string $value + * @param ?'group_translated_content' $value */ public function setType(?string $value = null): self { diff --git a/src/Unstable/Types/IntercomVersion.php b/src/Unstable/Types/IntercomVersion.php deleted file mode 100644 index 77ad898..0000000 --- a/src/Unstable/Types/IntercomVersion.php +++ /dev/null @@ -1,25 +0,0 @@ - $data An array of Internal Article objects + */ + #[JsonProperty('data'), ArrayType([InternalArticleListItem::class])] + private ?array $data; + + /** + * @param array{ + * type?: ?'list', + * pages?: ?CursorPages, + * totalCount?: ?int, + * data?: ?array, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->type = $values['type'] ?? null; + $this->pages = $values['pages'] ?? null; + $this->totalCount = $values['totalCount'] ?? null; + $this->data = $values['data'] ?? null; + } + + /** + * @return ?'list' + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?'list' $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?CursorPages + */ + public function getPages(): ?CursorPages + { + return $this->pages; + } + + /** + * @param ?CursorPages $value + */ + public function setPages(?CursorPages $value = null): self + { + $this->pages = $value; + return $this; + } + + /** + * @return ?int + */ + public function getTotalCount(): ?int + { + return $this->totalCount; + } + + /** + * @param ?int $value + */ + public function setTotalCount(?int $value = null): self + { + $this->totalCount = $value; + return $this; + } + + /** + * @return ?array + */ + public function getData(): ?array + { + return $this->data; + } + + /** + * @param ?array $value + */ + public function setData(?array $value = null): self + { + $this->data = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Unstable/Types/LinkedObject.php b/src/Unstable/Types/LinkedObject.php index 7e56a07..5ca5ec9 100644 --- a/src/Unstable/Types/LinkedObject.php +++ b/src/Unstable/Types/LinkedObject.php @@ -23,7 +23,7 @@ class LinkedObject extends JsonSerializableType private ?string $id; /** - * @var ?string $category Category of the Linked Ticket Object. + * @var ?value-of $category Category of the Linked Ticket Object. */ #[JsonProperty('category')] private ?string $category; @@ -32,7 +32,7 @@ class LinkedObject extends JsonSerializableType * @param array{ * type?: ?value-of, * id?: ?string, - * category?: ?string, + * category?: ?value-of, * } $values */ public function __construct( @@ -78,7 +78,7 @@ public function setId(?string $value = null): self } /** - * @return ?string + * @return ?value-of */ public function getCategory(): ?string { @@ -86,7 +86,7 @@ public function getCategory(): ?string } /** - * @param ?string $value + * @param ?value-of $value */ public function setCategory(?string $value = null): self { diff --git a/src/Unstable/Types/LinkedObjectCategory.php b/src/Unstable/Types/LinkedObjectCategory.php new file mode 100644 index 0000000..b98d103 --- /dev/null +++ b/src/Unstable/Types/LinkedObjectCategory.php @@ -0,0 +1,10 @@ + $source Source of the call. Can be "five9", "zoom_phone", or defaults to "aws_connect" + */ + #[JsonProperty('source')] + private ?string $source; + + /** + * @var ?array $data Additional metadata about the call + */ + #[JsonProperty('data'), ArrayType(['string' => 'mixed'])] + private ?array $data; + + /** + * @param array{ + * phoneNumber: string, + * callId: string, + * source?: ?value-of, + * data?: ?array, + * } $values + */ + public function __construct( + array $values, + ) { + $this->phoneNumber = $values['phoneNumber']; + $this->callId = $values['callId']; + $this->source = $values['source'] ?? null; + $this->data = $values['data'] ?? null; + } + + /** + * @return string + */ + public function getPhoneNumber(): string + { + return $this->phoneNumber; + } + + /** + * @param string $value + */ + public function setPhoneNumber(string $value): self + { + $this->phoneNumber = $value; + return $this; + } + + /** + * @return string + */ + public function getCallId(): string + { + return $this->callId; + } + + /** + * @param string $value + */ + public function setCallId(string $value): self + { + $this->callId = $value; + return $this; + } + + /** + * @return ?value-of + */ + public function getSource(): ?string + { + return $this->source; + } + + /** + * @param ?value-of $value + */ + public function setSource(?string $value = null): self + { + $this->source = $value; + return $this; + } + + /** + * @return ?array + */ + public function getData(): ?array + { + return $this->data; + } + + /** + * @param ?array $value + */ + public function setData(?array $value = null): self + { + $this->data = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Unstable/Types/RegisterFinVoiceCallRequestSource.php b/src/Unstable/Types/RegisterFinVoiceCallRequestSource.php new file mode 100644 index 0000000..eea9ce7 --- /dev/null +++ b/src/Unstable/Types/RegisterFinVoiceCallRequestSource.php @@ -0,0 +1,10 @@ + $options Array of objects representing the options of the list, with `value` as the key and the option as the value. At least two options are required. + */ + #[JsonProperty('options'), ArrayType([UpdateDataAttributeRequestOptionsOptionsItem::class])] + private array $options; + + /** + * @param array{ + * options: array, + * } $values + */ + public function __construct( + array $values, + ) { + $this->options = $values['options']; + } + + /** + * @return array + */ + public function getOptions(): array + { + return $this->options; + } + + /** + * @param array $value + */ + public function setOptions(array $value): self + { + $this->options = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Unstable/Types/UpdateDataAttributeRequestOptionsOptionsItem.php b/src/Unstable/Types/UpdateDataAttributeRequestOptionsOptionsItem.php new file mode 100644 index 0000000..24643a4 --- /dev/null +++ b/src/Unstable/Types/UpdateDataAttributeRequestOptionsOptionsItem.php @@ -0,0 +1,51 @@ +value = $values['value'] ?? null; + } + + /** + * @return ?string + */ + public function getValue(): ?string + { + return $this->value; + } + + /** + * @param ?string $value + */ + public function setValue(?string $value = null): self + { + $this->value = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Unstable/UnstableClient.php b/src/Unstable/UnstableClient.php index 7923ea8..3411588 100644 --- a/src/Unstable/UnstableClient.php +++ b/src/Unstable/UnstableClient.php @@ -8,9 +8,10 @@ use Intercom\Unstable\AwayStatusReasons\AwayStatusReasonsClient; use Intercom\Unstable\Export\ExportClient; use Intercom\Unstable\HelpCenter\HelpCenterClient; +use Intercom\Unstable\InternalArticles\InternalArticlesClient; use Intercom\Unstable\Companies\CompaniesClient; -use Intercom\Unstable\Contacts\ContactsClient; use Intercom\Unstable\Notes\NotesClient; +use Intercom\Unstable\Contacts\ContactsClient; use Intercom\Unstable\SubscriptionTypes\SubscriptionTypesClient; use Intercom\Unstable\Tags\TagsClient; use Intercom\Unstable\Conversations\ConversationsClient; @@ -25,12 +26,15 @@ use Intercom\Unstable\News\NewsClient; use Intercom\Unstable\Segments\SegmentsClient; use Intercom\Unstable\Switch_\SwitchClient; +use Intercom\Unstable\Calls\CallsClient; use Intercom\Unstable\Teams\TeamsClient; use Intercom\Unstable\TicketStates\TicketStatesClient; use Intercom\Unstable\TicketTypeAttributes\TicketTypeAttributesClient; use Intercom\Unstable\TicketTypes\TicketTypesClient; use Intercom\Unstable\Tickets\TicketsClient; use Intercom\Unstable\Visitors\VisitorsClient; +use Intercom\Unstable\Brands\BrandsClient; +use Intercom\Unstable\Emails\EmailsClient; use GuzzleHttp\ClientInterface; use Intercom\Core\Client\RawClient; @@ -67,20 +71,25 @@ class UnstableClient public HelpCenterClient $helpCenter; /** - * @var CompaniesClient $companies + * @var InternalArticlesClient $internalArticles */ - public CompaniesClient $companies; + public InternalArticlesClient $internalArticles; /** - * @var ContactsClient $contacts + * @var CompaniesClient $companies */ - public ContactsClient $contacts; + public CompaniesClient $companies; /** * @var NotesClient $notes */ public NotesClient $notes; + /** + * @var ContactsClient $contacts + */ + public ContactsClient $contacts; + /** * @var SubscriptionTypesClient $subscriptionTypes */ @@ -151,6 +160,11 @@ class UnstableClient */ public SwitchClient $switch_; + /** + * @var CallsClient $calls + */ + public CallsClient $calls; + /** * @var TeamsClient $teams */ @@ -181,6 +195,16 @@ class UnstableClient */ public VisitorsClient $visitors; + /** + * @var BrandsClient $brands + */ + public BrandsClient $brands; + + /** + * @var EmailsClient $emails + */ + public EmailsClient $emails; + /** * @var array{ * baseUrl?: string, @@ -188,7 +212,7 @@ class UnstableClient * maxRetries?: int, * timeout?: float, * headers?: array, - * } $options + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator */ private array $options; @@ -219,9 +243,10 @@ public function __construct( $this->awayStatusReasons = new AwayStatusReasonsClient($this->client, $this->options); $this->export = new ExportClient($this->client, $this->options); $this->helpCenter = new HelpCenterClient($this->client, $this->options); + $this->internalArticles = new InternalArticlesClient($this->client, $this->options); $this->companies = new CompaniesClient($this->client, $this->options); - $this->contacts = new ContactsClient($this->client, $this->options); $this->notes = new NotesClient($this->client, $this->options); + $this->contacts = new ContactsClient($this->client, $this->options); $this->subscriptionTypes = new SubscriptionTypesClient($this->client, $this->options); $this->tags = new TagsClient($this->client, $this->options); $this->conversations = new ConversationsClient($this->client, $this->options); @@ -236,11 +261,14 @@ public function __construct( $this->news = new NewsClient($this->client, $this->options); $this->segments = new SegmentsClient($this->client, $this->options); $this->switch_ = new SwitchClient($this->client, $this->options); + $this->calls = new CallsClient($this->client, $this->options); $this->teams = new TeamsClient($this->client, $this->options); $this->ticketStates = new TicketStatesClient($this->client, $this->options); $this->ticketTypeAttributes = new TicketTypeAttributesClient($this->client, $this->options); $this->ticketTypes = new TicketTypesClient($this->client, $this->options); $this->tickets = new TicketsClient($this->client, $this->options); $this->visitors = new VisitorsClient($this->client, $this->options); + $this->brands = new BrandsClient($this->client, $this->options); + $this->emails = new EmailsClient($this->client, $this->options); } } diff --git a/src/Unstable/Visitors/VisitorsClient.php b/src/Unstable/Visitors/VisitorsClient.php index a152e16..fc85313 100644 --- a/src/Unstable/Visitors/VisitorsClient.php +++ b/src/Unstable/Visitors/VisitorsClient.php @@ -26,7 +26,7 @@ class VisitorsClient * maxRetries?: int, * timeout?: float, * headers?: array, - * } $options + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator */ private array $options; diff --git a/src/Visitors/VisitorsClient.php b/src/Visitors/VisitorsClient.php index 8ec76f0..8e758c9 100644 --- a/src/Visitors/VisitorsClient.php +++ b/src/Visitors/VisitorsClient.php @@ -30,7 +30,7 @@ class VisitorsClient * maxRetries?: int, * timeout?: float, * headers?: array, - * } $options + * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator */ private array $options; @@ -69,11 +69,11 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Visitor + * @return ?Visitor * @throws IntercomException * @throws IntercomApiException */ - public function find(FindVisitorRequest $request, ?array $options = null): Visitor + public function find(FindVisitorRequest $request, ?array $options = null): ?Visitor { $options = array_merge($this->options, $options ?? []); $query = []; @@ -91,6 +91,9 @@ public function find(FindVisitorRequest $request, ?array $options = null): Visit $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Visitor::fromJson($json); } } catch (JsonException $e) { @@ -134,11 +137,11 @@ public function find(FindVisitorRequest $request, ?array $options = null): Visit * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Visitor + * @return ?Visitor * @throws IntercomException * @throws IntercomApiException */ - public function update(UpdateVisitorRequestWithId|UpdateVisitorRequestWithUserId $request, ?array $options = null): Visitor + public function update(UpdateVisitorRequestWithId|UpdateVisitorRequestWithUserId $request, ?array $options = null): ?Visitor { $options = array_merge($this->options, $options ?? []); try { @@ -154,6 +157,9 @@ public function update(UpdateVisitorRequestWithId|UpdateVisitorRequestWithUserId $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Visitor::fromJson($json); } } catch (JsonException $e) { diff --git a/tests/Core/Client/RawClientTest.php b/tests/Core/Client/RawClientTest.php index 7c677d2..e2c3f2a 100644 --- a/tests/Core/Client/RawClientTest.php +++ b/tests/Core/Client/RawClientTest.php @@ -5,6 +5,8 @@ use GuzzleHttp\Client; use GuzzleHttp\Handler\MockHandler; use GuzzleHttp\HandlerStack; +use GuzzleHttp\Promise as P; +use GuzzleHttp\Psr7\Request; use GuzzleHttp\Psr7\Response; use PHPUnit\Framework\TestCase; use Psr\Http\Client\ClientExceptionInterface; @@ -441,4 +443,229 @@ public function testShouldFailOn400Response(): void $this->assertEquals(1, $this->mockHandler->count()); } + + public function testRetryAfterSecondsHeaderControlsDelay(): void + { + $responses = [ + new Response(503, ['Retry-After' => '10']), + new Response(200), + ]; + $capturedOptions = []; + + $handler = function (RequestInterface $request, array $options) use (&$responses, &$capturedOptions) { + $capturedOptions[] = $options; + $response = array_shift($responses); + return P\Create::promiseFor($response); + }; + + $middleware = RetryMiddleware::create([ + 'maxRetries' => 2, + 'baseDelay' => 1000, + ]); + + $retryHandler = $middleware($handler); + $request = new Request('GET', $this->baseUrl . '/test'); + + $promise = $retryHandler($request, ['delay' => 0]); + $promise->wait(); + + $this->assertCount(2, $capturedOptions); + $this->assertSame(0, $capturedOptions[0]['delay']); + $delay = $capturedOptions[1]['delay']; + $this->assertGreaterThanOrEqual(10000, $delay); + $this->assertLessThanOrEqual(12000, $delay); + } + + public function testRetryAfterHttpDateHeaderIsHandled(): void + { + $retryAfterDate = gmdate('D, d M Y H:i:s \G\M\T', time() + 5); + + $responses = [ + new Response(503, ['Retry-After' => $retryAfterDate]), + new Response(200), + ]; + $capturedOptions = []; + + $handler = function (RequestInterface $request, array $options) use (&$responses, &$capturedOptions) { + $capturedOptions[] = $options; + $response = array_shift($responses); + return P\Create::promiseFor($response); + }; + + $middleware = RetryMiddleware::create([ + 'maxRetries' => 2, + 'baseDelay' => 1000, + ]); + + $retryHandler = $middleware($handler); + $request = new Request('GET', $this->baseUrl . '/test'); + + $promise = $retryHandler($request, ['delay' => 0]); + $promise->wait(); + + $this->assertCount(2, $capturedOptions); + $delay = $capturedOptions[1]['delay']; + $this->assertGreaterThan(0, $delay); + $this->assertLessThanOrEqual(60000, $delay); + } + + public function testRateLimitResetHeaderControlsDelay(): void + { + $resetTime = (int) floor(microtime(true)) + 5; + $responses = [ + new Response(429, ['X-RateLimit-Reset' => (string) $resetTime]), + new Response(200), + ]; + $capturedOptions = []; + + $handler = function (RequestInterface $request, array $options) use (&$responses, &$capturedOptions) { + $capturedOptions[] = $options; + $response = array_shift($responses); + return P\Create::promiseFor($response); + }; + + $middleware = RetryMiddleware::create([ + 'maxRetries' => 2, + 'baseDelay' => 1000, + ]); + + $retryHandler = $middleware($handler); + $request = new Request('GET', $this->baseUrl . '/test'); + + $promise = $retryHandler($request, ['delay' => 0]); + $promise->wait(); + + $this->assertCount(2, $capturedOptions); + $delay = $capturedOptions[1]['delay']; + $this->assertGreaterThan(0, $delay); + $this->assertLessThanOrEqual(60000, $delay); + } + + public function testRateLimitResetHeaderRespectsMaxDelayAndPositiveJitter(): void + { + $resetTime = (int) floor(microtime(true)) + 1000; + $responses = [ + new Response(429, ['X-RateLimit-Reset' => (string) $resetTime]), + new Response(200), + ]; + $capturedOptions = []; + + $handler = function (RequestInterface $request, array $options) use (&$responses, &$capturedOptions) { + $capturedOptions[] = $options; + $response = array_shift($responses); + return P\Create::promiseFor($response); + }; + + $middleware = RetryMiddleware::create([ + 'maxRetries' => 1, + 'baseDelay' => 1000, + ]); + + $retryHandler = $middleware($handler); + $request = new Request('GET', $this->baseUrl . '/test'); + + $promise = $retryHandler($request, ['delay' => 0]); + $promise->wait(); + + $delay = $capturedOptions[1]['delay']; + $this->assertGreaterThanOrEqual(60000, $delay); + $this->assertLessThanOrEqual(72000, $delay); + } + + public function testExponentialBackoffWithSymmetricJitterWhenNoHeaders(): void + { + $responses = [ + new Response(503), + new Response(200), + ]; + $capturedOptions = []; + + $handler = function (RequestInterface $request, array $options) use (&$responses, &$capturedOptions) { + $capturedOptions[] = $options; + $response = array_shift($responses); + return P\Create::promiseFor($response); + }; + + $middleware = RetryMiddleware::create([ + 'maxRetries' => 1, + 'baseDelay' => 1000, + ]); + + $retryHandler = $middleware($handler); + $request = new Request('GET', $this->baseUrl . '/test'); + + $promise = $retryHandler($request, ['delay' => 0]); + $promise->wait(); + + $this->assertCount(2, $capturedOptions); + $delay = $capturedOptions[1]['delay']; + $this->assertGreaterThanOrEqual(900, $delay); + $this->assertLessThanOrEqual(1100, $delay); + } + + public function testRetryAfterHeaderTakesPrecedenceOverRateLimitReset(): void + { + $resetTime = (int) floor(microtime(true)) + 30; + $responses = [ + new Response(503, [ + 'Retry-After' => '5', + 'X-RateLimit-Reset' => (string) $resetTime, + ]), + new Response(200), + ]; + $capturedOptions = []; + + $handler = function (RequestInterface $request, array $options) use (&$responses, &$capturedOptions) { + $capturedOptions[] = $options; + $response = array_shift($responses); + return P\Create::promiseFor($response); + }; + + $middleware = RetryMiddleware::create([ + 'maxRetries' => 2, + 'baseDelay' => 1000, + ]); + + $retryHandler = $middleware($handler); + $request = new Request('GET', $this->baseUrl . '/test'); + + $promise = $retryHandler($request, ['delay' => 0]); + $promise->wait(); + + $this->assertCount(2, $capturedOptions); + $delay = $capturedOptions[1]['delay']; + $this->assertGreaterThanOrEqual(5000, $delay); + $this->assertLessThanOrEqual(6000, $delay); + } + + public function testMaxDelayCapIsApplied(): void + { + $responses = [ + new Response(503, ['Retry-After' => '120']), + new Response(200), + ]; + $capturedOptions = []; + + $handler = function (RequestInterface $request, array $options) use (&$responses, &$capturedOptions) { + $capturedOptions[] = $options; + $response = array_shift($responses); + return P\Create::promiseFor($response); + }; + + $middleware = RetryMiddleware::create([ + 'maxRetries' => 2, + 'baseDelay' => 1000, + ]); + + $retryHandler = $middleware($handler); + $request = new Request('GET', $this->baseUrl . '/test'); + + $promise = $retryHandler($request, ['delay' => 0]); + $promise->wait(); + + $this->assertCount(2, $capturedOptions); + $delay = $capturedOptions[1]['delay']; + $this->assertGreaterThanOrEqual(60000, $delay); + $this->assertLessThanOrEqual(72000, $delay); + } } diff --git a/tests/Core/Json/ExhaustiveTest.php b/tests/Core/Json/ExhaustiveTest.php index 19c8425..1be79b1 100644 --- a/tests/Core/Json/ExhaustiveTest.php +++ b/tests/Core/Json/ExhaustiveTest.php @@ -142,7 +142,7 @@ public function testExhaustive(): void 'simple_property' => 'Test String', // Omit 'nullable_property' to test null serialization 'date_property' => '2023-01-01', - 'datetime_property' => '2023-01-01T12:34:56+00:00', + 'datetime_property' => '2023-01-01T12:34:56Z', 'string_array' => ['one', 'two', 'three'], 'map_property' => ['key1' => 1, 'key2' => 2], 'object_array' => [ diff --git a/tests/Core/Json/UnionArrayTest.php b/tests/Core/Json/UnionArrayTest.php index e3676e0..5a7d58e 100644 --- a/tests/Core/Json/UnionArrayTest.php +++ b/tests/Core/Json/UnionArrayTest.php @@ -37,7 +37,7 @@ public function testUnionArray(): void $expectedJson = json_encode( [ 'mixed_dates' => [ - 1 => '2023-01-01T12:00:00+00:00', + 1 => '2023-01-01T12:00:00Z', 2 => null, 3 => 'Some String' ]