matrix-dimension/web/app/shared/services/scalar/scalar-server-api.service.ts
Travis Ralston dce6bcde56 Require ?v=1.1 on Scalar /register and /account
For upstream compatibility and security.
2019-03-15 22:05:35 -06:00

27 lines
927 B
TypeScript

import { Injectable } from "@angular/core";
import { Http } from "@angular/http";
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";
@Injectable()
export class ScalarServerApiService extends AuthedApi {
constructor(http: Http) {
super(http)
}
public getAccount(): Promise<FE_ScalarAccountResponse> {
return this.authedGet("/api/v1/scalar/account", {v: SCALAR_API_VERSION}).map(res => res.json()).toPromise();
}
public register(openId: FE_ScalarOpenIdRequestBody): Promise<FE_ScalarRegisterResponse> {
return this.http.post("/api/v1/scalar/register", openId, {
params: {v: SCALAR_API_VERSION},
}).map(res => res.json()).toPromise();
}
}