Skip to content
This repository was archived by the owner on Feb 7, 2020. It is now read-only.

Commit 1fd619b

Browse files
committed
refactor: use send as prefix for all methods instead of create
The old methods will be removed in a future release
1 parent d17a7dc commit 1fd619b

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

projects/ngx-simple-http/src/lib/simple-http.service.ts

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,21 @@ export class SimpleHttpService {
1414
* @template P A TypeScript interface to type the HTTP request's parameters to
1515
* @template R A TypeScript interface to type the HTTP request's response to
1616
* @return A `HttpClient` instance
17+
* @deprecated Use {@link SimpleHttpService#sendHttpDelete}
1718
*/
1819
createHttpDelete<P extends any, R extends any>(apiEndpoint: string, apiParams: P, apiHeaders: HttpHeaders = null): Observable<R> {
20+
return this.sendHttpDelete<P, R>(apiEndpoint, apiParams, apiHeaders);
21+
}
22+
/**
23+
* Constructs and sends a HTTP DELETE request
24+
* @param apiEndpoint The API endpoint
25+
* @param apiParams Parameters to append to the API endpoint
26+
* @param apiHeaders HTTP headers to append to the request
27+
* @template P A TypeScript interface to type the HTTP request's parameters to
28+
* @template R A TypeScript interface to type the HTTP request's response to
29+
* @return A `HttpClient` instance
30+
*/
31+
sendHttpDelete<P extends any, R extends any>(apiEndpoint: string, apiParams: P, apiHeaders: HttpHeaders = null): Observable<R> {
1932
let params = new HttpParams();
2033
for (const prop in apiParams) {
2134
if (prop in apiParams && typeof apiParams[prop] !== undefined && apiParams[prop] !== null) {
@@ -39,6 +52,7 @@ export class SimpleHttpService {
3952
);
4053
}
4154
}
55+
4256
/**
4357
* Constructs and sends a HTTP GET request
4458
* @param apiEndpoint The API endpoint
@@ -47,8 +61,21 @@ export class SimpleHttpService {
4761
* @template P A TypeScript interface to type the HTTP request's parameters to
4862
* @template R A TypeScript interface to type the HTTP request's response to
4963
* @return A `HttpClient` instance
64+
* @deprecated Use {@link SimpleHttpService#sendHttpGet}
5065
*/
5166
createHttpGet<P extends any, R extends any>(apiEndpoint: string, apiParams: P, apiHeaders: HttpHeaders = null): Observable<R> {
67+
return this.sendHttpGet<P, R>(apiEndpoint, apiParams, apiHeaders);
68+
}
69+
/**
70+
* Constructs and sends a HTTP GET request
71+
* @param apiEndpoint The API endpoint
72+
* @param apiParams Parameters to append to the API endpoint
73+
* @param apiHeaders HTTP headers to append to the request
74+
* @template P A TypeScript interface to type the HTTP request's parameters to
75+
* @template R A TypeScript interface to type the HTTP request's response to
76+
* @return A `HttpClient` instance
77+
*/
78+
sendHttpGet<P extends any, R extends any>(apiEndpoint: string, apiParams: P, apiHeaders: HttpHeaders = null): Observable<R> {
5279
let params = new HttpParams();
5380
for (const prop in apiParams) {
5481
if (prop in apiParams && typeof apiParams[prop] !== undefined && apiParams[prop] !== null) {
@@ -72,6 +99,7 @@ export class SimpleHttpService {
7299
);
73100
}
74101
}
102+
75103
/**
76104
* Constructs and sends a HTTP POST request
77105
* @param apiEndpoint The API endpoint
@@ -82,8 +110,26 @@ export class SimpleHttpService {
82110
* @template P A TypeScript interface to type the HTTP request's parameters to
83111
* @template R A TypeScript interface to type the HTTP request's response to
84112
* @return A `HttpClient` instance
113+
* @deprecated Use {@link SimpleHttpService#sendHttpPost}
85114
*/
86115
createHttpPost<
116+
B extends any,
117+
P extends any,
118+
R extends any>(apiEndpoint: string, apiParams: P, apiBody: B = null, apiHeaders: HttpHeaders = null): Observable<R> {
119+
return this.sendHttpPost<B, P, R>(apiEndpoint, apiParams, apiBody, apiHeaders);
120+
}
121+
/**
122+
* Constructs and sends a HTTP POST request
123+
* @param apiEndpoint The API endpoint
124+
* @param apiParams Parameters to append to the API endpoint
125+
* @param apiBody The request body
126+
* @param apiHeaders HTTP headers to append to the request
127+
* @template B A TypeScript interface to type the HTTP request's body to
128+
* @template P A TypeScript interface to type the HTTP request's parameters to
129+
* @template R A TypeScript interface to type the HTTP request's response to
130+
* @return A `HttpClient` instance
131+
*/
132+
sendHttpPost<
87133
B extends any,
88134
P extends any,
89135
R extends any>(apiEndpoint: string, apiParams: P, apiBody: B = null, apiHeaders: HttpHeaders = null): Observable<R> {
@@ -144,6 +190,27 @@ export class SimpleHttpService {
144190
* @return A `HttpClient` instance
145191
*/
146192
createHttpPut<
193+
B extends any,
194+
P extends any,
195+
R extends any>(
196+
apiEndpoint: string,
197+
apiParams: P,
198+
apiBody: B,
199+
apiHeaders: HttpHeaders = null): Observable<R> {
200+
return this.sendHttpPut<B, P, R>(apiEndpoint, apiParams, apiBody, apiHeaders);
201+
}
202+
/**
203+
* Constructs and sends a HTTP PUT request
204+
* @param apiEndpoint The API endpoint
205+
* @param apiParams Parameters to append to the API endpoint
206+
* @param apiBody The request body
207+
* @param apiHeaders HTTP headers to append to the request
208+
* @template B A TypeScript interface to type the HTTP request's body to
209+
* @template P A TypeScript interface to type the HTTP request's parameters to
210+
* @template R A TypeScript interface to type the HTTP request's response to
211+
* @return A `HttpClient` instance
212+
*/
213+
sendHttpPut<
147214
B extends any,
148215
P extends any,
149216
R extends any>(

0 commit comments

Comments
 (0)