instagram-graph-api
Version:
A library to help perform requests to the Instagram Graph API.
193 lines (192 loc) • 6.97 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.GetObjectCommentsResponse = void 0;
const AbstractResponse_1 = require("../AbstractResponse");
/**
* Class that represents a response from requests to get the comments on an object.
*
* @author Tiago Grosso <tiagogrosso99@gmail.com>
* @since `next.release`
*/
class GetObjectCommentsResponse extends AbstractResponse_1.AbstractResponse {
/**
* The constructor.
*
* @param body the body of the response.
*/
constructor(body) {
super(body.data);
}
/**
* Gets an array with the ids of all the comments.
*
* @returns an array with the ids of all the comments.
*/
getIds() {
return this.data.map((elem) => elem.id);
}
/**
* Gets an array with the text of the all the comments.
* If a comment object does not have the 'text' field, 'undefined' is returned for that object.
*
* @returns an array with the text of the all the comments.
*/
getTexts() {
return this.data.map((elem) => elem.text);
}
/**
* Gets a map from the id of the comments to their text.
* If a comment object does not have the 'text' field, 'undefined' is returned for that object.
*
* @returns a map from the id of the comments to their 'text'.
*/
getTextsMap() {
return new Map(this.data.map((elem) => {
return [elem.id, elem.text];
}));
}
/**
* Gets an array with the timestamp of the all the comments.
* If a comment object does not have the 'timestamp' field, 'undefined' is returned for that object.
*
* @returns an array with the timestamp of the all the comments.
*/
getTimestamps() {
return this.data.map((elem) => elem.timestamp);
}
/**
* Gets a map from the id of the comments to their timestamp.
* If a comment object does not have the 'timestamp' field, 'undefined' is returned for that object.
*
* @returns a map from the id of the comments to their 'timestamp'.
*/
getTimestampsMap() {
return new Map(this.data.map((elem) => {
return [elem.id, elem.timestamp];
}));
}
/**
* Gets an array with whether each of the comments is hidden.
* If a comment object does not have the 'hidden' field, 'undefined' is returned for that object.
*
* @returns an array with whether each of the comments is hidden.
*/
getHidden() {
return this.data.map((elem) => elem.hidden);
}
/**
* Gets a map from the id of the comments to whether they are hidden.
* If a comment object does not have the 'hidden' field, 'undefined' is returned for that object.
*
* @returns a map from the id of the comments to whether it is hidden.
*/
getHiddenMap() {
return new Map(this.data.map((elem) => {
return [elem.id, elem.hidden];
}));
}
/**
* Gets an array with the like_count of the all the comments.
* If a comment object does not have the 'like_count' field, 'undefined' is returned for that object.
*
* @returns an array with the like_count of the all the comments.
*/
getLikeCounts() {
return this.data.map((elem) => elem.like_count);
}
/**
* Gets a map from the id of the comments to their like_count.
* If a comment object does not have the 'like_count' field, 'undefined' is returned for that object.
*
* @returns a map from the id of the comments to their 'like_count'.
*/
getLikeCountsMap() {
return new Map(this.data.map((elem) => {
return [elem.id, elem.like_count];
}));
}
/**
* Gets an array with the media of the all the comments.
* If a comment object does not have the 'media' field, 'undefined' is returned for that object.
*
* @returns an array with the media of the all the comments.
*/
getMediaObjects() {
return this.data.map((elem) => elem.media);
}
/**
* Gets a map from the id of the comments to their media.
* If a comment object does not have the 'media' field, 'undefined' is returned for that object.
*
* @returns a map from the id of the comments to their 'media'.
*/
getMediaObjectsMap() {
return new Map(this.data.map((elem) => {
return [elem.id, elem.media];
}));
}
/**
* Gets an array with the replies of the all the comments.
* If a comment object does not have the 'replies' field, 'undefined' is returned for that object.
* The replies field can only be returned for top level comments.
*
* @returns an array with the replies of the all the comments.
*/
getReplies() {
return this.data.map((elem) => { var _a; return (_a = elem.replies) === null || _a === void 0 ? void 0 : _a.data; });
}
/**
* Gets a map from the id of the comments to their replies.
* If a comment object does not have the 'replies' field, 'undefined' is returned for that object.
* The replies field can only be returned for top level comments.
*
* @returns a map from the id of the comments to their 'replies'.
*/
getRepliesMap() {
return new Map(this.data.map((elem) => {
var _a;
return [elem.id, (_a = elem.replies) === null || _a === void 0 ? void 0 : _a.data];
}));
}
/**
* Gets an array with the user of the all the comments.
* If a media object does not have the 'user' field, 'undefined' is returned for that object.
*
* @returns an array with the user of the all the comments.
*/
getUsers() {
return this.data.map((elem) => elem.user);
}
/**
* Gets a map from the id of the comments to their user.
* If a media object does not have the 'user' field, 'undefined' is returned for that object.
*
* @returns a map from the id of the comments to their 'user'.
*/
getUsersMap() {
return new Map(this.data.map((elem) => {
return [elem.id, elem.user];
}));
}
/**
* Gets an array with the username of the all the comments.
* If a media object does not have the 'username' field, 'undefined' is returned for that object.
*
* @returns an array with the username of the all the comments.
*/
getUsernames() {
return this.data.map((elem) => elem.username);
}
/**
* Gets a map from the id of the comments to their username.
* If a media object does not have the 'username' field, 'undefined' is returned for that object.
*
* @returns a map from the id of the comments to their 'username'.
*/
getUsernamesMap() {
return new Map(this.data.map((elem) => {
return [elem.id, elem.username];
}));
}
}
exports.GetObjectCommentsResponse = GetObjectCommentsResponse;