conductor-node 0.0.4 → 0.0.7

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
@@ -27,13 +27,13 @@ To send a request to a specific QuickBooks Desktop user, you must also supply th
27
27
  import Conductor from "conductor-node";
28
28
  const conductor = new Conductor("sk_test_...");
29
29
 
30
- conductor
31
- .sendRequest("mock_qbwc_username", {
32
- CustomerQueryRq: {
33
- MaxReturned: 1,
34
- },
30
+ conductor.qbd
31
+ .accountAdd("mock_qbwc_username", {
32
+ Name: "Test Account",
33
+ AccountType: "Bank",
34
+ OpenBalance: "100",
35
35
  })
36
- .then((customer) => {
37
- console.log("Response:", customer);
36
+ .then((account) => {
37
+ console.log("Response:", account);
38
38
  });
39
39
  ```
package/dist/Client.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- import type { QBXMLRequest, QBXMLResponse } from "@client/qbXMLTypes";
1
+ import ClientQBD from "conductor-node/qb/ClientQBD";
2
2
  export default class Client {
3
- private readonly apiKey;
4
- constructor(apiKey: string);
5
- sendRequest<T extends QBXMLRequest>(qbwcUsername: string, requestObj: T): Promise<QBXMLResponse<T>>;
3
+ readonly apiKey: string;
4
+ readonly verbose: boolean;
5
+ readonly qbd: ClientQBD;
6
+ constructor(apiKey: string, verbose?: boolean);
6
7
  }
package/dist/Client.js CHANGED
@@ -1,22 +1,17 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ const ClientQBD_1 = __importDefault(require("conductor-node/qb/ClientQBD"));
3
7
  class Client {
4
8
  apiKey;
5
- constructor(apiKey) {
9
+ verbose;
10
+ qbd;
11
+ constructor(apiKey, verbose = false) {
6
12
  this.apiKey = apiKey;
7
- }
8
- async sendRequest(qbwcUsername, requestObj) {
9
- const response = await fetch("https://conductor.ngrok.io", {
10
- body: JSON.stringify({ qbwcUsername, requestObj }),
11
- headers: {
12
- "Content-Type": "application/json",
13
- Authorization: `Bearer ${this.apiKey}`,
14
- },
15
- method: "POST",
16
- });
17
- const responseJSON = (await response.json());
18
- console.log("Client received response:", responseJSON);
19
- return responseJSON;
13
+ this.verbose = verbose;
14
+ this.qbd = new ClientQBD_1.default(this);
20
15
  }
21
16
  }
22
17
  exports.default = Client;
@@ -0,0 +1,38 @@
1
+ import type Client from "conductor-node/Client";
2
+ import type { AccountAdd, AccountQueryRq, AccountRet } from "conductor-node/qb/qbXMLTypes/Account";
3
+ import type { EmployeeAdd, EmployeeMod, EmployeeQueryRq, EmployeeRet } from "conductor-node/qb/qbXMLTypes/Employee";
4
+ export default class ClientQBD {
5
+ private readonly client;
6
+ constructor(rootClient: Client);
7
+ sendRequest(qbwcUsername: string, requestObj: object): Promise<object>;
8
+ accountAdd(qbwcUsername: string, params: AccountAdd): Promise<AccountRet>;
9
+ /**
10
+ * `AccountQuery` is a list query that returns data for all accounts that match
11
+ * the provided filter criteria. Notice that it returns only data internal to
12
+ * the account itself. It does not return any data about transactions
13
+ * involving the account. It does, however, return the parent account, if
14
+ * there is one. You can search across all accounts or you can specify an
15
+ * account type and search only those.
16
+ *
17
+ * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/accountquery
18
+ */
19
+ accountQuery(qbwcUsername: string, params: AccountQueryRq): Promise<AccountRet>;
20
+ /**
21
+ * Adds an employee with personal data about the employee as well as certain payroll-related data.
22
+ *
23
+ * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/employeeAdd
24
+ */
25
+ employeeAdd(qbwcUsername: string, params: EmployeeAdd): Promise<EmployeeRet>;
26
+ /**
27
+ * Modifies an existing employee.
28
+ *
29
+ * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/employeemod
30
+ */
31
+ employeeMod(qbwcUsername: string, params: EmployeeMod): Promise<EmployeeRet>;
32
+ /**
33
+ * Returns employee data.
34
+ *
35
+ * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/employeeQuery
36
+ */
37
+ employeeQuery(qbwcUsername: string, params: EmployeeQueryRq): Promise<EmployeeRet>;
38
+ }
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class ClientQBD {
4
+ client;
5
+ constructor(rootClient) {
6
+ this.client = rootClient;
7
+ }
8
+ async sendRequest(qbwcUsername, requestObj) {
9
+ if (this.client.verbose) {
10
+ console.log(`Client sent request for user ${qbwcUsername}:`, JSON.stringify(requestObj, null, 2));
11
+ }
12
+ const response = await fetch("https://conductor.ngrok.io", {
13
+ body: JSON.stringify({ qbwcUsername, requestObj }),
14
+ headers: {
15
+ "Content-Type": "application/json",
16
+ Authorization: `Bearer ${this.client.apiKey}`,
17
+ },
18
+ method: "POST",
19
+ });
20
+ const responseObj = (await response.json());
21
+ if (this.client.verbose) {
22
+ console.log(`Client received response for user ${qbwcUsername}:`, JSON.stringify(responseObj, null, 2));
23
+ }
24
+ return responseObj;
25
+ }
26
+ // https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/accountadd
27
+ async accountAdd(qbwcUsername, params) {
28
+ const response = (await this.sendRequest(qbwcUsername, {
29
+ AccountAddRq: { AccountAdd: params },
30
+ }));
31
+ const responseBody = response.AccountAddRs.AccountRet;
32
+ if (!responseBody) {
33
+ throw new Error("No response");
34
+ }
35
+ return responseBody;
36
+ }
37
+ /**
38
+ * `AccountQuery` is a list query that returns data for all accounts that match
39
+ * the provided filter criteria. Notice that it returns only data internal to
40
+ * the account itself. It does not return any data about transactions
41
+ * involving the account. It does, however, return the parent account, if
42
+ * there is one. You can search across all accounts or you can specify an
43
+ * account type and search only those.
44
+ *
45
+ * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/accountquery
46
+ */
47
+ async accountQuery(qbwcUsername, params) {
48
+ const response = (await this.sendRequest(qbwcUsername, {
49
+ AccountQueryRq: params,
50
+ }));
51
+ const responseBody = response.AccountQueryRs.AccountRet;
52
+ if (!responseBody) {
53
+ throw new Error("No response");
54
+ }
55
+ return responseBody;
56
+ }
57
+ /**
58
+ * Adds an employee with personal data about the employee as well as certain payroll-related data.
59
+ *
60
+ * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/employeeAdd
61
+ */
62
+ async employeeAdd(qbwcUsername, params) {
63
+ const response = (await this.sendRequest(qbwcUsername, {
64
+ EmployeeAddRq: { EmployeeAdd: params },
65
+ }));
66
+ const responseBody = response.EmployeeAddRs.EmployeeRet;
67
+ if (!responseBody) {
68
+ throw new Error("No response");
69
+ }
70
+ return responseBody;
71
+ }
72
+ /**
73
+ * Modifies an existing employee.
74
+ *
75
+ * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/employeemod
76
+ */
77
+ async employeeMod(qbwcUsername, params) {
78
+ const response = (await this.sendRequest(qbwcUsername, {
79
+ EmployeeModRq: { EmployeeMod: params },
80
+ }));
81
+ const responseBody = response.EmployeeModRs.EmployeeRet;
82
+ if (!responseBody) {
83
+ throw new Error("No response");
84
+ }
85
+ return responseBody;
86
+ }
87
+ /**
88
+ * Returns employee data.
89
+ *
90
+ * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/employeeQuery
91
+ */
92
+ async employeeQuery(qbwcUsername, params) {
93
+ const response = (await this.sendRequest(qbwcUsername, {
94
+ EmployeeQueryRq: params,
95
+ }));
96
+ const responseBody = response.EmployeeQueryRs.EmployeeRet;
97
+ if (!responseBody) {
98
+ throw new Error("No response");
99
+ }
100
+ return responseBody;
101
+ }
102
+ }
103
+ exports.default = ClientQBD;
@@ -0,0 +1,260 @@
1
+ import type { ActiveStatus, DataExtRet, NameFilter, NameRangeFilter } from "conductor-node/qb/qbXMLTypes/shared";
2
+ export interface AccountAddRq {
3
+ AccountAdd: AccountAdd;
4
+ IncludeRetElement?: string;
5
+ }
6
+ export interface AccountAddRs {
7
+ AccountRet?: AccountRet;
8
+ }
9
+ export interface AccountAdd {
10
+ /**
11
+ * The case-insensitive name of a list object, not including the names of its
12
+ * ancestors. Name must be unique, unless it is the Name of a “hierarchical”
13
+ * list object. List objects in different hierarchies can have duplicate names
14
+ * because their FullNames will still be unique. For example, two objects
15
+ * could both have the Name kitchen, but they could have unique FullNames,
16
+ * such as Job12:kitchen and Baker:kitchen. For built-in currencies, Name is
17
+ * the internationally accepted currency name and is not editable.
18
+ */
19
+ Name: string;
20
+ /**
21
+ * If `IsActive` is `true`, this object is currently enabled for use by
22
+ * QuickBooks. The default value is `true`.
23
+ */
24
+ IsActive?: boolean;
25
+ /**
26
+ * A reference to the list object that is one level above this one. For
27
+ * example, an inventory item with the `FullName` of
28
+ * `GermanCars:Mercedes-Benz:CL500I99AA` might have a parent object with the
29
+ * `FullName` of `GermanCars:Mercedes-Benz`. In a request, if a `ParentRef`
30
+ * aggregate includes both `FullName` and `ListID`, `FullName` will be
31
+ * ignored.
32
+ */
33
+ ParentRef?: ParentRef;
34
+ /**
35
+ * The type of QuickBooks account. You cannot create or modify a non-posting
36
+ * account through the SDK, because QuickBooks creates these accounts behind
37
+ * the scenes. This means that you cannot send an AccountAdd request with an
38
+ * AccountType of NonPosting.
39
+ */
40
+ AccountType: AccountType;
41
+ /**
42
+ * Account numbers appear in the QuickBooks chart of accounts, Account fields,
43
+ * and reports and graphs. If the `IsUsingAccountNumber` preference is `false`
44
+ * (that is, if the QuickBooks user has the account numbers Preference turned
45
+ * off), you can still set account numbers through the SDK, but the numbers
46
+ * will not be visible in the user interface.
47
+ */
48
+ AccountNumber?: string;
49
+ /**
50
+ * The bank account number or an identifying note about the account. If a
51
+ * `BankNumber` exists in a QuickBooks company file, it will only be returned
52
+ * to applications that have been granted permission to access sensitive data
53
+ * and that are using SDK v2.0 or greater.
54
+ */
55
+ BankNumber?: string;
56
+ /**
57
+ * A descriptive text field.
58
+ */
59
+ Desc?: string;
60
+ /**
61
+ * The amount of money in, or the value of, this account as of
62
+ * `OpenBalanceDate`. On a bank statement, the amount of money in the account
63
+ * at the beginning of the statement period.
64
+ */
65
+ OpenBalance?: string;
66
+ /**
67
+ * The date when an opening balance was entered for this account.
68
+ */
69
+ OpenBalanceDate?: Date;
70
+ /**
71
+ * Each item on a sales form is assigned a sales-tax code that indicates
72
+ * whether the item is taxable or non-taxable, and why. Two general codes,
73
+ * which can be modified but not deleted, appear on the sales-tax code list by
74
+ * default: `Non-taxable (Name = NON; Desc = Non-Taxable; IsTaxable = false)`,
75
+ * `Taxable (Name = TAX; Desc = Taxable; IsTaxable = true)`. A sales-tax code
76
+ * can be deleted only if it is no longer associated with any customer, item,
77
+ * or transaction. If the “Do You Charge Sales Tax?” preference within
78
+ * QuickBooks is set to No, QuickBooks will assign the default non-taxable
79
+ * sales-tax code to all sales. A `SalesTaxCodeRef` aggregate refers to a
80
+ * sales-tax code on the list. In a request, if a `SalesTaxCodeRef` aggregate
81
+ * includes both FullName and `ListID`, FullName will be ignored. In a
82
+ * Customer message, `SalesTaxCodeRef` refers to the sales-tax code that will
83
+ * be used for items related to this customer. In an ItemInventory message,
84
+ * `SalesTaxCodeRef` refers to the type of sales tax that will be charged for
85
+ * this item, if it is a taxable item and if sales tax is set up within
86
+ * QuickBooks.
87
+ */
88
+ SalesTaxCodeRef?: SalesTaxCodeRef;
89
+ /**
90
+ * An internal representation of the tax line associated with this account.
91
+ */
92
+ TaxLineID?: number;
93
+ /**
94
+ * The currency object contains all of the information needed by QuickBooks to
95
+ * display and use. For built-in currencies, the name and currency code values
96
+ * are internationally accepted values and thus are not editable. The comma
97
+ * format is editable, as is the IsActive status. For user-defined currencies,
98
+ * every value in the object is editable including name and currency code.
99
+ * When used with PriceLevels, the CurrencyRef should only be used with “per
100
+ * item” price levels.
101
+ */
102
+ CurrencyRef?: CurrencyRef;
103
+ }
104
+ export interface AccountQueryRq {
105
+ ListID?: string;
106
+ FullName?: string;
107
+ /**
108
+ * Limits the number of objects that a query returns. (To get a count of how
109
+ * many objects could possibly be returned, use the metaData query attribute.)
110
+ * If you include a `MaxReturned` value, it must be at least 1.
111
+ */
112
+ MaxReturned?: number;
113
+ /**
114
+ * Used in filters to select list objects based on whether or not they are
115
+ * currently enabled for use by QuickBooks. The default value is `ActiveOnly`,
116
+ * which selects only list objects that are active.
117
+ */
118
+ ActiveStatus?: ActiveStatus;
119
+ FromModifiedDate?: Date;
120
+ ToModifiedDate?: Date;
121
+ /**
122
+ * Filters according to the object’s `Name`.
123
+ */
124
+ NameFilter?: NameFilter;
125
+ /**
126
+ * Filters according to the object’s `Name`.
127
+ */
128
+ NameRangeFilter?: NameRangeFilter;
129
+ AccountType?: AccountType;
130
+ CurrencyFilter?: CurrencyFilter;
131
+ }
132
+ export interface AccountQueryRs {
133
+ AccountRet?: AccountRet;
134
+ }
135
+ export interface AccountRet {
136
+ /**
137
+ * Along with `FullName`, `ListID` is a way to identify a list object. When a
138
+ * list object is added to QuickBooks through the SDK or through the
139
+ * QuickBooks user interface, the server assigns it a `ListID`. A `ListID` is
140
+ * not unique across lists, but it is unique across each particular type of
141
+ * list. For example, two customers could not have the same `ListID`, and a
142
+ * customer could not have the same `ListID` as an employee (because Customer
143
+ * and Employee are both name lists). But a customer could have the same
144
+ * `ListID` as a non-inventory item.
145
+ */
146
+ ListID: string;
147
+ /**
148
+ * Time the object was created.
149
+ */
150
+ TimeCreated: string;
151
+ /**
152
+ * Time the object was last modified.
153
+ */
154
+ TimeModified: string;
155
+ /**
156
+ * A number that the server generates and assigns to this object. Every time
157
+ * the object is changed, the server will change its `EditSequence` value.
158
+ * When you try to modify a list object, you must provide its `EditSequence`.
159
+ * The server compares the `EditSequence` you provide with the `EditSequence`
160
+ * in memory to make sure you are dealing with the latest copy of the object.
161
+ * If you are not, the server will reject the request and return an error.
162
+ * Because `EditSequence` is only used to check whether two objects match,
163
+ * there is no reason to interpret its value.
164
+ */
165
+ EditSequence: string;
166
+ /**
167
+ * The case-insensitive name of a list object, not including the names of its
168
+ * ancestors. `Name` must be unique, unless it is the `Name` of a
169
+ * “hierarchical” list object. List objects in different hierarchies can have
170
+ * duplicate names because their `FullNames` will still be unique. For
171
+ * example, two objects could both have the `Name` kitchen, but they could
172
+ * have unique `FullNames`, such as Job12:kitchen and Baker:kitchen. For
173
+ * built-in currencies, `Name` is the internationally accepted currency name
174
+ * and is not editable.
175
+ */
176
+ Name: string;
177
+ /**
178
+ * `FullName` (along with `ListID`) is a way to identify a list object. The
179
+ * `FullName` is the name prefixed by the names of each ancestor, for example
180
+ * `Jones:Kitchen:Cabinets`. `FullName` values are not case-sensitive.
181
+ */
182
+ FullName: string;
183
+ /**
184
+ * If `IsActive` is true, this object is currently enabled for use by
185
+ * QuickBooks. The default value is `true`.
186
+ */
187
+ IsActive?: boolean;
188
+ /**
189
+ * A reference to the list object that is one level above this one. For
190
+ * example, an inventory item with the `FullName` of
191
+ * `GermanCars:Mercedes-Benz:CL500I99AA` might have a parent object with the
192
+ * `FullName` of `GermanCars:Mercedes-Benz`. In a request, if a `ParentRef`
193
+ * aggregate includes both `FullName` and `ListID`, `FullName` will be
194
+ * ignored.
195
+ */
196
+ ParentRef?: ParentRef;
197
+ /**
198
+ * The number of ancestors. For example, The customer job with `Name =
199
+ * carpets` and `FullName = Jones:Building2:carpets` would have a sublevel of
200
+ * 2.
201
+ */
202
+ Sublevel: number;
203
+ /**
204
+ * The type of QuickBooks account. You cannot create or modify a non-posting
205
+ * account through the SDK, because QuickBooks creates these accounts behind
206
+ * the scenes. This means that you cannot send an `AccountAdd` request with an
207
+ * `AccountType` of `NonPosting`.
208
+ */
209
+ AccountType: AccountType;
210
+ /**
211
+ * If `SpecialAccountType` returns a value, then QuickBooks automatically
212
+ * created this account when it was needed. Some special accounts cannot be
213
+ * overridden, because QuickBooks uses them exclusively for special purposes.
214
+ */
215
+ SpecialAccountType?: SpecialAccountType;
216
+ /**
217
+ * Indicates whether the account is used for tax.
218
+ */
219
+ IsTaxAccount?: boolean;
220
+ /**
221
+ * Account numbers appear in the QuickBooks chart of accounts, `Account`
222
+ * fields, and reports and graphs. If the `IsUsingAccountNumber` preference is
223
+ * false (that is, if the QuickBooks user has the account numbers Preference
224
+ * turned off), you can still set account numbers through the SDK, but the
225
+ * numbers will not be visible in the user interface.
226
+ */
227
+ AccountNumber?: string;
228
+ BankNumber?: string;
229
+ Desc?: string;
230
+ Balance?: string;
231
+ TotalBalance?: string;
232
+ SalesTaxCodeRef?: SalesTaxCodeRef;
233
+ TaxLineInfoRet?: {
234
+ TaxLineID: number;
235
+ TaxLineName?: string;
236
+ };
237
+ CashFlowClassification?: CashFlowClassification;
238
+ CurrencyRef?: CurrencyRef;
239
+ DataExtRet?: DataExtRet;
240
+ }
241
+ interface CurrencyFilter {
242
+ ListID?: string;
243
+ FullName?: string;
244
+ }
245
+ interface ParentRef {
246
+ ListID?: string;
247
+ FullName?: string;
248
+ }
249
+ interface SalesTaxCodeRef {
250
+ ListID?: string;
251
+ FullName?: string;
252
+ }
253
+ interface CurrencyRef {
254
+ ListID?: string;
255
+ FullName?: string;
256
+ }
257
+ declare type AccountType = "AccountsPayable" | "AccountsReceivable" | "Bank" | "CostOfGoodsSold" | "CreditCard" | "Equity" | "Expense" | "FixedAsset" | "Income" | "LongTermLiability" | "NonPosting" | "OtherAsset" | "OtherCurrentAsset" | "OtherCurrentLiability" | "OtherExpense" | "OtherIncome";
258
+ declare type SpecialAccountType = "AccountsPayable" | "AccountsReceivable" | "CondenseItemAdjustmentExpenses" | "CostOfGoodsSold" | "DirectDepositLiabilities" | "Estimates" | "ExchangeGainLoss" | "InventoryAssets" | "ItemReceiptAccount" | "OpeningBalanceEquity" | "PayrollExpenses" | "PayrollLiabilities" | "PettyCash" | "PurchaseOrders" | "ReconciliationDifferences" | "RetainedEarnings" | "SalesOrders" | "SalesTaxPayable" | "UncategorizedExpenses" | "UncategorizedIncome" | "UndepositedFunds";
259
+ declare type CashFlowClassification = "Financing" | "Investing" | "None" | "NotApplicable" | "Operating";
260
+ export {};
File without changes