conductor-node 0.4.0 → 1.0.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.
@@ -13,31 +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 (qbwcUsername, params) => {
17
- const response = (await this.sendRequest(qbwcUsername, {
18
- AccountAddRq: { AccountAdd: params },
19
- }));
20
- const responseBody = response.AccountAddRs.AccountRet;
21
- if (!responseBody) {
22
- throw new Error("No response");
23
- }
24
- return responseBody;
25
- },
16
+ add: async (qbwcUserId, params) => this.sendRequestBase(qbwcUserId, { AccountAddRq: { AccountAdd: params } }, "AccountAddRs", "AccountRet"),
26
17
  /**
27
18
  * Modifies an account.
28
19
  *
29
20
  * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/AccountMod
30
21
  */
31
- mod: async (qbwcUsername, params) => {
32
- const response = (await this.sendRequest(qbwcUsername, {
33
- AccountModRq: { AccountMod: params },
34
- }));
35
- const responseBody = response.AccountModRs.AccountRet;
36
- if (!responseBody) {
37
- throw new Error("No response");
38
- }
39
- return responseBody;
40
- },
22
+ mod: async (qbwcUserId, params) => this.sendRequestBase(qbwcUserId, { AccountModRq: { AccountMod: params } }, "AccountModRs", "AccountRet"),
41
23
  /**
42
24
  * `AccountQuery` is a list query that returns data for all accounts that
43
25
  * match the provided filter criteria. Notice that it returns only data
@@ -48,16 +30,7 @@ class ClientQBD extends BaseClient_1.default {
48
30
  *
49
31
  * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/AccountQuery
50
32
  */
51
- query: async (qbwcUsername, params) => {
52
- const response = (await this.sendRequest(qbwcUsername, {
53
- AccountQueryRq: params,
54
- }));
55
- const responseBody = response.AccountQueryRs.AccountRet;
56
- if (!responseBody) {
57
- throw new Error("No response");
58
- }
59
- return responseBody;
60
- },
33
+ query: async (qbwcUserId, params) => this.sendRequestBase(qbwcUserId, { AccountQueryRq: params }, "AccountQueryRs", "AccountRet"),
61
34
  };
