Skip to content

Commit

Permalink
Add new website.listSpamConversations() methods (et al)
Browse files Browse the repository at this point in the history
  • Loading branch information
valeriansaliou committed Oct 3, 2024
1 parent 4f86ad2 commit b7d97a8
Show file tree
Hide file tree
Showing 3 changed files with 128 additions and 0 deletions.
29 changes: 29 additions & 0 deletions EXAMPLES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,47 @@ All methods that you will most likely need when building a Crisp integration are
```
</details>

* **List Spam Conversations** [`user`]: [Reference](https://docs.crisp.chat/references/rest-api/v1/#list-spam-conversations)
* `CrispClient.website.listSpamConversations(websiteID, pageNumber)`
* <details>
<summary>See Example</summary>

```javascript
var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc";
var pageNumber = 1;
CrispClient.website.listSpamConversations(websiteID, pageNumber);
```
</details>

* **Resolve Spam Conversation Content** [`user`]: [Reference](https://docs.crisp.chat/references/rest-api/v1/#resolve-spam-conversation-content)
* `CrispClient.website.resolveSpamConversationContent(websiteID, spamID)`
* <details>
<summary>See Example</summary>

```javascript
var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc";
var spamID = "b45e7d75-61ab-416c-858b-1919b5fcfd10";
CrispClient.website.resolveSpamConversationContent(websiteID, spamID);
```
</details>

* **Submit Spam Conversation Decision** [`user`]: [Reference](https://docs.crisp.chat/references/rest-api/v1/#submit-spam-conversation-decision)
* `CrispClient.website.submitSpamConversationDecision(websiteID, spamID, action)`
* <details>
<summary>See Example</summary>

```javascript
var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc";
var spamID = "b45e7d75-61ab-416c-858b-1919b5fcfd10";
var action = "reject";
CrispClient.website.submitSpamConversationDecision(websiteID, spamID, action);
```
</details>


* #### **Website Conversation**
* **⭐ Create A New Conversation** [`user`, `plugin`]: [Reference](https://docs.crisp.chat/references/rest-api/v1/#create-a-new-conversation)
Expand Down
58 changes: 58 additions & 0 deletions lib/resources/WebsiteConversation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b7d97a8

Please sign in to comment.