screenshotone-api-sdk 1.1.6 → 1.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/@types/main.d.ts +2 -1
- package/dist/main.js +5 -4
- package/package.json +1 -1
- package/src/main.ts +10 -8
package/dist/@types/main.d.ts
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
export declare class Client {
|
|
5
5
|
private readonly accessKey;
|
|
6
6
|
private readonly secretKey;
|
|
7
|
-
|
|
7
|
+
private readonly apiBaseUrl;
|
|
8
|
+
constructor(accessKey: string, secretKey: string, apiBaseUrl?: string);
|
|
8
9
|
/**
|
|
9
10
|
* Generates an URL that can be used to send GET requests for taking screenshots.
|
|
10
11
|
*
|
package/dist/main.js
CHANGED
|
@@ -14,12 +14,13 @@ const API_ANIMATE_PATH = "/animate";
|
|
|
14
14
|
* Represents an API client for the ScreenshotOne.com API.
|
|
15
15
|
*/
|
|
16
16
|
class Client {
|
|
17
|
-
constructor(accessKey, secretKey) {
|
|
17
|
+
constructor(accessKey, secretKey, apiBaseUrl) {
|
|
18
18
|
if (!accessKey || !secretKey) {
|
|
19
19
|
throw new Error("Both non-empty access and secret keys are required");
|
|
20
20
|
}
|
|
21
21
|
this.accessKey = accessKey;
|
|
22
22
|
this.secretKey = secretKey;
|
|
23
|
+
this.apiBaseUrl = apiBaseUrl ? apiBaseUrl : API_BASE_URL;
|
|
23
24
|
}
|
|
24
25
|
/**
|
|
25
26
|
* Generates an URL that can be used to send GET requests for taking screenshots.
|
|
@@ -33,7 +34,7 @@ class Client {
|
|
|
33
34
|
const query = options.toQuery();
|
|
34
35
|
query.append("access_key", this.accessKey);
|
|
35
36
|
let queryString = query.toString();
|
|
36
|
-
return `${
|
|
37
|
+
return `${this.apiBaseUrl}${API_TAKE_PATH}?${queryString}`;
|
|
37
38
|
}
|
|
38
39
|
/**
|
|
39
40
|
* Generates the link that can be publicly available, but make sure
|
|
@@ -48,7 +49,7 @@ class Client {
|
|
|
48
49
|
let queryString = query.toString();
|
|
49
50
|
const signature = await (0, signature_1.signQueryString)(queryString, this.secretKey);
|
|
50
51
|
queryString += "&signature=" + signature;
|
|
51
|
-
return `${
|
|
52
|
+
return `${this.apiBaseUrl}${API_TAKE_PATH}?${queryString}`;
|
|
52
53
|
}
|
|
53
54
|
/**
|
|
54
55
|
* Generates the link that can be publicly available, but make sure
|
|
@@ -63,7 +64,7 @@ class Client {
|
|
|
63
64
|
let queryString = query.toString();
|
|
64
65
|
const signature = await (0, signature_1.signQueryString)(queryString, this.secretKey);
|
|
65
66
|
queryString += "&signature=" + signature;
|
|
66
|
-
return `${
|
|
67
|
+
return `${this.apiBaseUrl}${API_ANIMATE_PATH}?${queryString}`;
|
|
67
68
|
}
|
|
68
69
|
/**
|
|
69
70
|
* Generates a screenshot and return the image blob.
|
package/package.json
CHANGED
package/src/main.ts
CHANGED
|
@@ -12,8 +12,9 @@ const API_ANIMATE_PATH = "/animate";
|
|
|
12
12
|
export class Client {
|
|
13
13
|
private readonly accessKey: string;
|
|
14
14
|
private readonly secretKey: string;
|
|
15
|
+
private readonly apiBaseUrl: string;
|
|
15
16
|
|
|
16
|
-
constructor(accessKey: string, secretKey: string) {
|
|
17
|
+
constructor(accessKey: string, secretKey: string, apiBaseUrl?: string) {
|
|
17
18
|
if (!accessKey || !secretKey) {
|
|
18
19
|
throw new Error(
|
|
19
20
|
"Both non-empty access and secret keys are required"
|
|
@@ -22,6 +23,7 @@ export class Client {
|
|
|
22
23
|
|
|
23
24
|
this.accessKey = accessKey;
|
|
24
25
|
this.secretKey = secretKey;
|
|
26
|
+
this.apiBaseUrl = apiBaseUrl ? apiBaseUrl : API_BASE_URL;
|
|
25
27
|
}
|
|
26
28
|
|
|
27
29
|
/**
|
|
@@ -37,7 +39,7 @@ export class Client {
|
|
|
37
39
|
query.append("access_key", this.accessKey);
|
|
38
40
|
let queryString = query.toString();
|
|
39
41
|
|
|
40
|
-
return `${
|
|
42
|
+
return `${this.apiBaseUrl}${API_TAKE_PATH}?${queryString}`;
|
|
41
43
|
}
|
|
42
44
|
|
|
43
45
|
/**
|
|
@@ -55,7 +57,7 @@ export class Client {
|
|
|
55
57
|
const signature = await signQueryString(queryString, this.secretKey);
|
|
56
58
|
queryString += "&signature=" + signature;
|
|
57
59
|
|
|
58
|
-
return `${
|
|
60
|
+
return `${this.apiBaseUrl}${API_TAKE_PATH}?${queryString}`;
|
|
59
61
|
}
|
|
60
62
|
|
|
61
63
|
/**
|
|
@@ -73,7 +75,7 @@ export class Client {
|
|
|
73
75
|
const signature = await signQueryString(queryString, this.secretKey);
|
|
74
76
|
queryString += "&signature=" + signature;
|
|
75
77
|
|
|
76
|
-
return `${
|
|
78
|
+
return `${this.apiBaseUrl}${API_ANIMATE_PATH}?${queryString}`;
|
|
77
79
|
}
|
|
78
80
|
|
|
79
81
|
/**
|
|
@@ -139,9 +141,9 @@ export class Client {
|
|
|
139
141
|
path: string,
|
|
140
142
|
bucket?: string,
|
|
141
143
|
acl?: "public-read" | "",
|
|
142
|
-
storageClass?: string,
|
|
144
|
+
storageClass?: string,
|
|
143
145
|
accessKeyId?: string,
|
|
144
|
-
secretAccessKey?: string
|
|
146
|
+
secretAccessKey?: string
|
|
145
147
|
): Promise<{ bucket: string | null; key: string | null }> {
|
|
146
148
|
options.store(true).storagePath(path).responseType("empty");
|
|
147
149
|
|
|
@@ -155,10 +157,10 @@ export class Client {
|
|
|
155
157
|
options.storageClass(storageClass);
|
|
156
158
|
}
|
|
157
159
|
if (accessKeyId) {
|
|
158
|
-
options.storageAccessKeyId(accessKeyId)
|
|
160
|
+
options.storageAccessKeyId(accessKeyId);
|
|
159
161
|
}
|
|
160
162
|
if (secretAccessKey) {
|
|
161
|
-
options.storageSecretAccessKey(secretAccessKey)
|
|
163
|
+
options.storageSecretAccessKey(secretAccessKey);
|
|
162
164
|
}
|
|
163
165
|
|
|
164
166
|
const url =
|