conductor-node 1.0.0 → 1.0.1

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/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "conductor-node",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Conductor API wrapper",
5
5
  "author": "Danny Nemer <hi@DannyNemer.com>",
6
6
  "license": "MIT",
7
- "main": "dist/src/Client.js",
8
- "types": "dist/src/Client.d.ts",
7
+ "type": "commonjs",
8
+ "main": "./dist/src/Client.js",
9
+ "types": "./dist/src/Client.d.ts",
9
10
  "files": [
10
- "dist/src/**/*.[jt]s"
11
+ "./dist/src/**/*.[jt]s"
11
12
  ],
12
13
  "scripts": {
13
14
  "prepack": "yarn tsc && yarn tsc-alias",
@@ -1,13 +0,0 @@
1
- import type { Environment } from "./environment";
2
- export interface BaseClientOptions {
3
- apiKey: string;
4
- verbose?: boolean;
5
- environment?: Environment;
6
- }
7
- export default class BaseClient {
8
- protected readonly apiKey: string;
9
- protected readonly verbose: boolean;
10
- protected readonly serverURL: string;
11
- constructor({ apiKey, verbose, environment, }: BaseClientOptions);
12
- protected sendAPIRequest<T>(apiPath: string, qbwcUserId: string, requestObj: T): Promise<T>;
13
- }
@@ -1,43 +0,0 @@
1
- "use strict";
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
- class BaseClient {
11
- apiKey;
12
- verbose;
13
- serverURL;
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, qbwcUserId, requestObj) {
20
- const apiServerURL = `${this.serverURL}/${apiPath}`;
21
- if (this.verbose) {
22
- console.log(`Client sent request to ${apiServerURL} for user ${qbwcUserId}:`, JSON.stringify(requestObj, null, 2));
23
- }
24
- const response = await fetch(apiServerURL, {
25
- body: JSON.stringify({ qbwcUserId, 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 ${qbwcUserId}:`, JSON.stringify(responseObj, null, 2));
39
- }
40
- return responseObj;
41
- }
42
- }
43
- exports.default = BaseClient;
@@ -1,7 +0,0 @@
1
- import type { BaseClientOptions } from "./BaseClient";
2
- import ClientQBD from "./qbd/ClientQBD";
3
- export default class Client {
4
- /** QuickBooks Desktop integration. */
5
- readonly qbd: ClientQBD;
6
- constructor(options: BaseClientOptions);
7
- }
@@ -1,14 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const ClientQBD_1 = __importDefault(require("./qbd/ClientQBD"));
7
- class Client {
8
- /** QuickBooks Desktop integration. */
9
- qbd;
10
- constructor(options) {
11
- this.qbd = new ClientQBD_1.default(options);
12
- }
13
- }
14
- exports.default = Client;
@@ -1,2 +0,0 @@
1
- export declare type Environment = "development" | "staging";
2
- export declare function envToBaseServerURL(environment: Environment): string;
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.envToBaseServerURL = void 0;
4
- const STAGING_BASE_URL = "https://conductor-vgag.onrender.com";
5
- const DEVELOPMENT_BASE_URL = "https://conductor.ngrok.io";
6
- function envToBaseServerURL(environment) {
7
- switch (environment) {
8
- case "staging":
9
- return STAGING_BASE_URL;
10
- case "development":
11
- return DEVELOPMENT_BASE_URL;
12
- default:
13
- throw new Error("Invalid environment");
14
- }
15
- }
16
- exports.envToBaseServerURL = envToBaseServerURL;
@@ -1,255 +0,0 @@
1
- import BaseClient from "../BaseClient";
2
- import type * as qbd from "../qbd/qbdTypes";
3
- export interface QBXMLObj {
4
- [apiName: string]: object;
5
- }
6
- export default class ClientQBD extends BaseClient {
7
- account: {
8
- /**
9
- * Perform the same activities as a user does in the QB New Account form,
10
- * which can be accessed in QB by selecting "Lists" → "Chart of Accounts" →
11
- * "Accounts" → "New".
12
- *
13
- * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/AccountAdd
14
- */
15
- add: (qbwcUserId: string, params: qbd.AccountAddRq["AccountAdd"]) => Promise<NonNullable<qbd.AccountAddRs["AccountRet"]>>;
16
- /**
17
- * Modifies an account.
18
- *
19
- * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/AccountMod
20
- */
21
- mod: (qbwcUserId: string, params: qbd.AccountModRq["AccountMod"]) => Promise<NonNullable<qbd.AccountModRs["AccountRet"]>>;
22
- /**
23
- * `AccountQuery` is a list query that returns data for all accounts that
24
- * match the provided filter criteria. Notice that it returns only data
25
- * internal to the account itself. It does not return any data about
26
- * transactions involving the account. It does, however, return the parent
27
- * account, if there is one. You can search across all accounts or you can
28
- * specify an account type and search only those.
29
- *
30
- * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/AccountQuery
31
- */
32
- query: (qbwcUserId: string, params: qbd.AccountQueryRq) => Promise<NonNullable<qbd.AccountQueryRs["AccountRet"]>>;
33
- };
34
- customer: {
35
- /**
36
- * The customer list includes information about the QuickBooks user’s
37
- * customers and the individual jobs that are being performed for them. A
38
- * `CustomerRef` aggregate refers to one of the customers (or customer jobs)
39
- * on the list. In a request, if a `CustomerRef` aggregate includes both
40
- * `FullName` and `ListID`, `FullName` will be ignored. Special cases to
41
- * note:
42
- *
43
- * - In `SalesReceipt` and `ReceivePayment` requests, `CustomerRef` refers
44
- * to the customer or customer job to which the payment is credited.
45
- *
46
- * - In a `TimeTracking` request, CustomerRef refers to the customer or
47
- * customer job to which this time could be billed. If `IsBillable` is set
48
- * to true, `CustomerRef` is required in `TimeTrackingAdd`.
49
- *
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.
54
- *
55
- * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/CustomerAdd
56
- */
57
- add: (qbwcUserId: string, params: qbd.CustomerAddRq["CustomerAdd"]) => Promise<NonNullable<qbd.CustomerAddRs["CustomerRet"]>>;
58
- /**
59
- * Modifies the customer record.
60
- *
61
- * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/CustomerMod
62
- */
63
- mod: (qbwcUserId: string, params: qbd.CustomerModRq["CustomerMod"]) => Promise<NonNullable<qbd.CustomerModRs["CustomerRet"]>>;
64
- /**
65
- * Returns data for the specified customers.
66
- *
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`.
73
- *
74
- * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/CustomerQuery
75
- */
76
- query: (qbwcUserId: string, params: qbd.CustomerQueryRq) => Promise<NonNullable<qbd.CustomerQueryRs["CustomerRet"]>>;
77
- };
78
- employee: {
79
- /**
80
- * Adds an employee with personal data about the employee as well as certain
81
- * payroll-related data.
82
- *
83
- * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/EmployeeAdd
84
- */
85
- add: (qbwcUserId: string, params: qbd.EmployeeAddRq["EmployeeAdd"]) => Promise<NonNullable<qbd.EmployeeAddRs["EmployeeRet"]>>;
86
- /**
87
- * Modifies an existing employee.
88
- *
89
- * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/EmployeeMod
90
- */
91
- mod: (qbwcUserId: string, params: qbd.EmployeeModRq["EmployeeMod"]) => Promise<NonNullable<qbd.EmployeeModRs["EmployeeRet"]>>;
92
- /**
93
- * Returns employee data.
94
- *
95
- * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/EmployeeQuery
96
- */
97
- query: (qbwcUserId: string, params: qbd.EmployeeQueryRq) => Promise<NonNullable<qbd.EmployeeQueryRs["EmployeeRet"]>>;
98
- };
99
- journalEntry: {
100
- /**
101
- * The debit and credit lines can be intermingled. A credit line can legally
102
- * come first in the journal entry add.
103
- *
104
- * In traditional accounting, transactions are entered into the general
105
- * journal and categorized exclusively by account. In QuickBooks, most
106
- * transactions can be categorized either by account or by type (invoice,
107
- * check, and so on). For a few activities in QuickBooks, you must use the
108
- * general journal directly, for example for recording depreciation. Notice
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.
114
- *
115
- * Finally, DO NOT supply negative sign for the monetary amounts. QuickBooks
116
- * does that for you. If you do supply the negative sign, amounts will add
117
- * instead of cancel and you’ll get a runtime error.
118
- *
119
- * Querying for Condensed Transactions: If you need the query to return
120
- * condensed transactions, you can do this by using either an `Entity` or
121
- * `Account` filter in the journal query request. Alternatively, you could
122
- * use the The generic `TransactionQuery`, which can return condensed
123
- * transactions.
124
- *
125
- * If the transaction is a home currency adjustment, QuickBooks will ignore
126
- * the `IsAmountsEnteredInHomeCurrency`, `CurrencyRef`, and `ExchangeRate`
127
- * elements.
128
- *
129
- * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/JournalEntryAdd
130
- */
131
- add: (qbwcUserId: string, params: qbd.JournalEntryAddRq["JournalEntryAdd"]) => Promise<NonNullable<qbd.JournalEntryAddRs["JournalEntryRet"]>>;
132
- /**
133
- * Modifies a journal entry.
134
- *
135
- * If the transaction is a home currency adjustment, QuickBooks will ignore
136
- * the `IsAmountsEnteredInHomeCurrency`, `CurrencyRef`, and `ExchangeRate`
137
- * elements.
138
- *
139
- * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/JournalEntryMod
140
- */
141
- mod: (qbwcUserId: string, params: qbd.JournalEntryModRq["JournalEntryMod"]) => Promise<NonNullable<qbd.JournalEntryModRs["JournalEntryRet"]>>;
142
- /**
143
- * In traditional accounting, transactions are entered into the general
144
- * journal and categorized exclusively by account. In QuickBooks, most
145
- * transactions can be categorized either by account or by type (invoice,
146
- * check, and so on). For a few activities in QuickBooks, you must use the
147
- * general journal directly, for example for recording depreciation. Notice
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.
153
- *
154
- * Finally, DO NOT supply negative sign for the monetary amounts. QuickBooks
155
- * does that for you. If you do supply the negative sign, amounts will add
156
- * instead of cancel and you’ll get a runtime error.
157
- *
158
- * Querying for Condensed Transactions: If you need the query to return
159
- * condensed transactions, you can do this by using either an `Entity` or
160
- * `Account` filter in the journal query request. Alternatively, you could
161
- * use the The generic `TransactionQuery`, which can return condensed
162
- * transactions.
163
- *
164
- * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/JournalEntryQuery
165
- */
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"]>>;
218
- };
219
- vendor: {
220
- /**
221
- * Adds a vendor.
222
- *
223
- * A vendor is any person or company from whom a small business owner buys
224
- * goods and services. (Banks and tax agencies usually are included on the
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.
230
- *
231
- * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/VendorAdd
232
- */
233
- add: (qbwcUserId: string, params: qbd.VendorAddRq["VendorAdd"]) => Promise<NonNullable<qbd.VendorAddRs["VendorRet"]>>;
234
- /**
235
- * Modifies a vendor.
236
- *
237
- * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/VendorMod
238
- */
239
- mod: (qbwcUserId: string, params: qbd.VendorModRq["VendorMod"]) => Promise<NonNullable<qbd.VendorModRs["VendorRet"]>>;
240
- /**
241
- * Queries for the specified vendor or set of vendors.
242
- *
243
- * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/VendorQuery
244
- */
245
- query: (qbwcUserId: string, params: qbd.VendorQueryRq) => Promise<NonNullable<qbd.VendorQueryRs["VendorRet"]>>;
246
- };
247
- /**
248
- * Send any QBXML request to QuickBooks Desktop.
249
- *
250
- * Available APIs:
251
- * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop
252
- */
253
- sendRequest(qbwcUserId: string, requestObj: QBXMLObj): Promise<QBXMLObj>;
254
- private sendRequestBase;
255
- }
@@ -1,266 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const BaseClient_1 = __importDefault(require("../BaseClient"));
7
- class ClientQBD extends BaseClient_1.default {
8
- account = {
9
- /**
10
- * Perform the same activities as a user does in the QB New Account form,
11
- * which can be accessed in QB by selecting "Lists" → "Chart of Accounts" →
12
- * "Accounts" → "New".
13
- *
14
- * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/AccountAdd
15
- */
16
- add: async (qbwcUserId, params) => this.sendRequestBase(qbwcUserId, { AccountAddRq: { AccountAdd: params } }, "AccountAddRs", "AccountRet"),
17
- /**
18
- * Modifies an account.
19
- *
20
- * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/AccountMod
21
- */
22
- mod: async (qbwcUserId, params) => this.sendRequestBase(qbwcUserId, { AccountModRq: { AccountMod: params } }, "AccountModRs", "AccountRet"),
23
- /**
24
- * `AccountQuery` is a list query that returns data for all accounts that
25
- * match the provided filter criteria. Notice that it returns only data
26
- * internal to the account itself. It does not return any data about
27
- * transactions involving the account. It does, however, return the parent
28
- * account, if there is one. You can search across all accounts or you can
29
- * specify an account type and search only those.
30
- *
31
- * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/AccountQuery
32
- */
33
- query: async (qbwcUserId, params) => this.sendRequestBase(qbwcUserId, { AccountQueryRq: params }, "AccountQueryRs", "AccountRet"),
34
- };
35
- customer = {
36
- /**
37
- * The customer list includes information about the QuickBooks user’s
38
- * customers and the individual jobs that are being performed for them. A
39
- * `CustomerRef` aggregate refers to one of the customers (or customer jobs)
40
- * on the list. In a request, if a `CustomerRef` aggregate includes both
41
- * `FullName` and `ListID`, `FullName` will be ignored. Special cases to
42
- * note:
43
- *
44
- * - In `SalesReceipt` and `ReceivePayment` requests, `CustomerRef` refers
45
- * to the customer or customer job to which the payment is credited.
46
- *
47
- * - In a `TimeTracking` request, CustomerRef refers to the customer or
48
- * customer job to which this time could be billed. If `IsBillable` is set
49
- * to true, `CustomerRef` is required in `TimeTrackingAdd`.
50
- *
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.
55
- *
56
- * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/CustomerAdd
57
- */
58
- add: async (qbwcUserId, params) => this.sendRequestBase(qbwcUserId, { CustomerAddRq: { CustomerAdd: params } }, "CustomerAddRs", "CustomerRet"),
59
- /**
60
- * Modifies the customer record.
61
- *
62
- * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/CustomerMod
63
- */
64
- mod: async (qbwcUserId, params) => this.sendRequestBase(qbwcUserId, { CustomerModRq: { CustomerMod: params } }, "CustomerModRs", "CustomerRet"),
65
- /**
66
- * Returns data for the specified customers.
67
- *
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`.
74
- *
75
- * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/CustomerQuery
76
- */
77
- query: async (qbwcUserId, params) => this.sendRequestBase(qbwcUserId, { CustomerQueryRq: params }, "CustomerQueryRs", "CustomerRet"),
78
- };
79
- employee = {
80
- /**
81
- * Adds an employee with personal data about the employee as well as certain
82
- * payroll-related data.
83
- *
84
- * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/EmployeeAdd
85
- */
86
- add: async (qbwcUserId, params) => this.sendRequestBase(qbwcUserId, { EmployeeAddRq: { EmployeeAdd: params } }, "EmployeeAddRs", "EmployeeRet"),
87
- /**
88
- * Modifies an existing employee.
89
- *
90
- * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/EmployeeMod
91
- */
92
- mod: async (qbwcUserId, params) => this.sendRequestBase(qbwcUserId, { EmployeeModRq: { EmployeeMod: params } }, "EmployeeModRs", "EmployeeRet"),
93
- /**
94
- * Returns employee data.
95
- *
96
- * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/EmployeeQuery
97
- */
98
- query: async (qbwcUserId, params) => this.sendRequestBase(qbwcUserId, { EmployeeQueryRq: params }, "EmployeeQueryRs", "EmployeeRet"),
99
- };
100
- journalEntry = {
101
- /**
102
- * The debit and credit lines can be intermingled. A credit line can legally
103
- * come first in the journal entry add.
104
- *
105
- * In traditional accounting, transactions are entered into the general
106
- * journal and categorized exclusively by account. In QuickBooks, most
107
- * transactions can be categorized either by account or by type (invoice,
108
- * check, and so on). For a few activities in QuickBooks, you must use the
109
- * general journal directly, for example for recording depreciation. Notice
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.
115
- *
116
- * Finally, DO NOT supply negative sign for the monetary amounts. QuickBooks
117
- * does that for you. If you do supply the negative sign, amounts will add
118
- * instead of cancel and you’ll get a runtime error.
119
- *
120
- * Querying for Condensed Transactions: If you need the query to return
121
- * condensed transactions, you can do this by using either an `Entity` or
122
- * `Account` filter in the journal query request. Alternatively, you could
123
- * use the The generic `TransactionQuery`, which can return condensed
124
- * transactions.
125
- *
126
- * If the transaction is a home currency adjustment, QuickBooks will ignore
127
- * the `IsAmountsEnteredInHomeCurrency`, `CurrencyRef`, and `ExchangeRate`
128
- * elements.
129
- *
130
- * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/JournalEntryAdd
131
- */
132
- add: async (qbwcUserId, params) => this.sendRequestBase(qbwcUserId, { JournalEntryAddRq: { JournalEntryAdd: params } }, "JournalEntryAddRs", "JournalEntryRet"),
133
- /**
134
- * Modifies a journal entry.
135
- *
136
- * If the transaction is a home currency adjustment, QuickBooks will ignore
137
- * the `IsAmountsEnteredInHomeCurrency`, `CurrencyRef`, and `ExchangeRate`
138
- * elements.
139
- *
140
- * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/JournalEntryMod
141
- */
142
- mod: async (qbwcUserId, params) => this.sendRequestBase(qbwcUserId, { JournalEntryModRq: { JournalEntryMod: params } }, "JournalEntryModRs", "JournalEntryRet"),
143
- /**
144
- * In traditional accounting, transactions are entered into the general
145
- * journal and categorized exclusively by account. In QuickBooks, most
146
- * transactions can be categorized either by account or by type (invoice,
147
- * check, and so on). For a few activities in QuickBooks, you must use the
148
- * general journal directly, for example for recording depreciation. Notice
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.
154
- *
155
- * Finally, DO NOT supply negative sign for the monetary amounts. QuickBooks
156
- * does that for you. If you do supply the negative sign, amounts will add
157
- * instead of cancel and you’ll get a runtime error.
158
- *
159
- * Querying for Condensed Transactions: If you need the query to return
160
- * condensed transactions, you can do this by using either an `Entity` or
161
- * `Account` filter in the journal query request. Alternatively, you could
162
- * use the The generic `TransactionQuery`, which can return condensed
163
- * transactions.
164
- *
165
- * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/JournalEntryQuery
166
- */
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"),
219
- };
220
- vendor = {
221
- /**
222
- * Adds a vendor.
223
- *
224
- * A vendor is any person or company from whom a small business owner buys
225
- * goods and services. (Banks and tax agencies usually are included on the
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.
231
- *
232
- * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/VendorAdd
233
- */
234
- add: async (qbwcUserId, params) => this.sendRequestBase(qbwcUserId, { VendorAddRq: { VendorAdd: params } }, "VendorAddRs", "VendorRet"),
235
- /**
236
- * Modifies a vendor.
237
- *
238
- * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/VendorMod
239
- */
240
- mod: async (qbwcUserId, params) => this.sendRequestBase(qbwcUserId, { VendorModRq: { VendorMod: params } }, "VendorModRs", "VendorRet"),
241
- /**
242
- * Queries for the specified vendor or set of vendors.
243
- *
244
- * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/VendorQuery
245
- */
246
- query: async (qbwcUserId, params) => this.sendRequestBase(qbwcUserId, { VendorQueryRq: params }, "VendorQueryRs", "VendorRet"),
247
- };
248
- /**
249
- * Send any QBXML request to QuickBooks Desktop.
250
- *
251
- * Available APIs:
252
- * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop
253
- */
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;
264
- }
265
- }
266
- exports.default = ClientQBD;