UNPKG

loop-modules

Version:

Shared modules for the Loop product suite.

133 lines (132 loc) 4.14 kB
import { Http, Response } from '@angular/http'; import { Store } from '@ngrx/store'; import { Observable } from 'rxjs/Observable'; import { ResponseBody } from './response-body.interface'; import { APIRequestOptions } from './api-request-options.interface'; export declare abstract class APIDispatcher { http: Http; store: Store<any>; protected lastRequest: ResponseBody; loaded: boolean; fetchingNext: boolean; constructor(http: Http, store: Store<any>); /** * Wraps the http layer for GET requests * Injects Core API standards for filtering, sorting and pagination * * @param {string} url The relative API url * @param {number} [page=0] The page of the dataset to request * @param {number} [size=10] The maximum number of results to return * @param {APIRequestOptions} [options] The optional request options * @returns Observable of http get request */ get(url: string, page?: number, size?: number, options?: APIRequestOptions): Observable<Response>; /** * Wraps the http layer for POST requests * Injects Core API standards used for fetching items by identities * Allows for filtering, sorting and pagination * * @param {string} url The relative API url * @param {*} requestBody The request body to send to the server * @param {number} [page=0] The page of the dataset to request * @param {number} [size=10] The maximum number of results to return * @param {APIRequestOptions} [options] The optional request options * @returns */ post(url: string, requestBody: any, page?: number, size?: number, options?: APIRequestOptions): Observable<Response>; handleError(error: any): any; /** * This clears the previous requests * * @memberOf APIDispatcher */ clearRequest(): void; /** * Determines if the paginated request has another page, based on the total number of pages vs. the currently requested content * * @readonly * @type {boolean} * @memberOf APIDispatcher */ readonly hasNext: boolean; /** * The get parameter fragment for page numbers * * @protected * @param {number} page * @returns {string} */ protected getPageFragment(page: number): string; /** * The get parameter fragment for collection size * * @protected * @param {number} size * @returns {string} */ protected getSizeFragment(size: number): string; /** * The get parameter fragments * * @protected * @param {APIRequestOptions} options * @returns {string} */ protected getOptionalFragments(options: APIRequestOptions): string; /** * The get parameter fragment for search term * * @protected * @param {string} search * @returns {string} */ protected getSearchFragment(search: string): string; /** * The get parameter fragment for sort by * * @protected * @param {string} sortBy * @returns {string} */ protected getSortByFragment(sortBy: string): string; /** * The get parameter fragment for sort direction * * @protected * @param {string} sortDir * @returns {string} */ protected getSortDirFragment(sortDir: string): string; /** * The get parameter fragment for unread * * @protected * @param {string} unread * @returns {string} */ protected getUnreadFragment(unread: string): string; /** * The get parameter fragment for unread * * @protected * @param {string} unread * @returns {string} */ protected getArchivedFragment(archived: boolean): string; /** * The get parameter fragment for unread * * @protected * @param {string} unread * @returns {string} */ protected getIsReviewedFragment(reviewed: boolean): string; /** * The get parameter fragment for unread * * @protected * @param {string} unread * @returns {string} */ protected getIsSubmittedFragment(submitted: boolean): string; }