instagram-graph-api
Version:
A library to help perform requests to the Instagram Graph API.
82 lines (81 loc) • 2.19 kB
TypeScript
import { AxiosResponse } from 'axios';
import { Method, RequestConfig } from './RequestConfig';
import { AbstractResponse } from './AbstractResponse';
import { Params } from './Params';
import { PageOption } from '../Enums';
/**
* The type of the page option token used to add paging params to the request.
*/
export declare 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 constructor.
*
* @param accessToken the access token.
*/
constructor(accessToken: string);
/**
* 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.
*/
addPaging(pageOptionToken: PageOptionToken): void;
/**
* Adds the range params to the request.
*
* @param since the since param.
* @param until the until param.
*/
addRange(since: Date, until: Date): void;
/**
* Adds the limit param to the request.
*
* @param limit the number of objects to retrieve.
*/
addLimit(limit: number): void;
/**
* Parses the response into a response object.
*
* @param response the parsed response.
*/
protected abstract parseResponse(response: AxiosResponse<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;
}