UNPKG

instagram-graph-api

Version:

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

100 lines (99 loc) 2.75 kB
import { Method, RequestConfig } from './RequestConfig'; import { AbstractResponse } from './AbstractResponse'; import { Params } from './Params'; import { ApiVersion, PageOption } from '../Enums'; /** * The type of the page option token used to add paging params to the request. */ export type PageOptionToken = { option: PageOption; value: string; }; /** * Abstract class to represent requests to the Instagram Graph API. * * @param R the type of the response. * * @author Tiago Grosso <tiagogrosso99@gmail.com> * @since 0.2.0 */ export declare abstract class AbstractRequest<R extends AbstractResponse<unknown>> { /** * The request params. */ protected params: Params; /** * The API Version. */ protected apiVersion?: ApiVersion; /** * The constructor. * * @param accessToken the access token. * @param apiVersion the API version. */ protected constructor(accessToken: string, apiVersion?: ApiVersion); /** * Builds the config of the request. * * @returns the request config. */ config(): RequestConfig; /** * Executes the requests and returns a promise of the parsed response. * * @returns the promise of a parsed response. */ execute(): Promise<R>; /** * Adds a paging param to the request. * * @param pageOptionToken the page option token to create the param. * * @returns this request, for use in chain invocation. */ withPaging(pageOptionToken: PageOptionToken): this; /** * Adds the range params to the request. * * @param since the since param. * @param until the until param. * * @returns this request, for use in chain invocation. */ withRange(since: Date, until: Date): this; /** * Adds the limit param to the request. * * @param limit the number of objects to retrieve. * * @returns this request, for use in chain invocation. */ withLimit(limit: number): this; /** * Sets the API version that the request will use. * * @param apiVersion the API version to use. * * @returns this request, for use in chain invocation. */ withApiVersion(apiVersion: ApiVersion | undefined): this; /** * Parses the response into a response object. * * @param response the parsed response. */ protected abstract parseResponse(response: unknown): R; /** * Gets the url for the request. * * @returns the url for the request. */ protected abstract url(): string; /** * Gets the method for the request. * * @returns the method for the request. */ protected method(): Method; }