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