clean up
This commit is contained in:
@@ -1,27 +1,27 @@
|
||||
import SupportedBrowser from "./SupportedBrowser";
|
||||
import SupportedBrowser from './SupportedBrowser';
|
||||
|
||||
// Source: https://github.com/browserstack/api
|
||||
|
||||
export class BrowserstackApi {
|
||||
private readonly _baseUrl: string = 'https://api.browserstack.com/5';
|
||||
private readonly _authorizationHeader: string;
|
||||
private readonly _baseUrl: string = 'https://api.browserstack.com/5';
|
||||
private readonly _authorizationHeader: string;
|
||||
|
||||
constructor(username: string, accessKey: string) {
|
||||
this._authorizationHeader = `Basic ${Buffer.from(`${username}:${accessKey}`).toString('base64')}`;
|
||||
constructor(username: string, accessKey: string) {
|
||||
this._authorizationHeader = `Basic ${Buffer.from(`${username}:${accessKey}`).toString('base64')}`;
|
||||
}
|
||||
|
||||
public async getSupportedBrowsers(): Promise<SupportedBrowser[]> {
|
||||
const endpoint = `${this._baseUrl}/browsers?flat=true`;
|
||||
const headers = {
|
||||
Authorization: this._authorizationHeader
|
||||
};
|
||||
|
||||
const response = await fetch(endpoint, {headers});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to fetch BrowserStack supported browsers due to [ ${response.statusText}]`);
|
||||
}
|
||||
|
||||
public async getSupportedBrowsers(): Promise<SupportedBrowser[]> {
|
||||
const endpoint = `${this._baseUrl}/browsers?flat=true`;
|
||||
const headers = {
|
||||
'Authorization': this._authorizationHeader
|
||||
};
|
||||
|
||||
const response = await fetch(endpoint, { headers });
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to fetch BrowserStack supported browsers due to [ ${response.statusText}]`);
|
||||
}
|
||||
|
||||
return response.json() as Promise<SupportedBrowser[]>;
|
||||
}
|
||||
}
|
||||
return response.json() as Promise<SupportedBrowser[]>;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
type SupportedBrowser = {
|
||||
os: string;
|
||||
os_version: string;
|
||||
browser: string;
|
||||
device: string;
|
||||
browser_version: string | null;
|
||||
real_mobile: boolean;
|
||||
}
|
||||
os: string;
|
||||
os_version: string;
|
||||
browser: string;
|
||||
device: string;
|
||||
browser_version: string | null;
|
||||
real_mobile: boolean;
|
||||
};
|
||||
|
||||
export default SupportedBrowser;
|
||||
export default SupportedBrowser;
|
||||
|
||||
Reference in New Issue
Block a user