diff --git a/EXAMPLES.md b/EXAMPLES.md index f3347f2..d44b39a 100644 --- a/EXAMPLES.md +++ b/EXAMPLES.md @@ -45,6 +45,35 @@ CrispClient.website.deleteSuggestedConversationDataKey(websiteID, key); ========================= +https://docs.crisp.chat/references/rest-api/v1/#list-spam-conversations + +var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc"; +var pageNumber = 1; + +CrispClient.website.listSpamConversations(websiteID, pageNumber); + +========================= + +https://docs.crisp.chat/references/rest-api/v1/#resolve-spam-conversation-content + +var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc"; +var spamID = "b45e7d75-61ab-416c-858b-1919b5fcfd10"; + +CrispClient.website.resolveSpamConversationContent(websiteID, spamID); + +========================= + +https://docs.crisp.chat/references/rest-api/v1/#submit-spam-conversation-decision + +var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc"; +var spamID = "b45e7d75-61ab-416c-858b-1919b5fcfd10"; + +var action = "reject"; + +CrispClient.website.submitSpamConversationDecision(websiteID, spamID, action); + +========================= + https://docs.crisp.chat/references/rest-api/v1/#create-a-new-conversation var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc"; diff --git a/README.md b/README.md index 0b88cce..c7ce5d1 100644 --- a/README.md +++ b/README.md @@ -234,6 +234,47 @@ All methods that you will most likely need when building a Crisp integration are ``` + * **List Spam Conversations** [`user`]: [Reference](https://docs.crisp.chat/references/rest-api/v1/#list-spam-conversations) + * `CrispClient.website.listSpamConversations(websiteID, pageNumber)` + *
+ See Example + + ```javascript + var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc"; + var pageNumber = 1; + + CrispClient.website.listSpamConversations(websiteID, pageNumber); + ``` +
+ + * **Resolve Spam Conversation Content** [`user`]: [Reference](https://docs.crisp.chat/references/rest-api/v1/#resolve-spam-conversation-content) + * `CrispClient.website.resolveSpamConversationContent(websiteID, spamID)` + *
+ See Example + + ```javascript + var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc"; + var spamID = "b45e7d75-61ab-416c-858b-1919b5fcfd10"; + + CrispClient.website.resolveSpamConversationContent(websiteID, spamID); + ``` +
+ + * **Submit Spam Conversation Decision** [`user`]: [Reference](https://docs.crisp.chat/references/rest-api/v1/#submit-spam-conversation-decision) + * `CrispClient.website.submitSpamConversationDecision(websiteID, spamID, action)` + *
+ See Example + + ```javascript + var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc"; + var spamID = "b45e7d75-61ab-416c-858b-1919b5fcfd10"; + + var action = "reject"; + + CrispClient.website.submitSpamConversationDecision(websiteID, spamID, action); + ``` +
+ * #### **Website Conversation** * **⭐ Create A New Conversation** [`user`, `plugin`]: [Reference](https://docs.crisp.chat/references/rest-api/v1/#create-a-new-conversation) diff --git a/lib/resources/WebsiteConversation.js b/lib/resources/WebsiteConversation.js index 6c81290..75d5446 100644 --- a/lib/resources/WebsiteConversation.js +++ b/lib/resources/WebsiteConversation.js @@ -110,6 +110,64 @@ function WebsiteConversation(service, crisp) { ); }; + /** + * List Spam Conversations + * @memberof WebsiteConversation + * @public + * @method listSpamConversations + * @param {string} websiteID + * @param {number} pageNumber + * @return {Promise} + */ + service.listSpamConversations = function(websiteID, pageNumber) { + return crisp.get( + crisp._prepareRestUrl([ + "website", websiteID, "conversations", "spams", pageNumber + ]) + ); + }; + + /** + * Resolve Spam Conversation Content + * @memberof WebsiteConversation + * @public + * @method resolveSpamConversationContent + * @param {string} websiteID + * @param {string} spamID + * @return {Promise} + */ + service.resolveSpamConversationContent = function(websiteID, spamID) { + return crisp.get( + crisp._prepareRestUrl([ + "website", websiteID, "conversations", "spam", spamID, "content" + ]) + ); + }; + + /** + * Submit Spam Conversation Decision + * @memberof WebsiteConversation + * @public + * @method submitSpamConversationDecision + * @param {string} websiteID + * @param {string} spamID + * @param {string} action + * @return {Promise} + */ + service.submitSpamConversationDecision = function(websiteID, spamID, action) { + return crisp.post( + crisp._prepareRestUrl([ + "website", websiteID, "conversations", "spam", spamID, "decision" + ]), + + null, + + { + action : action + } + ); + }; + /** * Create A New Conversation * @memberof WebsiteConversation