62
35
  customer = {
63
36
  /**
@@ -65,68 +38,43 @@ class ClientQBD extends BaseClient_1.default {
65
38
  * customers and the individual jobs that are being performed for them. A
66
39
  * `CustomerRef` aggregate refers to one of the customers (or customer jobs)
67
40
  * on the list. In a request, if a `CustomerRef` aggregate includes both
68
- * `FullName` and `ListID`, `FullName` will be ignored. Special cases to note:
41
+ * `FullName` and `ListID`, `FullName` will be ignored. Special cases to
42
+ * note:
69
43
  *
70
- * - In `SalesReceipt` and `ReceivePayment` requests, `CustomerRef` refers to
71
- * the customer or customer job to which the payment is credited.
44
+ * - In `SalesReceipt` and `ReceivePayment` requests, `CustomerRef` refers
45
+ * to the customer or customer job to which the payment is credited.
72
46
  *
73
47
  * - In a `TimeTracking` request, CustomerRef refers to the customer or
74
48
  * customer job to which this time could be billed. If `IsBillable` is set
75
49
  * to true, `CustomerRef` is required in `TimeTrackingAdd`.
76
50
  *
77
- * - In an `ExpenseLineAdd` request, if `AccountRef` refers to an A/P account,
78
- * `CustomerRef` must refer to a vendor (not to a customer). If `AccountRef`
79
- * refers to any other type of account, the `CustomerRef` must refer to a
80
- * customer.
51
+ * - In an `ExpenseLineAdd` request, if `AccountRef` refers to an A/P
52
+ * account, `CustomerRef` must refer to a vendor (not to a customer). If
53
+ * `AccountRef` refers to any other type of account, the `CustomerRef`
54
+ * must refer to a customer.
81
55
  *
82
56
  * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/CustomerAdd
83
57
  */
84
- add: async (qbwcUsername, params) => {
85
- const response = (await this.sendRequest(qbwcUsername, {
86
- CustomerAddRq: { CustomerAdd: params },
87
- }));
88
- const responseBody = response.CustomerAddRs.CustomerRet;
89
- if (!responseBody) {
90
- throw new Error("No response");
91
- }
92
- return responseBody;
93
- },
58
+ add: async (qbwcUserId, params) => this.sendRequestBase(qbwcUserId, { CustomerAddRq: { CustomerAdd: params } }, "CustomerAddRs", "CustomerRet"),
94
59
  /**
95
60
  * Modifies the customer record.
96
61
  *
97
62
  * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/CustomerMod
98
63
  */
99
- mod: async (qbwcUsername, params) => {
100
- const response = (await this.sendRequest(qbwcUsername, {
101
- CustomerModRq: { CustomerMod: params },
102
- }));
103
- const responseBody = response.CustomerModRs.CustomerRet;
104
- if (!responseBody) {
105
- throw new Error("No response");
106
- }
107
- return responseBody;
108
- },
64
+ mod: async (qbwcUserId, params) => this.sendRequestBase(qbwcUserId, { CustomerModRq: { CustomerMod: params } }, "CustomerModRs", "CustomerRet"),
109
65
  /**
110
66
  * Returns data for the specified customers.
111
67
  *
112
- * Important: We highly recommend that you use the `IncludeRetElement` tag in
113
- * your `CustomerQuery` to include any data you want but do NOT include the
114
- * `ShipAddress` data in the `Response`, unless you need to get the shipping
115
- * address for a particular customer. Excluding the shipping address data will
116
- * significantly improve the performance of the `CustomerQuery`.
68
+ * Important: We highly recommend that you use the `IncludeRetElement` tag
69
+ * in your `CustomerQuery` to include any data you want but do NOT include
70
+ * the `ShipAddress` data in the `Response`, unless you need to get the
71
+ * shipping address for a particular customer. Excluding the shipping
72
+ * address data will significantly improve the performance of the
73
+ * `CustomerQuery`.
117
74
  *
118
75
  * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/CustomerQuery
119
76
  */
120
- query: async (qbwcUsername, params) => {
121
- const response = (await this.sendRequest(qbwcUsername, {
122
- CustomerQueryRq: params,
123
- }));
124
- const responseBody = response.CustomerQueryRs.CustomerRet;
125
- if (!responseBody) {
126
- throw new Error("No response");
127
- }
128
- return responseBody;
129
- },
77
+ query: async (qbwcUserId, params) => this.sendRequestBase(qbwcUserId, { CustomerQueryRq: params }, "CustomerQueryRs", "CustomerRet"),
130
78
  };
131
79
  employee = {
132
80
  /**
@@ -135,46 +83,19 @@ class ClientQBD extends BaseClient_1.default {
135
83
  *
136
84
  * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/EmployeeAdd
137
85
  */
138
- add: async (qbwcUsername, params) => {
139
- const response = (await this.sendRequest(qbwcUsername, {
140
- EmployeeAddRq: { EmployeeAdd: params },
141
- }));
142
- const responseBody = response.EmployeeAddRs.EmployeeRet;
143
- if (!responseBody) {
144
- throw new Error("No response");
145
- }
146
- return responseBody;
147
- },
86
+ add: async (qbwcUserId, params) => this.sendRequestBase(qbwcUserId, { EmployeeAddRq: { EmployeeAdd: params } }, "EmployeeAddRs", "EmployeeRet"),
148
87
  /**
149
88
  * Modifies an existing employee.
150
89
  *
151
90
  * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/EmployeeMod
152
91
  */
153
- mod: async (qbwcUsername, params) => {
154
- const response = (await this.sendRequest(qbwcUsername, {
155
- EmployeeModRq: { EmployeeMod: params },
156
- }));
157
- const responseBody = response.EmployeeModRs.EmployeeRet;
158
- if (!responseBody) {
159
- throw new Error("No response");
160
- }
161
- return responseBody;
162
- },
92
+ mod: async (qbwcUserId, params) => this.sendRequestBase(qbwcUserId, { EmployeeModRq: { EmployeeMod: params } }, "EmployeeModRs", "EmployeeRet"),
163
93
  /**
164
94
  * Returns employee data.
165
95
  *
166
96
  * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/EmployeeQuery
167
97
  */
168
- query: async (qbwcUsername, params) => {
169
- const response = (await this.sendRequest(qbwcUsername, {
170
- EmployeeQueryRq: params,
171
- }));
172
- const responseBody = response.EmployeeQueryRs.EmployeeRet;
173
- if (!responseBody) {
174
- throw new Error("No response");
175
- }
176
- return responseBody;
177
- },
98
+ query: async (qbwcUserId, params) => this.sendRequestBase(qbwcUserId, { EmployeeQueryRq: params }, "EmployeeQueryRs", "EmployeeRet"),
178
99
  };
