Fetch list comments

Fetch list comments

❗️

This API may require setup from support before use. Please contact [email protected] to enable this in your store.

swat.fetchListComments

Fetches the Comments of a List with the given lid

Definition

swat.fetchListComments(options, onSuccess, onError)

Example

Here's an example of how you can use this API to fetch Comments of a specific List :

// Define the opts
let options = {
  // List Id
  lid: "list-id"
  // limit: 8 // Optional Limit on number of comments to return
  // sincets: timeinmilliseconds // Optional The timestamp from when returned comments should begin
  // continuation: continuationtoken // Optional Continuation token passed back in the response
};

// Define success callback
let onSuccess = function(commentsObj) { 
  // Executed when list comments are successfully fetched
  console.log("Successfully fetch List Comments", commentsObj);
}

// Define error callback
let onError = function(error) {
  // Error is an xhrObject
  console.log("Error while fetching List Comments", error);
}

swat.fetchListComments(options, onSuccess, onError);

API Parameters

ArgumentTypeDescription
optionsobjectoptions is a simple object containing config required for fetching List Comments
onSuccessfunctionCalled when the List Comments are successfully fetched.
onErrorfunctionCalled when there is an error while fetching the List Comments.

Success Response

The success response is a Map containing continuation token and List Comments

{
  "continuation": null,
  "results": [
    {
      "cid": "comment-id",
      "userinfo": {
        "em": "email-id",
        "fname": "first name",
        "lname": "last name"
      },
      "txt": "My third comment is here",
      "lid": "list-id",
      "cts": 145555555511
    }
  ]
}

Other References

options

ArgumentTypeRequiredDescription
options.lidstringYesUnique id of the List to fetch Comments for
options.limitnumberoptionalNumber of Comments to fetch. Defaults to 100
options.continuationstringoptionalContinuation token to paginate with the initial limit, returned in the response. Null when limit is not hit
options.sincetsnumberoptionalTimestamp in milliseconds to fetch comments since

List Comments

Fields in List Comment Response

{
  "cid": "System generated comment id",
  "lid": "List id for the comment",
  "txt": "Comment text",
  "via": "set as 'email' if comment received via email",
  "cby": "Created by email address",
  "uby": "Updated by email address",
  "cts": "Created at in milliseconds",
  "userinfo": {} // userinfo for the comment adder
}
ArgumentTypeRequiredDescription
cidstringYesComment id - system generated guid for the comment
lidstringYesList id - system generated guid for the list
viastringoptionalSet as email if comment was received via email, else undefined
txtstringYesComment content
cpropsobjectoptionalMap of custom fields
ctsnumberYesCreated time at in milliseconds
cbystringYesEmail address of the user who added the commentDefaults to 1. Quantity included for the action
userinfoobjectYesUser info of the comment adder
userinfo.emstringYesEmail address of the adder
userinfo.fnamestringYesFirst name of the adder
userinfo.lnamestringYesLast name of the adder