2017-12-21 04:28:43 +00:00
|
|
|
import { Injectable } from "@angular/core";
|
|
|
|
import { Http } from "@angular/http";
|
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";
|
2017-12-21 04:28:43 +00:00
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
export class ScalarServerApiService extends AuthedApi {
|
|
|
|
constructor(http: Http) {
|
|
|
|
super(http)
|
|
|
|
}
|
|
|
|
|
2019-03-24 20:37:51 +00:00
|
|
|
public ping(): Promise<any> {
|
|
|
|
return this.http.get("/api/v1/scalar/ping").map(res => res.json()).toPromise();
|
|
|
|
}
|
|
|
|
|
2017-12-24 09:02:57 +00:00
|
|
|
public getAccount(): Promise<FE_ScalarAccountResponse> {
|
2017-12-21 04:28:43 +00:00
|
|
|
return this.authedGet("/api/v1/scalar/account").map(res => res.json()).toPromise();
|
|
|
|
}
|
2019-03-13 06:28:12 +00:00
|
|
|
|
|
|
|
public register(openId: FE_ScalarOpenIdRequestBody): Promise<FE_ScalarRegisterResponse> {
|
|
|
|
return this.http.post("/api/v1/scalar/register", openId).map(res => res.json()).toPromise();
|
|
|
|
}
|
2017-12-21 04:28:43 +00:00
|
|
|
}
|