UNPKG

912 BPlain TextView Raw
1/**
2 * @module botbuilder
3 */
4/**
5 * Copyright (c) Microsoft Corporation. All rights reserved.
6 * Licensed under the MIT License.
7 */
8
9import { AppCredentials } from "./auth/appCredentials";
10
11export class EmulatorApiClient {
12 public static async emulateOAuthCards(credentials: AppCredentials, emulatorUrl: string, emulate: boolean): Promise<boolean> {
13 let token = await credentials.getToken();
14 let requestUrl: string = emulatorUrl + (emulatorUrl.endsWith('/') ? '' : '/') + `api/usertoken/emulateOAuthCards?emulate=${ (!!emulate).toString() }`;
15
16 const res = await fetch(requestUrl, {
17 method: 'POST',
18 headers: {
19 Authorization: `Bearer ${ token }`
20 }
21 });
22
23 if (res.ok) {
24 return true;
25 } else {
26 throw new Error(`EmulateOAuthCards failed with status code: ${ res.status }`);
27 }
28 }
29}
\No newline at end of file