UNPKG

@iota-pico/core

Version:
59 lines (58 loc) 2.6 kB
/** * Represents a client for performing communication. * @interface */ export interface INetworkClient { /** * Get data asynchronously. * @param additionalPath An additional path append to the endpoint path. * @param additionalHeaders Extra headers to send with the request. * @returns Promise which resolves to the object returned or rejects with error. */ get(additionalPath?: string, additionalHeaders?: { [header: string]: string; }): Promise<string>; /** * Post data asynchronously. * @param additionalPath An additional path append to the endpoint path. * @param data The data to send. * @param additionalHeaders Extra headers to send with the request. * @returns Promise which resolves to the object returned or rejects with error. */ post(data: string, additionalPath?: string, additionalHeaders?: { [header: string]: string; }): Promise<string>; /** * Get data as JSON asynchronously. * @typeparam U The generic type for the returned object. * @param additionalPath An additional path append to the endpoint path. * @param additionalHeaders Extra headers to send with the request. * @returns Promise which resolves to the object returned or rejects with error. */ getJson<U>(additionalPath?: string, additionalHeaders?: { [header: string]: string; }): Promise<U>; /** * Post data as JSON asynchronously. * @typeparam T The generic type for the object to send. * @typeparam U The generic type for the returned object. * @param data The data to send. * @param additionalPath An additional path append to the endpoint path. * @param additionalHeaders Extra headers to send with the request. * @returns Promise which resolves to the object returned or rejects with error. */ postJson<T, U>(data: T, additionalPath?: string, additionalHeaders?: { [header: string]: string; }): Promise<U>; /** * Perform a request asynchronously. * @param method The method to send the data with. * @param data The data to send. * @param additionalPath An additional path append to the endpoint path. * @param additionalHeaders Extra headers to send with the request. * @returns Promise which resolves to the object returned or rejects with error. */ doRequest(method: string, data: string, additionalPath?: string, additionalHeaders?: { [header: string]: string; }): Promise<string>; }