Fetch comments in product
swat.fetchListItemComments
Fetches the Comments of a given List Item
Definition
swat.fetchListItemComments(options, onSuccess, onError)
Example
Here's an example of how you can use this API to fetch Comments of a specific List Item :
// Define the opts
let options = {
// List Id
lid: "list-id",
empi: 123,
epi: 111
// 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(response) {
// Executed when list item comments are successfully fetched
console.log("Successfully fetch List Item Comments", response);
}
// Define error callback
let onError = function(error) {
// Error is an xhrObject
console.log("Error while fetching List Item Comments", error);
}
swat.fetchListItemComments(options, onSuccess, onError);
API Parameters
Argument | Type | Description |
---|---|---|
options | object | options is a simple object containing config required for fetching List Item Comments |
onSuccess | function | Called when the List Item Comments are successfully fetched. |
onError | function | Called when there is an error while fetching the List Item Comments. |
Success Response
The success response is a Map containing continuation token and List Item 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",
"empi": 123,
"epi": 111,
"cts": 145555555511
}
]
}
Other References
options
Argument | Type | Required | Description |
---|---|---|---|
opts.lid | string | Yes | Unique id of the List to fetch Comments for |
opts.empi | string | Yes | Product master id of the List Item to fetch Comments for |
opts.epi | string | Yes | Product variant id of the List Item to fetch Comments for |
opts.limit | number | optional | Number of Comments to fetch. Defaults to 100 |
opts.continuation | string | optional | Continuation token to paginate with the initial limit, returned in the response. Null when limit is not hit |
opts.sincets | number | optional | Timestamp in milliseconds to fetch comments since |
List Item Comments
Fields in List Item Comment Response
{
"cid": "System generated comment id",
"lid": "List id for the comment",
"empi": "Product ID",
"epi": "Product Variant ID",
"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
}
Argument | Type | Required | Description |
---|---|---|---|
cid | string | Yes | Comment id - system generated guid for the comment |
lid | string | Yes | List id - system generated guid for the list |
epi | number/string | Yes | Variant id of the product |
empi | number/string | Yes | Product id of the product |
via | string | optional | Set as email if comment was received via email, else undefined |
txt | string | Yes | Comment content |
cprops | object | optional | Map of custom fields |
cts | number | Yes | Created time at in milliseconds |
cby | string | Yes | Email address of the user who added the commentDefaults to 1. Quantity included for the action |
userinfo | object | Yes | User info of the comment adder |
userinfo.em | string | Yes | Email address of the adder |
userinfo.fname | string | Yes | First name of the adder |
userinfo.lname | string | Yes | Last name of the adder |
Updated over 1 year ago