2017-12-20 23:28:43 -05:00
|
|
|
import { Http, Response } from "@angular/http";
|
|
|
|
import { Observable } from "rxjs/Observable";
|
2017-12-22 23:08:10 -05:00
|
|
|
import { SessionStorage } from "../SessionStorage";
|
2017-12-20 23:28:43 -05:00
|
|
|
|
|
|
|
export class AuthedApi {
|
|
|
|
constructor(protected http: Http) {
|
|
|
|
}
|
|
|
|
|
|
|
|
protected authedGet(url: string, qs?: any): Observable<Response> {
|
|
|
|
if (!qs) qs = {};
|
2017-12-22 23:08:10 -05:00
|
|
|
qs["scalar_token"] = SessionStorage.scalarToken;
|
2017-12-20 23:28:43 -05:00
|
|
|
return this.http.get(url, {params: qs});
|
|
|
|
}
|
2017-12-23 23:40:01 -05:00
|
|
|
|
|
|
|
protected authedPost(url: string, body?: any): Observable<Response> {
|
|
|
|
if (!body) body = {};
|
|
|
|
const qs = {scalar_token: SessionStorage.scalarToken};
|
|
|
|
return this.http.post(url, body, {params: qs});
|
|
|
|
}
|
2018-03-25 18:20:15 -04:00
|
|
|
|
|
|
|
protected authedDelete(url: string, qs?: any): Observable<Response> {
|
|
|
|
if (!qs) qs = {};
|
|
|
|
qs["scalar_token"] = SessionStorage.scalarToken;
|
|
|
|
return this.http.delete(url, {params: qs});
|
|
|
|
}
|
2017-12-20 23:28:43 -05:00
|
|
|
}
|