UNPKG

@allthings/sdk

Version:
30 lines (29 loc) 1.53 kB
/// <reference types="node" /> import { ITokenStore, TokenRequester } from '../oauth/types'; import { IAllthingsRestClientOptions } from './types'; interface IFormOptions { readonly [key: string]: readonly any[]; } interface IBodyFormData { readonly formData: IFormOptions; } interface IBody { readonly [key: string]: any; } export interface IRequestOptions { readonly body?: IBodyFormData | IBody; readonly headers?: { readonly [key: string]: string; }; readonly query?: { readonly [parameter: string]: string; }; } export type RequestResult = Promise<any>; export type HttpVerb = 'delete' | 'get' | 'head' | 'patch' | 'post' | 'put'; export type MethodHttpRequest = (httpMethod: string, apiMethod: string, payload?: IRequestOptions, returnRawResultObject?: boolean) => RequestResult; export type IntervalSet = Set<NodeJS.Timer>; export declare function responseWasSuccessful(response: Response): boolean; export declare function makeApiRequest(oauthTokenStore: ITokenStore, oauthTokenRequester: TokenRequester, options: IAllthingsRestClientOptions, httpMethod: HttpVerb, apiMethod: string, payload?: IRequestOptions, returnRawResultObject?: boolean): (previousResult: any, iteration: number) => Promise<Response>; export default function request(oauthTokenStore: ITokenStore, oauthTokenRequester: TokenRequester, options: IAllthingsRestClientOptions, httpMethod: HttpVerb, apiMethod: string, payload?: IRequestOptions, returnRawResultObject?: boolean): RequestResult; export {};