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.
package/README.md CHANGED
@@ -19,14 +19,15 @@ The package must be configured with your account's secret key, which is availabl
19
19
 
20
20
  Currently supports executing any [QuickBooks Desktop API](https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop) via JSON and receiving the response in JSON. In the future, Conductor will incorporate extensive typings for these APIs.
21
21
 
22
- To send a request to a specific QuickBooks Desktop user, you must also supply the username that is in their `.qwc` file that you provided them.
22
+ To send a request to a specific QuickBooks Desktop user, you must also supply their user id.
23
23
 
24
24
  ```ts
25
25
  import Conductor from "conductor-node";
26
26
  const conductor = new Conductor({ apiKey: "sk_test_..." });
27
27
 
28
+ const mock_qbwc_user_id = "1";
28
29
  conductor.qbd.account
29
- .add("mock_qbwc_username", {
30
+ .add(mock_qbwc_user_id, {
30
31
  Name: "Test Account",
31
32
  AccountType: "Bank",
32
33
  OpenBalance: "100",
@@ -9,5 +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>(apiPath: string, username: string, requestObj: T): Promise<T>;
12
+ protected sendAPIRequest<T>(apiPath: string, qbwcUserId: string, requestObj: T): Promise<T>;
13
13
  }
@@ -16,13 +16,13 @@ class BaseClient {
16
16
  this.verbose = verbose;
17
17
  this.serverURL = (0, environment_1.envToBaseServerURL)(environment);
18
18
  }
19
- async sendAPIRequest(apiPath, username, requestObj) {
19
+ async sendAPIRequest(apiPath, qbwcUserId, requestObj) {
20
20
  const apiServerURL = `${this.serverURL}/${apiPath}`;
21
21
  if (this.verbose) {
22
- console.log(`Client sent request to ${apiServerURL} for user ${username}:`, JSON.stringify(requestObj, null, 2));
22
+ console.log(`Client sent request to ${apiServerURL} for user ${qbwcUserId}:`, JSON.stringify(requestObj, null, 2));
23
23
  }
24
24
  const response = await fetch(apiServerURL, {
25
- body: JSON.stringify({ username, requestObj }),
25
+ body: JSON.stringify({ qbwcUserId, requestObj }),
26
26
  headers: {
27
27
  "Content-Type": "application/json",
28
28
  Authorization: `Bearer ${this.apiKey}`,
@@ -35,7 +35,7 @@ class BaseClient {
35
35
  }
36
36
  const responseObj = (await response.json());
37
37
  if (this.verbose) {
38
- console.log(`Client received response for user ${username}:`, JSON.stringify(responseObj, null, 2));
38
+ console.log(`Client received response for user ${qbwcUserId}:`, JSON.stringify(responseObj, null, 2));
39
39
  }
40
40
  return responseObj;
41
41
  }
@@ -12,13 +12,13 @@ export default class ClientQBD extends BaseClient {
12
12
  *
13
13
  * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/AccountAdd
14
14
  */
15
- add: (qbwcUsername: string, params: qbd.AccountAddRq["AccountAdd"]) => Promise<qbd.AccountAddRs["AccountRet"]>;
15
+ add: (qbwcUserId: string, params: qbd.AccountAddRq["AccountAdd"]) => Promise<NonNullable<qbd.AccountAddRs["AccountRet"]>>;
16
16
  /**
17
17
  * Modifies an account.
18
18
  *
19
19
  * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/AccountMod
20
20
  */
21
- mod: (qbwcUsername: string, params: qbd.AccountModRq["AccountMod"]) => Promise<qbd.AccountModRs["AccountRet"]>;
21
+ mod: (qbwcUserId: string, params: qbd.AccountModRq["AccountMod"]) => Promise<NonNullable<qbd.AccountModRs["AccountRet"]>>;
22
22
  /**
23
23
  * `AccountQuery` is a list query that returns data for all accounts that
24
24
  * match the provided filter criteria. Notice that it returns only data
@@ -29,7 +29,7 @@ export default class ClientQBD extends BaseClient {
29
29
  *
30
30
  * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/AccountQuery
31
31
  */
32
- query: (qbwcUsername: string, params: qbd.AccountQueryRq) => Promise<qbd.AccountQueryRs["AccountRet"]>;
32
+ query: (qbwcUserId: string, params: qbd.AccountQueryRq) => Promise<NonNullable<qbd.AccountQueryRs["AccountRet"]>>;
33
33
  };
34
34
  customer: {
35
35
  /**
@@ -37,41 +37,43 @@ export default class ClientQBD extends BaseClient {
37
37
  * customers and the individual jobs that are being performed for them. A
38
38
  * `CustomerRef` aggregate refers to one of the customers (or customer jobs)
39
39
  * on the list. In a request, if a `CustomerRef` aggregate includes both
40
- * `FullName` and `ListID`, `FullName` will be ignored. Special cases to note:
40
+ * `FullName` and `ListID`, `FullName` will be ignored. Special cases to
41
+ * note:
41
42
  *
42
- * - In `SalesReceipt` and `ReceivePayment` requests, `CustomerRef` refers to
43
- * the customer or customer job to which the payment is credited.
43
+ * - In `SalesReceipt` and `ReceivePayment` requests, `CustomerRef` refers
44
+ * to the customer or customer job to which the payment is credited.
44
45
  *
45
46
  * - In a `TimeTracking` request, CustomerRef refers to the customer or
46
47
  * customer job to which this time could be billed. If `IsBillable` is set
47
48
  * to true, `CustomerRef` is required in `TimeTrackingAdd`.
48
49
  *
49
- * - In an `ExpenseLineAdd` request, if `AccountRef` refers to an A/P account,
50
- * `CustomerRef` must refer to a vendor (not to a customer). If `AccountRef`
51
- * refers to any other type of account, the `CustomerRef` must refer to a
52
- * customer.
50
+ * - In an `ExpenseLineAdd` request, if `AccountRef` refers to an A/P
51
+ * account, `CustomerRef` must refer to a vendor (not to a customer). If
52
+ * `AccountRef` refers to any other type of account, the `CustomerRef`
53
+ * must refer to a customer.
53
54
  *
54
55
  * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/CustomerAdd
55
56
  */
56
- add: (qbwcUsername: string, params: qbd.CustomerAddRq["CustomerAdd"]) => Promise<qbd.CustomerAddRs["CustomerRet"]>;
57
+ add: (qbwcUserId: string, params: qbd.CustomerAddRq["CustomerAdd"]) => Promise<NonNullable<qbd.CustomerAddRs["CustomerRet"]>>;
57
58
  /**
58
59
  * Modifies the customer record.
59
60
  *
60
61
  * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/CustomerMod
61
62
  */
62
- mod: (qbwcUsername: string, params: qbd.CustomerModRq["CustomerMod"]) => Promise<qbd.CustomerModRs["CustomerRet"]>;
63
+ mod: (qbwcUserId: string, params: qbd.CustomerModRq["CustomerMod"]) => Promise<NonNullable<qbd.CustomerModRs["CustomerRet"]>>;
63
64
  /**
64
65
  * Returns data for the specified customers.
65
66
  *
66
- * Important: We highly recommend that you use the `IncludeRetElement` tag in
67
- * your `CustomerQuery` to include any data you want but do NOT include the
68
- * `ShipAddress` data in the `Response`, unless you need to get the shipping
69
- * address for a particular customer. Excluding the shipping address data will
70
- * significantly improve the performance of the `CustomerQuery`.
67
+ * Important: We highly recommend that you use the `IncludeRetElement` tag
68
+ * in your `CustomerQuery` to include any data you want but do NOT include
69
+ * the `ShipAddress` data in the `Response`, unless you need to get the
70
+ * shipping address for a particular customer. Excluding the shipping
71
+ * address data will significantly improve the performance of the
72
+ * `CustomerQuery`.
71
73
  *
72
74
  * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/CustomerQuery
73
75
  */
74
- query: (qbwcUsername: string, params: qbd.CustomerQueryRq) => Promise<qbd.CustomerQueryRs["CustomerRet"]>;
76
+ query: (qbwcUserId: string, params: qbd.CustomerQueryRq) => Promise<NonNullable<qbd.CustomerQueryRs["CustomerRet"]>>;
75
77
  };
76
78
  employee: {
77
79
  /**
@@ -80,19 +82,19 @@ export default class ClientQBD extends BaseClient {
80
82
  *
81
83
  * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/EmployeeAdd
82
84
  */
83
- add: (qbwcUsername: string, params: qbd.EmployeeAddRq["EmployeeAdd"]) => Promise<qbd.EmployeeAddRs["EmployeeRet"]>;
85
+ add: (qbwcUserId: string, params: qbd.EmployeeAddRq["EmployeeAdd"]) => Promise<NonNullable<qbd.EmployeeAddRs["EmployeeRet"]>>;
84
86
  /**
85
87
  * Modifies an existing employee.
86
88
  *
87
89
  * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/EmployeeMod
88
90
  */
89
- mod: (qbwcUsername: string, params: qbd.EmployeeModRq["EmployeeMod"]) => Promise<qbd.EmployeeModRs["EmployeeRet"]>;
91
+ mod: (qbwcUserId: string, params: qbd.EmployeeModRq["EmployeeMod"]) => Promise<NonNullable<qbd.EmployeeModRs["EmployeeRet"]>>;
90
92
  /**
91
93
  * Returns employee data.
92
94
  *
93
95
  * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/EmployeeQuery
94
96
  */
95
- query: (qbwcUsername: string, params: qbd.EmployeeQueryRq) => Promise<qbd.EmployeeQueryRs["EmployeeRet"]>;
97
+ query: (qbwcUserId: string, params: qbd.EmployeeQueryRq) => Promise<NonNullable<qbd.EmployeeQueryRs["EmployeeRet"]>>;
96
98
  };
97
99
  journalEntry: {
98
100
  /**
@@ -104,11 +106,11 @@ export default class ClientQBD extends BaseClient {
104
106
  * transactions can be categorized either by account or by type (invoice,
105
107
  * check, and so on). For a few activities in QuickBooks, you must use the
106
108
  * general journal directly, for example for recording depreciation. Notice
107
- * that you must supply the credit line and a corresponding debit line in the
108
- * same request. It will not work to supply them in two distinct requests. You
109
- * can supply as many credit lines and debit lines in one single request as
110
- * you want so long as the total monetary amount from the credits equals the
111
- * total monetary amount from the debits in that request.
109
+ * that you must supply the credit line and a corresponding debit line in
110
+ * the same request. It will not work to supply them in two distinct
111
+ * requests. You can supply as many credit lines and debit lines in one
112
+ * single request as you want so long as the total monetary amount from the
113
+ * credits equals the total monetary amount from the debits in that request.
112
114
  *
113
115
  * Finally, DO NOT supply negative sign for the monetary amounts. QuickBooks
114
116
  * does that for you. If you do supply the negative sign, amounts will add
@@ -116,8 +118,8 @@ export default class ClientQBD extends BaseClient {
116
118
  *
117
119
  * Querying for Condensed Transactions: If you need the query to return
118
120
  * condensed transactions, you can do this by using either an `Entity` or
119
- * `Account` filter in the journal query request. Alternatively, you could use
120
- * the The generic `TransactionQuery`, which can return condensed
121
+ * `Account` filter in the journal query request. Alternatively, you could
122
+ * use the The generic `TransactionQuery`, which can return condensed
121
123
  * transactions.
122
124
  *
123
125
  * If the transaction is a home currency adjustment, QuickBooks will ignore
@@ -126,7 +128,7 @@ export default class ClientQBD extends BaseClient {
126
128
  *
127
129
  * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/JournalEntryAdd
128
130
  */
129
- add: (qbwcUsername: string, params: qbd.JournalEntryAddRq) => Promise<qbd.JournalEntryAddRs["JournalEntryRet"]>;
131
+ add: (qbwcUserId: string, params: qbd.JournalEntryAddRq["JournalEntryAdd"]) => Promise<NonNullable<qbd.JournalEntryAddRs["JournalEntryRet"]>>;
130
132
  /**
131
133
  * Modifies a journal entry.
132
134
  *
@@ -136,18 +138,18 @@ export default class ClientQBD extends BaseClient {
136
138
  *
137
139
  * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/JournalEntryMod
138
140
  */
139
- mod: (qbwcUsername: string, params: qbd.JournalEntryModRq["JournalEntryMod"]) => Promise<qbd.JournalEntryModRs["JournalEntryRet"]>;
141
+ mod: (qbwcUserId: string, params: qbd.JournalEntryModRq["JournalEntryMod"]) => Promise<NonNullable<qbd.JournalEntryModRs["JournalEntryRet"]>>;
140
142
  /**
141
143
  * In traditional accounting, transactions are entered into the general
142
144
  * journal and categorized exclusively by account. In QuickBooks, most
143
145
  * transactions can be categorized either by account or by type (invoice,
144
146
  * check, and so on). For a few activities in QuickBooks, you must use the
145
147
  * general journal directly, for example for recording depreciation. Notice
146
- * that you must supply the credit line and a corresponding debit line in the
147
- * same request. It will not work to supply them in two distinct requests. You
148
- * can supply as many credit lines and debit lines in one single request as
149
- * you want so long as the total monetary amount from the credits equals the
150
- * total monetary amount from the debits in that request.
148
+ * that you must supply the credit line and a corresponding debit line in
149
+ * the same request. It will not work to supply them in two distinct
150
+ * requests. You can supply as many credit lines and debit lines in one
151
+ * single request as you want so long as the total monetary amount from the
152
+ * credits equals the total monetary amount from the debits in that request.
151
153
  *
152
154
  * Finally, DO NOT supply negative sign for the monetary amounts. QuickBooks
153
155
  * does that for you. If you do supply the negative sign, amounts will add
@@ -155,13 +157,64 @@ export default class ClientQBD extends BaseClient {
155
157
  *
156
158
  * Querying for Condensed Transactions: If you need the query to return
157
159
  * condensed transactions, you can do this by using either an `Entity` or
158
- * `Account` filter in the journal query request. Alternatively, you could use
159
- * the The generic `TransactionQuery`, which can return condensed
160
+ * `Account` filter in the journal query request. Alternatively, you could
161
+ * use the The generic `TransactionQuery`, which can return condensed
160
162
  * transactions.
161
163
  *
162
164
  * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/JournalEntryQuery
163
165
  */
164
- query: (qbwcUsername: string, params: qbd.JournalEntryQueryRq) => Promise<qbd.JournalEntryQueryRs["JournalEntryRet"]>;
166
+ query: (qbwcUserId: string, params: qbd.JournalEntryQueryRq) => Promise<NonNullable<qbd.JournalEntryQueryRs["JournalEntryRet"]>>;
167
+ };
168
+ timeTracking: {
169
+ /**
170
+ * The time-tracking transactions that are returned in this query include
171
+ * time tracking information that was entered into QuickBooks manually or
172
+ * gathered using the QuickBooks “Timer” or “Stopwatch.” Note that the
173
+ * QuickBooks Timer application can run on its own without QuickBooks, but
174
+ * the QuickBooks SDK cannot access the Timer data directly. The Timer data
175
+ * must be imported into QuickBooks before it is accessible via the SDK.)
176
+ *
177
+ * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/TimeTrackingQuery
178
+ */
179
+ add: (qbwcUserId: string, params: qbd.TimeTrackingAddRq["TimeTrackingAdd"]) => Promise<NonNullable<qbd.TimeTrackingAddRs["TimeTrackingRet"]>>;
180
+ /**
181
+ * Modifies a time tracking transaction.
182
+ *
183
+ * This allows you to modify time entry and mark time entered as billed.
184
+ * Applications using qbXML spec levels less than 6.0 aren’t able to Modify
185
+ * a time tracking transaction. However, those applications can achieve the
186
+ * results of a modify operation by deleting the time tracking transaction
187
+ * (using `TxnDelRq`) and then re-adding it with the desired values. You can
188
+ * do this only if no other downstream transactions have used that
189
+ * particular time tracking transaction. (Otherwise, the `TxnDel` request
190
+ * will fail.) This differs slightly from the UI, which allows these
191
+ * transactions to be edited directly. However, even in the UI, modifying a
192
+ * time tracking transaction does not result in changes to any downstream
193
+ * transactions that use it. There is no link between an invoice and the
194
+ * time entries. However when you do the invoicing from QuickBooks,
195
+ * QuickBooks does mark the time entries as “billed.” If you don’t record
196
+ * the time entries as billed properly, then you get into a user workflow
197
+ * issue where every time the user creates an invoice for a customer, QB
198
+ * pops up a dialog asking if they want to bill the un-billed time (which
199
+ * you already billed from your app). That’s why beginning with QB2007 and
200
+ * qbXML spec 6.0 we added support for the “BillableStatus” field *and* add
201
+ * `TimeTrackingMod` so that you can mark the time as billed when you create
202
+ * an invoice for it.
203
+ *
204
+ * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/TimeTrackingMod
205
+ */
206
+ mod: (qbwcUserId: string, params: qbd.TimeTrackingModRq["TimeTrackingMod"]) => Promise<NonNullable<qbd.TimeTrackingModRs["TimeTrackingRet"]>>;
207
+ /**
208
+ * The time-tracking transactions that are returned in this query include
209
+ * time tracking information that was entered into QuickBooks manually or
210
+ * gathered using the QuickBooks “Timer” or “Stopwatch.” Note that the
211
+ * QuickBooks Timer application can run on its own without QuickBooks, but
212
+ * the QuickBooks SDK cannot access the Timer data directly. The Timer data
213
+ * must be imported into QuickBooks before it is accessible via the SDK.)
214
+ *
215
+ * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/TimeTrackingQuery
216
+ */
217
+ query: (qbwcUserId: string, params: qbd.TimeTrackingQueryRq) => Promise<NonNullable<qbd.TimeTrackingQueryRs["TimeTrackingRet"]>>;
165
218
  };
166
219
  vendor: {
167
220
  /**
@@ -169,32 +222,34 @@ export default class ClientQBD extends BaseClient {
169
222
  *
170
223
  * A vendor is any person or company from whom a small business owner buys
171
224
  * goods and services. (Banks and tax agencies usually are included on the
172
- * vendor list.) A company’s vendor list contains information such as account
173
- * balance and contact information about each vendor. A `VendorRef` aggregate
174
- * refers to one of the vendors on the list. In a request, if a `VendorRef`
175
- * aggregate includes both `FullName` and `ListID`, `FullName` will be
176
- * ignored.
225
+ * vendor list.) A company’s vendor list contains information such as
226
+ * account balance and contact information about each vendor. A `VendorRef`
227
+ * aggregate refers to one of the vendors on the list. In a request, if a
228
+ * `VendorRef` aggregate includes both `FullName` and `ListID`, `FullName`
229
+ * will be ignored.
177
230
  *
178
231
  * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/VendorAdd
179
232
  */
180
- add: (qbwcUsername: string, params: qbd.VendorAddRq["VendorAdd"]) => Promise<qbd.VendorAddRs["VendorRet"]>;
233
+ add: (qbwcUserId: string, params: qbd.VendorAddRq["VendorAdd"]) => Promise<NonNullable<qbd.VendorAddRs["VendorRet"]>>;
181
234
  /**
182
235
  * Modifies a vendor.
183
236
  *
184
237
  * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/VendorMod
185
238
  */
186
- mod: (qbwcUsername: string, params: qbd.VendorModRq["VendorMod"]) => Promise<qbd.VendorModRs["VendorRet"]>;
239
+ mod: (qbwcUserId: string, params: qbd.VendorModRq["VendorMod"]) => Promise<NonNullable<qbd.VendorModRs["VendorRet"]>>;
187
240
  /**
188
241
  * Queries for the specified vendor or set of vendors.
189
242
  *
190
243
  * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/VendorQuery
191
244
  */
192
- query: (qbwcUsername: string, params: qbd.VendorQueryRq) => Promise<qbd.VendorQueryRs["VendorRet"]>;
245
+ query: (qbwcUserId: string, params: qbd.VendorQueryRq) => Promise<NonNullable<qbd.VendorQueryRs["VendorRet"]>>;
193
246
  };
194
247
  /**
195
248
  * Send any QBXML request to QuickBooks Desktop.
196
249
  *
197
- * Available APIs: https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop
250
+ * Available APIs:
251
+ * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop
198
252
  */
199
- sendRequest(qbwcUsername: string, requestObj: QBXMLObj): Promise<QBXMLObj>;
253
+ sendRequest(qbwcUserId: string, requestObj: QBXMLObj): Promise<QBXMLObj>;
254
+ private sendRequestBase;
200
255
  }