@panoptic-it-solutions/quickbooks-client 0.1.4 → 0.3.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/dist/index.d.mts +345 -89
- package/dist/index.d.ts +345 -89
- package/dist/index.js +392 -36
- package/dist/index.mjs +392 -36
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -20,6 +20,8 @@ interface QuickBooksConfig {
|
|
|
20
20
|
/** Options for initializing the client */
|
|
21
21
|
interface QuickBooksClientOptions extends QuickBooksConfig {
|
|
22
22
|
tokenStore: TokenStore;
|
|
23
|
+
/** QBO API minor version (e.g. 75). Appended to all API URLs. */
|
|
24
|
+
minorVersion?: number;
|
|
23
25
|
/** Optional logging hook */
|
|
24
26
|
onLog?: (level: "debug" | "info" | "warn" | "error", message: string, data?: unknown) => void;
|
|
25
27
|
}
|
|
@@ -60,6 +62,11 @@ interface QueryResponse<T> {
|
|
|
60
62
|
};
|
|
61
63
|
time?: string;
|
|
62
64
|
}
|
|
65
|
+
/** Ref type used throughout QBO entities */
|
|
66
|
+
interface Ref {
|
|
67
|
+
value: string;
|
|
68
|
+
name?: string;
|
|
69
|
+
}
|
|
63
70
|
/** Base entity with common fields */
|
|
64
71
|
interface BaseEntity {
|
|
65
72
|
Id?: string;
|
|
@@ -69,42 +76,44 @@ interface BaseEntity {
|
|
|
69
76
|
LastUpdatedTime?: string;
|
|
70
77
|
};
|
|
71
78
|
}
|
|
72
|
-
/**
|
|
79
|
+
/** Address */
|
|
80
|
+
interface Address {
|
|
81
|
+
Id?: string;
|
|
82
|
+
Line1?: string;
|
|
83
|
+
Line2?: string;
|
|
84
|
+
City?: string;
|
|
85
|
+
CountrySubDivisionCode?: string;
|
|
86
|
+
PostalCode?: string;
|
|
87
|
+
Country?: string;
|
|
88
|
+
}
|
|
73
89
|
interface Invoice extends BaseEntity {
|
|
74
90
|
DocNumber?: string;
|
|
75
91
|
TxnDate?: string;
|
|
76
92
|
DueDate?: string;
|
|
77
93
|
TotalAmt?: number;
|
|
78
94
|
Balance?: number;
|
|
79
|
-
CustomerRef?:
|
|
80
|
-
value: string;
|
|
81
|
-
name?: string;
|
|
82
|
-
};
|
|
95
|
+
CustomerRef?: Ref;
|
|
83
96
|
Line?: InvoiceLine[];
|
|
84
97
|
BillEmail?: {
|
|
85
98
|
Address?: string;
|
|
86
99
|
};
|
|
87
|
-
CurrencyRef?:
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
};
|
|
100
|
+
CurrencyRef?: Ref;
|
|
101
|
+
TxnTaxDetail?: TxnTaxDetail;
|
|
102
|
+
PrivateNote?: string;
|
|
91
103
|
}
|
|
92
104
|
interface InvoiceLine {
|
|
93
105
|
Id?: string;
|
|
94
106
|
LineNum?: number;
|
|
95
107
|
Description?: string;
|
|
96
108
|
Amount?: number;
|
|
97
|
-
DetailType?: string;
|
|
109
|
+
DetailType?: "SalesItemLineDetail" | "SubTotalLineDetail" | "DiscountLineDetail" | "GroupLineDetail" | string;
|
|
98
110
|
SalesItemLineDetail?: {
|
|
99
|
-
ItemRef?:
|
|
100
|
-
|
|
101
|
-
name?: string;
|
|
102
|
-
};
|
|
111
|
+
ItemRef?: Ref;
|
|
112
|
+
TaxCodeRef?: Ref;
|
|
103
113
|
Qty?: number;
|
|
104
114
|
UnitPrice?: number;
|
|
105
115
|
};
|
|
106
116
|
}
|
|
107
|
-
/** Customer entity */
|
|
108
117
|
interface Customer extends BaseEntity {
|
|
109
118
|
DisplayName?: string;
|
|
110
119
|
CompanyName?: string;
|
|
@@ -120,36 +129,13 @@ interface Customer extends BaseEntity {
|
|
|
120
129
|
ShipAddr?: Address;
|
|
121
130
|
Balance?: number;
|
|
122
131
|
Active?: boolean;
|
|
123
|
-
PaymentMethodRef?: {
|
|
124
|
-
value: string;
|
|
125
|
-
name?: string;
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
interface Address {
|
|
129
|
-
Id?: string;
|
|
130
|
-
Line1?: string;
|
|
131
|
-
Line2?: string;
|
|
132
|
-
City?: string;
|
|
133
|
-
CountrySubDivisionCode?: string;
|
|
134
|
-
PostalCode?: string;
|
|
135
|
-
Country?: string;
|
|
136
132
|
}
|
|
137
|
-
/** Payment entity */
|
|
138
133
|
interface Payment extends BaseEntity {
|
|
139
134
|
TxnDate?: string;
|
|
140
135
|
TotalAmt?: number;
|
|
141
|
-
CustomerRef?:
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
};
|
|
145
|
-
DepositToAccountRef?: {
|
|
146
|
-
value: string;
|
|
147
|
-
name?: string;
|
|
148
|
-
};
|
|
149
|
-
PaymentMethodRef?: {
|
|
150
|
-
value: string;
|
|
151
|
-
name?: string;
|
|
152
|
-
};
|
|
136
|
+
CustomerRef?: Ref;
|
|
137
|
+
DepositToAccountRef?: Ref;
|
|
138
|
+
PaymentMethodRef?: Ref;
|
|
153
139
|
Line?: PaymentLine[];
|
|
154
140
|
}
|
|
155
141
|
interface PaymentLine {
|
|
@@ -159,7 +145,6 @@ interface PaymentLine {
|
|
|
159
145
|
TxnType: string;
|
|
160
146
|
}>;
|
|
161
147
|
}
|
|
162
|
-
/** Account entity */
|
|
163
148
|
interface Account extends BaseEntity {
|
|
164
149
|
Name?: string;
|
|
165
150
|
AccountType?: string;
|
|
@@ -168,8 +153,8 @@ interface Account extends BaseEntity {
|
|
|
168
153
|
Active?: boolean;
|
|
169
154
|
Classification?: string;
|
|
170
155
|
FullyQualifiedName?: string;
|
|
156
|
+
CurrencyRef?: Ref;
|
|
171
157
|
}
|
|
172
|
-
/** Vendor entity */
|
|
173
158
|
interface Vendor extends BaseEntity {
|
|
174
159
|
DisplayName?: string;
|
|
175
160
|
CompanyName?: string;
|
|
@@ -184,34 +169,227 @@ interface Vendor extends BaseEntity {
|
|
|
184
169
|
BillAddr?: Address;
|
|
185
170
|
Balance?: number;
|
|
186
171
|
Active?: boolean;
|
|
172
|
+
TaxIdentifier?: string;
|
|
173
|
+
CurrencyRef?: Ref;
|
|
187
174
|
}
|
|
188
|
-
/** Bill entity */
|
|
189
175
|
interface Bill extends BaseEntity {
|
|
190
176
|
DocNumber?: string;
|
|
191
177
|
TxnDate?: string;
|
|
192
178
|
DueDate?: string;
|
|
193
179
|
TotalAmt?: number;
|
|
194
180
|
Balance?: number;
|
|
195
|
-
VendorRef?:
|
|
196
|
-
|
|
197
|
-
name?: string;
|
|
198
|
-
};
|
|
181
|
+
VendorRef?: Ref;
|
|
182
|
+
APAccountRef?: Ref;
|
|
199
183
|
Line?: BillLine[];
|
|
184
|
+
TxnTaxDetail?: TxnTaxDetail;
|
|
185
|
+
PrivateNote?: string;
|
|
186
|
+
CurrencyRef?: Ref;
|
|
187
|
+
DepartmentRef?: Ref;
|
|
200
188
|
}
|
|
201
189
|
interface BillLine {
|
|
202
190
|
Id?: string;
|
|
203
191
|
LineNum?: number;
|
|
204
192
|
Description?: string;
|
|
205
193
|
Amount?: number;
|
|
206
|
-
DetailType?: string;
|
|
194
|
+
DetailType?: "AccountBasedExpenseLineDetail" | "ItemBasedExpenseLineDetail" | string;
|
|
207
195
|
AccountBasedExpenseLineDetail?: {
|
|
208
|
-
AccountRef?:
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
196
|
+
AccountRef?: Ref;
|
|
197
|
+
TaxCodeRef?: Ref;
|
|
198
|
+
BillableStatus?: "Billable" | "NotBillable" | "HasBeenBilled";
|
|
199
|
+
CustomerRef?: Ref;
|
|
200
|
+
TaxAmount?: number;
|
|
201
|
+
};
|
|
202
|
+
ItemBasedExpenseLineDetail?: {
|
|
203
|
+
ItemRef?: Ref;
|
|
204
|
+
TaxCodeRef?: Ref;
|
|
205
|
+
BillableStatus?: "Billable" | "NotBillable" | "HasBeenBilled";
|
|
206
|
+
CustomerRef?: Ref;
|
|
207
|
+
Qty?: number;
|
|
208
|
+
UnitPrice?: number;
|
|
212
209
|
};
|
|
213
210
|
}
|
|
214
|
-
|
|
211
|
+
interface BillPayment extends BaseEntity {
|
|
212
|
+
VendorRef?: Ref;
|
|
213
|
+
TotalAmt?: number;
|
|
214
|
+
PayType?: "Check" | "CreditCard";
|
|
215
|
+
DocNumber?: string;
|
|
216
|
+
TxnDate?: string;
|
|
217
|
+
APAccountRef?: Ref;
|
|
218
|
+
DepartmentRef?: Ref;
|
|
219
|
+
CurrencyRef?: Ref;
|
|
220
|
+
PrivateNote?: string;
|
|
221
|
+
Line?: BillPaymentLine[];
|
|
222
|
+
CheckPayment?: {
|
|
223
|
+
BankAccountRef?: Ref;
|
|
224
|
+
PrintStatus?: "NeedToPrint" | "NotSet";
|
|
225
|
+
};
|
|
226
|
+
CreditCardPayment?: {
|
|
227
|
+
CCAccountRef?: Ref;
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
interface BillPaymentLine {
|
|
231
|
+
Amount?: number;
|
|
232
|
+
LinkedTxn?: Array<{
|
|
233
|
+
TxnId: string;
|
|
234
|
+
TxnType: "Bill" | string;
|
|
235
|
+
}>;
|
|
236
|
+
}
|
|
237
|
+
interface CreditMemo extends BaseEntity {
|
|
238
|
+
DocNumber?: string;
|
|
239
|
+
TxnDate?: string;
|
|
240
|
+
TotalAmt?: number;
|
|
241
|
+
Balance?: number;
|
|
242
|
+
RemainingCredit?: number;
|
|
243
|
+
CustomerRef?: Ref;
|
|
244
|
+
Line?: CreditMemoLine[];
|
|
245
|
+
BillEmail?: {
|
|
246
|
+
Address?: string;
|
|
247
|
+
};
|
|
248
|
+
CurrencyRef?: Ref;
|
|
249
|
+
TxnTaxDetail?: TxnTaxDetail;
|
|
250
|
+
PrivateNote?: string;
|
|
251
|
+
DepartmentRef?: Ref;
|
|
252
|
+
}
|
|
253
|
+
interface CreditMemoLine {
|
|
254
|
+
Id?: string;
|
|
255
|
+
LineNum?: number;
|
|
256
|
+
Description?: string;
|
|
257
|
+
Amount?: number;
|
|
258
|
+
DetailType?: "SalesItemLineDetail" | "SubTotalLineDetail" | string;
|
|
259
|
+
SalesItemLineDetail?: {
|
|
260
|
+
ItemRef?: Ref;
|
|
261
|
+
TaxCodeRef?: Ref;
|
|
262
|
+
Qty?: number;
|
|
263
|
+
UnitPrice?: number;
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
interface VendorCredit extends BaseEntity {
|
|
267
|
+
DocNumber?: string;
|
|
268
|
+
TxnDate?: string;
|
|
269
|
+
TotalAmt?: number;
|
|
270
|
+
Balance?: number;
|
|
271
|
+
VendorRef?: Ref;
|
|
272
|
+
APAccountRef?: Ref;
|
|
273
|
+
Line?: VendorCreditLine[];
|
|
274
|
+
CurrencyRef?: Ref;
|
|
275
|
+
PrivateNote?: string;
|
|
276
|
+
DepartmentRef?: Ref;
|
|
277
|
+
}
|
|
278
|
+
interface VendorCreditLine {
|
|
279
|
+
Id?: string;
|
|
280
|
+
LineNum?: number;
|
|
281
|
+
Description?: string;
|
|
282
|
+
Amount?: number;
|
|
283
|
+
DetailType?: "AccountBasedExpenseLineDetail" | "ItemBasedExpenseLineDetail" | string;
|
|
284
|
+
AccountBasedExpenseLineDetail?: {
|
|
285
|
+
AccountRef?: Ref;
|
|
286
|
+
TaxCodeRef?: Ref;
|
|
287
|
+
BillableStatus?: "Billable" | "NotBillable" | "HasBeenBilled";
|
|
288
|
+
CustomerRef?: Ref;
|
|
289
|
+
};
|
|
290
|
+
ItemBasedExpenseLineDetail?: {
|
|
291
|
+
ItemRef?: Ref;
|
|
292
|
+
TaxCodeRef?: Ref;
|
|
293
|
+
BillableStatus?: "Billable" | "NotBillable" | "HasBeenBilled";
|
|
294
|
+
CustomerRef?: Ref;
|
|
295
|
+
Qty?: number;
|
|
296
|
+
UnitPrice?: number;
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
interface TaxCode extends BaseEntity {
|
|
300
|
+
Name?: string;
|
|
301
|
+
Description?: string;
|
|
302
|
+
Active?: boolean;
|
|
303
|
+
Taxable?: boolean;
|
|
304
|
+
TaxGroup?: boolean;
|
|
305
|
+
SalesTaxRateList?: {
|
|
306
|
+
TaxRateDetail?: TaxRateDetail[];
|
|
307
|
+
};
|
|
308
|
+
PurchaseTaxRateList?: {
|
|
309
|
+
TaxRateDetail?: TaxRateDetail[];
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
interface TaxRateDetail {
|
|
313
|
+
TaxRateRef?: Ref;
|
|
314
|
+
TaxTypeApplicable?: "TaxOnAmount" | "TaxOnAmountPlusTax" | "TaxOnTax";
|
|
315
|
+
TaxOrder?: number;
|
|
316
|
+
}
|
|
317
|
+
interface TaxRate extends BaseEntity {
|
|
318
|
+
Name?: string;
|
|
319
|
+
Description?: string;
|
|
320
|
+
RateValue?: number;
|
|
321
|
+
Active?: boolean;
|
|
322
|
+
AgencyRef?: Ref;
|
|
323
|
+
TaxReturnLineRef?: Ref;
|
|
324
|
+
SpecialTaxType?: string;
|
|
325
|
+
DisplayType?: string;
|
|
326
|
+
}
|
|
327
|
+
/** Tax detail block used on transactions (Invoice, Bill, CreditMemo, etc.) */
|
|
328
|
+
interface TxnTaxDetail {
|
|
329
|
+
TxnTaxCodeRef?: Ref;
|
|
330
|
+
TotalTax?: number;
|
|
331
|
+
TaxLine?: TaxLine[];
|
|
332
|
+
}
|
|
333
|
+
interface TaxLine {
|
|
334
|
+
Amount?: number;
|
|
335
|
+
DetailType?: "TaxLineDetail";
|
|
336
|
+
TaxLineDetail?: {
|
|
337
|
+
TaxRateRef?: Ref;
|
|
338
|
+
PercentBased?: boolean;
|
|
339
|
+
TaxPercent?: number;
|
|
340
|
+
NetAmountTaxable?: number;
|
|
341
|
+
TaxInclusiveAmount?: number;
|
|
342
|
+
OverrideDeltaAmount?: number;
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
interface Attachable extends BaseEntity {
|
|
346
|
+
FileName?: string;
|
|
347
|
+
FileAccessUri?: string;
|
|
348
|
+
TempDownloadUri?: string;
|
|
349
|
+
Size?: number;
|
|
350
|
+
ContentType?: string;
|
|
351
|
+
Category?: string;
|
|
352
|
+
Lat?: string;
|
|
353
|
+
Long?: string;
|
|
354
|
+
PlaceName?: string;
|
|
355
|
+
Note?: string;
|
|
356
|
+
Tag?: string;
|
|
357
|
+
ThumbnailFileAccessUri?: string;
|
|
358
|
+
ThumbnailTempDownloadUri?: string;
|
|
359
|
+
AttachableRef?: AttachableRef[];
|
|
360
|
+
}
|
|
361
|
+
interface AttachableRef {
|
|
362
|
+
EntityRef?: Ref;
|
|
363
|
+
IncludeOnSend?: boolean;
|
|
364
|
+
LineInfo?: string;
|
|
365
|
+
NoRefOnly?: boolean;
|
|
366
|
+
/** e.g. "Bill", "Invoice", "VendorCredit" */
|
|
367
|
+
Inactive?: boolean;
|
|
368
|
+
}
|
|
369
|
+
interface CompanyInfo extends BaseEntity {
|
|
370
|
+
CompanyName?: string;
|
|
371
|
+
LegalName?: string;
|
|
372
|
+
CompanyAddr?: Address;
|
|
373
|
+
CustomerCommunicationAddr?: Address;
|
|
374
|
+
LegalAddr?: Address;
|
|
375
|
+
PrimaryPhone?: {
|
|
376
|
+
FreeFormNumber?: string;
|
|
377
|
+
};
|
|
378
|
+
CompanyStartDate?: string;
|
|
379
|
+
FiscalYearStartMonth?: string;
|
|
380
|
+
Country?: string;
|
|
381
|
+
Email?: {
|
|
382
|
+
Address?: string;
|
|
383
|
+
};
|
|
384
|
+
WebAddr?: {
|
|
385
|
+
URI?: string;
|
|
386
|
+
};
|
|
387
|
+
SupportedLanguages?: string;
|
|
388
|
+
NameValue?: Array<{
|
|
389
|
+
Name: string;
|
|
390
|
+
Value: string;
|
|
391
|
+
}>;
|
|
392
|
+
}
|
|
215
393
|
interface Item extends BaseEntity {
|
|
216
394
|
Name?: string;
|
|
217
395
|
Description?: string;
|
|
@@ -221,15 +399,41 @@ interface Item extends BaseEntity {
|
|
|
221
399
|
UnitPrice?: number;
|
|
222
400
|
PurchaseCost?: number;
|
|
223
401
|
QtyOnHand?: number;
|
|
224
|
-
IncomeAccountRef?:
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
402
|
+
IncomeAccountRef?: Ref;
|
|
403
|
+
ExpenseAccountRef?: Ref;
|
|
404
|
+
AssetAccountRef?: Ref;
|
|
405
|
+
Taxable?: boolean;
|
|
406
|
+
SalesTaxIncluded?: boolean;
|
|
407
|
+
PurchaseTaxIncluded?: boolean;
|
|
408
|
+
SalesTaxCodeRef?: Ref;
|
|
409
|
+
PurchaseTaxCodeRef?: Ref;
|
|
410
|
+
}
|
|
411
|
+
interface BatchItemRequest {
|
|
412
|
+
/** Unique ID for this batch item (you choose) */
|
|
413
|
+
bId: string;
|
|
414
|
+
/** Operation to perform */
|
|
415
|
+
operation: "create" | "update" | "delete" | "query";
|
|
416
|
+
/** Only for non-query operations: entity name e.g. "Bill", "Invoice" */
|
|
417
|
+
optionsData?: string;
|
|
418
|
+
/** The entity payload (for create/update/delete) */
|
|
419
|
+
[entityName: string]: unknown;
|
|
420
|
+
}
|
|
421
|
+
interface BatchItemResponse {
|
|
422
|
+
bId: string;
|
|
423
|
+
[key: string]: unknown;
|
|
424
|
+
Fault?: {
|
|
425
|
+
Error?: Array<{
|
|
426
|
+
Message?: string;
|
|
427
|
+
Detail?: string;
|
|
428
|
+
code?: string;
|
|
429
|
+
}>;
|
|
430
|
+
type?: string;
|
|
231
431
|
};
|
|
232
432
|
}
|
|
433
|
+
interface BatchResponse {
|
|
434
|
+
BatchItemResponse: BatchItemResponse[];
|
|
435
|
+
time?: string;
|
|
436
|
+
}
|
|
233
437
|
|
|
234
438
|
/**
|
|
235
439
|
* QuickBooks Online API Client
|
|
@@ -242,9 +446,14 @@ declare class QuickBooksClient {
|
|
|
242
446
|
private tokenStore;
|
|
243
447
|
private requestTimestamps;
|
|
244
448
|
private onLog;
|
|
449
|
+
private minorVersion;
|
|
245
450
|
constructor(options: QuickBooksClientOptions);
|
|
246
451
|
private validateConfig;
|
|
247
452
|
private log;
|
|
453
|
+
/**
|
|
454
|
+
* Append minorversion query param to a URL if configured
|
|
455
|
+
*/
|
|
456
|
+
private appendMinorVersion;
|
|
248
457
|
/**
|
|
249
458
|
* Rate limiting - ensures we don't exceed 500 requests/minute
|
|
250
459
|
*/
|
|
@@ -281,6 +490,8 @@ declare class QuickBooksClient {
|
|
|
281
490
|
createPayment(payment: Partial<Payment>): Promise<Payment>;
|
|
282
491
|
getAccount(id: string): Promise<Account>;
|
|
283
492
|
getAccounts(where?: string): Promise<Account[]>;
|
|
493
|
+
createAccount(account: Partial<Account>): Promise<Account>;
|
|
494
|
+
updateAccount(account: Account): Promise<Account>;
|
|
284
495
|
getVendor(id: string): Promise<Vendor>;
|
|
285
496
|
getVendors(where?: string): Promise<Vendor[]>;
|
|
286
497
|
createVendor(vendor: Partial<Vendor>): Promise<Vendor>;
|
|
@@ -289,14 +500,59 @@ declare class QuickBooksClient {
|
|
|
289
500
|
getBills(where?: string): Promise<Bill[]>;
|
|
290
501
|
createBill(bill: Partial<Bill>): Promise<Bill>;
|
|
291
502
|
updateBill(bill: Bill): Promise<Bill>;
|
|
503
|
+
deleteBill(id: string, syncToken: string): Promise<void>;
|
|
504
|
+
getBillPayment(id: string): Promise<BillPayment>;
|
|
505
|
+
getBillPayments(where?: string): Promise<BillPayment[]>;
|
|
506
|
+
createBillPayment(billPayment: Partial<BillPayment>): Promise<BillPayment>;
|
|
507
|
+
updateBillPayment(billPayment: BillPayment): Promise<BillPayment>;
|
|
508
|
+
deleteBillPayment(id: string, syncToken: string): Promise<void>;
|
|
509
|
+
getCreditMemo(id: string): Promise<CreditMemo>;
|
|
510
|
+
getCreditMemos(where?: string): Promise<CreditMemo[]>;
|
|
511
|
+
createCreditMemo(creditMemo: Partial<CreditMemo>): Promise<CreditMemo>;
|
|
512
|
+
updateCreditMemo(creditMemo: CreditMemo): Promise<CreditMemo>;
|
|
513
|
+
deleteCreditMemo(id: string, syncToken: string): Promise<void>;
|
|
514
|
+
getVendorCredit(id: string): Promise<VendorCredit>;
|
|
515
|
+
getVendorCredits(where?: string): Promise<VendorCredit[]>;
|
|
516
|
+
createVendorCredit(vendorCredit: Partial<VendorCredit>): Promise<VendorCredit>;
|
|
517
|
+
updateVendorCredit(vendorCredit: VendorCredit): Promise<VendorCredit>;
|
|
518
|
+
deleteVendorCredit(id: string, syncToken: string): Promise<void>;
|
|
519
|
+
getTaxCode(id: string): Promise<TaxCode>;
|
|
520
|
+
getTaxCodes(where?: string): Promise<TaxCode[]>;
|
|
521
|
+
getTaxRate(id: string): Promise<TaxRate>;
|
|
522
|
+
getTaxRates(where?: string): Promise<TaxRate[]>;
|
|
292
523
|
getItem(id: string): Promise<Item>;
|
|
293
524
|
getItems(where?: string): Promise<Item[]>;
|
|
294
525
|
createItem(item: Partial<Item>): Promise<Item>;
|
|
295
526
|
updateItem(item: Item): Promise<Item>;
|
|
527
|
+
getAttachable(id: string): Promise<Attachable>;
|
|
528
|
+
getAttachables(where?: string): Promise<Attachable[]>;
|
|
529
|
+
/**
|
|
530
|
+
* Upload a file and attach it to an entity.
|
|
531
|
+
* Uses multipart/form-data — the QBO upload endpoint differs from standard CRUD.
|
|
532
|
+
*/
|
|
533
|
+
uploadAttachable(file: Blob | Buffer, fileName: string, contentType: string, attachTo?: {
|
|
534
|
+
entityType: string;
|
|
535
|
+
entityId: string;
|
|
536
|
+
}): Promise<Attachable>;
|
|
537
|
+
updateAttachable(attachable: Attachable): Promise<Attachable>;
|
|
538
|
+
deleteAttachable(id: string, syncToken: string): Promise<void>;
|
|
539
|
+
/**
|
|
540
|
+
* Execute a batch of up to 30 operations in a single API call.
|
|
541
|
+
* Each item needs a unique bId and the entity payload.
|
|
542
|
+
*
|
|
543
|
+
* @example
|
|
544
|
+
* ```ts
|
|
545
|
+
* const results = await client.batch([
|
|
546
|
+
* { bId: "1", operation: "create", Bill: { VendorRef: { value: "1" }, Line: [...] } },
|
|
547
|
+
* { bId: "2", operation: "query", optionsData: "SELECT * FROM Vendor WHERE Id = '1'" },
|
|
548
|
+
* ]);
|
|
549
|
+
* ```
|
|
550
|
+
*/
|
|
551
|
+
batch(items: BatchItemRequest[]): Promise<BatchResponse>;
|
|
296
552
|
/**
|
|
297
553
|
* Get company info
|
|
298
554
|
*/
|
|
299
|
-
getCompanyInfo(): Promise<
|
|
555
|
+
getCompanyInfo(): Promise<CompanyInfo>;
|
|
300
556
|
/**
|
|
301
557
|
* Check if connected to QuickBooks
|
|
302
558
|
*/
|
|
@@ -312,6 +568,32 @@ declare class QuickBooksClient {
|
|
|
312
568
|
}>;
|
|
313
569
|
}
|
|
314
570
|
|
|
571
|
+
/**
|
|
572
|
+
* QuickBooks Error Handling
|
|
573
|
+
*/
|
|
574
|
+
/** Error codes for QuickBooks API errors */
|
|
575
|
+
declare const QB_ERROR_CODES: {
|
|
576
|
+
readonly TOKEN_EXPIRED: "QB_TOKEN_EXPIRED";
|
|
577
|
+
readonly REFRESH_FAILED: "QB_REFRESH_FAILED";
|
|
578
|
+
readonly UNAUTHORIZED: "QB_UNAUTHORIZED";
|
|
579
|
+
readonly INVALID_REALM: "QB_INVALID_REALM";
|
|
580
|
+
readonly API_ERROR: "QB_API_ERROR";
|
|
581
|
+
readonly RATE_LIMIT: "QB_RATE_LIMIT";
|
|
582
|
+
readonly NETWORK_ERROR: "QB_NETWORK_ERROR";
|
|
583
|
+
readonly INVALID_CONFIG: "QB_INVALID_CONFIG";
|
|
584
|
+
readonly TOKEN_STORE_ERROR: "QB_TOKEN_STORE_ERROR";
|
|
585
|
+
};
|
|
586
|
+
type QuickBooksErrorCode = (typeof QB_ERROR_CODES)[keyof typeof QB_ERROR_CODES];
|
|
587
|
+
/** Custom error class for QuickBooks-related errors */
|
|
588
|
+
declare class QuickBooksError extends Error {
|
|
589
|
+
code: QuickBooksErrorCode;
|
|
590
|
+
status?: number | undefined;
|
|
591
|
+
details?: unknown | undefined;
|
|
592
|
+
constructor(message: string, code: QuickBooksErrorCode, status?: number | undefined, details?: unknown | undefined);
|
|
593
|
+
}
|
|
594
|
+
/** Handle and normalize errors from QuickBooks API */
|
|
595
|
+
declare function handleQuickBooksError(error: unknown): QuickBooksError;
|
|
596
|
+
|
|
315
597
|
/**
|
|
316
598
|
* OAuth 2.0 implementation for QuickBooks Online
|
|
317
599
|
*
|
|
@@ -347,30 +629,4 @@ declare function isTokenExpired(expiresAt: number, bufferSeconds?: number): bool
|
|
|
347
629
|
*/
|
|
348
630
|
declare function generateState(): string;
|
|
349
631
|
|
|
350
|
-
|
|
351
|
-
* QuickBooks Error Handling
|
|
352
|
-
*/
|
|
353
|
-
/** Error codes for QuickBooks API errors */
|
|
354
|
-
declare const QB_ERROR_CODES: {
|
|
355
|
-
readonly TOKEN_EXPIRED: "QB_TOKEN_EXPIRED";
|
|
356
|
-
readonly REFRESH_FAILED: "QB_REFRESH_FAILED";
|
|
357
|
-
readonly UNAUTHORIZED: "QB_UNAUTHORIZED";
|
|
358
|
-
readonly INVALID_REALM: "QB_INVALID_REALM";
|
|
359
|
-
readonly API_ERROR: "QB_API_ERROR";
|
|
360
|
-
readonly RATE_LIMIT: "QB_RATE_LIMIT";
|
|
361
|
-
readonly NETWORK_ERROR: "QB_NETWORK_ERROR";
|
|
362
|
-
readonly INVALID_CONFIG: "QB_INVALID_CONFIG";
|
|
363
|
-
readonly TOKEN_STORE_ERROR: "QB_TOKEN_STORE_ERROR";
|
|
364
|
-
};
|
|
365
|
-
type QuickBooksErrorCode = (typeof QB_ERROR_CODES)[keyof typeof QB_ERROR_CODES];
|
|
366
|
-
/** Custom error class for QuickBooks-related errors */
|
|
367
|
-
declare class QuickBooksError extends Error {
|
|
368
|
-
code: QuickBooksErrorCode;
|
|
369
|
-
status?: number | undefined;
|
|
370
|
-
details?: unknown | undefined;
|
|
371
|
-
constructor(message: string, code: QuickBooksErrorCode, status?: number | undefined, details?: unknown | undefined);
|
|
372
|
-
}
|
|
373
|
-
/** Handle and normalize errors from QuickBooks API */
|
|
374
|
-
declare function handleQuickBooksError(error: unknown): QuickBooksError;
|
|
375
|
-
|
|
376
|
-
export { type Account, type Address, type BaseEntity, type Bill, type BillLine, type Customer, type Invoice, type InvoiceLine, type Item, type OAuthTokenResponse, type Payment, type PaymentLine, QB_ERROR_CODES, type QueryResponse, type QuickBooksApiError, QuickBooksClient, type QuickBooksClientOptions, type QuickBooksConfig, QuickBooksError, type QuickBooksErrorCode, type QuickBooksTokens, type TokenStore, type Vendor, calculateTokenExpiry, exchangeCodeForTokens, generateAuthUrl, generateState, handleQuickBooksError, isTokenExpired, refreshTokens, revokeTokens };
|
|
632
|
+
export { type Account, type Address, type Attachable, type AttachableRef, type BaseEntity, type BatchItemRequest, type BatchItemResponse, type BatchResponse, type Bill, type BillLine, type BillPayment, type BillPaymentLine, type CompanyInfo, type CreditMemo, type CreditMemoLine, type Customer, type Invoice, type InvoiceLine, type Item, type OAuthTokenResponse, type Payment, type PaymentLine, QB_ERROR_CODES, type QueryResponse, type QuickBooksApiError, QuickBooksClient, type QuickBooksClientOptions, type QuickBooksConfig, QuickBooksError, type QuickBooksErrorCode, type QuickBooksTokens, type Ref, type TaxCode, type TaxLine, type TaxRate, type TaxRateDetail, type TokenStore, type TxnTaxDetail, type Vendor, type VendorCredit, type VendorCreditLine, calculateTokenExpiry, exchangeCodeForTokens, generateAuthUrl, generateState, handleQuickBooksError, isTokenExpired, refreshTokens, revokeTokens };
|