UNPKG

instagram-graph-api

Version:

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

43 lines (42 loc) 1.49 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AbstractGetHashtagMediaRequest = void 0; const Enums_1 = require("../../../Enums"); const AbstractRequest_1 = require("../../AbstractRequest"); const GetHashtagMediaResponse_1 = require("./GetHashtagMediaResponse"); /** * A request that gets information about the media of an hashtag. * * @author Tiago Grosso <tiagogrosso99@gmail.com> * @since 0.5.0 */ class AbstractGetHashtagMediaRequest extends AbstractRequest_1.AbstractRequest { /** * The constructor. * * @param accessToken the access token. * @param hashtagId the id of the hashtag. * @param userId the id of the user making the request. * @param fields the fields to retrieve from the API. If no field is specified, all are retrieved. */ constructor(accessToken, hashtagId, userId, ...fields) { super(accessToken); this.hashtagId = hashtagId; this.params.user_id = userId; const fieldsSet = fields.length > 0 ? new Set(fields) : new Set(Object.values(Enums_1.HashtagMediaField)); this.params.fields = Array.from(fieldsSet).join(','); } /** * @inheritdoc */ parseResponse(response) { return new GetHashtagMediaResponse_1.GetHashtagMediaResponse(response.data); } /** * @inheritdoc */ url() { return `/${this.hashtagId}`; } } exports.AbstractGetHashtagMediaRequest = AbstractGetHashtagMediaRequest;