UNPKG

@ioniczoo/pigeon-restful-provider

Version:

HTTP Service Provider for Ionic: Our skillful mail pigeon will help you carry out REST requests. Our Pigeon is a RESTful Provider.

84 lines (83 loc) 2.63 kB
import { Config } from 'ionic-angular'; import { AlertController } from 'ionic-angular'; import { LoadingController } from 'ionic-angular'; import { HttpClient } from '@angular/common/http'; import { HttpHeaders } from '@angular/common/http'; import { HttpParams } from '@angular/common/http'; /** * Pigeon Restful Provider * * HTTP Service Provider for Ionic */ export declare class RestfulProvider { private http; private config; private alertCtrl; private loadingCtrl; /** * Request Method HTTP * * ``` js * * console.log('Run'); * * restful: Restful = Restful(); * restful.request('get', '/api/1.0/user') * .then((data) => { restful.alert('Status', data.statusText); }) * .catch((data) => { restful.errorMessage(data); }); * * console.log('Or'); * * let data: Promise = restful.request('get', '/api/1.0/user'); * ``` * * @param {HttpClient} http provider http * @param {Config} config provider http * @param {AlertController} alertCtrl controller alert * @param {LoadingController} loadingCtrl controller loading */ constructor(http: HttpClient, config: Config, alertCtrl: AlertController, loadingCtrl: LoadingController); /** * Request Method HTTP * * ``` js * restful.request('get', '/api/1.0/user') * .then((data) => { restful.alert('Status', data.statusText); }) * .catch((data) => { restful.errorMessage(data); }); * ``` * * @param {string} method http method * @param {string} url server url * @param {any} body request body * @param {any} params request params * @return {Promise} */ request(method: string, url: string, body?: any, params?: HttpParams, headers?: HttpHeaders): Promise<{}>; /** * Alert * * ``` js * restful.request('get', '/api/1.0/user') * .then((data) => { restful.alert('Status', data.statusText); }) * .catch((data) => { restful.errorMessage(data); }); * ``` * * @param {string} title alert title * @param {string} subTitle alert subtitle * @return {void} */ private alert; /** * Default Message Error * * ``` js * restful.request('get', '/api/1.0/user') * .then((data) => { restful.alert('Status', data.statusText); }) * .catch((data) => { restful.errorMessage(data); }); * ``` * * @param {any} error http error return * @return {void} */ private errorMessage; }