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