diff --git a/README.md b/README.md index 7581040..ba24b67 100644 --- a/README.md +++ b/README.md @@ -96,11 +96,11 @@ Refer directly to [the library source code](https://github.com/crisp-im/go-crisp * #### **Website Batch** * **Batch Resolve Conversations** [`user`]: [Reference](https://docs.crisp.chat/references/rest-api/v1/#batch-resolve-items) - * `client.Website.BatchResolveConversations(websiteID string, sessions []string) (*Response, error)` + * `client.Website.BatchResolveConversations(websiteID string, operation WebsiteBatchConversationsOperation) (*Response, error)` * **Batch Read Conversations** [`user`]: [Reference](https://docs.crisp.chat/references/rest-api/v1/#batch-read-items) - * `client.Website.BatchReadConversations(websiteID string, sessions []string) (*Response, error)` + * `client.Website.BatchReadConversations(websiteID string, operation WebsiteBatchConversationsOperation) (*Response, error)` * **Batch Remove Conversations** [`user`]: [Reference](https://docs.crisp.chat/references/rest-api/v1/#batch-remove-items) - * `client.Website.BatchRemoveConversations(websiteID string, sessions []string) (*Response, error)` + * `client.Website.BatchRemoveConversations(websiteID string, operation WebsiteBatchConversationsOperation) (*Response, error)` * **Batch Remove People** [`user`]: [Reference](https://docs.crisp.chat/references/rest-api/v1/#batch-remove-items) * `client.Website.BatchRemovePeople(websiteID string, people WebsiteBatchPeopleOperationInner) (*Response, error)` @@ -218,7 +218,7 @@ Refer directly to [the library source code](https://github.com/crisp-im/go-crisp * **List Conversations (Search Variant)** [`user`, `plugin`]: [Reference](https://docs.crisp.chat/references/rest-api/v1/#list-conversations) * `client.Website.SearchConversations(websiteID string, pageNumber uint, searchQuery string, searchType string) (*[]Conversation, *Response, error)` * **List Conversations (Filter Variant)** [`user`, `plugin`]: [Reference](https://docs.crisp.chat/references/rest-api/v1/#list-conversations) - * `client.Website.FilterConversations(websiteID string, pageNumber uint, filterUnread bool, filterResolved bool, filterNotResolved bool, filterMention bool, filterAssigned bool, filterUnassigned bool) (*[]Conversation, *Response, error)` + * `client.Website.FilterConversations(websiteID string, pageNumber uint, filterInboxID string, filterUnread bool, filterResolved bool, filterNotResolved bool, filterMention bool, filterAssigned bool, filterUnassigned bool) (*[]Conversation, *Response, error)` * **List Suggested Conversation Segments** [`user`, `plugin`]: [Reference](https://docs.crisp.chat/references/rest-api/v1/#list-suggested-conversation-segments) * `client.Website.ListSuggestedConversationSegments(websiteID string, pageNumber uint) (*[]ConversationSuggestedSegment, *Response, error)` * **Delete Suggested Conversation Segment** [`user`, `plugin`]: [Reference](https://docs.crisp.chat/references/rest-api/v1/#delete-suggested-conversation-segment) @@ -295,6 +295,8 @@ Refer directly to [the library source code](https://github.com/crisp-im/go-crisp * `client.Website.GetConversationRoutingAssign(websiteID string, sessionID string) (*ConversationRoutingAssign, *Response, error)` * **⭐ Assign Conversation Routing** [`user`, `plugin`]: [Reference](https://docs.crisp.chat/references/rest-api/v1/#assign-conversation-routing) * `client.Website.AssignConversationRouting(websiteID string, sessionID string, assign ConversationRoutingAssignUpdate) (*Response, error)` + * **Update Conversation Inbox** [`user`, `plugin`]: [Reference](https://docs.crisp.chat/references/rest-api/v1/#update-conversation-inbox) + * `client.Website.UpdateConversationInbox(websiteID string, sessionID string, inboxID *string) (*Response, error)` * **⭐ Get Conversation Metas** [`user`, `plugin`]: [Reference](https://docs.crisp.chat/references/rest-api/v1/#get-conversation-metas) * `client.Website.GetConversationMetas(websiteID string, sessionID string) (*ConversationMeta, *Response, error)` * **⭐ Update Conversation Metas** [`user`, `plugin`]: [Reference](https://docs.crisp.chat/references/rest-api/v1/#update-conversation-metas) @@ -650,6 +652,8 @@ Available events are listed below: * `session:set_mentions` * **Session Set Routing** [`user`, `plugin`]: * `session:set_routing` + * **Session Set Inbox** [`user`, `plugin`]: + * `session:set_inbox` * **Session Removed** [`user`, `plugin`]: * `session:removed` diff --git a/crisp/events.go b/crisp/events.go index a4ed1c7..bf3eec8 100644 --- a/crisp/events.go +++ b/crisp/events.go @@ -488,6 +488,14 @@ type EventsReceiveSessionSetRouting struct { RoutingID *string `json:"routing_id"` } +// EventsReceiveSessionSetInbox maps session:set_inbox +type EventsReceiveSessionSetInbox struct { + EventsGeneric + EventsSessionGeneric + InboxID *string `json:"inbox_id"` + PreviousInboxID *string `json:"previous_inbox_id,omitempty"` +} + // EventsReceiveSessionRemoved maps session:removed type EventsReceiveSessionRemoved struct { EventsGeneric @@ -1102,6 +1110,12 @@ func (evt EventsReceiveSessionSetRouting) String() string { } +// String returns the string representation of EventsReceiveSessionSetInbox +func (evt EventsReceiveSessionSetInbox) String() string { + return Stringify(evt) +} + + // String returns the string representation of EventsReceiveSessionRemoved func (evt EventsReceiveSessionRemoved) String() string { return Stringify(evt) diff --git a/crisp/website_batch.go b/crisp/website_batch.go index 3af2db5..b8750ef 100644 --- a/crisp/website_batch.go +++ b/crisp/website_batch.go @@ -11,6 +11,7 @@ import ( // WebsiteBatchConversationsOperation mapping type WebsiteBatchConversationsOperation struct { + InboxID *string `json:"inbox_id,omitempty"` Sessions []string `json:"sessions,omitempty"` } @@ -32,25 +33,25 @@ type WebsiteBatchPeopleOperationInnerSearch struct { } // BatchResolveConversations resolves given (or all) items in website (conversation variant). -func (service *WebsiteService) BatchResolveConversations(websiteID string, sessions []string) (*Response, error) { +func (service *WebsiteService) BatchResolveConversations(websiteID string, operation WebsiteBatchConversationsOperation) (*Response, error) { url := fmt.Sprintf("website/%s/batch/resolve", websiteID) - req, _ := service.client.NewRequest("PATCH", url, WebsiteBatchConversationsOperation{Sessions: sessions}) + req, _ := service.client.NewRequest("PATCH", url, operation) return service.client.Do(req, nil) } // BatchReadConversations marks given (or all) items as read in website (conversation variant). -func (service *WebsiteService) BatchReadConversations(websiteID string, sessions []string) (*Response, error) { +func (service *WebsiteService) BatchReadConversations(websiteID string, operation WebsiteBatchConversationsOperation) (*Response, error) { url := fmt.Sprintf("website/%s/batch/read", websiteID) - req, _ := service.client.NewRequest("PATCH", url, WebsiteBatchConversationsOperation{Sessions: sessions}) + req, _ := service.client.NewRequest("PATCH", url, operation) return service.client.Do(req, nil) } // BatchRemoveConversations removes given items in website (conversation variant). -func (service *WebsiteService) BatchRemoveConversations(websiteID string, sessions []string) (*Response, error) { +func (service *WebsiteService) BatchRemoveConversations(websiteID string, operation WebsiteBatchConversationsOperation) (*Response, error) { url := fmt.Sprintf("website/%s/batch/remove", websiteID) - req, _ := service.client.NewRequest("PATCH", url, WebsiteBatchConversationsOperation{Sessions: sessions}) + req, _ := service.client.NewRequest("PATCH", url, operation) return service.client.Do(req, nil) } diff --git a/crisp/website_conversation.go b/crisp/website_conversation.go index 28b44c7..ae5a694 100644 --- a/crisp/website_conversation.go +++ b/crisp/website_conversation.go @@ -27,6 +27,7 @@ type ConversationData struct { type Conversation struct { SessionID *string `json:"session_id,omitempty"` WebsiteID *string `json:"website_id,omitempty"` + InboxID *string `json:"inbox_id,omitempty"` PeopleID *string `json:"people_id,omitempty"` State *string `json:"state,omitempty"` Status *uint8 `json:"status,omitempty"` @@ -817,6 +818,11 @@ type ConversationOriginalData struct { Data *ConversationOriginal `json:"data,omitempty"` } +// ConversationInboxUpdate mapping +type ConversationInboxUpdate struct { + InboxID *string `json:"inbox_id,omitempty"` +} + // ConversationStateData mapping type ConversationStateData struct { Data *ConversationState `json:"data,omitempty"` @@ -1140,8 +1146,9 @@ func (service *WebsiteService) SearchConversations(websiteID string, pageNumber // FilterConversations filters conversations for website. -func (service *WebsiteService) FilterConversations(websiteID string, pageNumber uint, filterUnread bool, filterResolved bool, filterNotResolved bool, filterMention bool, filterAssigned bool, filterUnassigned bool) (*[]Conversation, *Response, error) { +func (service *WebsiteService) FilterConversations(websiteID string, pageNumber uint, filterInboxID string, filterUnread bool, filterResolved bool, filterNotResolved bool, filterMention bool, filterAssigned bool, filterUnassigned bool) (*[]Conversation, *Response, error) { var ( + filterInboxIDValue string filterUnreadValue string filterResolvedValue string filterNotResolvedValue string @@ -1150,6 +1157,8 @@ func (service *WebsiteService) FilterConversations(websiteID string, pageNumber filterUnassignedValue string ) + filterInboxIDValue = filterInboxID + if filterUnread == true { filterUnreadValue = "1" } else { @@ -1186,7 +1195,7 @@ func (service *WebsiteService) FilterConversations(websiteID string, pageNumber filterUnassignedValue = "0" } - url := fmt.Sprintf("website/%s/conversations/%d?filter_unread=%s&filter_resolved=%s&filter_not_resolved=%s&filter_mention=%s&filter_assigned=%s&filter_unassigned=%s", websiteID, pageNumber, url.QueryEscape(filterUnreadValue), url.QueryEscape(filterResolvedValue), url.QueryEscape(filterNotResolvedValue), url.QueryEscape(filterMentionValue), url.QueryEscape(filterAssignedValue), url.QueryEscape(filterUnassignedValue)) + url := fmt.Sprintf("website/%s/conversations/%d?filter_inbox_id=%s&filter_unread=%s&filter_resolved=%s&filter_not_resolved=%s&filter_mention=%s&filter_assigned=%s&filter_unassigned=%s", websiteID, pageNumber, url.QueryEscape(filterInboxIDValue), url.QueryEscape(filterUnreadValue), url.QueryEscape(filterResolvedValue), url.QueryEscape(filterNotResolvedValue), url.QueryEscape(filterMentionValue), url.QueryEscape(filterAssignedValue), url.QueryEscape(filterUnassignedValue)) req, _ := service.client.NewRequest("GET", url, nil) conversations := new(ConversationListData) @@ -1634,6 +1643,15 @@ func (service *WebsiteService) AssignConversationRouting(websiteID string, sessi } +// UpdateConversationInbox updates inbox used for conversation. +func (service *WebsiteService) UpdateConversationInbox(websiteID string, sessionID string, inboxID *string) (*Response, error) { + url := fmt.Sprintf("website/%s/conversation/%s/inbox", websiteID, sessionID) + req, _ := service.client.NewRequest("PATCH", url, ConversationInboxUpdate{&inboxID}) + + return service.client.Do(req, nil) +} + + // GetConversationMetas resolves conversation meta information. func (service *WebsiteService) GetConversationMetas(websiteID string, sessionID string) (*ConversationMeta, *Response, error) { url := fmt.Sprintf("website/%s/conversation/%s/meta", websiteID, sessionID) diff --git a/crisp/website_visitors.go b/crisp/website_visitors.go index b94367a..94ae29e 100644 --- a/crisp/website_visitors.go +++ b/crisp/website_visitors.go @@ -31,6 +31,7 @@ type WebsiteVisitorListData struct { // WebsiteVisitor mapping type WebsiteVisitor struct { SessionID *string `json:"session_id,omitempty"` + InboxID *string `json:"inbox_id,omitempty"` Nickname *string `json:"nickname,omitempty"` Email *string `json:"email,omitempty"` Avatar *string `json:"avatar,omitempty"`