conductor-node 0.1.1 → 0.1.2
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/src/BaseClient.d.ts +1 -0
- package/dist/src/BaseClient.js +23 -0
- package/dist/src/qb/ClientQBD.js +1 -20
- package/package.json +1 -1
package/dist/src/BaseClient.d.ts
CHANGED
|
@@ -9,4 +9,5 @@ export default class BaseClient {
|
|
|
9
9
|
protected readonly verbose: boolean;
|
|
10
10
|
protected readonly serverURL: string;
|
|
11
11
|
constructor({ apiKey, verbose, environment, }: BaseClientOptions);
|
|
12
|
+
protected sendAPIRequest<T>(username: string, requestObj: T, apiPath: string): Promise<T>;
|
|
12
13
|
}
|
package/dist/src/BaseClient.js
CHANGED
|
@@ -16,5 +16,28 @@ class BaseClient {
|
|
|
16
16
|
this.verbose = verbose;
|
|
17
17
|
this.serverURL = (0, environment_1.envToBaseServerURL)(environment);
|
|
18
18
|
}
|
|
19
|
+
async sendAPIRequest(username, requestObj, apiPath) {
|
|
20
|
+
const apiServerURL = `${this.serverURL}/${apiPath}`;
|
|
21
|
+
if (this.verbose) {
|
|
22
|
+
console.log(`Client sent request to ${apiServerURL} for user ${username}:`, JSON.stringify(requestObj, null, 2));
|
|
23
|
+
}
|
|
24
|
+
const response = await fetch(apiServerURL, {
|
|
25
|
+
body: JSON.stringify({ username, requestObj }),
|
|
26
|
+
headers: {
|
|
27
|
+
"Content-Type": "application/json",
|
|
28
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
29
|
+
},
|
|
30
|
+
method: "POST",
|
|
31
|
+
});
|
|
32
|
+
if (response.status >= 400) {
|
|
33
|
+
const errorMessage = (await response.text()) || response.statusText;
|
|
34
|
+
throw new Error(`Request to ${apiServerURL} failed with status ${response.status}: ${errorMessage}`);
|
|
35
|
+
}
|
|
36
|
+
const responseObj = (await response.json());
|
|
37
|
+
if (this.verbose) {
|
|
38
|
+
console.log(`Client received response for user ${username}:`, JSON.stringify(responseObj, null, 2));
|
|
39
|
+
}
|
|
40
|
+
return responseObj;
|
|
41
|
+
}
|
|
19
42
|
}
|
|
20
43
|
exports.default = BaseClient;
|
package/dist/src/qb/ClientQBD.js
CHANGED
|
@@ -11,26 +11,7 @@ class ClientQBD extends BaseClient_1.default {
|
|
|
11
11
|
* Available APIs: https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop
|
|
12
12
|
*/
|
|
13
13
|
async sendRequest(qbwcUsername, requestObj) {
|
|
14
|
-
|
|
15
|
-
if (this.verbose) {
|
|
16
|
-
console.log(`Client sent request to ${apiServerURL} for user ${qbwcUsername}:`, JSON.stringify(requestObj, null, 2));
|
|
17
|
-
}
|
|
18
|
-
const response = await fetch(apiServerURL, {
|
|
19
|
-
body: JSON.stringify({ qbwcUsername, requestObj }),
|
|
20
|
-
headers: {
|
|
21
|
-
"Content-Type": "application/json",
|
|
22
|
-
Authorization: `Bearer ${this.apiKey}`,
|
|
23
|
-
},
|
|
24
|
-
method: "POST",
|
|
25
|
-
});
|
|
26
|
-
if (response.status >= 400) {
|
|
27
|
-
throw new Error(`Request to ${apiServerURL} failed with status ${response.status}: ${response.statusText}`);
|
|
28
|
-
}
|
|
29
|
-
const responseObj = (await response.json());
|
|
30
|
-
if (this.verbose) {
|
|
31
|
-
console.log(`Client received response for user ${qbwcUsername}:`, JSON.stringify(responseObj, null, 2));
|
|
32
|
-
}
|
|
33
|
-
return responseObj;
|
|
14
|
+
return this.sendAPIRequest(qbwcUsername, requestObj, "qbd");
|
|
34
15
|
}
|
|
35
16
|
/**
|
|
36
17
|
* Perform the same activities as a user does in the QB New Account form,
|