2017-12-20 23:28:43 -05:00
|
|
|
import { Injectable } from "@angular/core";
|
|
|
|
import { Http } from "@angular/http";
|
2019-03-13 02:28:12 -04:00
|
|
|
import {
|
|
|
|
FE_ScalarAccountResponse,
|
|
|
|
FE_ScalarOpenIdRequestBody,
|
|
|
|
FE_ScalarRegisterResponse
|
|
|
|
} from "../../models/scalar-server-responses";
|
2018-03-24 19:16:52 -04:00
|
|
|
import { AuthedApi } from "../authed-api";
|
2019-03-15 22:02:21 -04:00
|
|
|
import { SCALAR_API_VERSION } from "../../../../../src/utils/common-constants";
|
2017-12-20 23:28:43 -05:00
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
export class ScalarServerApiService extends AuthedApi {
|
|
|
|
constructor(http: Http) {
|
|
|
|
super(http)
|
|
|
|
}
|
|
|
|
|
2019-03-24 16:37:51 -04:00
|
|
|
public ping(): Promise<any> {
|
|
|
|
return this.http.get("/api/v1/scalar/ping").map(res => res.json()).toPromise();
|
|
|
|
}
|
|
|
|
|
2017-12-24 04:02:57 -05:00
|
|
|
public getAccount(): Promise<FE_ScalarAccountResponse> {
|
2019-03-15 22:02:21 -04:00
|
|
|
return this.authedGet("/api/v1/scalar/account", {v: SCALAR_API_VERSION}).map(res => res.json()).toPromise();
|
2017-12-20 23:28:43 -05:00
|
|
|
}
|
2019-03-13 02:28:12 -04:00
|
|
|
|
|
|
|
public register(openId: FE_ScalarOpenIdRequestBody): Promise<FE_ScalarRegisterResponse> {
|
2019-03-15 22:02:21 -04:00
|
|
|
return this.http.post("/api/v1/scalar/register", openId, {
|
|
|
|
params: {v: SCALAR_API_VERSION},
|
|
|
|
}).map(res => res.json()).toPromise();
|
2019-03-13 02:28:12 -04:00
|
|
|
}
|
2017-12-20 23:28:43 -05:00
|
|
|
}
|