1 | import { HttpClient } from '@angular/common/http';
|
2 | import { Router } from '@angular/router';
|
3 | import { Store } from '@ngrx/store';
|
4 | import { Observable } from 'rxjs/Observable';
|
5 | import 'rxjs/add/operator/share';
|
6 | import 'rxjs/add/operator/catch';
|
7 | import 'rxjs/add/operator/map';
|
8 | import 'rxjs/add/observable/of';
|
9 | export declare class ApiHttpService {
|
10 | private httpSvc;
|
11 | private storeSvc;
|
12 | private routerSvc;
|
13 |
|
14 | protected cache: {
|
15 | [key: string]: Observable<any>;
|
16 | };
|
17 | constructor(httpSvc: HttpClient, storeSvc: Store<IStore.root>, routerSvc: Router);
|
18 | /**
|
19 | * Make a GET request with simple caching
|
20 | * @param url - The URL location of the webapi
|
21 | * @param updateCache - Refresh the version in the cache
|
22 | */
|
23 | get<T>(url: string, updateCache?: boolean): Observable<T>;
|
24 | /**
|
25 | * Make a GET request and load the results into the store
|
26 | * @param url - The URL location of the webapi
|
27 | * @param id - The location to put the results in the store
|
28 | * @param updateCache - Refresh the version in the cache
|
29 | */
|
30 | protected getStore<T>(url: string, apiMap?: IStore.ApiMap, updateCache?: boolean): Observable<T>;
|
31 | /**
|
32 | * Make a POST request and load the results into the store
|
33 | * @param url - The URL location of the endpoint
|
34 | * @param id - The location to put the results in the store
|
35 | * @param data - The data to pass to the server
|
36 | */
|
37 | protected postStore<T>(url: string, apiMap: IStore.ApiMap, data: any): Observable<T>;
|
38 | /**
|
39 | * Make a PUT request
|
40 | * @param url - The URL location of the webapi
|
41 | * @param data - The data to pass to the server
|
42 | */
|
43 | protected putStore<T>(url: string, apiMap: IStore.ApiMap, data: any): Observable<T>;
|
44 | /**
|
45 | * Make a DELETE request
|
46 | * @param url - The URL location of the webapi
|
47 | * @param apiMap - The ApiMap object
|
48 | * @param element - The element or collection of elements being deleted
|
49 | */
|
50 | protected deleteStore<T>(url: string, apiMap: IStore.ApiMap, element: any | any[]): Observable<T>;
|
51 | /**
|
52 | * When an authentication check fails
|
53 | * @param error
|
54 | */
|
55 | private endSession(error);
|
56 | }
|
57 | export declare namespace IStore {
|
58 | |
59 |
|
60 |
|
61 |
|
62 | interface api {
|
63 | users?: Mapped<{
|
64 | user: string;
|
65 | email: string;
|
66 | name: string;
|
67 | phone: string;
|
68 | username: string;
|
69 | website: string;
|
70 | }>;
|
71 | }
|
72 |
|
73 | interface ApiMapping {
|
74 | users?: ApiMap;
|
75 | }
|
76 |
|
77 | interface ui {
|
78 | modal?: {
|
79 | modalId: string;
|
80 | options: {};
|
81 | data: any;
|
82 | };
|
83 | }
|
84 | |
85 |
|
86 |
|
87 |
|
88 | interface root {
|
89 | api?: api;
|
90 | ui?: ui;
|
91 | apiStatus?: apiStatus;
|
92 | }
|
93 |
|
94 | interface apiStatus {
|
95 | [key: string]: ApiStatus;
|
96 | }
|
97 |
|
98 | interface Mapped<T> {
|
99 |
|
100 | src?: T[];
|
101 |
|
102 | dict?: {
|
103 | [key: string]: T;
|
104 | };
|
105 |
|
106 | uniques?: {
|
107 | [key: string]: T;
|
108 | };
|
109 | }
|
110 | interface StateStatuses {
|
111 | users?: ApiStatus;
|
112 | }
|
113 | interface ApiStatus {
|
114 | loading?: boolean;
|
115 | loaded?: boolean;
|
116 | loadError?: any;
|
117 | modifying?: boolean;
|
118 | modified?: boolean;
|
119 | modifyError?: any;
|
120 | }
|
121 |
|
122 | interface ApiMap {
|
123 |
|
124 | endpoint?: string;
|
125 |
|
126 | storeProperty?: string;
|
127 |
|
128 | uniqueId?: string | string[];
|
129 |
|
130 | map?: any;
|
131 |
|
132 | mapSrc?: string;
|
133 |
|
134 | data?: any;
|
135 | }
|
136 | interface Rest {
|
137 | storeProp: string;
|
138 | path: string;
|
139 | }
|
140 | }
|