1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | import { AppCredentials } from "./auth/appCredentials";
|
10 |
|
11 | export 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 |