matrix-dimension/web/app/shared/services/scalar/scalar-server-api.service.ts

31 lines
1.0 KiB
TypeScript
Raw Normal View History

import { Injectable } from "@angular/core";
import {
FE_ScalarAccountResponse,
FE_ScalarOpenIdRequestBody,
FE_ScalarRegisterResponse
} from "../../models/scalar-server-responses";
import { AuthedApi } from "../authed-api";
import { SCALAR_API_VERSION } from "../../../../../src/utils/common-constants";
2019-06-29 06:21:56 +00:00
import { HttpClient } from "@angular/common/http";
@Injectable()
export class ScalarServerApiService extends AuthedApi {
2019-06-29 06:21:56 +00:00
constructor(http: HttpClient) {
super(http)
}
public ping(): Promise<any> {
2019-06-29 06:21:56 +00:00
return this.http.get("/api/v1/scalar/ping").toPromise();
}
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();
}
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, {
params: {v: SCALAR_API_VERSION},
2019-06-29 06:21:56 +00:00
}).toPromise();
}
}