179
100
  journalEntry = {
180
101
  /**
@@ -186,11 +107,11 @@ class ClientQBD extends BaseClient_1.default {
186
107
  * transactions can be categorized either by account or by type (invoice,
187
108
  * check, and so on). For a few activities in QuickBooks, you must use the
188
109
  * general journal directly, for example for recording depreciation. Notice
189
- * that you must supply the credit line and a corresponding debit line in the
190
- * same request. It will not work to supply them in two distinct requests. You
191
- * can supply as many credit lines and debit lines in one single request as
192
- * you want so long as the total monetary amount from the credits equals the
193
- * total monetary amount from the debits in that request.
110
+ * that you must supply the credit line and a corresponding debit line in
111
+ * the same request. It will not work to supply them in two distinct
112
+ * requests. You can supply as many credit lines and debit lines in one
113
+ * single request as you want so long as the total monetary amount from the
114
+ * credits equals the total monetary amount from the debits in that request.
194
115
  *
195
116
  * Finally, DO NOT supply negative sign for the monetary amounts. QuickBooks
196
117
  * does that for you. If you do supply the negative sign, amounts will add
@@ -198,8 +119,8 @@ class ClientQBD extends BaseClient_1.default {
198
119
  *
199
120
  * Querying for Condensed Transactions: If you need the query to return
200
121
  * condensed transactions, you can do this by using either an `Entity` or
201
- * `Account` filter in the journal query request. Alternatively, you could use
202
- * the The generic `TransactionQuery`, which can return condensed
122
+ * `Account` filter in the journal query request. Alternatively, you could
123
+ * use the The generic `TransactionQuery`, which can return condensed
203
124
  * transactions.
204
125
  *
205
126
  * If the transaction is a home currency adjustment, QuickBooks will ignore
@@ -208,16 +129,7 @@ class ClientQBD extends BaseClient_1.default {
208
129
  *
209
130
  * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/JournalEntryAdd
210
131
  */
211
- add: async (qbwcUsername, params) => {
212
- const response = (await this.sendRequest(qbwcUsername, {
213
- JournalEntryAddRq: params,
214
- }));
215
- const responseBody = response.JournalEntryAddRs.JournalEntryRet;
216
- if (!responseBody) {
217
- throw new Error("No response");
218
- }
219
- return responseBody;
220
- },
132
+ add: async (qbwcUserId, params) => this.sendRequestBase(qbwcUserId, { JournalEntryAddRq: { JournalEntryAdd: params } }, "JournalEntryAddRs", "JournalEntryRet"),
221
133
  /**
222
134
  * Modifies a journal entry.
223
135
  *
@@ -227,27 +139,18 @@ class ClientQBD extends BaseClient_1.default {
227
139
  *
228
140
  * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/JournalEntryMod
229
141
  */
230
- mod: async (qbwcUsername, params) => {
231
- const response = (await this.sendRequest(qbwcUsername, {
232
- JournalEntryModRq: { JournalEntryMod: params },
233
- }));
234
- const responseBody = response.JournalEntryModRs.JournalEntryRet;
235
- if (!responseBody) {
236
- throw new Error("No response");
237
- }
238
- return responseBody;
239
- },
142
+ mod: async (qbwcUserId, params) => this.sendRequestBase(qbwcUserId, { JournalEntryModRq: { JournalEntryMod: params } }, "JournalEntryModRs", "JournalEntryRet"),
240
143
  /**
241
144
  * In traditional accounting, transactions are entered into the general
242
145
  * journal and categorized exclusively by account. In QuickBooks, most
243
146
  * transactions can be categorized either by account or by type (invoice,
244
147
  * check, and so on). For a few activities in QuickBooks, you must use the
245
148
  * general journal directly, for example for recording depreciation. Notice
246
- * that you must supply the credit line and a corresponding debit line in the
247
- * same request. It will not work to supply them in two distinct requests. You
248
- * can supply as many credit lines and debit lines in one single request as
249
- * you want so long as the total monetary amount from the credits equals the
250
- * total monetary amount from the debits in that request.
149
+ * that you must supply the credit line and a corresponding debit line in
150
+ * the same request. It will not work to supply them in two distinct
151
+ * requests. You can supply as many credit lines and debit lines in one
152
+ * single request as you want so long as the total monetary amount from the
153
+ * credits equals the total monetary amount from the debits in that request.
251
154
  *
252
155
  * Finally, DO NOT supply negative sign for the monetary amounts. QuickBooks
253
156
  * does that for you. If you do supply the negative sign, amounts will add
@@ -255,22 +158,64 @@ class ClientQBD extends BaseClient_1.default {
255
158
  *
256
159
  * Querying for Condensed Transactions: If you need the query to return
257
160
  * condensed transactions, you can do this by using either an `Entity` or
258
- * `Account` filter in the journal query request. Alternatively, you could use
259
- * the The generic `TransactionQuery`, which can return condensed
161
+ * `Account` filter in the journal query request. Alternatively, you could
162
+ * use the The generic `TransactionQuery`, which can return condensed
260
163
  * transactions.
261
164
  *
262
165
  * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/JournalEntryQuery
263
166
  */
264
- query: async (qbwcUsername, params) => {
265
- const response = (await this.sendRequest(qbwcUsername, {
266
- JournalEntryQueryRq: params,
267
- }));
268
- const responseBody = response.JournalEntryQueryRs.JournalEntryRet;
269
- if (!responseBody) {
270
- throw new Error("No response");
271
- }
272
- return responseBody;
273
- },
167
+ query: async (qbwcUserId, params) => this.sendRequestBase(qbwcUserId, { JournalEntryQueryRq: params }, "JournalEntryQueryRs", "JournalEntryRet"),
168
+ };
169
+ timeTracking = {
170
+ /**
171
+ * The time-tracking transactions that are returned in this query include
172
+ * time tracking information that was entered into QuickBooks manually or
173
+ * gathered using the QuickBooks “Timer” or “Stopwatch.” Note that the
174
+ * QuickBooks Timer application can run on its own without QuickBooks, but
175
+ * the QuickBooks SDK cannot access the Timer data directly. The Timer data
176
+ * must be imported into QuickBooks before it is accessible via the SDK.)
177
+ *
178
+ * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/TimeTrackingQuery
179
+ */
180
+ add: async (qbwcUserId, params) => this.sendRequestBase(qbwcUserId, { TimeTrackingAddRq: { TimeTrackingAdd: params } }, "TimeTrackingAddRs", "TimeTrackingRet"),
181
+ /**
182
+ * Modifies a time tracking transaction.
183
+ *
184
+ * This allows you to modify time entry and mark time entered as billed.
185
+ * Applications using qbXML spec levels less than 6.0 aren’t able to Modify
186
+ * a time tracking transaction. However, those applications can achieve the
187
+ * results of a modify operation by deleting the time tracking transaction
188
+ * (using `TxnDelRq`) and then re-adding it with the desired values. You can
189
+ * do this only if no other downstream transactions have used that
190
+ * particular time tracking transaction. (Otherwise, the `TxnDel` request
191
+ * will fail.) This differs slightly from the UI, which allows these
192
+ * transactions to be edited directly. However, even in the UI, modifying a
193
+ * time tracking transaction does not result in changes to any downstream
194
+ * transactions that use it. There is no link between an invoice and the
195
+ * time entries. However when you do the invoicing from QuickBooks,
196
+ * QuickBooks does mark the time entries as “billed.” If you don’t record
197
+ * the time entries as billed properly, then you get into a user workflow
198
+ * issue where every time the user creates an invoice for a customer, QB
199
+ * pops up a dialog asking if they want to bill the un-billed time (which
200
+ * you already billed from your app). That’s why beginning with QB2007 and
201
+ * qbXML spec 6.0 we added support for the “BillableStatus” field *and* add
202
+ * `TimeTrackingMod` so that you can mark the time as billed when you create
203
+ * an invoice for it.
204
+ *
205
+ * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/TimeTrackingMod
206
+ */
207
+ mod: async (qbwcUserId, params) => this.sendRequestBase(qbwcUserId, { TimeTrackingModRq: { TimeTrackingMod: params } }, "TimeTrackingModRs", "TimeTrackingRet"),
208
+ /**
209
+ * The time-tracking transactions that are returned in this query include
210
+ * time tracking information that was entered into QuickBooks manually or
211
+ * gathered using the QuickBooks “Timer” or “Stopwatch.” Note that the
212
+ * QuickBooks Timer application can run on its own without QuickBooks, but
213
+ * the QuickBooks SDK cannot access the Timer data directly. The Timer data
214
+ * must be imported into QuickBooks before it is accessible via the SDK.)
215
+ *
216
+ * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/TimeTrackingQuery
217
+ */
218
+ query: async (qbwcUserId, params) => this.sendRequestBase(qbwcUserId, { TimeTrackingQueryRq: params }, "TimeTrackingQueryRs", "TimeTrackingRet"),
274
219
  };
