meta-cloud-api
Version:
TypeScript wrapper for Meta's Cloud API
51 lines (48 loc) • 2.19 kB
TypeScript
import { H as HttpMethodsEnum } from './enums-BZd9T2ul.js';
type GeneralRequestBody = Record<string, unknown>;
interface GeneralHeaderInterface {
/**
* Authorization token. This is required for all HTTP requests made to the graph API.
* @default 'Bearer '
*/
Authorization: string;
/**
* Content type of the message being sent. This is required for all HTTP requests made to the graph API.
* @default 'application/json'
*/
'Content-Type': string;
/**
* User agent field sent in all requests. This is used to gather SDK usage metrics and help
* better triage support requests.
* @default `WA_SDK/${ SDK_version } (Node.js ${ process.version })`
*/
'User-Agent': string;
}
interface RequesterResponseInterface<T> {
json: () => Promise<T>;
}
interface ResponseSuccess {
success: boolean;
}
interface ResponseData<T> {
data: T;
}
interface ResponsePagination<T> {
data: T[];
paging: Paging;
}
interface Paging {
cursors: {
before: string;
after: string;
};
next: string;
}
declare class RequesterClass {
constructor(apiVersion: string, phoneNumberId: number, accessToken: string, businessAcctId: string, userAgent: string);
sendRequest: (method: HttpMethodsEnum, path: string, timeout: number, body?: GeneralRequestBody, contentType?: string, additionalHeaders?: Record<string, string>) => Promise<RequesterResponseInterface<unknown>>;
getJson<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: GeneralRequestBody, additionalHeaders?: Record<string, string>): Promise<T>;
sendFormData<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, formData: FormData, additionalHeaders?: Record<string, string>): Promise<T>;
sendUrlEncodedForm<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, formData: Record<string, string>, additionalHeaders?: Record<string, string>): Promise<T>;
}
export { type GeneralHeaderInterface as G, type Paging as P, RequesterClass as R, type GeneralRequestBody as a, type RequesterResponseInterface as b, type ResponseData as c, type ResponsePagination as d, type ResponseSuccess as e };