instagram-graph-api
Version:
A library to help perform requests to the Instagram Graph API.
41 lines (40 loc) • 1.27 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.GetPageInfoRequest = void 0;
const GetPageInfoResponse_1 = require("./GetPageInfoResponse");
const AbstractRequest_1 = require("../../AbstractRequest");
const Enums_1 = require("../../../Enums");
/**
* A request that gets information about a page.
*
* @author Tiago Grosso <tiagogrosso99@gmail.com>
* @since 0.2.0
*/
class GetPageInfoRequest extends AbstractRequest_1.AbstractRequest {
/**
* The constructor.
*
* @param accessToken the access token.
* @param pageId the page id.
* @param fields the fields to retrieve from the API. If no field is specified, all are retrieved.
*/
constructor(accessToken, pageId, ...fields) {
super(accessToken);
this.pageId = pageId;
const fieldsSet = fields.length > 0 ? new Set(fields) : new Set(Object.values(Enums_1.PageField));
this.params.fields = Array.from(fieldsSet).join(',');
}
/**
* @inheritdoc
*/
parseResponse(response) {
return new GetPageInfoResponse_1.GetPageInfoResponse(response.data);
}
/**
* @inheritdoc
*/
url() {
return `/${this.pageId}`;
}
}
exports.GetPageInfoRequest = GetPageInfoRequest;