UNPKG

instagram-graph-api

Version:

A library to help perform requests to the Instagram Graph API.

35 lines (34 loc) 1.34 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.GetRepliesRequest = void 0; const Enums_1 = require("../../../Enums"); const GetObjectCommentsResponse_1 = require("../../common/GetObjectCommentsResponse"); const AbstractRepliesRequest_1 = require("./AbstractRepliesRequest"); /** * A request to get the replies to a comment. * * @author Tiago Grosso <tiagogrosso99@gmail.com> * @since `next.release` */ class GetRepliesRequest extends AbstractRepliesRequest_1.AbstractRepliesRequest { /** * The constructor. * * @param accessToken the access token. * @param pageId the id of the comment. * @param fields the fields to retrieve from the API. If no field is specified, all are retrieved. */ constructor(accessToken, commentId, ...fields) { super(accessToken, commentId); const fieldsSet = fields.length > 0 ? new Set(fields) : new Set(Object.values(Enums_1.CommentField)); fieldsSet.delete(Enums_1.CommentField.REPLIES); // Only allowed for top level comments. this.params.fields = Array.from(fieldsSet).join(','); } /** * @inheritdoc */ parseResponse(response) { return new GetObjectCommentsResponse_1.GetObjectCommentsResponse(response.data); } } exports.GetRepliesRequest = GetRepliesRequest;