matrix-dimension/src/matrix/MatrixLiteClient.ts

30 lines
755 B
TypeScript
Raw Normal View History

import { doClientApiCall } from "./helpers";
export interface MatrixUrlPreview {
// This is really the only parameter we care about
"og:title"?: string;
}
export class MatrixLiteClient {
constructor(private accessToken: string) {
}
2018-03-24 03:26:14 +00:00
public async getUrlPreview(url: string): Promise<MatrixUrlPreview> {
return doClientApiCall(
"GET",
"/_matrix/media/r0/preview_url",
{access_token: this.accessToken, url: url}
2018-03-24 03:26:14 +00:00
);
}
2018-03-24 03:26:14 +00:00
public async whoAmI(): Promise<string> {
const response = await doClientApiCall(
"GET",
"/_matrix/client/r0/account/whoami",
{access_token: this.accessToken}
2018-03-24 03:26:14 +00:00
);
return response['user_id'];
}
}