2017-12-20 23:28:43 -05:00
|
|
|
import { Injectable } from "@angular/core";
|
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";
|
2019-06-29 02:21:56 -04:00
|
|
|
import { HttpClient } from "@angular/common/http";
|
2017-12-20 23:28:43 -05:00
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
export class ScalarServerApiService extends AuthedApi {
|
2019-06-29 02:21:56 -04:00
|
|
|
constructor(http: HttpClient) {
|
2017-12-20 23:28:43 -05:00
|
|
|
super(http)
|
|
|
|
}
|
|
|
|
|
2019-03-24 16:37:51 -04:00
|
|
|
public ping(): Promise<any> {
|
2019-06-29 02:21:56 -04:00
|
|
|
return this.http.get("/api/v1/scalar/ping").toPromise();
|
2019-03-24 16:37:51 -04:00
|
|
|
}
|
|
|
|
|
2017-12-24 04:02:57 -05:00
|
|
|
public getAccount(): Promise<FE_ScalarAccountResponse> {
|
2019-06-29 02:21:56 -04:00
|
|
|
return this.authedGet<FE_ScalarAccountResponse>("/api/v1/scalar/account", {v: SCALAR_API_VERSION}).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-06-29 02:21:56 -04:00
|
|
|
return this.http.post<FE_ScalarRegisterResponse>("/api/v1/scalar/register", openId, {
|
2019-03-15 22:02:21 -04:00
|
|
|
params: {v: SCALAR_API_VERSION},
|
2019-06-29 02:21:56 -04:00
|
|
|
}).toPromise();
|
2019-03-13 02:28:12 -04:00
|
|
|
}
|
2017-12-20 23:28:43 -05:00
|
|
|
}
|