jade-integration-utils
Version:
A tool made for any type of http requisitions and to manage localstorage. This package works into Angular and Ionic projects (maybe you can run this in ReactNative, MAYBE!).
61 lines (60 loc) • 2.58 kB
TypeScript
import { HttpStatusService } from './http-status.service';
import { Result } from '../Models/Paginator';
import { Router } from '@angular/router';
export declare class GenericService {
http: HttpStatusService;
router: Router;
private _auth;
constructor(http: HttpStatusService, router: Router);
/**
* configureHttp
*/
configureHttp(url: string): void;
/**
*
* @param endpoint end point to access
* @param queryParams = null; a string for example: name=Ronaldo&type=2 doesn't write ? \n(In case send GET without queryParams, just pass null end use endpoint to do it. Ex: cars/example)
*/
get<T>(endpoint?: string, queryParams?: string): Promise<Result<T>>;
/**
*
* @param endpoint end point to access
* @param queryParams = null; a string for example: name=Ronaldo&type=2 doesn't write ? \n(In case send GET without queryParams, just pass null end use endpoint to do it. Ex: cars/example)
*/
get_file(endpoint?: string, queryParams?: string): Promise<any>;
/**
*
* @param endpoint end point to access
* @param queryParams = null; a string for example: name=Ronaldo&type=2 doesn't write ? \n(In case send GET without queryParams, just pass null end use endpoint to do it. Ex: cars/example)
*/
get_any(endpoint?: string, queryParams?: string): Promise<any>;
getById<T>(id: number, endpoint?: string): Promise<Result<T>>;
/**
* Use to request POST.
* @param body K -> K is the model dto to pass with body
* @param endpoint String -> string to be pass with endpoint access
*/
post<T, K>(body: K, endpoint?: string): Promise<Result<T>>;
/**
* Use to request formData with files
* Don't forget.to call default_options
* @param body K -> K is the model dto to pass with body
* @param endpoint String -> string to be pass with endpoint access
*/
formData<T, K>(body: K, endpoint?: string): Promise<Result<T>>;
/**
* Use to request POST.
* @param body K -> K is the model dto to pass with body
* @param endpoint String -> string to be pass with endpoint access
*/
put<T, K>(body: K, endpoint?: string): Promise<Result<T>>;
delete<T>(id: number, endpoint?: string): Promise<Result<T>>;
set_token(auth: string): void;
get_token(): string;
get options(): any;
set options(options: any);
default_options(): void;
set auth(auth: string);
get auth(): string;
downloadFile(data: any): void;
}