conductor-node 3.0.0 → 3.1.0
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/README.md +3 -3
- package/dist/src/BaseClient.d.ts +3 -10
- package/dist/src/BaseClient.js +3 -37
- package/dist/src/Client.d.ts +18 -4
- package/dist/src/Client.js +51 -3
- package/dist/src/qbd/{ClientQBD.d.ts → ClientQbd.d.ts} +20 -23
- package/dist/src/qbd/{ClientQBD.js → ClientQbd.js} +27 -24
- package/package.json +7 -2
package/README.md
CHANGED
|
@@ -17,14 +17,14 @@ yarn add conductor-node
|
|
|
17
17
|
|
|
18
18
|
Instantiate `Conductor` with your account's secret key, which is available from Danny.
|
|
19
19
|
|
|
20
|
-
The `Conductor` instance can execute _any_ read or write [QuickBooks Desktop API](https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop) through TypeScript and receive a fully-typed response. Each request requires the user-id of a specific QuickBooks Desktop user.
|
|
20
|
+
The `Conductor` instance can execute _any_ read or write [QuickBooks Desktop API](https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop) through TypeScript and receive a fully-typed response. Each request requires the integration-user-connection id of a specific QuickBooks Desktop user.
|
|
21
21
|
|
|
22
22
|
```ts
|
|
23
23
|
import Conductor from "conductor-node";
|
|
24
24
|
const conductor = new Conductor("sk_test_...");
|
|
25
25
|
|
|
26
|
-
const
|
|
27
|
-
const newAccount = await conductor.qbd.account.add(
|
|
26
|
+
const mockQbdUserConnectionId = "1";
|
|
27
|
+
const newAccount = await conductor.qbd.account.add(mockQbdUserConnectionId, {
|
|
28
28
|
Name: "Test Account",
|
|
29
29
|
AccountType: "Bank",
|
|
30
30
|
OpenBalance: "100",
|
package/dist/src/BaseClient.d.ts
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import type
|
|
2
|
-
export interface BaseClientOptions {
|
|
3
|
-
verbose?: boolean;
|
|
4
|
-
environment?: Environment;
|
|
5
|
-
}
|
|
1
|
+
import type Client from "./Client";
|
|
6
2
|
export default class BaseClient {
|
|
7
|
-
protected readonly
|
|
8
|
-
|
|
9
|
-
protected readonly serverURL: string;
|
|
10
|
-
constructor(apiKey: string, { verbose, environment }: BaseClientOptions);
|
|
11
|
-
protected sendAPIRequest<T>(apiPath: string, integrationUserId: string, requestObj: T): Promise<T>;
|
|
3
|
+
protected readonly root: Client;
|
|
4
|
+
constructor(client: Client);
|
|
12
5
|
}
|
package/dist/src/BaseClient.js
CHANGED
|
@@ -1,43 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const environment_1 = require("./environment");
|
|
4
|
-
// Store properties via superclass `BaseClient` instead of on `Client` passed to
|
|
5
|
-
// the integration clients (e.g., `ClientQBD`) to hide these properties from the
|
|
6
|
-
// dev user while still allowing the integration clients to access them.
|
|
7
|
-
//
|
|
8
|
-
// Downside: These values are stored in each subclass instead of sharing a
|
|
9
|
-
// single store (e.g., `Client`).
|
|
10
3
|
class BaseClient {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
constructor(apiKey, { verbose = false, environment = "staging" }) {
|
|
15
|
-
this.apiKey = apiKey;
|
|
16
|
-
this.verbose = verbose;
|
|
17
|
-
this.serverURL = (0, environment_1.envToBaseServerURL)(environment);
|
|
18
|
-
}
|
|
19
|
-
async sendAPIRequest(apiPath, integrationUserId, requestObj) {
|
|
20
|
-
const apiServerURL = `${this.serverURL}/${apiPath}`;
|
|
21
|
-
if (this.verbose) {
|
|
22
|
-
console.log(`Client sent request to ${apiServerURL} for ${apiPath} user ${integrationUserId}:`, JSON.stringify(requestObj, null, 2));
|
|
23
|
-
}
|
|
24
|
-
const response = await fetch(apiServerURL, {
|
|
25
|
-
body: JSON.stringify({ integrationUserId, 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 ${apiPath} user ${integrationUserId}:`, JSON.stringify(responseObj, null, 2));
|
|
39
|
-
}
|
|
40
|
-
return responseObj;
|
|
4
|
+
root;
|
|
5
|
+
constructor(client) {
|
|
6
|
+
this.root = client;
|
|
41
7
|
}
|
|
42
8
|
}
|
|
43
9
|
exports.default = BaseClient;
|
package/dist/src/Client.d.ts
CHANGED
|
@@ -1,7 +1,21 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import
|
|
1
|
+
import type { Environment } from "./environment";
|
|
2
|
+
import ClientQbd from "./qbd/ClientQbd";
|
|
3
|
+
export interface ClientOptions {
|
|
4
|
+
/** Log the each request and response. */
|
|
5
|
+
verbose?: boolean;
|
|
6
|
+
environment?: Environment;
|
|
7
|
+
}
|
|
8
|
+
export interface IntegrationRequestParams {
|
|
9
|
+
integrationUserConnectionId: string;
|
|
10
|
+
requestObject: object;
|
|
11
|
+
}
|
|
3
12
|
export default class Client {
|
|
4
13
|
/** QuickBooks Desktop integration. */
|
|
5
|
-
readonly qbd:
|
|
6
|
-
|
|
14
|
+
readonly qbd: ClientQbd;
|
|
15
|
+
private readonly serverURL;
|
|
16
|
+
private readonly gqlClient;
|
|
17
|
+
private readonly verbose;
|
|
18
|
+
constructor(apiKey: string, { verbose, environment }?: ClientOptions);
|
|
19
|
+
integrationUserConnections(): Promise<object[]>;
|
|
20
|
+
integrationRequest(integrationRequestParams: IntegrationRequestParams): Promise<object>;
|
|
7
21
|
}
|
package/dist/src/Client.js
CHANGED
|
@@ -3,12 +3,60 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
6
|
+
const environment_1 = require("./environment");
|
|
7
|
+
const ClientQbd_1 = __importDefault(require("./qbd/ClientQbd"));
|
|
8
|
+
const graphql_request_1 = require("graphql-request");
|
|
7
9
|
class Client {
|
|
8
10
|
/** QuickBooks Desktop integration. */
|
|
9
11
|
qbd;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
serverURL;
|
|
13
|
+
gqlClient;
|
|
14
|
+
verbose;
|
|
15
|
+
constructor(apiKey, { verbose = false, environment = "staging" } = {}) {
|
|
16
|
+
this.verbose = verbose;
|
|
17
|
+
this.serverURL = (0, environment_1.envToBaseServerURL)(environment);
|
|
18
|
+
this.gqlClient = new graphql_request_1.GraphQLClient(`${this.serverURL}/graphql`, {
|
|
19
|
+
headers: {
|
|
20
|
+
authorization: `Bearer ${apiKey}`,
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
this.qbd = new ClientQbd_1.default(this);
|
|
24
|
+
}
|
|
25
|
+
async integrationUserConnections() {
|
|
26
|
+
const data = await this.gqlClient.request(`#graphql
|
|
27
|
+
query {
|
|
28
|
+
integrationUserConnections {
|
|
29
|
+
id
|
|
30
|
+
integration {
|
|
31
|
+
id
|
|
32
|
+
name
|
|
33
|
+
}
|
|
34
|
+
username
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
`);
|
|
38
|
+
// @ts-expect-error - This will pass after we integrate GQL codegen.
|
|
39
|
+
return data.integrationUserConnections;
|
|
40
|
+
}
|
|
41
|
+
// TODO: Hide this method from the dev user while still allowing the
|
|
42
|
+
// integration clients to access it.
|
|
43
|
+
async integrationRequest(integrationRequestParams) {
|
|
44
|
+
if (this.verbose) {
|
|
45
|
+
console.log(`Client sent request to ${this.serverURL}:`, JSON.stringify(integrationRequestParams, null, 2));
|
|
46
|
+
console.time("Request time");
|
|
47
|
+
}
|
|
48
|
+
const response = await this.gqlClient.request(`#graphql
|
|
49
|
+
query IntegrationRequest($integrationRequestParams: IntegrationRequestParams!) {
|
|
50
|
+
integrationRequest(integrationRequestParams: $integrationRequestParams)
|
|
51
|
+
}
|
|
52
|
+
`, { integrationRequestParams });
|
|
53
|
+
// @ts-expect-error - This will pass after we integrate GQL codegen.
|
|
54
|
+
const responseBody = response.integrationRequest;
|
|
55
|
+
if (this.verbose) {
|
|
56
|
+
console.timeEnd("Request time");
|
|
57
|
+
console.log(`Client received response from ${this.serverURL}:`, JSON.stringify(responseBody, null, 2));
|
|
58
|
+
}
|
|
59
|
+
return responseBody;
|
|
12
60
|
}
|
|
13
61
|
}
|
|
14
62
|
exports.default = Client;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import BaseClient from "../BaseClient";
|
|
2
2
|
import type * as qbd from "../qbd/qbdTypes";
|
|
3
|
-
export
|
|
4
|
-
[apiName: string]: object;
|
|
5
|
-
}
|
|
6
|
-
export default class ClientQBD extends BaseClient {
|
|
3
|
+
export default class ClientQbd extends BaseClient {
|
|
7
4
|
account: {
|
|
8
5
|
/**
|
|
9
6
|
* Perform the same activities as a user does in the QB New Account form,
|
|
@@ -12,13 +9,13 @@ export default class ClientQBD extends BaseClient {
|
|
|
12
9
|
*
|
|
13
10
|
* https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/AccountAdd
|
|
14
11
|
*/
|
|
15
|
-
add: (
|
|
12
|
+
add: (integrationUserConnectionId: string, params: qbd.AccountAddRq["AccountAdd"]) => Promise<NonNullable<qbd.AccountAddRs["AccountRet"]>>;
|
|
16
13
|
/**
|
|
17
14
|
* Modifies an account.
|
|
18
15
|
*
|
|
19
16
|
* https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/AccountMod
|
|
20
17
|
*/
|
|
21
|
-
mod: (
|
|
18
|
+
mod: (integrationUserConnectionId: string, params: qbd.AccountModRq["AccountMod"]) => Promise<NonNullable<qbd.AccountModRs["AccountRet"]>>;
|
|
22
19
|
/**
|
|
23
20
|
* `AccountQuery` is a list query that returns data for all accounts that
|
|
24
21
|
* match the provided filter criteria. Notice that it returns only data
|
|
@@ -29,7 +26,7 @@ export default class ClientQBD extends BaseClient {
|
|
|
29
26
|
*
|
|
30
27
|
* https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/AccountQuery
|
|
31
28
|
*/
|
|
32
|
-
query: (
|
|
29
|
+
query: (integrationUserConnectionId: string, params: qbd.AccountQueryRq) => Promise<NonNullable<qbd.AccountQueryRs["AccountRet"]>>;
|
|
33
30
|
};
|
|
34
31
|
customer: {
|
|
35
32
|
/**
|
|
@@ -54,13 +51,13 @@ export default class ClientQBD extends BaseClient {
|
|
|
54
51
|
*
|
|
55
52
|
* https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/CustomerAdd
|
|
56
53
|
*/
|
|
57
|
-
add: (
|
|
54
|
+
add: (integrationUserConnectionId: string, params: qbd.CustomerAddRq["CustomerAdd"]) => Promise<NonNullable<qbd.CustomerAddRs["CustomerRet"]>>;
|
|
58
55
|
/**
|
|
59
56
|
* Modifies the customer record.
|
|
60
57
|
*
|
|
61
58
|
* https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/CustomerMod
|
|
62
59
|
*/
|
|
63
|
-
mod: (
|
|
60
|
+
mod: (integrationUserConnectionId: string, params: qbd.CustomerModRq["CustomerMod"]) => Promise<NonNullable<qbd.CustomerModRs["CustomerRet"]>>;
|
|
64
61
|
/**
|
|
65
62
|
* Returns data for the specified customers.
|
|
66
63
|
*
|
|
@@ -73,7 +70,7 @@ export default class ClientQBD extends BaseClient {
|
|
|
73
70
|
*
|
|
74
71
|
* https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/CustomerQuery
|
|
75
72
|
*/
|
|
76
|
-
query: (
|
|
73
|
+
query: (integrationUserConnectionId: string, params: qbd.CustomerQueryRq) => Promise<NonNullable<qbd.CustomerQueryRs["CustomerRet"]>>;
|
|
77
74
|
};
|
|
78
75
|
employee: {
|
|
79
76
|
/**
|
|
@@ -82,19 +79,19 @@ export default class ClientQBD extends BaseClient {
|
|
|
82
79
|
*
|
|
83
80
|
* https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/EmployeeAdd
|
|
84
81
|
*/
|
|
85
|
-
add: (
|
|
82
|
+
add: (integrationUserConnectionId: string, params: qbd.EmployeeAddRq["EmployeeAdd"]) => Promise<NonNullable<qbd.EmployeeAddRs["EmployeeRet"]>>;
|
|
86
83
|
/**
|
|
87
84
|
* Modifies an existing employee.
|
|
88
85
|
*
|
|
89
86
|
* https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/EmployeeMod
|
|
90
87
|
*/
|
|
91
|
-
mod: (
|
|
88
|
+
mod: (integrationUserConnectionId: string, params: qbd.EmployeeModRq["EmployeeMod"]) => Promise<NonNullable<qbd.EmployeeModRs["EmployeeRet"]>>;
|
|
92
89
|
/**
|
|
93
90
|
* Returns employee data.
|
|
94
91
|
*
|
|
95
92
|
* https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/EmployeeQuery
|
|
96
93
|
*/
|
|
97
|
-
query: (
|
|
94
|
+
query: (integrationUserConnectionId: string, params: qbd.EmployeeQueryRq) => Promise<NonNullable<qbd.EmployeeQueryRs["EmployeeRet"]>>;
|
|
98
95
|
};
|
|
99
96
|
journalEntry: {
|
|
100
97
|
/**
|
|
@@ -128,7 +125,7 @@ export default class ClientQBD extends BaseClient {
|
|
|
128
125
|
*
|
|
129
126
|
* https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/JournalEntryAdd
|
|
130
127
|
*/
|
|
131
|
-
add: (
|
|
128
|
+
add: (integrationUserConnectionId: string, params: qbd.JournalEntryAddRq["JournalEntryAdd"]) => Promise<NonNullable<qbd.JournalEntryAddRs["JournalEntryRet"]>>;
|
|
132
129
|
/**
|
|
133
130
|
* Modifies a journal entry.
|
|
134
131
|
*
|
|
@@ -138,7 +135,7 @@ export default class ClientQBD extends BaseClient {
|
|
|
138
135
|
*
|
|
139
136
|
* https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/JournalEntryMod
|
|
140
137
|
*/
|
|
141
|
-
mod: (
|
|
138
|
+
mod: (integrationUserConnectionId: string, params: qbd.JournalEntryModRq["JournalEntryMod"]) => Promise<NonNullable<qbd.JournalEntryModRs["JournalEntryRet"]>>;
|
|
142
139
|
/**
|
|
143
140
|
* In traditional accounting, transactions are entered into the general
|
|
144
141
|
* journal and categorized exclusively by account. In QuickBooks, most
|
|
@@ -163,7 +160,7 @@ export default class ClientQBD extends BaseClient {
|
|
|
163
160
|
*
|
|
164
161
|
* https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/JournalEntryQuery
|
|
165
162
|
*/
|
|
166
|
-
query: (
|
|
163
|
+
query: (integrationUserConnectionId: string, params: qbd.JournalEntryQueryRq) => Promise<NonNullable<qbd.JournalEntryQueryRs["JournalEntryRet"]>>;
|
|
167
164
|
};
|
|
168
165
|
timeTracking: {
|
|
169
166
|
/**
|
|
@@ -176,7 +173,7 @@ export default class ClientQBD extends BaseClient {
|
|
|
176
173
|
*
|
|
177
174
|
* https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/TimeTrackingQuery
|
|
178
175
|
*/
|
|
179
|
-
add: (
|
|
176
|
+
add: (integrationUserConnectionId: string, params: qbd.TimeTrackingAddRq["TimeTrackingAdd"]) => Promise<NonNullable<qbd.TimeTrackingAddRs["TimeTrackingRet"]>>;
|
|
180
177
|
/**
|
|
181
178
|
* Modifies a time tracking transaction.
|
|
182
179
|
*
|
|
@@ -203,7 +200,7 @@ export default class ClientQBD extends BaseClient {
|
|
|
203
200
|
*
|
|
204
201
|
* https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/TimeTrackingMod
|
|
205
202
|
*/
|
|
206
|
-
mod: (
|
|
203
|
+
mod: (integrationUserConnectionId: string, params: qbd.TimeTrackingModRq["TimeTrackingMod"]) => Promise<NonNullable<qbd.TimeTrackingModRs["TimeTrackingRet"]>>;
|
|
207
204
|
/**
|
|
208
205
|
* The time-tracking transactions that are returned in this query include
|
|
209
206
|
* time tracking information that was entered into QuickBooks manually or
|
|
@@ -214,7 +211,7 @@ export default class ClientQBD extends BaseClient {
|
|
|
214
211
|
*
|
|
215
212
|
* https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/TimeTrackingQuery
|
|
216
213
|
*/
|
|
217
|
-
query: (
|
|
214
|
+
query: (integrationUserConnectionId: string, params: qbd.TimeTrackingQueryRq) => Promise<NonNullable<qbd.TimeTrackingQueryRs["TimeTrackingRet"]>>;
|
|
218
215
|
};
|
|
219
216
|
vendor: {
|
|
220
217
|
/**
|
|
@@ -230,19 +227,19 @@ export default class ClientQBD extends BaseClient {
|
|
|
230
227
|
*
|
|
231
228
|
* https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/VendorAdd
|
|
232
229
|
*/
|
|
233
|
-
add: (
|
|
230
|
+
add: (integrationUserConnectionId: string, params: qbd.VendorAddRq["VendorAdd"]) => Promise<NonNullable<qbd.VendorAddRs["VendorRet"]>>;
|
|
234
231
|
/**
|
|
235
232
|
* Modifies a vendor.
|
|
236
233
|
*
|
|
237
234
|
* https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/VendorMod
|
|
238
235
|
*/
|
|
239
|
-
mod: (
|
|
236
|
+
mod: (integrationUserConnectionId: string, params: qbd.VendorModRq["VendorMod"]) => Promise<NonNullable<qbd.VendorModRs["VendorRet"]>>;
|
|
240
237
|
/**
|
|
241
238
|
* Queries for the specified vendor or set of vendors.
|
|
242
239
|
*
|
|
243
240
|
* https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/VendorQuery
|
|
244
241
|
*/
|
|
245
|
-
query: (
|
|
242
|
+
query: (integrationUserConnectionId: string, params: qbd.VendorQueryRq) => Promise<NonNullable<qbd.VendorQueryRs["VendorRet"]>>;
|
|
246
243
|
};
|
|
247
244
|
/**
|
|
248
245
|
* Send any QBXML request to QuickBooks Desktop.
|
|
@@ -250,6 +247,6 @@ export default class ClientQBD extends BaseClient {
|
|
|
250
247
|
* Available APIs:
|
|
251
248
|
* https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop
|
|
252
249
|
*/
|
|
253
|
-
sendRequest(
|
|
250
|
+
sendRequest(integrationUserConnectionId: string, requestObject: object): Promise<object>;
|
|
254
251
|
private sendRequestBase;
|
|
255
252
|
}
|
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const BaseClient_1 = __importDefault(require("../BaseClient"));
|
|
7
|
-
class
|
|
7
|
+
class ClientQbd extends BaseClient_1.default {
|
|
8
8
|
account = {
|
|
9
9
|
/**
|
|
10
10
|
* Perform the same activities as a user does in the QB New Account form,
|
|
@@ -13,13 +13,13 @@ class ClientQBD extends BaseClient_1.default {
|
|
|
13
13
|
*
|
|
14
14
|
* https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/AccountAdd
|
|
15
15
|
*/
|
|
16
|
-
add: async (
|
|
16
|
+
add: async (integrationUserConnectionId, params) => this.sendRequestBase(integrationUserConnectionId, { AccountAddRq: { AccountAdd: params } }, "AccountAddRs", "AccountRet"),
|
|
17
17
|
/**
|
|
18
18
|
* Modifies an account.
|
|
19
19
|
*
|
|
20
20
|
* https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/AccountMod
|
|
21
21
|
*/
|
|
22
|
-
mod: async (
|
|
22
|
+
mod: async (integrationUserConnectionId, params) => this.sendRequestBase(integrationUserConnectionId, { AccountModRq: { AccountMod: params } }, "AccountModRs", "AccountRet"),
|
|
23
23
|
/**
|
|
24
24
|
* `AccountQuery` is a list query that returns data for all accounts that
|
|
25
25
|
* match the provided filter criteria. Notice that it returns only data
|
|
@@ -30,7 +30,7 @@ class ClientQBD extends BaseClient_1.default {
|
|
|
30
30
|
*
|
|
31
31
|
* https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/AccountQuery
|
|
32
32
|
*/
|
|
33
|
-
query: async (
|
|
33
|
+
query: async (integrationUserConnectionId, params) => this.sendRequestBase(integrationUserConnectionId, { AccountQueryRq: params }, "AccountQueryRs", "AccountRet"),
|
|
34
34
|
};
|
|
35
35
|
customer = {
|
|
36
36
|
/**
|
|
@@ -55,13 +55,13 @@ class ClientQBD extends BaseClient_1.default {
|
|
|
55
55
|
*
|
|
56
56
|
* https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/CustomerAdd
|
|
57
57
|
*/
|
|
58
|
-
add: async (
|
|
58
|
+
add: async (integrationUserConnectionId, params) => this.sendRequestBase(integrationUserConnectionId, { CustomerAddRq: { CustomerAdd: params } }, "CustomerAddRs", "CustomerRet"),
|
|
59
59
|
/**
|
|
60
60
|
* Modifies the customer record.
|
|
61
61
|
*
|
|
62
62
|
* https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/CustomerMod
|
|
63
63
|
*/
|
|
64
|
-
mod: async (
|
|
64
|
+
mod: async (integrationUserConnectionId, params) => this.sendRequestBase(integrationUserConnectionId, { CustomerModRq: { CustomerMod: params } }, "CustomerModRs", "CustomerRet"),
|
|
65
65
|
/**
|
|
66
66
|
* Returns data for the specified customers.
|
|
67
67
|
*
|
|
@@ -74,7 +74,7 @@ class ClientQBD extends BaseClient_1.default {
|
|
|
74
74
|
*
|
|
75
75
|
* https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/CustomerQuery
|
|
76
76
|
*/
|
|
77
|
-
query: async (
|
|
77
|
+
query: async (integrationUserConnectionId, params) => this.sendRequestBase(integrationUserConnectionId, { CustomerQueryRq: params }, "CustomerQueryRs", "CustomerRet"),
|
|
78
78
|
};
|
|
79
79
|
employee = {
|
|
80
80
|
/**
|
|
@@ -83,19 +83,19 @@ class ClientQBD extends BaseClient_1.default {
|
|
|
83
83
|
*
|
|
84
84
|
* https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/EmployeeAdd
|
|
85
85
|
*/
|
|
86
|
-
add: async (
|
|
86
|
+
add: async (integrationUserConnectionId, params) => this.sendRequestBase(integrationUserConnectionId, { EmployeeAddRq: { EmployeeAdd: params } }, "EmployeeAddRs", "EmployeeRet"),
|
|
87
87
|
/**
|
|
88
88
|
* Modifies an existing employee.
|
|
89
89
|
*
|
|
90
90
|
* https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/EmployeeMod
|
|
91
91
|
*/
|
|
92
|
-
mod: async (
|
|
92
|
+
mod: async (integrationUserConnectionId, params) => this.sendRequestBase(integrationUserConnectionId, { EmployeeModRq: { EmployeeMod: params } }, "EmployeeModRs", "EmployeeRet"),
|
|
93
93
|
/**
|
|
94
94
|
* Returns employee data.
|
|
95
95
|
*
|
|
96
96
|
* https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/EmployeeQuery
|
|
97
97
|
*/
|
|
98
|
-
query: async (
|
|
98
|
+
query: async (integrationUserConnectionId, params) => this.sendRequestBase(integrationUserConnectionId, { EmployeeQueryRq: params }, "EmployeeQueryRs", "EmployeeRet"),
|
|
99
99
|
};
|
|
100
100
|
journalEntry = {
|
|
101
101
|
/**
|
|
@@ -129,7 +129,7 @@ class ClientQBD extends BaseClient_1.default {
|
|
|
129
129
|
*
|
|
130
130
|
* https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/JournalEntryAdd
|
|
131
131
|
*/
|
|
132
|
-
add: async (
|
|
132
|
+
add: async (integrationUserConnectionId, params) => this.sendRequestBase(integrationUserConnectionId, { JournalEntryAddRq: { JournalEntryAdd: params } }, "JournalEntryAddRs", "JournalEntryRet"),
|
|
133
133
|
/**
|
|
134
134
|
* Modifies a journal entry.
|
|
135
135
|
*
|
|
@@ -139,7 +139,7 @@ class ClientQBD extends BaseClient_1.default {
|
|
|
139
139
|
*
|
|
140
140
|
* https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/JournalEntryMod
|
|
141
141
|
*/
|
|
142
|
-
mod: async (
|
|
142
|
+
mod: async (integrationUserConnectionId, params) => this.sendRequestBase(integrationUserConnectionId, { JournalEntryModRq: { JournalEntryMod: params } }, "JournalEntryModRs", "JournalEntryRet"),
|
|
143
143
|
/**
|
|
144
144
|
* In traditional accounting, transactions are entered into the general
|
|
145
145
|
* journal and categorized exclusively by account. In QuickBooks, most
|
|
@@ -164,7 +164,7 @@ class ClientQBD extends BaseClient_1.default {
|
|
|
164
164
|
*
|
|
165
165
|
* https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/JournalEntryQuery
|
|
166
166
|
*/
|
|
167
|
-
query: async (
|
|
167
|
+
query: async (integrationUserConnectionId, params) => this.sendRequestBase(integrationUserConnectionId, { JournalEntryQueryRq: params }, "JournalEntryQueryRs", "JournalEntryRet"),
|
|
168
168
|
};
|
|
169
169
|
timeTracking = {
|
|
170
170
|
/**
|
|
@@ -177,7 +177,7 @@ class ClientQBD extends BaseClient_1.default {
|
|
|
177
177
|
*
|
|
178
178
|
* https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/TimeTrackingQuery
|
|
179
179
|
*/
|
|
180
|
-
add: async (
|
|
180
|
+
add: async (integrationUserConnectionId, params) => this.sendRequestBase(integrationUserConnectionId, { TimeTrackingAddRq: { TimeTrackingAdd: params } }, "TimeTrackingAddRs", "TimeTrackingRet"),
|
|
181
181
|
/**
|
|
182
182
|
* Modifies a time tracking transaction.
|
|
183
183
|
*
|
|
@@ -204,7 +204,7 @@ class ClientQBD extends BaseClient_1.default {
|
|
|
204
204
|
*
|
|
205
205
|
* https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/TimeTrackingMod
|
|
206
206
|
*/
|
|
207
|
-
mod: async (
|
|
207
|
+
mod: async (integrationUserConnectionId, params) => this.sendRequestBase(integrationUserConnectionId, { TimeTrackingModRq: { TimeTrackingMod: params } }, "TimeTrackingModRs", "TimeTrackingRet"),
|
|
208
208
|
/**
|
|
209
209
|
* The time-tracking transactions that are returned in this query include
|
|
210
210
|
* time tracking information that was entered into QuickBooks manually or
|
|
@@ -215,7 +215,7 @@ class ClientQBD extends BaseClient_1.default {
|
|
|
215
215
|
*
|
|
216
216
|
* https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/TimeTrackingQuery
|
|
217
217
|
*/
|
|
218
|
-
query: async (
|
|
218
|
+
query: async (integrationUserConnectionId, params) => this.sendRequestBase(integrationUserConnectionId, { TimeTrackingQueryRq: params }, "TimeTrackingQueryRs", "TimeTrackingRet"),
|
|
219
219
|
};
|
|
220
220
|
vendor = {
|
|
221
221
|
/**
|
|
@@ -231,19 +231,19 @@ class ClientQBD extends BaseClient_1.default {
|
|
|
231
231
|
*
|
|
232
232
|
* https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/VendorAdd
|
|
233
233
|
*/
|
|
234
|
-
add: async (
|
|
234
|
+
add: async (integrationUserConnectionId, params) => this.sendRequestBase(integrationUserConnectionId, { VendorAddRq: { VendorAdd: params } }, "VendorAddRs", "VendorRet"),
|
|
235
235
|
/**
|
|
236
236
|
* Modifies a vendor.
|
|
237
237
|
*
|
|
238
238
|
* https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/VendorMod
|
|
239
239
|
*/
|
|
240
|
-
mod: async (
|
|
240
|
+
mod: async (integrationUserConnectionId, params) => this.sendRequestBase(integrationUserConnectionId, { VendorModRq: { VendorMod: params } }, "VendorModRs", "VendorRet"),
|
|
241
241
|
/**
|
|
242
242
|
* Queries for the specified vendor or set of vendors.
|
|
243
243
|
*
|
|
244
244
|
* https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/VendorQuery
|
|
245
245
|
*/
|
|
246
|
-
query: async (
|
|
246
|
+
query: async (integrationUserConnectionId, params) => this.sendRequestBase(integrationUserConnectionId, { VendorQueryRq: params }, "VendorQueryRs", "VendorRet"),
|
|
247
247
|
};
|
|
248
248
|
/**
|
|
249
249
|
* Send any QBXML request to QuickBooks Desktop.
|
|
@@ -251,11 +251,14 @@ class ClientQBD extends BaseClient_1.default {
|
|
|
251
251
|
* Available APIs:
|
|
252
252
|
* https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop
|
|
253
253
|
*/
|
|
254
|
-
async sendRequest(
|
|
255
|
-
return this.
|
|
254
|
+
async sendRequest(integrationUserConnectionId, requestObject) {
|
|
255
|
+
return this.root.integrationRequest({
|
|
256
|
+
integrationUserConnectionId,
|
|
257
|
+
requestObject,
|
|
258
|
+
});
|
|
256
259
|
}
|
|
257
|
-
async sendRequestBase(
|
|
258
|
-
const response = (await this.sendRequest(
|
|
260
|
+
async sendRequestBase(integrationUserConnectionId, params, responseKey, responseBodyKey) {
|
|
261
|
+
const response = (await this.sendRequest(integrationUserConnectionId, params));
|
|
259
262
|
const responseBody = response[responseKey]?.[responseBodyKey];
|
|
260
263
|
if (responseBody == null) {
|
|
261
264
|
throw new Error("No response");
|
|
@@ -263,4 +266,4 @@ class ClientQBD extends BaseClient_1.default {
|
|
|
263
266
|
return responseBody;
|
|
264
267
|
}
|
|
265
268
|
}
|
|
266
|
-
exports.default =
|
|
269
|
+
exports.default = ClientQbd;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "conductor-node",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "Conductor API wrapper",
|
|
5
5
|
"author": "Danny Nemer <hi@DannyNemer.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -12,9 +12,14 @@
|
|
|
12
12
|
],
|
|
13
13
|
"scripts": {
|
|
14
14
|
"prepack": "yarn tsc && yarn tsc-alias",
|
|
15
|
-
"postpack": "rm -rf dist"
|
|
15
|
+
"postpack": "rm -rf dist",
|
|
16
|
+
"test-staging": "yarn ts-node ./test/sendMockRequest"
|
|
16
17
|
},
|
|
17
18
|
"devDependencies": {
|
|
18
19
|
"tsc-alias": "^1.7.0"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"graphql": "^16.6.0",
|
|
23
|
+
"graphql-request": "^5.0.0"
|
|
19
24
|
}
|
|
20
25
|
}
|