275
220
  vendor = {
276
221
  /**
@@ -278,62 +223,44 @@ class ClientQBD extends BaseClient_1.default {
278
223
  *
279
224
  * A vendor is any person or company from whom a small business owner buys
280
225
  * goods and services. (Banks and tax agencies usually are included on the
281
- * vendor list.) A company’s vendor list contains information such as account
282
- * balance and contact information about each vendor. A `VendorRef` aggregate
283
- * refers to one of the vendors on the list. In a request, if a `VendorRef`
284
- * aggregate includes both `FullName` and `ListID`, `FullName` will be
285
- * ignored.
226
+ * vendor list.) A company’s vendor list contains information such as
227
+ * account balance and contact information about each vendor. A `VendorRef`
228
+ * aggregate refers to one of the vendors on the list. In a request, if a
229
+ * `VendorRef` aggregate includes both `FullName` and `ListID`, `FullName`
230
+ * will be ignored.
286
231
  *
287
232
  * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/VendorAdd
288
233
  */
289
- add: async (qbwcUsername, params) => {
290
- const response = (await this.sendRequest(qbwcUsername, {
291
- VendorAddRq: { VendorAdd: params },
292
- }));
293
- const responseBody = response.VendorAddRs.VendorRet;
294
- if (!responseBody) {
295
- throw new Error("No response");
296
- }
297
- return responseBody;
298
- },
234
+ add: async (qbwcUserId, params) => this.sendRequestBase(qbwcUserId, { VendorAddRq: { VendorAdd: params } }, "VendorAddRs", "VendorRet"),
299
235
  /**
300
236
  * Modifies a vendor.
301
237
  *
302
238
  * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/VendorMod
303
239
  */
304
- mod: async (qbwcUsername, params) => {
305
- const response = (await this.sendRequest(qbwcUsername, {
306
- VendorModRq: { VendorMod: params },
307
- }));
308
- const responseBody = response.VendorModRs.VendorRet;
309
- if (!responseBody) {
310
- throw new Error("No response");
311
- }
312
- return responseBody;
313
- },
240
+ mod: async (qbwcUserId, params) => this.sendRequestBase(qbwcUserId, { VendorModRq: { VendorMod: params } }, "VendorModRs", "VendorRet"),
314
241
  /**
315
242
  * Queries for the specified vendor or set of vendors.
316
243
  *
317
244
  * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/VendorQuery
318
245
  */
319
- query: async (qbwcUsername, params) => {
320
- const response = (await this.sendRequest(qbwcUsername, {
321
- VendorQueryRq: params,
322
- }));
323
- const responseBody = response.VendorQueryRs.VendorRet;
324
- if (!responseBody) {
325
- throw new Error("No response");
326
- }
327
- return responseBody;
328
- },
246
+ query: async (qbwcUserId, params) => this.sendRequestBase(qbwcUserId, { VendorQueryRq: params }, "VendorQueryRs", "VendorRet"),
329
247
  };
330
248
  /**
331
249
  * Send any QBXML request to QuickBooks Desktop.
332
250
  *
333
- * Available APIs: https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop
251
+ * Available APIs:
252
+ * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop
334
253
  */
335
- async sendRequest(qbwcUsername, requestObj) {
336
- return this.sendAPIRequest("qbd", qbwcUsername, requestObj);
254
+ async sendRequest(qbwcUserId, requestObj) {
255
+ return this.sendAPIRequest("qbd", qbwcUserId, requestObj);
256
+ }
257
+ async sendRequestBase(qbwcUserId, params, responseKey, responseBodyKey) {
258
+ const response = (await this.sendRequest(qbwcUserId, params));
259
+ const responseBody = response[responseKey]?.[responseBodyKey];
260
+ if (responseBody == null) {
261
+ throw new Error("No response");
262
+ }
263
+ return responseBody;
337
264
  }
338
265
  }
339
266
  exports.default = ClientQBD;