instagram-graph-api
Version:
A library to help perform requests to the Instagram Graph API.
301 lines (300 loc) • 11.4 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.GetPageMediaResponse = void 0;
const AbstractResponse_1 = require("../../AbstractResponse");
const Paging_1 = require("../../data/Paging");
/**
* Class that represents a response from a Page Media request.
*
* @author Tiago Grosso <tiagogrosso99@gmail.com>
* @since 0.1.0
*/
class GetPageMediaResponse extends AbstractResponse_1.AbstractResponse {
/**
* The constructor.
*
* @param body the body of the response
*/
constructor(body) {
super(body.data);
this.paging = new Paging_1.Paging(body.paging);
}
/**
* Gets the paging of the response.
*
* @returns the paging of the response.
*/
getPaging() {
return this.paging;
}
/**
* Gets an array with the ids of all the media objects.
*
* @returns an array with the ids of all the media objects.
*/
getIds() {
return this.data.map((elem) => elem.id);
}
/**
* Gets an array with the caption of the all the media objects.
* If a media object does not have the 'caption' field, 'undefined' is returned for that object.
*
* @returns an array with the caption of the all the media objects.
*/
getCaptions() {
return this.data.map((elem) => elem.caption);
}
/**
* Gets a map from the id of the media objects to their caption.
* If a media object does have not a the 'caption' field, 'undefined' is returned for that object.
*
* @returns a map from the id of the media objects to their 'caption'.
*/
getCaptionsMap() {
return new Map(this.data.map((elem) => {
return [elem.id, elem.caption];
}));
}
/**
* Gets an array with the comments count of the all the media objects.
* If a media object does not have the 'comments_count' field, 'undefined' is returned for that object.
*
* @returns an array with the 'comments_count' of the all the media objects.
*/
getCommentsCount() {
return this.data.map((elem) => elem.comments_count);
}
/**
* Gets a map from the id of the media objects to their comments count.
* If a media object does have not a the 'comments_count' field, 'undefined' is returned for that object.
*
* @returns a map from the id of the media objects to whether their 'comments_count'.
*/
getCommentsCountMap() {
return new Map(this.data.map((elem) => {
return [elem.id, elem.comments_count];
}));
}
/**
* Gets an array with the ig_id of the all the media objects.
* If a media object does not have the 'like_count' field, 'undefined' is returned for that object.
*
* @returns an array with the ig_id of the all the media objects.
*/
getIgIds() {
return this.data.map((elem) => elem.ig_id);
}
/**
* Gets a map from the id of the media objects to their ig_id.
* If a media object does not have the 'like_count' field, 'undefined' is returned for that object.
*
* @returns a map from the ig of the media objects to their 'ig_id'.
*/
getIgIdsMap() {
return new Map(this.data.map((elem) => {
return [elem.id, elem.ig_id];
}));
}
/**
* Gets an array with the 'is_comment_enabled' of the all the media objects.
* If a media object does not have the 'is_comment_enabled' field, 'undefined' is returned for that object.
*
* @returns an array with the 'is_comment_enabled' of the all the media objects.
*/
getCommentsEnabled() {
return this.data.map((elem) => elem.is_comment_enabled);
}
/**
* Gets a map from the id of the media objects to whether they have comments enabled.
* If a media object does have not a the 'is_comment_enabled' field, 'undefined' is returned for that object.
*
* @returns a map from the id of the media objects to whether they have comments enabled.
*/
getCommentsEnabledMap() {
return new Map(this.data.map((elem) => {
return [elem.id, elem.is_comment_enabled];
}));
}
/**
* Gets an array with the like counts of the all the media objects.
* If a media object does not have the 'like_count' field, 'undefined' is returned for that object.
*
* @returns an array with the like counts of the all the media objects.
*/
getLikes() {
return this.data.map((elem) => elem.like_count);
}
/**
* Gets a map from the id of the media objects to their like count.
* If a media object does have not a the 'like_count' field, 'undefined' is returned for that object.
*
* @returns a map from the id of the media objects to their 'like_count'.
*/
getLikesMap() {
return new Map(this.data.map((elem) => {
return [elem.id, elem.like_count];
}));
}
/**
* Gets an array with the media types of the all the media objects.
* If a media object does not have the 'media_type' field, 'undefined' is returned for that object.
*
* @returns an array with the media types of the all the media objects.
*/
getMediaTypes() {
return this.data.map((elem) => elem.media_type);
}
/**
* Gets a map from the id of the media objects to their media type.
* If a media object does have not a the 'media_type' field, 'undefined' is returned for that object.
*
* @returns a map from the id of the media objects to their 'media_type'.
*/
getMediaTypesMap() {
return new Map(this.data.map((elem) => {
return [elem.id, elem.media_type];
}));
}
/**
* Gets an array with the media URLs of the all the media object.
* If a media object does not have the 'media_url' field, 'undefined' is returned for that object.
*
* @returns an array with the media URLs of the all the media objects.
*/
getMediaUrls() {
return this.data.map((elem) => elem.media_url);
}
/**
* Gets a map from the id of the media objects to their media URL.
* If a media object does have not a the 'media_url' field, 'undefined' is returned for that object.
*
* @returns a map from the id of the media objects to their 'media_url'.
*/
getMediaUrlsMap() {
return new Map(this.data.map((elem) => {
return [elem.id, elem.media_url];
}));
}
/**
* Gets an array with the media owner of the all the media object.
* If a media object does not have the 'owner' field, 'undefined' is returned for that object.
*
* @returns an array with the media owner of the all the media objects.
*/
getMediaOwners() {
return this.data.map((elem) => elem.owner);
}
/**
* Gets a map from the id of the media objects to their media owner.
* If a media object does have not a the 'owner' field, 'undefined' is returned for that object.
*
* @returns a map from the id of the media objects to their 'owner'.
*/
getMediaOwnersMap() {
return new Map(this.data.map((elem) => {
return [elem.id, elem.owner];
}));
}
/**
* Gets an array with the id of media owner of the all the media object.
* If a media object does not have the 'owner' field, 'undefined' is returned for that object.
*
* @returns an array with the id of media owner of the all the media objects.
*/
getMediaOwnerIds() {
return this.data.map((elem) => { var _a; return (_a = elem.owner) === null || _a === void 0 ? void 0 : _a.id; });
}
/**
* Gets a map from the id of the media objects to the id of their media owner.
* If a media object does have not a the 'owner' field, 'undefined' is returned for that object.
*
* @returns a map from the id of the media objects to their 'owner.id'.
*/
getMediaOwnerIdsMap() {
return new Map(this.data.map((elem) => {
var _a;
return [elem.id, (_a = elem.owner) === null || _a === void 0 ? void 0 : _a.id];
}));
}
/**
* Gets an array with the media owner of the all the permalinks.
* If a media object does not have the 'permalink' field, 'undefined' is returned for that object.
*
* @returns an array with the permalinks of the all the media objects.
*/
getPermalinks() {
return this.data.map((elem) => elem.permalink);
}
/**
* Gets a map from the id of the media objects to their permalink.
* If a media object does have not a the 'permalink' field, 'undefined' is returned for that object.
*
* @returns a map from the id of the media objects to their 'permalink'.
*/
getPermalinksMap() {
return new Map(this.data.map((elem) => {
return [elem.id, elem.permalink];
}));
}
/**
* Gets an array with the media owner of the all the shortcodes.
* If a media object does not have the 'shortcode' field, 'undefined' is returned for that object.
*
* @returns an array with the shortcodes of the all the media objects.
*/
getShortcodes() {
return this.data.map((elem) => elem.shortcode);
}
/**
* Gets a map from the id of the media objects to their shortcode.
* If a media object does have not a the 'shortcode' field, 'undefined' is returned for that object.
*
* @returns a map from the id of the media objects to their 'shortcode'.
*/
getShortcodesMap() {
return new Map(this.data.map((elem) => {
return [elem.id, elem.shortcode];
}));
}
/**
* Gets an array with the media owner of the all the timestamps.
* If a media object does not have the 'timestamp' field, 'undefined' is returned for that object.
*
* @returns an array with the timestamps of the all the media objects.
*/
getTimestamps() {
return this.data.map((elem) => (elem.timestamp != undefined ? new Date(elem.timestamp) : undefined));
}
/**
* Gets a map from the id of the media objects to their timestamp.
* If a media object does have not a the 'timestamp' field, 'undefined' is returned for that object.
*
* @returns a map from the id of the media objects to their 'timestamp'.
*/
getTimestampsMap() {
return new Map(this.data.map((elem) => {
return [elem.id, elem.timestamp != undefined ? new Date(elem.timestamp) : undefined];
}));
}
/**
* Gets an array with the media owner of the all the usernames.
* If a media object does not have the 'username' field, 'undefined' is returned for that object.
*
* @returns an array with the usernames of the all the media objects.
*/
getUsernames() {
return this.data.map((elem) => elem.username);
}
/**
* Gets a map from the id of the media objects to their username.
* If a media object does have not a the 'username' field, 'undefined' is returned for that object.
*
* @returns a map from the id of the media objects to their 'username'.
*/
getUsernamesMap() {
return new Map(this.data.map((elem) => {
return [elem.id, elem.username];
}));
}
}
exports.GetPageMediaResponse = GetPageMediaResponse;