@smartbills/sdk 1.1.0-alpha.1 → 1.1.0-alpha.10
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/cjs/index.cjs +1 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/types/index.d.ts +1087 -15
- package/package.json +2 -2
package/dist/types/index.d.ts
CHANGED
|
@@ -744,12 +744,19 @@ interface UpdateInstallationStatusRequest {
|
|
|
744
744
|
status: AppInstallationStatus;
|
|
745
745
|
}
|
|
746
746
|
|
|
747
|
+
/** Configuration for the underlying HTTP transport layer. */
|
|
747
748
|
interface HttpClientConfig {
|
|
748
749
|
baseUrl: string;
|
|
749
750
|
timeout?: number;
|
|
750
751
|
maxRetries?: number;
|
|
751
752
|
retryDelay?: number;
|
|
752
753
|
}
|
|
754
|
+
/**
|
|
755
|
+
* Low-level HTTP client that wraps Axios with automatic retry, error mapping,
|
|
756
|
+
* and multi-tenant header injection.
|
|
757
|
+
*
|
|
758
|
+
* Not intended for direct use — access services through {@link SmartbillsClient} instead.
|
|
759
|
+
*/
|
|
753
760
|
declare class HttpClient {
|
|
754
761
|
private readonly instance;
|
|
755
762
|
private accessToken?;
|
|
@@ -773,6 +780,11 @@ declare class HttpClient {
|
|
|
773
780
|
delete<T>(url: string, config?: AxiosRequestConfig): Promise<T>;
|
|
774
781
|
upload<T>(url: string, formData: FormData, config?: AxiosRequestConfig): Promise<T>;
|
|
775
782
|
downloadBlob(url: string, config?: AxiosRequestConfig): Promise<Blob>;
|
|
783
|
+
downloadBlobWithFilename(method: string, url: string, data?: unknown, config?: AxiosRequestConfig): Promise<{
|
|
784
|
+
blob: Blob;
|
|
785
|
+
filename?: string;
|
|
786
|
+
}>;
|
|
787
|
+
private parseContentDispositionFilename;
|
|
776
788
|
private requestWithRetry;
|
|
777
789
|
private calculateRetryDelay;
|
|
778
790
|
private parseError;
|
|
@@ -801,6 +813,10 @@ declare abstract class BaseService {
|
|
|
801
813
|
protected _delete<T>(url: string, options?: RequestOptions): Promise<T>;
|
|
802
814
|
protected _upload<T>(url: string, formData: FormData, options?: RequestOptions): Promise<T>;
|
|
803
815
|
protected _download(url: string, options?: RequestOptions): Promise<Blob>;
|
|
816
|
+
protected _downloadWithFilename(method: string, url: string, data?: unknown, options?: RequestOptions): Promise<{
|
|
817
|
+
blob: Blob;
|
|
818
|
+
filename?: string;
|
|
819
|
+
}>;
|
|
804
820
|
protected businessUrl(path: string, options?: RequestOptions): string;
|
|
805
821
|
}
|
|
806
822
|
|
|
@@ -1165,7 +1181,10 @@ declare class ApprobationService extends BaseService {
|
|
|
1165
1181
|
* @returns The expense report
|
|
1166
1182
|
* @throws {SmartbillsNotFoundError} If the report is not found
|
|
1167
1183
|
*/
|
|
1168
|
-
getById(reportId: number,
|
|
1184
|
+
getById(reportId: number, params?: {
|
|
1185
|
+
sortBy?: string;
|
|
1186
|
+
sortOrder?: string;
|
|
1187
|
+
}, options?: RequestOptions): Promise<SBExpenseReport>;
|
|
1169
1188
|
/**
|
|
1170
1189
|
* Approves an expense report.
|
|
1171
1190
|
*
|
|
@@ -1311,8 +1330,13 @@ declare class ApprobationService extends BaseService {
|
|
|
1311
1330
|
* @throws {SmartbillsNotFoundError} If the report is not found
|
|
1312
1331
|
*/
|
|
1313
1332
|
downloadAttachmentsZip(reportId: number, options?: RequestOptions): Promise<Blob>;
|
|
1333
|
+
updateExpense(reportId: number, expenseId: number, data: unknown, options?: RequestOptions): Promise<unknown>;
|
|
1334
|
+
saveExpenseReview(reportId: number, data: ExpenseReportApproveRequest & {
|
|
1335
|
+
saveExpenseReviewOnly?: boolean;
|
|
1336
|
+
}, options?: RequestOptions): Promise<SBExpenseReport>;
|
|
1314
1337
|
}
|
|
1315
1338
|
|
|
1339
|
+
/** Represents the current subscription state for a business. */
|
|
1316
1340
|
interface SBSubscription {
|
|
1317
1341
|
id: string;
|
|
1318
1342
|
planName?: string;
|
|
@@ -1325,6 +1349,7 @@ interface SBSubscription {
|
|
|
1325
1349
|
cancelAtPeriodEnd?: boolean;
|
|
1326
1350
|
canceledAt?: string;
|
|
1327
1351
|
}
|
|
1352
|
+
/** Represents a billing invoice issued to the business. */
|
|
1328
1353
|
interface SBInvoice {
|
|
1329
1354
|
id: string;
|
|
1330
1355
|
number?: string;
|
|
@@ -1340,6 +1365,7 @@ interface SBInvoice {
|
|
|
1340
1365
|
hostedInvoiceUrl?: string;
|
|
1341
1366
|
invoicePdfUrl?: string;
|
|
1342
1367
|
}
|
|
1368
|
+
/** Preview of the next invoice based on the current subscription and usage. */
|
|
1343
1369
|
interface SBUpcomingInvoice {
|
|
1344
1370
|
total: number;
|
|
1345
1371
|
subtotal: number;
|
|
@@ -1349,18 +1375,21 @@ interface SBUpcomingInvoice {
|
|
|
1349
1375
|
periodEnd?: string;
|
|
1350
1376
|
lines?: SBInvoiceLine[];
|
|
1351
1377
|
}
|
|
1378
|
+
/** A single line item on an invoice. */
|
|
1352
1379
|
interface SBInvoiceLine {
|
|
1353
1380
|
description?: string;
|
|
1354
1381
|
amount: number;
|
|
1355
1382
|
currency: string;
|
|
1356
1383
|
quantity?: number;
|
|
1357
1384
|
}
|
|
1385
|
+
/** Tracks resource consumption against a quota limit (e.g., receipts, expenses). */
|
|
1358
1386
|
interface SBBillingUsage {
|
|
1359
1387
|
quotaKey: string;
|
|
1360
1388
|
used: number;
|
|
1361
1389
|
limit: number;
|
|
1362
1390
|
percentage: number;
|
|
1363
1391
|
}
|
|
1392
|
+
/** Represents an available billing plan that a business can subscribe to. */
|
|
1364
1393
|
interface SBBillingPlan {
|
|
1365
1394
|
id: string;
|
|
1366
1395
|
name: string;
|
|
@@ -1370,23 +1399,29 @@ interface SBBillingPlan {
|
|
|
1370
1399
|
interval: string;
|
|
1371
1400
|
features?: string[];
|
|
1372
1401
|
}
|
|
1402
|
+
/** Request payload for upgrading or starting a trial on a specific plan. */
|
|
1373
1403
|
interface UpgradeSubscriptionRequest {
|
|
1374
1404
|
planId: string;
|
|
1375
1405
|
}
|
|
1406
|
+
/** Request payload for creating a Stripe billing portal session. */
|
|
1376
1407
|
interface CreatePortalSessionRequest {
|
|
1377
1408
|
returnUrl?: string;
|
|
1378
1409
|
}
|
|
1410
|
+
/** Contains the URL for a Stripe billing portal session. */
|
|
1379
1411
|
interface SBPortalSession {
|
|
1380
1412
|
url: string;
|
|
1381
1413
|
}
|
|
1414
|
+
/** Query parameters for listing billing invoices. */
|
|
1382
1415
|
interface InvoiceListRequest {
|
|
1383
1416
|
page?: number;
|
|
1384
1417
|
pageSize?: number;
|
|
1385
1418
|
}
|
|
1419
|
+
/** Query parameters for retrieving usage history. */
|
|
1386
1420
|
interface UsageHistoryRequest {
|
|
1387
1421
|
page?: number;
|
|
1388
1422
|
pageSize?: number;
|
|
1389
1423
|
}
|
|
1424
|
+
/** Represents a payment method on file for billing. */
|
|
1390
1425
|
interface SBBillingPaymentMethod {
|
|
1391
1426
|
id: string;
|
|
1392
1427
|
type: string;
|
|
@@ -1398,32 +1433,58 @@ interface SBBillingPaymentMethod {
|
|
|
1398
1433
|
expYear: number;
|
|
1399
1434
|
};
|
|
1400
1435
|
}
|
|
1436
|
+
/** Contains the client secret needed to complete a Stripe SetupIntent flow. */
|
|
1401
1437
|
interface SBSetupIntent {
|
|
1402
1438
|
clientSecret: string;
|
|
1403
1439
|
}
|
|
1440
|
+
/** Result of validating whether a subscription can be downgraded. */
|
|
1404
1441
|
interface SBDowngradeValidation {
|
|
1405
1442
|
canDowngrade: boolean;
|
|
1406
1443
|
blockers?: string[];
|
|
1407
1444
|
}
|
|
1408
1445
|
|
|
1446
|
+
/**
|
|
1447
|
+
* Service for managing billing, subscriptions, and usage within a business.
|
|
1448
|
+
*
|
|
1449
|
+
* Provides methods to manage the business subscription plan, view invoices,
|
|
1450
|
+
* track usage quotas, manage payment methods, and create billing portal sessions.
|
|
1451
|
+
*/
|
|
1409
1452
|
declare class BillingService extends BaseService {
|
|
1453
|
+
/** Retrieves the current subscription for the business. */
|
|
1410
1454
|
getSubscription(options?: RequestOptions): Promise<SBSubscription>;
|
|
1455
|
+
/** Upgrades the business subscription to a new plan. */
|
|
1411
1456
|
upgradeSubscription(data: UpgradeSubscriptionRequest, options?: RequestOptions): Promise<SBSubscription>;
|
|
1457
|
+
/** Cancels the current business subscription. */
|
|
1412
1458
|
cancelSubscription(options?: RequestOptions): Promise<SBSubscription>;
|
|
1459
|
+
/** Retrieves all available billing plans. */
|
|
1413
1460
|
getPlans(options?: RequestOptions): Promise<SBBillingPlan[]>;
|
|
1461
|
+
/** Starts a trial subscription for the specified plan. */
|
|
1414
1462
|
startTrial(data: UpgradeSubscriptionRequest, options?: RequestOptions): Promise<SBSubscription>;
|
|
1463
|
+
/** Activates the free tier subscription for the business. */
|
|
1415
1464
|
activateFreeTier(options?: RequestOptions): Promise<SBSubscription>;
|
|
1465
|
+
/** Validates whether the business can downgrade to a lower plan without losing features. */
|
|
1416
1466
|
validateDowngrade(data: UpgradeSubscriptionRequest, options?: RequestOptions): Promise<SBDowngradeValidation>;
|
|
1467
|
+
/** Lists billing invoices for the business with pagination support. */
|
|
1417
1468
|
listInvoices(params?: InvoiceListRequest, options?: RequestOptions): Promise<SBListResponse<SBInvoice>>;
|
|
1469
|
+
/** Retrieves a specific billing invoice by its Stripe ID. */
|
|
1418
1470
|
getInvoice(invoiceId: string, options?: RequestOptions): Promise<SBInvoice>;
|
|
1471
|
+
/** Retrieves the upcoming invoice preview based on the current subscription. */
|
|
1419
1472
|
getUpcomingInvoice(options?: RequestOptions): Promise<SBUpcomingInvoice>;
|
|
1473
|
+
/** Retrieves current usage across all quota keys for the business. */
|
|
1420
1474
|
getUsage(options?: RequestOptions): Promise<SBBillingUsage[]>;
|
|
1475
|
+
/** Retrieves historical usage data with pagination support. */
|
|
1421
1476
|
getUsageHistory(params?: UsageHistoryRequest, options?: RequestOptions): Promise<SBListResponse<SBBillingUsage>>;
|
|
1477
|
+
/** Retrieves current usage for a specific quota key (e.g., "receipts", "expenses"). */
|
|
1422
1478
|
getUsageByKey(quotaKey: string, options?: RequestOptions): Promise<SBBillingUsage>;
|
|
1479
|
+
/** Creates a Stripe billing portal session URL for self-service subscription management. */
|
|
1423
1480
|
createPortalSession(data?: CreatePortalSessionRequest, options?: RequestOptions): Promise<SBPortalSession>;
|
|
1481
|
+
/** Retrieves all payment methods on file for the business. */
|
|
1424
1482
|
getPaymentMethods(options?: RequestOptions): Promise<SBBillingPaymentMethod[]>;
|
|
1483
|
+
/** Creates a Stripe SetupIntent for securely collecting a new payment method. */
|
|
1425
1484
|
createSetupIntent(options?: RequestOptions): Promise<SBSetupIntent>;
|
|
1485
|
+
/** Detaches (removes) a payment method from the business. */
|
|
1426
1486
|
detachPaymentMethod(paymentMethodId: string, options?: RequestOptions): Promise<void>;
|
|
1487
|
+
/** Sets a payment method as the default for future billing. */
|
|
1427
1488
|
setDefaultPaymentMethod(paymentMethodId: string, options?: RequestOptions): Promise<void>;
|
|
1428
1489
|
}
|
|
1429
1490
|
|
|
@@ -1772,6 +1833,7 @@ interface PaginateTransactionRequest extends PaginationRequest {
|
|
|
1772
1833
|
maxAmount?: number;
|
|
1773
1834
|
hasAttachment?: boolean;
|
|
1774
1835
|
employeeId?: number;
|
|
1836
|
+
payerType?: PayerType;
|
|
1775
1837
|
}
|
|
1776
1838
|
/**
|
|
1777
1839
|
* Request payload for updating an existing transaction.
|
|
@@ -1784,6 +1846,7 @@ interface TransactionUpdateRequest {
|
|
|
1784
1846
|
categoryId?: number;
|
|
1785
1847
|
note?: string;
|
|
1786
1848
|
vendorId?: number;
|
|
1849
|
+
payerType?: PayerType;
|
|
1787
1850
|
}
|
|
1788
1851
|
/**
|
|
1789
1852
|
* Request payload for batch-updating multiple transactions.
|
|
@@ -1795,6 +1858,7 @@ interface TransactionBatchUpdateRequest {
|
|
|
1795
1858
|
total?: number;
|
|
1796
1859
|
categoryId?: number;
|
|
1797
1860
|
vendorId?: number;
|
|
1861
|
+
payerType?: PayerType;
|
|
1798
1862
|
}
|
|
1799
1863
|
|
|
1800
1864
|
/**
|
|
@@ -2873,6 +2937,21 @@ interface SyncSessionListRequest extends PaginationRequest {
|
|
|
2873
2937
|
interface SBEmailAccountAuthorizeResponse {
|
|
2874
2938
|
authorizationUrl: string;
|
|
2875
2939
|
}
|
|
2940
|
+
interface SBSharedMailbox {
|
|
2941
|
+
email: string;
|
|
2942
|
+
mailboxId: number;
|
|
2943
|
+
syncEnabled: boolean;
|
|
2944
|
+
}
|
|
2945
|
+
interface SBValidateSharedMailboxResponse {
|
|
2946
|
+
valid: boolean;
|
|
2947
|
+
reason?: string;
|
|
2948
|
+
displayName?: string;
|
|
2949
|
+
}
|
|
2950
|
+
interface SBHistoricalSyncResponse {
|
|
2951
|
+
message: string;
|
|
2952
|
+
fromDate?: string;
|
|
2953
|
+
toDate?: string;
|
|
2954
|
+
}
|
|
2876
2955
|
|
|
2877
2956
|
/**
|
|
2878
2957
|
* Service for managing email accounts used for receipt ingestion.
|
|
@@ -2965,7 +3044,9 @@ declare class EmailAccountService extends BaseService {
|
|
|
2965
3044
|
* @returns The reconnection authorization response
|
|
2966
3045
|
* @throws {SmartbillsNotFoundError} If the account is not found
|
|
2967
3046
|
*/
|
|
2968
|
-
reconnect(accountId: number,
|
|
3047
|
+
reconnect(accountId: number, data?: {
|
|
3048
|
+
password?: string;
|
|
3049
|
+
}, options?: RequestOptions): Promise<SBEmailAccount>;
|
|
2969
3050
|
/**
|
|
2970
3051
|
* Enables an email account.
|
|
2971
3052
|
*
|
|
@@ -3013,6 +3094,15 @@ declare class EmailAccountService extends BaseService {
|
|
|
3013
3094
|
* @throws {SmartbillsNotFoundError} If the account or mailbox is not found
|
|
3014
3095
|
*/
|
|
3015
3096
|
updateMailbox(accountId: number, mailboxId: number, data: MailboxUpdateRequest, options?: RequestOptions): Promise<SBMailbox>;
|
|
3097
|
+
getSyncSessions(accountId: number, params?: SyncSessionListRequest, options?: RequestOptions): Promise<SBListResponse<SBSyncSession>>;
|
|
3098
|
+
authorizeWithParams(params: {
|
|
3099
|
+
provider: string;
|
|
3100
|
+
redirect?: string;
|
|
3101
|
+
payerType?: string;
|
|
3102
|
+
}, options?: RequestOptions): Promise<SBEmailAccountAuthorizeResponse>;
|
|
3103
|
+
validateSharedMailbox(accountId: number, email: string, options?: RequestOptions): Promise<SBValidateSharedMailboxResponse>;
|
|
3104
|
+
addSharedMailbox(accountId: number, email: string, options?: RequestOptions): Promise<SBSharedMailbox>;
|
|
3105
|
+
removeSharedMailbox(accountId: number, email: string, options?: RequestOptions): Promise<void>;
|
|
3016
3106
|
}
|
|
3017
3107
|
|
|
3018
3108
|
/**
|
|
@@ -3023,6 +3113,7 @@ declare class EmailAccountService extends BaseService {
|
|
|
3023
3113
|
interface SBExpenseJob extends SBEntity, SBTimestamps {
|
|
3024
3114
|
fileName?: string;
|
|
3025
3115
|
status: string;
|
|
3116
|
+
jobStatus?: number | string;
|
|
3026
3117
|
progress?: number;
|
|
3027
3118
|
totalItems?: number;
|
|
3028
3119
|
processedItems?: number;
|
|
@@ -3031,12 +3122,22 @@ interface SBExpenseJob extends SBEntity, SBTimestamps {
|
|
|
3031
3122
|
employeeId?: number;
|
|
3032
3123
|
error?: string;
|
|
3033
3124
|
completedAt?: string;
|
|
3125
|
+
expenseReportId?: number;
|
|
3126
|
+
categoryId?: number;
|
|
3127
|
+
transactionId?: number;
|
|
3128
|
+
note?: string;
|
|
3129
|
+
attachment?: {
|
|
3130
|
+
id?: number;
|
|
3131
|
+
fileName?: string;
|
|
3132
|
+
url?: string;
|
|
3133
|
+
cdnUrl?: string;
|
|
3134
|
+
};
|
|
3034
3135
|
}
|
|
3035
3136
|
/**
|
|
3036
3137
|
* Request parameters for listing expense jobs with optional status filter.
|
|
3037
3138
|
*/
|
|
3038
3139
|
interface ExpenseJobListRequest extends PaginationRequest {
|
|
3039
|
-
status?: string;
|
|
3140
|
+
status?: string | string[];
|
|
3040
3141
|
}
|
|
3041
3142
|
|
|
3042
3143
|
/**
|
|
@@ -3105,6 +3206,7 @@ declare class ExpenseJobService extends BaseService {
|
|
|
3105
3206
|
* @throws {SmartbillsNotFoundError} If the employee or job is not found
|
|
3106
3207
|
*/
|
|
3107
3208
|
retryEmployeeJob(employeeId: number, jobId: number, options?: RequestOptions): Promise<void>;
|
|
3209
|
+
listByExpenseReport(reportId: number, params?: ExpenseJobListRequest, options?: RequestOptions): Promise<SBListResponse<SBExpenseJob>>;
|
|
3108
3210
|
}
|
|
3109
3211
|
|
|
3110
3212
|
/**
|
|
@@ -3221,6 +3323,11 @@ declare class ExpenseReportExpenseService extends BaseService {
|
|
|
3221
3323
|
* @throws {SmartbillsNotFoundError} If the employee, report, or expense is not found
|
|
3222
3324
|
*/
|
|
3223
3325
|
editForEmployee(employeeId: number, reportId: number, expenseId: number, data: EditExpenseInReportRequest, options?: RequestOptions): Promise<unknown>;
|
|
3326
|
+
replace(reportId: number, oldExpenseId: number, data: {
|
|
3327
|
+
newExpenseId: number;
|
|
3328
|
+
categoryId?: number;
|
|
3329
|
+
notes?: string;
|
|
3330
|
+
}, options?: RequestOptions): Promise<unknown>;
|
|
3224
3331
|
}
|
|
3225
3332
|
|
|
3226
3333
|
/**
|
|
@@ -3284,6 +3391,11 @@ declare class ExpenseReportService extends BaseService {
|
|
|
3284
3391
|
* @returns Paginated list of expense reports
|
|
3285
3392
|
*/
|
|
3286
3393
|
list(params?: ExpenseReportListRequest, options?: RequestOptions): Promise<SBListResponse<SBExpenseReport>>;
|
|
3394
|
+
listForEmployee(employeeId: number, params?: ExpenseReportListRequest, options?: RequestOptions): Promise<SBListResponse<SBExpenseReport>>;
|
|
3395
|
+
getByIdForEmployee(employeeId: number, reportId: number, params?: {
|
|
3396
|
+
sortBy?: string;
|
|
3397
|
+
sortOrder?: string;
|
|
3398
|
+
}, options?: RequestOptions): Promise<SBExpenseReport>;
|
|
3287
3399
|
/**
|
|
3288
3400
|
* Retrieves a single expense report by ID.
|
|
3289
3401
|
*
|
|
@@ -3297,7 +3409,10 @@ declare class ExpenseReportService extends BaseService {
|
|
|
3297
3409
|
* const report = await client.expenseReports.getById(123);
|
|
3298
3410
|
* ```
|
|
3299
3411
|
*/
|
|
3300
|
-
getById(reportId: number,
|
|
3412
|
+
getById(reportId: number, params?: {
|
|
3413
|
+
sortBy?: string;
|
|
3414
|
+
sortOrder?: string;
|
|
3415
|
+
}, options?: RequestOptions): Promise<SBExpenseReport>;
|
|
3301
3416
|
/**
|
|
3302
3417
|
* Lists expense reports belonging to the current user.
|
|
3303
3418
|
*
|
|
@@ -3541,10 +3656,22 @@ interface BulkAssignVendorRequest {
|
|
|
3541
3656
|
interface BulkDeleteExpensesRequest {
|
|
3542
3657
|
expenseIds: number[];
|
|
3543
3658
|
}
|
|
3659
|
+
interface BulkAssignPayerTypeRequest {
|
|
3660
|
+
expenseIds: number[];
|
|
3661
|
+
payerType: PayerType;
|
|
3662
|
+
}
|
|
3663
|
+
interface BulkSetNoteRequest {
|
|
3664
|
+
expenseIds: number[];
|
|
3665
|
+
note: string | null;
|
|
3666
|
+
}
|
|
3667
|
+
interface ExpenseReviewUpdateRequest {
|
|
3668
|
+
isReviewed: boolean;
|
|
3669
|
+
}
|
|
3544
3670
|
/**
|
|
3545
3671
|
* Request payload for exporting expenses to a file.
|
|
3546
3672
|
*/
|
|
3547
3673
|
interface ExpenseExportRequest {
|
|
3674
|
+
expenseIds?: number[];
|
|
3548
3675
|
startDate?: string;
|
|
3549
3676
|
endDate?: string;
|
|
3550
3677
|
categoryId?: number;
|
|
@@ -3558,6 +3685,7 @@ interface ExpenseExportRequest {
|
|
|
3558
3685
|
*/
|
|
3559
3686
|
interface ExpenseAttachmentDownloadRequest {
|
|
3560
3687
|
expenseIds: number[];
|
|
3688
|
+
fileNameTemplate?: string;
|
|
3561
3689
|
}
|
|
3562
3690
|
/**
|
|
3563
3691
|
* Request parameters for listing expenses with filters and pagination.
|
|
@@ -3575,18 +3703,28 @@ interface ExpenseListRequest extends PaginationRequest {
|
|
|
3575
3703
|
status?: string;
|
|
3576
3704
|
expenseReportStatus?: string[];
|
|
3577
3705
|
}
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3706
|
+
declare enum ExpenseSplitType {
|
|
3707
|
+
EQUAL = 0,
|
|
3708
|
+
BY_PERCENTAGE = 1,
|
|
3709
|
+
BY_LINE_ITEM = 2
|
|
3710
|
+
}
|
|
3711
|
+
interface ExpenseSplitLineItem {
|
|
3712
|
+
lineItemId: number;
|
|
3713
|
+
quantity?: number;
|
|
3714
|
+
percentage?: number;
|
|
3715
|
+
fullAmount?: boolean;
|
|
3716
|
+
}
|
|
3581
3717
|
interface ExpenseSplitRequest {
|
|
3718
|
+
splitType: ExpenseSplitType;
|
|
3582
3719
|
splits: ExpenseSplitItem[];
|
|
3583
3720
|
}
|
|
3584
|
-
/**
|
|
3585
|
-
* A single split item when dividing an expense.
|
|
3586
|
-
*/
|
|
3587
3721
|
interface ExpenseSplitItem {
|
|
3588
|
-
|
|
3589
|
-
|
|
3722
|
+
name?: string;
|
|
3723
|
+
percentage?: number;
|
|
3724
|
+
amount?: number;
|
|
3725
|
+
lineItems?: ExpenseSplitLineItem[];
|
|
3726
|
+
categoryId?: number | null;
|
|
3727
|
+
memo?: string | null;
|
|
3590
3728
|
note?: string;
|
|
3591
3729
|
}
|
|
3592
3730
|
/**
|
|
@@ -3600,6 +3738,43 @@ interface SBExpenseValidateResponse {
|
|
|
3600
3738
|
* Response for bulk expense operations.
|
|
3601
3739
|
*/
|
|
3602
3740
|
type SBExpenseBulkActionResponse = SBBulkActionResponse;
|
|
3741
|
+
interface PresignedUploadFileRequest {
|
|
3742
|
+
fileName: string;
|
|
3743
|
+
contentType: string;
|
|
3744
|
+
fileSize: number;
|
|
3745
|
+
}
|
|
3746
|
+
interface PresignedUploadRequest {
|
|
3747
|
+
files: PresignedUploadFileRequest[];
|
|
3748
|
+
vendorId?: number;
|
|
3749
|
+
expenseReportId?: number;
|
|
3750
|
+
categoryId?: number;
|
|
3751
|
+
type?: string;
|
|
3752
|
+
payerType?: string;
|
|
3753
|
+
}
|
|
3754
|
+
interface PresignedUploadFileResponse {
|
|
3755
|
+
fileName: string;
|
|
3756
|
+
s3Key: string;
|
|
3757
|
+
uploadUrl: string;
|
|
3758
|
+
contentType: string;
|
|
3759
|
+
}
|
|
3760
|
+
interface PresignedUploadResponse {
|
|
3761
|
+
uploadSessionId: string;
|
|
3762
|
+
files: PresignedUploadFileResponse[];
|
|
3763
|
+
}
|
|
3764
|
+
interface ConfirmUploadFileRequest {
|
|
3765
|
+
s3Key: string;
|
|
3766
|
+
fileName: string;
|
|
3767
|
+
contentType: string;
|
|
3768
|
+
}
|
|
3769
|
+
interface ConfirmUploadRequest {
|
|
3770
|
+
uploadSessionId: string;
|
|
3771
|
+
files: ConfirmUploadFileRequest[];
|
|
3772
|
+
vendorId?: number;
|
|
3773
|
+
expenseReportId?: number;
|
|
3774
|
+
categoryId?: number;
|
|
3775
|
+
type?: string;
|
|
3776
|
+
payerType?: string;
|
|
3777
|
+
}
|
|
3603
3778
|
|
|
3604
3779
|
/**
|
|
3605
3780
|
* Service for managing expenses (receipts and transactions) within a business.
|
|
@@ -3777,6 +3952,7 @@ declare class ExpenseService extends BaseService {
|
|
|
3777
3952
|
* @returns Bulk action response with success and failure counts
|
|
3778
3953
|
*/
|
|
3779
3954
|
bulkAssignCategory(data: BulkAssignCategoryRequest, options?: RequestOptions): Promise<SBExpenseBulkActionResponse>;
|
|
3955
|
+
bulkAssignPayerType(data: BulkAssignPayerTypeRequest, options?: RequestOptions): Promise<SBExpenseBulkActionResponse>;
|
|
3780
3956
|
/**
|
|
3781
3957
|
* Bulk assigns multiple expenses to an expense report.
|
|
3782
3958
|
*
|
|
@@ -3793,6 +3969,8 @@ declare class ExpenseService extends BaseService {
|
|
|
3793
3969
|
* @returns Bulk action response with success and failure counts
|
|
3794
3970
|
*/
|
|
3795
3971
|
bulkAssignVendor(data: BulkAssignVendorRequest, options?: RequestOptions): Promise<SBExpenseBulkActionResponse>;
|
|
3972
|
+
bulkSetNote(data: BulkSetNoteRequest, options?: RequestOptions): Promise<SBExpenseBulkActionResponse>;
|
|
3973
|
+
updateReview(expenseId: number, data: ExpenseReviewUpdateRequest, options?: RequestOptions): Promise<SBTransaction>;
|
|
3796
3974
|
/**
|
|
3797
3975
|
* Bulk deletes multiple expenses.
|
|
3798
3976
|
*
|
|
@@ -3809,6 +3987,10 @@ declare class ExpenseService extends BaseService {
|
|
|
3809
3987
|
* @returns Blob containing the exported file
|
|
3810
3988
|
*/
|
|
3811
3989
|
export(data: ExpenseExportRequest, options?: RequestOptions): Promise<Blob>;
|
|
3990
|
+
exportWithFilename(data: ExpenseExportRequest, options?: RequestOptions): Promise<{
|
|
3991
|
+
blob: Blob;
|
|
3992
|
+
filename?: string;
|
|
3993
|
+
}>;
|
|
3812
3994
|
/**
|
|
3813
3995
|
* Downloads expense attachments as a zip or combined file.
|
|
3814
3996
|
*
|
|
@@ -3817,6 +3999,15 @@ declare class ExpenseService extends BaseService {
|
|
|
3817
3999
|
* @returns Blob containing the downloaded attachments
|
|
3818
4000
|
*/
|
|
3819
4001
|
downloadAttachments(data: ExpenseAttachmentDownloadRequest, options?: RequestOptions): Promise<Blob>;
|
|
4002
|
+
downloadAttachmentsWithFilename(data: ExpenseAttachmentDownloadRequest, options?: RequestOptions): Promise<{
|
|
4003
|
+
blob: Blob;
|
|
4004
|
+
filename?: string;
|
|
4005
|
+
}>;
|
|
4006
|
+
downloadSingleAttachment(expenseId: number, options?: RequestOptions): Promise<Blob>;
|
|
4007
|
+
downloadSingleAttachmentWithFilename(expenseId: number, options?: RequestOptions): Promise<{
|
|
4008
|
+
blob: Blob;
|
|
4009
|
+
filename?: string;
|
|
4010
|
+
}>;
|
|
3820
4011
|
/**
|
|
3821
4012
|
* Splits an expense into multiple transactions.
|
|
3822
4013
|
*
|
|
@@ -3836,6 +4027,10 @@ declare class ExpenseService extends BaseService {
|
|
|
3836
4027
|
* @returns Array of updated expense transactions
|
|
3837
4028
|
*/
|
|
3838
4029
|
batchUpdate(data: unknown[], options?: RequestOptions): Promise<SBTransaction[]>;
|
|
4030
|
+
presignUpload(request: PresignedUploadRequest, options?: RequestOptions): Promise<PresignedUploadResponse>;
|
|
4031
|
+
confirmUpload(request: ConfirmUploadRequest, options?: RequestOptions): Promise<unknown>;
|
|
4032
|
+
presignEmployeeUpload(employeeId: number, request: PresignedUploadRequest, options?: RequestOptions): Promise<PresignedUploadResponse>;
|
|
4033
|
+
confirmEmployeeUpload(employeeId: number, request: ConfirmUploadRequest, options?: RequestOptions): Promise<unknown>;
|
|
3839
4034
|
}
|
|
3840
4035
|
|
|
3841
4036
|
/**
|
|
@@ -3918,6 +4113,15 @@ declare class IntegrationService extends BaseService {
|
|
|
3918
4113
|
* @throws {SmartbillsNotFoundError} If the app is not found
|
|
3919
4114
|
*/
|
|
3920
4115
|
getMarketplaceApp(slug: string, options?: RequestOptions): Promise<SBMarketplaceApp>;
|
|
4116
|
+
getInstallationById(installationId: string, options?: RequestOptions): Promise<SBIntegration>;
|
|
4117
|
+
getInstallation(appSlug: string, installationId: string, options?: RequestOptions): Promise<SBIntegration>;
|
|
4118
|
+
getSessionToken(installationId: string, options?: RequestOptions): Promise<SBSessionTokenResponse>;
|
|
4119
|
+
retryInstallation(appSlug: string, installationId: string, options?: RequestOptions): Promise<SBIntegrationAuthorizeResponse>;
|
|
4120
|
+
abortInstallation(appSlug: string, installationId: string, options?: RequestOptions): Promise<SBIntegration>;
|
|
4121
|
+
updateInstallationStatus(appSlug: string, installationId: string, data: {
|
|
4122
|
+
status: string;
|
|
4123
|
+
errorMessage?: string;
|
|
4124
|
+
}, options?: RequestOptions): Promise<SBIntegration>;
|
|
3921
4125
|
}
|
|
3922
4126
|
|
|
3923
4127
|
/**
|
|
@@ -4821,7 +5025,7 @@ declare class ReportingService extends BaseService {
|
|
|
4821
5025
|
* @param options - Request options including businessId, locale, and abort signal
|
|
4822
5026
|
* @returns Array of monthly expense summaries
|
|
4823
5027
|
*/
|
|
4824
|
-
monthlySummary(params: ReportingRequest, options?: RequestOptions): Promise<SBExpenseMonthlySummary
|
|
5028
|
+
monthlySummary(params: ReportingRequest, options?: RequestOptions): Promise<SBExpenseMonthlySummary>;
|
|
4825
5029
|
/**
|
|
4826
5030
|
* Retrieves expense breakdown by category.
|
|
4827
5031
|
*
|
|
@@ -5721,17 +5925,843 @@ declare class WorkflowService extends BaseService {
|
|
|
5721
5925
|
createFromTemplate(templateId: string, options?: RequestOptions): Promise<SBWorkflow>;
|
|
5722
5926
|
}
|
|
5723
5927
|
|
|
5928
|
+
/** Represents a customer of the business (buyer / receipt recipient). */
|
|
5929
|
+
interface SBCustomer extends SBEntity, SBTimestamps {
|
|
5930
|
+
firstName?: string;
|
|
5931
|
+
lastName?: string;
|
|
5932
|
+
name?: string;
|
|
5933
|
+
email?: string;
|
|
5934
|
+
phone?: string;
|
|
5935
|
+
acceptsMarketing?: boolean;
|
|
5936
|
+
taxExempt?: boolean;
|
|
5937
|
+
billingAddress?: SBAddress;
|
|
5938
|
+
shippingAddress?: SBAddress;
|
|
5939
|
+
ordersCount?: number;
|
|
5940
|
+
totalSpent?: number;
|
|
5941
|
+
}
|
|
5942
|
+
/** Query parameters for listing customers with search support. */
|
|
5943
|
+
interface CustomerListRequest extends PaginationRequest {
|
|
5944
|
+
search?: string;
|
|
5945
|
+
searchTerm?: string;
|
|
5946
|
+
}
|
|
5947
|
+
/** Payload for creating a new customer. */
|
|
5948
|
+
interface CustomerCreateRequest {
|
|
5949
|
+
firstName?: string;
|
|
5950
|
+
lastName?: string;
|
|
5951
|
+
name?: string;
|
|
5952
|
+
email?: string;
|
|
5953
|
+
phone?: string;
|
|
5954
|
+
acceptsMarketing?: boolean;
|
|
5955
|
+
taxExempt?: boolean;
|
|
5956
|
+
billingAddress?: SBAddress;
|
|
5957
|
+
shippingAddress?: SBAddress;
|
|
5958
|
+
}
|
|
5959
|
+
/** Payload for updating an existing customer. All fields are optional. */
|
|
5960
|
+
type CustomerUpdateRequest = Partial<CustomerCreateRequest>;
|
|
5961
|
+
|
|
5962
|
+
/**
|
|
5963
|
+
* Service for managing customers within a business.
|
|
5964
|
+
*
|
|
5965
|
+
* Customers represent the people or organizations that purchase
|
|
5966
|
+
* goods or services from the business.
|
|
5967
|
+
*/
|
|
5968
|
+
declare class CustomerService extends BaseService {
|
|
5969
|
+
/**
|
|
5970
|
+
* Retrieves a paginated list of customers.
|
|
5971
|
+
*
|
|
5972
|
+
* @param params - Optional filters, search, and pagination parameters
|
|
5973
|
+
* @param options - Request options including business context and abort signal
|
|
5974
|
+
* @returns A paginated list of customers
|
|
5975
|
+
*/
|
|
5976
|
+
list(params?: CustomerListRequest, options?: RequestOptions): Promise<SBListResponse<SBCustomer>>;
|
|
5977
|
+
/**
|
|
5978
|
+
* Retrieves a single customer by ID.
|
|
5979
|
+
*
|
|
5980
|
+
* @param id - The customer ID
|
|
5981
|
+
* @param options - Request options including business context and abort signal
|
|
5982
|
+
* @returns The customer
|
|
5983
|
+
* @throws {SmartbillsNotFoundError} If the customer is not found
|
|
5984
|
+
*/
|
|
5985
|
+
getById(id: number, options?: RequestOptions): Promise<SBCustomer>;
|
|
5986
|
+
/**
|
|
5987
|
+
* Creates a new customer.
|
|
5988
|
+
*
|
|
5989
|
+
* @param data - The customer creation payload
|
|
5990
|
+
* @param options - Request options including business context and abort signal
|
|
5991
|
+
* @returns The newly created customer
|
|
5992
|
+
* @throws {SmartbillsValidationError} If the provided data fails validation
|
|
5993
|
+
*/
|
|
5994
|
+
create(data: CustomerCreateRequest, options?: RequestOptions): Promise<SBCustomer>;
|
|
5995
|
+
/**
|
|
5996
|
+
* Updates an existing customer.
|
|
5997
|
+
*
|
|
5998
|
+
* @param id - The customer ID
|
|
5999
|
+
* @param data - The fields to update
|
|
6000
|
+
* @param options - Request options including business context and abort signal
|
|
6001
|
+
* @returns The updated customer
|
|
6002
|
+
* @throws {SmartbillsNotFoundError} If the customer is not found
|
|
6003
|
+
* @throws {SmartbillsValidationError} If the provided data fails validation
|
|
6004
|
+
*/
|
|
6005
|
+
update(id: number, data: CustomerUpdateRequest, options?: RequestOptions): Promise<SBCustomer>;
|
|
6006
|
+
/**
|
|
6007
|
+
* Deletes a customer.
|
|
6008
|
+
*
|
|
6009
|
+
* @param id - The customer ID
|
|
6010
|
+
* @param options - Request options including business context and abort signal
|
|
6011
|
+
* @throws {SmartbillsNotFoundError} If the customer is not found
|
|
6012
|
+
*/
|
|
6013
|
+
delete(id: number, options?: RequestOptions): Promise<void>;
|
|
6014
|
+
}
|
|
6015
|
+
|
|
6016
|
+
/** A lightweight representation of a team member within a department. */
|
|
6017
|
+
interface SBDepartmentMember {
|
|
6018
|
+
id: number;
|
|
6019
|
+
firstName?: string;
|
|
6020
|
+
lastName?: string;
|
|
6021
|
+
email?: string;
|
|
6022
|
+
avatar?: string;
|
|
6023
|
+
}
|
|
6024
|
+
/** Represents an organizational department within a business. */
|
|
6025
|
+
interface SBDepartment extends SBEntity, SBTimestamps {
|
|
6026
|
+
name: string;
|
|
6027
|
+
code?: string;
|
|
6028
|
+
description?: string;
|
|
6029
|
+
managerName?: string;
|
|
6030
|
+
isActive: boolean;
|
|
6031
|
+
active?: boolean;
|
|
6032
|
+
employeeCount?: number;
|
|
6033
|
+
teamMembers?: SBDepartmentMember[];
|
|
6034
|
+
}
|
|
6035
|
+
/** Query parameters for listing departments with search support. */
|
|
6036
|
+
interface DepartmentListRequest extends PaginationRequest {
|
|
6037
|
+
search?: string;
|
|
6038
|
+
}
|
|
6039
|
+
/** Payload for creating a new department. */
|
|
6040
|
+
interface DepartmentCreateRequest {
|
|
6041
|
+
name: string;
|
|
6042
|
+
code?: string;
|
|
6043
|
+
description?: string;
|
|
6044
|
+
managerName?: string;
|
|
6045
|
+
isActive?: boolean;
|
|
6046
|
+
teamMemberIds?: number[];
|
|
6047
|
+
}
|
|
6048
|
+
/** Payload for updating an existing department. */
|
|
6049
|
+
type DepartmentUpdateRequest = DepartmentCreateRequest;
|
|
6050
|
+
|
|
6051
|
+
/**
|
|
6052
|
+
* Service for managing departments within a business.
|
|
6053
|
+
*
|
|
6054
|
+
* Departments are organizational units used to categorize expenses,
|
|
6055
|
+
* employees, and budgets within a business.
|
|
6056
|
+
*/
|
|
6057
|
+
declare class DepartmentService extends BaseService {
|
|
6058
|
+
/**
|
|
6059
|
+
* Retrieves a paginated list of departments.
|
|
6060
|
+
*
|
|
6061
|
+
* @param params - Optional filters and pagination parameters
|
|
6062
|
+
* @param options - Request options including business context and abort signal
|
|
6063
|
+
* @returns A paginated list of departments
|
|
6064
|
+
*/
|
|
6065
|
+
list(params?: DepartmentListRequest, options?: RequestOptions): Promise<SBListResponse<SBDepartment>>;
|
|
6066
|
+
/**
|
|
6067
|
+
* Retrieves a single department by ID.
|
|
6068
|
+
*
|
|
6069
|
+
* @param id - The department ID
|
|
6070
|
+
* @param options - Request options including business context and abort signal
|
|
6071
|
+
* @returns The department
|
|
6072
|
+
* @throws {SmartbillsNotFoundError} If the department is not found
|
|
6073
|
+
*/
|
|
6074
|
+
getById(id: number, options?: RequestOptions): Promise<SBDepartment>;
|
|
6075
|
+
/**
|
|
6076
|
+
* Creates a new department.
|
|
6077
|
+
*
|
|
6078
|
+
* @param data - The department creation payload
|
|
6079
|
+
* @param options - Request options including business context and abort signal
|
|
6080
|
+
* @returns The newly created department
|
|
6081
|
+
* @throws {SmartbillsValidationError} If the provided data fails validation
|
|
6082
|
+
*/
|
|
6083
|
+
create(data: DepartmentCreateRequest, options?: RequestOptions): Promise<SBDepartment>;
|
|
6084
|
+
/**
|
|
6085
|
+
* Updates an existing department.
|
|
6086
|
+
*
|
|
6087
|
+
* @param id - The department ID
|
|
6088
|
+
* @param data - The fields to update
|
|
6089
|
+
* @param options - Request options including business context and abort signal
|
|
6090
|
+
* @returns The updated department
|
|
6091
|
+
* @throws {SmartbillsNotFoundError} If the department is not found
|
|
6092
|
+
* @throws {SmartbillsValidationError} If the provided data fails validation
|
|
6093
|
+
*/
|
|
6094
|
+
update(id: number, data: DepartmentUpdateRequest, options?: RequestOptions): Promise<SBDepartment>;
|
|
6095
|
+
/**
|
|
6096
|
+
* Deletes a department.
|
|
6097
|
+
*
|
|
6098
|
+
* @param id - The department ID
|
|
6099
|
+
* @param options - Request options including business context and abort signal
|
|
6100
|
+
* @throws {SmartbillsNotFoundError} If the department is not found
|
|
6101
|
+
*/
|
|
6102
|
+
delete(id: number, options?: RequestOptions): Promise<void>;
|
|
6103
|
+
}
|
|
6104
|
+
|
|
6105
|
+
/** Represents a product or service offered by the business. */
|
|
6106
|
+
interface SBProduct extends SBEntity, SBTimestamps {
|
|
6107
|
+
name: string;
|
|
6108
|
+
description?: string;
|
|
6109
|
+
price?: number;
|
|
6110
|
+
sku?: string;
|
|
6111
|
+
}
|
|
6112
|
+
/** Query parameters for listing products with optional search. */
|
|
6113
|
+
interface ProductListRequest extends PaginationRequest {
|
|
6114
|
+
search?: string;
|
|
6115
|
+
}
|
|
6116
|
+
|
|
6117
|
+
/**
|
|
6118
|
+
* Service for managing products within a business.
|
|
6119
|
+
*
|
|
6120
|
+
* Products represent the goods or services sold by the business
|
|
6121
|
+
* and appear on receipts and invoices.
|
|
6122
|
+
*/
|
|
6123
|
+
declare class ProductService extends BaseService {
|
|
6124
|
+
/**
|
|
6125
|
+
* Retrieves a paginated list of products.
|
|
6126
|
+
*
|
|
6127
|
+
* @param params - Optional filters, search, and pagination parameters
|
|
6128
|
+
* @param options - Request options including business context and abort signal
|
|
6129
|
+
* @returns A paginated list of products
|
|
6130
|
+
*/
|
|
6131
|
+
list(params?: ProductListRequest, options?: RequestOptions): Promise<SBListResponse<SBProduct>>;
|
|
6132
|
+
/**
|
|
6133
|
+
* Retrieves a single product by ID.
|
|
6134
|
+
*
|
|
6135
|
+
* @param id - The product ID
|
|
6136
|
+
* @param options - Request options including business context and abort signal
|
|
6137
|
+
* @returns The product
|
|
6138
|
+
* @throws {SmartbillsNotFoundError} If the product is not found
|
|
6139
|
+
*/
|
|
6140
|
+
getById(id: number, options?: RequestOptions): Promise<SBProduct>;
|
|
6141
|
+
}
|
|
6142
|
+
|
|
6143
|
+
/** Represents a tax rate configured for a business. */
|
|
6144
|
+
interface SBTax extends SBEntity, SBTimestamps {
|
|
6145
|
+
name: string;
|
|
6146
|
+
rate: number;
|
|
6147
|
+
code?: string;
|
|
6148
|
+
isDefault?: boolean;
|
|
6149
|
+
}
|
|
6150
|
+
/** Query parameters for listing tax rates with optional search. */
|
|
6151
|
+
interface TaxListRequest extends PaginationRequest {
|
|
6152
|
+
search?: string;
|
|
6153
|
+
}
|
|
6154
|
+
|
|
6155
|
+
/**
|
|
6156
|
+
* Service for managing tax configurations within a business.
|
|
6157
|
+
*
|
|
6158
|
+
* Taxes define the tax rates applied to receipts, invoices, and
|
|
6159
|
+
* expense items (e.g., GST, HST, PST, VAT).
|
|
6160
|
+
*/
|
|
6161
|
+
declare class TaxService extends BaseService {
|
|
6162
|
+
/**
|
|
6163
|
+
* Retrieves a paginated list of tax configurations.
|
|
6164
|
+
*
|
|
6165
|
+
* @param params - Optional filters and pagination parameters
|
|
6166
|
+
* @param options - Request options including business context and abort signal
|
|
6167
|
+
* @returns A paginated list of tax configurations
|
|
6168
|
+
*/
|
|
6169
|
+
list(params?: TaxListRequest, options?: RequestOptions): Promise<SBListResponse<SBTax>>;
|
|
6170
|
+
/**
|
|
6171
|
+
* Retrieves a single tax configuration by ID.
|
|
6172
|
+
*
|
|
6173
|
+
* @param id - The tax ID
|
|
6174
|
+
* @param options - Request options including business context and abort signal
|
|
6175
|
+
* @returns The tax configuration
|
|
6176
|
+
* @throws {SmartbillsNotFoundError} If the tax is not found
|
|
6177
|
+
*/
|
|
6178
|
+
getById(id: number, options?: RequestOptions): Promise<SBTax>;
|
|
6179
|
+
}
|
|
6180
|
+
|
|
6181
|
+
/** Represents a promotional code that can be applied to receipts or transactions. */
|
|
6182
|
+
interface SBPromoCode extends SBEntity, SBTimestamps {
|
|
6183
|
+
name: string;
|
|
6184
|
+
code: string;
|
|
6185
|
+
type: string;
|
|
6186
|
+
value: number;
|
|
6187
|
+
active: boolean;
|
|
6188
|
+
}
|
|
6189
|
+
|
|
6190
|
+
/**
|
|
6191
|
+
* Service for managing promotional codes within a business.
|
|
6192
|
+
*
|
|
6193
|
+
* Promo codes provide discounts to customers on receipts and invoices.
|
|
6194
|
+
*/
|
|
6195
|
+
declare class PromoCodeService extends BaseService {
|
|
6196
|
+
/**
|
|
6197
|
+
* Retrieves a single promotional code by ID.
|
|
6198
|
+
*
|
|
6199
|
+
* @param id - The promo code ID
|
|
6200
|
+
* @param options - Request options including business context and abort signal
|
|
6201
|
+
* @returns The promotional code
|
|
6202
|
+
* @throws {SmartbillsNotFoundError} If the promo code is not found
|
|
6203
|
+
*/
|
|
6204
|
+
getById(id: number, options?: RequestOptions): Promise<SBPromoCode>;
|
|
6205
|
+
}
|
|
6206
|
+
|
|
6207
|
+
/** Represents an expense category used to classify and organize expenses. */
|
|
6208
|
+
interface SBCategory extends SBEntity, SBTimestamps {
|
|
6209
|
+
name: string;
|
|
6210
|
+
code?: string;
|
|
6211
|
+
isVisible: boolean;
|
|
6212
|
+
businessId?: number;
|
|
6213
|
+
userId?: number;
|
|
6214
|
+
}
|
|
6215
|
+
/** Payload for creating a new expense category. */
|
|
6216
|
+
interface CategoryCreateRequest {
|
|
6217
|
+
name: string;
|
|
6218
|
+
code?: string;
|
|
6219
|
+
isVisible?: boolean;
|
|
6220
|
+
}
|
|
6221
|
+
/** Payload for updating an existing expense category. */
|
|
6222
|
+
interface CategoryUpdateRequest {
|
|
6223
|
+
name?: string;
|
|
6224
|
+
code?: string;
|
|
6225
|
+
isVisible?: boolean;
|
|
6226
|
+
}
|
|
6227
|
+
|
|
6228
|
+
/**
|
|
6229
|
+
* Service for managing expense categories within a business.
|
|
6230
|
+
*
|
|
6231
|
+
* Categories are used to classify expenses for reporting, budgeting,
|
|
6232
|
+
* and accounting purposes (e.g., Travel, Meals, Office Supplies).
|
|
6233
|
+
*/
|
|
6234
|
+
declare class CategoryService extends BaseService {
|
|
6235
|
+
/**
|
|
6236
|
+
* Retrieves all expense categories for the business.
|
|
6237
|
+
*
|
|
6238
|
+
* @param options - Request options including business context and abort signal
|
|
6239
|
+
* @returns An array of expense categories
|
|
6240
|
+
*/
|
|
6241
|
+
list(options?: RequestOptions): Promise<SBCategory[]>;
|
|
6242
|
+
/**
|
|
6243
|
+
* Retrieves a single expense category by ID.
|
|
6244
|
+
*
|
|
6245
|
+
* @param id - The category ID
|
|
6246
|
+
* @param options - Request options including business context and abort signal
|
|
6247
|
+
* @returns The expense category
|
|
6248
|
+
* @throws {SmartbillsNotFoundError} If the category is not found
|
|
6249
|
+
*/
|
|
6250
|
+
getById(id: number, options?: RequestOptions): Promise<SBCategory>;
|
|
6251
|
+
/**
|
|
6252
|
+
* Creates a new expense category.
|
|
6253
|
+
*
|
|
6254
|
+
* @param data - The category creation payload
|
|
6255
|
+
* @param options - Request options including business context and abort signal
|
|
6256
|
+
* @returns The newly created category
|
|
6257
|
+
* @throws {SmartbillsValidationError} If the provided data fails validation
|
|
6258
|
+
*/
|
|
6259
|
+
create(data: CategoryCreateRequest, options?: RequestOptions): Promise<SBCategory>;
|
|
6260
|
+
/**
|
|
6261
|
+
* Updates an existing expense category.
|
|
6262
|
+
*
|
|
6263
|
+
* @param id - The category ID
|
|
6264
|
+
* @param data - The fields to update
|
|
6265
|
+
* @param options - Request options including business context and abort signal
|
|
6266
|
+
* @returns The updated category
|
|
6267
|
+
* @throws {SmartbillsNotFoundError} If the category is not found
|
|
6268
|
+
* @throws {SmartbillsValidationError} If the provided data fails validation
|
|
6269
|
+
*/
|
|
6270
|
+
update(id: number, data: CategoryUpdateRequest, options?: RequestOptions): Promise<SBCategory>;
|
|
6271
|
+
/**
|
|
6272
|
+
* Deletes an expense category.
|
|
6273
|
+
*
|
|
6274
|
+
* @param id - The category ID
|
|
6275
|
+
* @param options - Request options including business context and abort signal
|
|
6276
|
+
* @throws {SmartbillsNotFoundError} If the category is not found
|
|
6277
|
+
*/
|
|
6278
|
+
delete(id: number, options?: RequestOptions): Promise<void>;
|
|
6279
|
+
}
|
|
6280
|
+
|
|
6281
|
+
/** Lightweight representation of an employee's manager. */
|
|
6282
|
+
interface SBEmployeeManager {
|
|
6283
|
+
id: number;
|
|
6284
|
+
firstName: string;
|
|
6285
|
+
lastName: string;
|
|
6286
|
+
name: string;
|
|
6287
|
+
email: string;
|
|
6288
|
+
}
|
|
6289
|
+
/** Department association for an employee. */
|
|
6290
|
+
interface SBEmployeeDepartment {
|
|
6291
|
+
departmentId: number;
|
|
6292
|
+
departmentName: string;
|
|
6293
|
+
}
|
|
6294
|
+
/** Location association for an employee. */
|
|
6295
|
+
interface SBEmployeeLocation {
|
|
6296
|
+
locationId: number;
|
|
6297
|
+
locationName: string;
|
|
6298
|
+
}
|
|
6299
|
+
/** Represents an employee within a business, including their manager, departments, and locations. */
|
|
6300
|
+
interface SBEmployee extends SBEntity, SBTimestamps {
|
|
6301
|
+
businessId: number;
|
|
6302
|
+
userId: number;
|
|
6303
|
+
employeeIdentifier?: string;
|
|
6304
|
+
firstName: string;
|
|
6305
|
+
lastName: string;
|
|
6306
|
+
name: string;
|
|
6307
|
+
email: string;
|
|
6308
|
+
phoneNumber?: string;
|
|
6309
|
+
managerId?: number;
|
|
6310
|
+
manager?: SBEmployeeManager;
|
|
6311
|
+
status: string;
|
|
6312
|
+
isMemberOnPlatform: boolean;
|
|
6313
|
+
birthdate?: string;
|
|
6314
|
+
departments?: SBEmployeeDepartment[];
|
|
6315
|
+
locations?: SBEmployeeLocation[];
|
|
6316
|
+
}
|
|
6317
|
+
/** Query parameters for listing employees with optional search and status filter. */
|
|
6318
|
+
interface EmployeeListRequest extends PaginationRequest {
|
|
6319
|
+
search?: string;
|
|
6320
|
+
status?: string;
|
|
6321
|
+
}
|
|
6322
|
+
/** Payload for creating a new employee record. */
|
|
6323
|
+
interface EmployeeCreateRequest {
|
|
6324
|
+
businessId: number;
|
|
6325
|
+
employeeIdentifier?: string;
|
|
6326
|
+
firstName: string;
|
|
6327
|
+
lastName: string;
|
|
6328
|
+
email: string;
|
|
6329
|
+
phoneNumber?: string;
|
|
6330
|
+
managerId?: number;
|
|
6331
|
+
departmentIds?: number[];
|
|
6332
|
+
locationIds?: number[];
|
|
6333
|
+
birthdate?: string;
|
|
6334
|
+
}
|
|
6335
|
+
/** Payload for updating an existing employee record. All fields are optional. */
|
|
6336
|
+
type EmployeeUpdateRequest = Partial<Omit<EmployeeCreateRequest, "businessId">>;
|
|
6337
|
+
/** Payload for assigning or removing a manager from a single employee. */
|
|
6338
|
+
interface EmployeeSetManagerRequest {
|
|
6339
|
+
managerId: number | null;
|
|
6340
|
+
}
|
|
6341
|
+
/** Payload for bulk-assigning a manager to multiple employees at once. */
|
|
6342
|
+
interface EmployeeBulkAssignManagerRequest {
|
|
6343
|
+
employeeIds: number[];
|
|
6344
|
+
managerId: number | null;
|
|
6345
|
+
}
|
|
6346
|
+
|
|
6347
|
+
/**
|
|
6348
|
+
* Service for managing employees within a business.
|
|
6349
|
+
*
|
|
6350
|
+
* Employees are team members who can submit expenses, be assigned to departments,
|
|
6351
|
+
* and have managers in the organizational hierarchy.
|
|
6352
|
+
*/
|
|
6353
|
+
declare class EmployeeService extends BaseService {
|
|
6354
|
+
/**
|
|
6355
|
+
* Retrieves a paginated list of employees.
|
|
6356
|
+
*
|
|
6357
|
+
* @param params - Optional filters, search, and pagination parameters
|
|
6358
|
+
* @param options - Request options including business context and abort signal
|
|
6359
|
+
* @returns A paginated list of employees
|
|
6360
|
+
*/
|
|
6361
|
+
list(params?: EmployeeListRequest, options?: RequestOptions): Promise<SBListResponse<SBEmployee>>;
|
|
6362
|
+
/**
|
|
6363
|
+
* Retrieves a single employee by ID.
|
|
6364
|
+
*
|
|
6365
|
+
* @param id - The employee ID
|
|
6366
|
+
* @param options - Request options including business context and abort signal
|
|
6367
|
+
* @returns The employee
|
|
6368
|
+
* @throws {SmartbillsNotFoundError} If the employee is not found
|
|
6369
|
+
*/
|
|
6370
|
+
getById(id: number, options?: RequestOptions): Promise<SBEmployee>;
|
|
6371
|
+
/**
|
|
6372
|
+
* Creates a new employee.
|
|
6373
|
+
*
|
|
6374
|
+
* @param data - The employee creation payload
|
|
6375
|
+
* @param options - Request options including business context and abort signal
|
|
6376
|
+
* @returns The newly created employee
|
|
6377
|
+
* @throws {SmartbillsValidationError} If the provided data fails validation
|
|
6378
|
+
*/
|
|
6379
|
+
create(data: EmployeeCreateRequest, options?: RequestOptions): Promise<SBEmployee>;
|
|
6380
|
+
/**
|
|
6381
|
+
* Updates an existing employee.
|
|
6382
|
+
*
|
|
6383
|
+
* @param id - The employee ID
|
|
6384
|
+
* @param data - The fields to update
|
|
6385
|
+
* @param options - Request options including business context and abort signal
|
|
6386
|
+
* @returns The updated employee
|
|
6387
|
+
* @throws {SmartbillsNotFoundError} If the employee is not found
|
|
6388
|
+
* @throws {SmartbillsValidationError} If the provided data fails validation
|
|
6389
|
+
*/
|
|
6390
|
+
update(id: number, data: EmployeeUpdateRequest, options?: RequestOptions): Promise<SBEmployee>;
|
|
6391
|
+
/**
|
|
6392
|
+
* Deletes an employee.
|
|
6393
|
+
*
|
|
6394
|
+
* @param id - The employee ID
|
|
6395
|
+
* @param options - Request options including business context and abort signal
|
|
6396
|
+
* @throws {SmartbillsNotFoundError} If the employee is not found
|
|
6397
|
+
*/
|
|
6398
|
+
delete(id: number, options?: RequestOptions): Promise<void>;
|
|
6399
|
+
/**
|
|
6400
|
+
* Assigns a manager to an employee.
|
|
6401
|
+
*
|
|
6402
|
+
* @param employeeId - The employee ID
|
|
6403
|
+
* @param data - The manager assignment payload
|
|
6404
|
+
* @param options - Request options including business context and abort signal
|
|
6405
|
+
* @returns The updated employee with the new manager
|
|
6406
|
+
* @throws {SmartbillsNotFoundError} If the employee is not found
|
|
6407
|
+
*/
|
|
6408
|
+
setManager(employeeId: number, data: EmployeeSetManagerRequest, options?: RequestOptions): Promise<SBEmployee>;
|
|
6409
|
+
/**
|
|
6410
|
+
* Assigns a manager to multiple employees in a single bulk operation.
|
|
6411
|
+
*
|
|
6412
|
+
* @param data - The bulk manager assignment payload with employee IDs and manager ID
|
|
6413
|
+
* @param options - Request options including business context and abort signal
|
|
6414
|
+
*/
|
|
6415
|
+
bulkAssignManager(data: EmployeeBulkAssignManagerRequest, options?: RequestOptions): Promise<void>;
|
|
6416
|
+
/**
|
|
6417
|
+
* Activates an employee.
|
|
6418
|
+
*
|
|
6419
|
+
* @param employeeId - The employee ID
|
|
6420
|
+
* @param options - Request options including business context and abort signal
|
|
6421
|
+
* @returns The activated employee
|
|
6422
|
+
* @throws {SmartbillsNotFoundError} If the employee is not found
|
|
6423
|
+
*/
|
|
6424
|
+
setActive(employeeId: number, options?: RequestOptions): Promise<SBEmployee>;
|
|
6425
|
+
/**
|
|
6426
|
+
* Deactivates an employee without removing them.
|
|
6427
|
+
*
|
|
6428
|
+
* @param employeeId - The employee ID
|
|
6429
|
+
* @param options - Request options including business context and abort signal
|
|
6430
|
+
* @returns The deactivated employee
|
|
6431
|
+
* @throws {SmartbillsNotFoundError} If the employee is not found
|
|
6432
|
+
*/
|
|
6433
|
+
setInactive(employeeId: number, options?: RequestOptions): Promise<SBEmployee>;
|
|
6434
|
+
}
|
|
6435
|
+
|
|
6436
|
+
/** Represents a file attachment (e.g., receipt image, PDF) associated with an expense or transaction. */
|
|
6437
|
+
interface SBAttachment extends SBEntity, SBTimestamps {
|
|
6438
|
+
fileName: string;
|
|
6439
|
+
fileSize: number;
|
|
6440
|
+
versionId: string;
|
|
6441
|
+
url: string;
|
|
6442
|
+
thumbnailUrl: string;
|
|
6443
|
+
}
|
|
6444
|
+
/** Query parameters for listing attachments with optional search. */
|
|
6445
|
+
interface AttachmentListRequest extends PaginationRequest {
|
|
6446
|
+
searchTerm?: string;
|
|
6447
|
+
}
|
|
6448
|
+
/** Payload for renaming an existing attachment. */
|
|
6449
|
+
interface AttachmentRenameRequest {
|
|
6450
|
+
fileName: string;
|
|
6451
|
+
}
|
|
6452
|
+
|
|
6453
|
+
/**
|
|
6454
|
+
* Service for managing file attachments on expenses and receipts.
|
|
6455
|
+
*
|
|
6456
|
+
* Attachments are images or documents (PDF, JPEG, PNG) associated with
|
|
6457
|
+
* expenses, receipts, or bills as proof of purchase.
|
|
6458
|
+
*/
|
|
6459
|
+
declare class AttachmentService extends BaseService {
|
|
6460
|
+
/**
|
|
6461
|
+
* Retrieves a paginated list of attachments.
|
|
6462
|
+
*
|
|
6463
|
+
* @param params - Optional filters and pagination parameters
|
|
6464
|
+
* @param options - Request options including business context and abort signal
|
|
6465
|
+
* @returns A paginated list of attachments
|
|
6466
|
+
*/
|
|
6467
|
+
list(params?: AttachmentListRequest, options?: RequestOptions): Promise<SBListResponse<SBAttachment>>;
|
|
6468
|
+
/**
|
|
6469
|
+
* Retrieves a single attachment by ID.
|
|
6470
|
+
*
|
|
6471
|
+
* @param id - The attachment ID
|
|
6472
|
+
* @param options - Request options including business context and abort signal
|
|
6473
|
+
* @returns The attachment with its metadata and URL
|
|
6474
|
+
* @throws {SmartbillsNotFoundError} If the attachment is not found
|
|
6475
|
+
*/
|
|
6476
|
+
getById(id: number, options?: RequestOptions): Promise<SBAttachment>;
|
|
6477
|
+
/**
|
|
6478
|
+
* Renames an attachment.
|
|
6479
|
+
*
|
|
6480
|
+
* @param id - The attachment ID
|
|
6481
|
+
* @param data - The rename payload with the new filename
|
|
6482
|
+
* @param options - Request options including business context and abort signal
|
|
6483
|
+
* @returns The renamed attachment
|
|
6484
|
+
* @throws {SmartbillsNotFoundError} If the attachment is not found
|
|
6485
|
+
*/
|
|
6486
|
+
rename(id: number, data: AttachmentRenameRequest, options?: RequestOptions): Promise<SBAttachment>;
|
|
6487
|
+
/**
|
|
6488
|
+
* Deletes an attachment.
|
|
6489
|
+
*
|
|
6490
|
+
* @param id - The attachment ID
|
|
6491
|
+
* @param options - Request options including business context and abort signal
|
|
6492
|
+
* @throws {SmartbillsNotFoundError} If the attachment is not found
|
|
6493
|
+
*/
|
|
6494
|
+
delete(id: number, options?: RequestOptions): Promise<void>;
|
|
6495
|
+
}
|
|
6496
|
+
|
|
6497
|
+
/** Represents an email forwarding configuration for a user or business. */
|
|
6498
|
+
interface SBEmailForwardingConfig extends SBEntity, SBTimestamps {
|
|
6499
|
+
userId?: number;
|
|
6500
|
+
businessId?: number;
|
|
6501
|
+
forwardingEmail?: string;
|
|
6502
|
+
name?: string;
|
|
6503
|
+
origin?: string;
|
|
6504
|
+
personalizedSlug?: string;
|
|
6505
|
+
emailAddress: string;
|
|
6506
|
+
departmentId?: number;
|
|
6507
|
+
employeeId?: number;
|
|
6508
|
+
isActive: boolean;
|
|
6509
|
+
}
|
|
6510
|
+
/** Payload for creating or updating an email forwarding configuration. */
|
|
6511
|
+
interface EmailForwardingConfigRequest {
|
|
6512
|
+
userId?: number;
|
|
6513
|
+
businessId?: number;
|
|
6514
|
+
forwardingEmail?: string;
|
|
6515
|
+
personalizedSlug?: string;
|
|
6516
|
+
name?: string;
|
|
6517
|
+
origin?: string;
|
|
6518
|
+
departmentId?: number;
|
|
6519
|
+
employeeId?: number;
|
|
6520
|
+
}
|
|
6521
|
+
|
|
6522
|
+
/**
|
|
6523
|
+
* Service for managing email forwarding configurations.
|
|
6524
|
+
*
|
|
6525
|
+
* Email forwarding allows businesses and users to automatically forward
|
|
6526
|
+
* receipt emails to Smartbills for expense ingestion and processing.
|
|
6527
|
+
*/
|
|
6528
|
+
declare class EmailForwardingService extends BaseService {
|
|
6529
|
+
/**
|
|
6530
|
+
* Lists all email forwarding configurations for a business.
|
|
6531
|
+
*
|
|
6532
|
+
* @param businessId - The business ID
|
|
6533
|
+
* @param options - Request options including locale and abort signal
|
|
6534
|
+
* @returns An array of email forwarding configurations
|
|
6535
|
+
*/
|
|
6536
|
+
listBusiness(businessId: number, options?: RequestOptions): Promise<SBEmailForwardingConfig[]>;
|
|
6537
|
+
/**
|
|
6538
|
+
* Retrieves the email forwarding configuration for a specific user.
|
|
6539
|
+
*
|
|
6540
|
+
* @param userId - The user ID
|
|
6541
|
+
* @param businessId - Optional business ID to scope the configuration
|
|
6542
|
+
* @param options - Request options including locale and abort signal
|
|
6543
|
+
* @returns The user's email forwarding configuration
|
|
6544
|
+
*/
|
|
6545
|
+
getUser(userId: number, businessId?: number, options?: RequestOptions): Promise<SBEmailForwardingConfig>;
|
|
6546
|
+
/**
|
|
6547
|
+
* Configures email forwarding for a business.
|
|
6548
|
+
*
|
|
6549
|
+
* @param data - The forwarding configuration payload
|
|
6550
|
+
* @param options - Request options including locale and abort signal
|
|
6551
|
+
* @returns The created email forwarding configuration
|
|
6552
|
+
* @throws {SmartbillsValidationError} If the provided data fails validation
|
|
6553
|
+
*/
|
|
6554
|
+
configureBusiness(data: EmailForwardingConfigRequest, options?: RequestOptions): Promise<SBEmailForwardingConfig>;
|
|
6555
|
+
/**
|
|
6556
|
+
* Configures email forwarding for a user.
|
|
6557
|
+
*
|
|
6558
|
+
* @param data - The forwarding configuration payload
|
|
6559
|
+
* @param options - Request options including locale and abort signal
|
|
6560
|
+
* @returns The created email forwarding configuration
|
|
6561
|
+
* @throws {SmartbillsValidationError} If the provided data fails validation
|
|
6562
|
+
*/
|
|
6563
|
+
configureUser(data: EmailForwardingConfigRequest, options?: RequestOptions): Promise<SBEmailForwardingConfig>;
|
|
6564
|
+
/**
|
|
6565
|
+
* Disables email forwarding for a business.
|
|
6566
|
+
*
|
|
6567
|
+
* @param businessId - The business ID
|
|
6568
|
+
* @param options - Request options including locale and abort signal
|
|
6569
|
+
* @returns The disabled email forwarding configuration
|
|
6570
|
+
*/
|
|
6571
|
+
disableBusiness(businessId: number, options?: RequestOptions): Promise<SBEmailForwardingConfig>;
|
|
6572
|
+
/**
|
|
6573
|
+
* Disables email forwarding for a user.
|
|
6574
|
+
*
|
|
6575
|
+
* @param userId - The user ID
|
|
6576
|
+
* @param options - Request options including locale and abort signal
|
|
6577
|
+
* @returns The disabled email forwarding configuration
|
|
6578
|
+
*/
|
|
6579
|
+
disableUser(userId: number, options?: RequestOptions): Promise<SBEmailForwardingConfig>;
|
|
6580
|
+
}
|
|
6581
|
+
|
|
6582
|
+
interface SBAuthorizedSender {
|
|
6583
|
+
id: number;
|
|
6584
|
+
userId: number;
|
|
6585
|
+
businessId: number | null;
|
|
6586
|
+
emailAddress: string;
|
|
6587
|
+
createdAt: string;
|
|
6588
|
+
}
|
|
6589
|
+
interface CreateAuthorizedSenderRequest {
|
|
6590
|
+
emailAddress: string;
|
|
6591
|
+
}
|
|
6592
|
+
|
|
6593
|
+
declare class AuthorizedSenderService extends BaseService {
|
|
6594
|
+
list(businessId: number, options?: RequestOptions): Promise<SBAuthorizedSender[]>;
|
|
6595
|
+
create(businessId: number, data: CreateAuthorizedSenderRequest, options?: RequestOptions): Promise<SBAuthorizedSender>;
|
|
6596
|
+
delete(businessId: number, id: number, options?: RequestOptions): Promise<void>;
|
|
6597
|
+
}
|
|
6598
|
+
|
|
6599
|
+
/** The type of rule that determines how loyalty points are accrued. */
|
|
6600
|
+
type LoyaltyRuleType = "visit" | "spend" | "item_variation" | "category";
|
|
6601
|
+
/** Base shape shared by all loyalty accrual rules. */
|
|
6602
|
+
interface SBLoyaltyRuleBase {
|
|
6603
|
+
id?: string;
|
|
6604
|
+
type: LoyaltyRuleType;
|
|
6605
|
+
value: number;
|
|
6606
|
+
description?: string;
|
|
6607
|
+
}
|
|
6608
|
+
/** Configuration data specific to visit-based loyalty rules. */
|
|
6609
|
+
interface SBVisitRuleData {
|
|
6610
|
+
minimumAmountMoney?: number;
|
|
6611
|
+
taxMode?: "include_tax" | "exclude_tax";
|
|
6612
|
+
}
|
|
6613
|
+
/** Configuration data specific to spend-based loyalty rules. */
|
|
6614
|
+
interface SBSpendRuleData {
|
|
6615
|
+
taxMode?: "include_tax" | "exclude_tax";
|
|
6616
|
+
excludedCategoryIds?: string[];
|
|
6617
|
+
excludedItemVariationIds?: string[];
|
|
6618
|
+
}
|
|
6619
|
+
/** Configuration data specific to item-variation-based loyalty rules. */
|
|
6620
|
+
interface SBItemVariationRuleData {
|
|
6621
|
+
itemVariationId: string;
|
|
6622
|
+
}
|
|
6623
|
+
/** Configuration data specific to category-based loyalty rules. */
|
|
6624
|
+
interface SBCategoryRuleData {
|
|
6625
|
+
categoryId: string;
|
|
6626
|
+
}
|
|
6627
|
+
/** Discriminated union of all loyalty accrual rule types. */
|
|
6628
|
+
type SBLoyaltyRule = (SBLoyaltyRuleBase & {
|
|
6629
|
+
type: "visit";
|
|
6630
|
+
visitData?: SBVisitRuleData;
|
|
6631
|
+
}) | (SBLoyaltyRuleBase & {
|
|
6632
|
+
type: "spend";
|
|
6633
|
+
spendData?: SBSpendRuleData;
|
|
6634
|
+
}) | (SBLoyaltyRuleBase & {
|
|
6635
|
+
type: "item_variation";
|
|
6636
|
+
itemVariationData?: SBItemVariationRuleData;
|
|
6637
|
+
}) | (SBLoyaltyRuleBase & {
|
|
6638
|
+
type: "category";
|
|
6639
|
+
categoryData?: SBCategoryRuleData;
|
|
6640
|
+
});
|
|
6641
|
+
/** How rewards are distributed to loyalty members. */
|
|
6642
|
+
type LoyaltyRewardType = "points" | "cashback" | "tier";
|
|
6643
|
+
/** Current lifecycle status of a loyalty program. */
|
|
6644
|
+
type LoyaltyProgramStatus = "active" | "draft";
|
|
6645
|
+
/** Represents a loyalty program configured for a business. */
|
|
6646
|
+
interface SBLoyaltyProgram extends SBEntity, SBTimestamps {
|
|
6647
|
+
name: string;
|
|
6648
|
+
description: string;
|
|
6649
|
+
status: LoyaltyProgramStatus;
|
|
6650
|
+
memberCount: number;
|
|
6651
|
+
pointsIssued: number;
|
|
6652
|
+
rewardType: LoyaltyRewardType;
|
|
6653
|
+
rewardValue: number;
|
|
6654
|
+
rules: SBLoyaltyRule[];
|
|
6655
|
+
}
|
|
6656
|
+
/** Payload for creating a new loyalty program. */
|
|
6657
|
+
interface LoyaltyProgramCreateRequest {
|
|
6658
|
+
name: string;
|
|
6659
|
+
description: string;
|
|
6660
|
+
rewardType: LoyaltyRewardType;
|
|
6661
|
+
rewardValue: number;
|
|
6662
|
+
status: LoyaltyProgramStatus;
|
|
6663
|
+
rules: SBLoyaltyRule[];
|
|
6664
|
+
}
|
|
6665
|
+
/** Payload for updating an existing loyalty program. All fields are optional. */
|
|
6666
|
+
interface LoyaltyProgramUpdateRequest extends Partial<LoyaltyProgramCreateRequest> {
|
|
6667
|
+
}
|
|
6668
|
+
/** Query parameters for listing loyalty programs. */
|
|
6669
|
+
interface LoyaltyProgramListRequest extends PaginationRequest {
|
|
6670
|
+
}
|
|
6671
|
+
|
|
6672
|
+
/**
|
|
6673
|
+
* Service for managing loyalty programs.
|
|
6674
|
+
*
|
|
6675
|
+
* Loyalty programs allow businesses to reward repeat customers
|
|
6676
|
+
* with points, stamps, or tier-based rewards.
|
|
6677
|
+
*/
|
|
6678
|
+
declare class LoyaltyService extends BaseService {
|
|
6679
|
+
/**
|
|
6680
|
+
* Retrieves a paginated list of loyalty programs.
|
|
6681
|
+
*
|
|
6682
|
+
* @param params - Optional filters and pagination parameters
|
|
6683
|
+
* @param options - Request options including locale and abort signal
|
|
6684
|
+
* @returns A paginated list of loyalty programs
|
|
6685
|
+
*/
|
|
6686
|
+
list(params?: LoyaltyProgramListRequest, options?: RequestOptions): Promise<SBListResponse<SBLoyaltyProgram>>;
|
|
6687
|
+
/**
|
|
6688
|
+
* Retrieves a single loyalty program by ID.
|
|
6689
|
+
*
|
|
6690
|
+
* @param id - The loyalty program ID
|
|
6691
|
+
* @param options - Request options including locale and abort signal
|
|
6692
|
+
* @returns The loyalty program
|
|
6693
|
+
* @throws {SmartbillsNotFoundError} If the loyalty program is not found
|
|
6694
|
+
*/
|
|
6695
|
+
getById(id: string, options?: RequestOptions): Promise<SBLoyaltyProgram>;
|
|
6696
|
+
/**
|
|
6697
|
+
* Creates a new loyalty program.
|
|
6698
|
+
*
|
|
6699
|
+
* @param data - The loyalty program creation payload
|
|
6700
|
+
* @param options - Request options including locale and abort signal
|
|
6701
|
+
* @returns The newly created loyalty program
|
|
6702
|
+
* @throws {SmartbillsValidationError} If the provided data fails validation
|
|
6703
|
+
*/
|
|
6704
|
+
create(data: LoyaltyProgramCreateRequest, options?: RequestOptions): Promise<SBLoyaltyProgram>;
|
|
6705
|
+
/**
|
|
6706
|
+
* Updates an existing loyalty program.
|
|
6707
|
+
*
|
|
6708
|
+
* @param id - The loyalty program ID
|
|
6709
|
+
* @param data - The fields to update
|
|
6710
|
+
* @param options - Request options including locale and abort signal
|
|
6711
|
+
* @returns The updated loyalty program
|
|
6712
|
+
* @throws {SmartbillsNotFoundError} If the loyalty program is not found
|
|
6713
|
+
* @throws {SmartbillsValidationError} If the provided data fails validation
|
|
6714
|
+
*/
|
|
6715
|
+
update(id: string, data: LoyaltyProgramUpdateRequest, options?: RequestOptions): Promise<SBLoyaltyProgram>;
|
|
6716
|
+
/**
|
|
6717
|
+
* Deletes a loyalty program.
|
|
6718
|
+
*
|
|
6719
|
+
* @param id - The loyalty program ID
|
|
6720
|
+
* @param options - Request options including locale and abort signal
|
|
6721
|
+
* @throws {SmartbillsNotFoundError} If the loyalty program is not found
|
|
6722
|
+
*/
|
|
6723
|
+
delete(id: string, options?: RequestOptions): Promise<void>;
|
|
6724
|
+
}
|
|
6725
|
+
|
|
6726
|
+
/**
|
|
6727
|
+
* Configuration options for initializing a {@link SmartbillsClient}.
|
|
6728
|
+
*/
|
|
5724
6729
|
interface SmartbillsClientOptions {
|
|
6730
|
+
/** Override the Smartbills API base URL. Defaults to `https://api.smartbills.io`. */
|
|
5725
6731
|
baseUrl?: string;
|
|
6732
|
+
/** OAuth2 access token for authenticating requests. */
|
|
5726
6733
|
accessToken?: string;
|
|
6734
|
+
/** Business ID to scope all requests to a specific business tenant. */
|
|
5727
6735
|
businessId?: number;
|
|
6736
|
+
/** Locale code for localized API responses (e.g., "en-CA", "fr-CA"). */
|
|
5728
6737
|
locale?: string;
|
|
6738
|
+
/** Request timeout in milliseconds. */
|
|
5729
6739
|
timeout?: number;
|
|
6740
|
+
/** Maximum number of automatic retries on transient failures. */
|
|
5730
6741
|
maxRetries?: number;
|
|
6742
|
+
/** Delay in milliseconds between retries. */
|
|
5731
6743
|
retryDelay?: number;
|
|
5732
6744
|
}
|
|
5733
6745
|
declare const DEFAULT_BASE_URL = "https://api.smartbills.io";
|
|
5734
6746
|
|
|
6747
|
+
/**
|
|
6748
|
+
* The main entry point for the Smartbills SDK.
|
|
6749
|
+
*
|
|
6750
|
+
* Provides access to all Smartbills API services through a single client instance.
|
|
6751
|
+
* Handles authentication, business context, and locale configuration.
|
|
6752
|
+
*
|
|
6753
|
+
* @example
|
|
6754
|
+
* ```typescript
|
|
6755
|
+
* const client = new SmartbillsClient({
|
|
6756
|
+
* accessToken: "your-access-token",
|
|
6757
|
+
* businessId: 42,
|
|
6758
|
+
* locale: "en-CA",
|
|
6759
|
+
* });
|
|
6760
|
+
*
|
|
6761
|
+
* const expenses = await client.expenses.listBusiness({ limit: 25 });
|
|
6762
|
+
* const report = await client.expenseReports.create({ name: "Q1 Travel" });
|
|
6763
|
+
* ```
|
|
6764
|
+
*/
|
|
5735
6765
|
declare class SmartbillsClient {
|
|
5736
6766
|
protected readonly http: HttpClient;
|
|
5737
6767
|
readonly users: UserService;
|
|
@@ -5762,23 +6792,63 @@ declare class SmartbillsClient {
|
|
|
5762
6792
|
readonly tables: TableService;
|
|
5763
6793
|
readonly billing: BillingService;
|
|
5764
6794
|
readonly workflows: WorkflowService;
|
|
6795
|
+
readonly customers: CustomerService;
|
|
6796
|
+
readonly departments: DepartmentService;
|
|
6797
|
+
readonly products: ProductService;
|
|
6798
|
+
readonly taxes: TaxService;
|
|
6799
|
+
readonly promoCodes: PromoCodeService;
|
|
6800
|
+
readonly categories: CategoryService;
|
|
6801
|
+
readonly employees: EmployeeService;
|
|
6802
|
+
readonly attachments: AttachmentService;
|
|
6803
|
+
readonly emailForwarding: EmailForwardingService;
|
|
6804
|
+
readonly authorizedSenders: AuthorizedSenderService;
|
|
6805
|
+
readonly loyalty: LoyaltyService;
|
|
6806
|
+
/**
|
|
6807
|
+
* Creates a new Smartbills client instance.
|
|
6808
|
+
*
|
|
6809
|
+
* @param options - Configuration options for the client (base URL, auth token, business ID, locale, retry settings)
|
|
6810
|
+
*/
|
|
5765
6811
|
constructor(options?: SmartbillsClientOptions);
|
|
6812
|
+
/** Sets the OAuth2 access token used for authenticating API requests. */
|
|
5766
6813
|
setAccessToken(token: string | undefined): void;
|
|
6814
|
+
/** Sets the business context for multi-tenant API requests. */
|
|
5767
6815
|
setBusinessId(id: number | undefined): void;
|
|
6816
|
+
/** Sets the locale for localized API responses (e.g., "en-CA", "fr-CA"). */
|
|
5768
6817
|
setLocale(locale: string | undefined): void;
|
|
6818
|
+
/** The current OAuth2 access token, if set. */
|
|
5769
6819
|
get accessToken(): string | undefined;
|
|
6820
|
+
/** The current business ID context, if set. */
|
|
5770
6821
|
get businessId(): number | undefined;
|
|
6822
|
+
/** The current locale for API responses, if set. */
|
|
5771
6823
|
get locale(): string | undefined;
|
|
5772
6824
|
}
|
|
5773
6825
|
|
|
6826
|
+
/**
|
|
6827
|
+
* Interface for providing access credentials to the Smartbills SDK.
|
|
6828
|
+
*
|
|
6829
|
+
* Implement this interface to supply custom credential retrieval logic,
|
|
6830
|
+
* such as refreshing tokens from an auth provider.
|
|
6831
|
+
*/
|
|
5774
6832
|
interface CredentialProvider {
|
|
6833
|
+
/** Returns the current access token, or `undefined` if not authenticated. */
|
|
5775
6834
|
getAccessToken(): string | undefined;
|
|
6835
|
+
/** Optional callback invoked when the current token has expired, allowing automatic refresh. */
|
|
5776
6836
|
onTokenExpired?(): Promise<string | undefined>;
|
|
5777
6837
|
}
|
|
6838
|
+
/**
|
|
6839
|
+
* Simple credential provider that stores an access token in memory.
|
|
6840
|
+
*
|
|
6841
|
+
* @example
|
|
6842
|
+
* ```typescript
|
|
6843
|
+
* const cred = new AccessToken("my-jwt-token");
|
|
6844
|
+
* console.log(cred.getAccessToken()); // "my-jwt-token"
|
|
6845
|
+
* ```
|
|
6846
|
+
*/
|
|
5778
6847
|
declare class AccessToken implements CredentialProvider {
|
|
5779
6848
|
private token?;
|
|
5780
6849
|
constructor(token?: string);
|
|
5781
6850
|
getAccessToken(): string | undefined;
|
|
6851
|
+
/** Updates the stored access token. Pass `undefined` to clear it. */
|
|
5782
6852
|
setToken(token: string | undefined): void;
|
|
5783
6853
|
}
|
|
5784
6854
|
|
|
@@ -5922,5 +6992,7 @@ declare function isConflictError(error: unknown): error is SmartbillsConflictErr
|
|
|
5922
6992
|
declare function isQuotaError(error: unknown): error is SmartbillsQuotaError;
|
|
5923
6993
|
declare function isRetryableError(error: unknown): boolean;
|
|
5924
6994
|
|
|
5925
|
-
|
|
5926
|
-
|
|
6995
|
+
declare function uploadFileToS3(uploadUrl: string, file: Blob | ArrayBuffer, contentType: string): Promise<void>;
|
|
6996
|
+
|
|
6997
|
+
export { AccessToken, AppInstallationService, AppInstallationStatus, ApprobationService, AttachmentService, AuthorizedSenderService, BaseService, BillApprovalStatus, BillApprovalType, BillService, BillStatus, BillingService, BusinessService, BusinessUserService, CategoryService, CheckoutDocumentType, CheckoutPaymentStatus, CheckoutService, CheckoutStatus, ConnectAccountStatus, ConnectService, CustomerService, DEFAULT_BASE_URL, DepartmentService, EmailAccountService, EmailAccountStatus, EmailAccountSyncStatus, EmailAccountType, EmailForwardingService, EmployeeService, ErrorCode, ExpenseItemStatus, ExpenseJobService, ExpenseReportAuditLogAction, ExpenseReportExpenseService, ExpenseReportPaymentService, ExpenseReportService, ExpenseReportStatus, ExpenseService, ExpenseSplitType, HttpClient, IntegrationService, IntegrationStatus, InvitationService, InvitationStatus, LocationService, LoyaltyService, MailboxType, MembershipRole, MembershipService, NotificationService, NotificationType, PayerType, PaymentMethodService, ProductService, PromoCodeService, ReceiptPaymentStatus, ReceiptPaymentType, ReceiptService, ReceiptSource, ReceiptType, ReportingService, SmartbillsApiError, SmartbillsAuthenticationError, SmartbillsClient, SmartbillsConflictError, SmartbillsError, SmartbillsNetworkError, SmartbillsNotFoundError, SmartbillsPermissionError, SmartbillsQuotaError, SmartbillsRateLimitError, SmartbillsValidationError, SyncTriggerType, TableService, TaxService, TransactionService, TransactionType, UserService, VendorConnectionService, VendorConnectionStatus, VendorService, WorkflowService, WorkflowTriggerType, isApiError, isAuthenticationError, isConflictError, isNetworkError, isNotFoundError, isPermissionError, isQuotaError, isRateLimitError, isRetryableError, isSmartbillsError, isValidationError, uploadFileToS3 };
|
|
6998
|
+
export type { AddExpenseToReportRequest, AddExpensesToReportBatchRequest, ApprobationListRequest, AssociateExpenseReportUpdateRequest, AttachmentListRequest, AttachmentRenameRequest, BillApprovalRequest, BillBatchUpdateRequest, BillCancelRequest, BillCreateRequest, BillListRequest, BillMarkPaidRequest, BillReschedulePaymentRequest, BillRetryPaymentRequest, BillSchedulePaymentRequest, BillSubmitForApprovalRequest, BillTransitionRequest, BillUpdateRequest, BulkAssignCategoryRequest, BulkAssignExpenseReportRequest, BulkAssignPayerTypeRequest, BulkAssignReportCategoryRequest, BulkAssignVendorRequest, BulkBillApproveRequest, BulkBillCancelPaymentRequest, BulkBillDeleteRequest, BulkBillMarkPaidRequest, BulkBillRemindRequest, BulkBillRetryPaymentRequest, BulkBillSchedulePaymentRequest, BulkBillUnscheduleRequest, BulkBillUpdateRequest, BulkDeleteExpenseReportsRequest, BulkDeleteExpensesRequest, BulkDeleteVendorsRequest, BulkRemoveReportExpensesRequest, BulkSetNoteRequest, BusinessBatchUpdateRequest, BusinessBrandCreateRequest, BusinessCreateRequest, BusinessUpdateRequest, CategoryCreateRequest, CategoryUpdateRequest, ConfirmUploadFileRequest, ConfirmUploadRequest, ConnectOnboardingRequest, CreateAuthorizedSenderRequest, CreateCheckoutPaymentIntentRequest, CreatePaymentMethodRequest, CreatePortalSessionRequest, CredentialProvider, CustomerCreateRequest, CustomerListRequest, CustomerUpdateRequest, DepartmentCreateRequest, DepartmentListRequest, DepartmentUpdateRequest, EditExpenseInReportRequest, EmailAccountImapCreateRequest, EmailAccountListRequest, EmailAccountOAuth2CreateRequest, EmailAccountUpdateRequest, EmailForwardingConfigRequest, EmployeeBulkAssignManagerRequest, EmployeeCreateRequest, EmployeeListRequest, EmployeeSetManagerRequest, EmployeeUpdateRequest, ErrorCodeType, ExpenseAttachmentDownloadRequest, ExpenseCategoryUpdateRequest, ExpenseExportRequest, ExpenseJobListRequest, ExpenseListRequest, ExpenseNoteUpdateRequest, ExpenseOverTimeRequest, ExpenseReportApproveRequest, ExpenseReportAssignLedgerAccountRequest, ExpenseReportCommentCreateRequest, ExpenseReportCreateRequest, ExpenseReportExportRequest, ExpenseReportListRequest, ExpenseReportPartialReimburseRequest, ExpenseReportPlanReimbursementRequest, ExpenseReportRecallRequest, ExpenseReportReimburseRequest, ExpenseReportRejectRequest, ExpenseReportRequestChangesRequest, ExpenseReportUpdateRequest, ExpenseReviewUpdateRequest, ExpenseSplitItem, ExpenseSplitLineItem, ExpenseSplitRequest, HistoricalSyncRequest, HttpClientConfig, IntegrationCallbackRequest, IntegrationListRequest, InvitationCreateRequest, InvitationListRequest, InvoiceListRequest, LocationBatchCreateRequest, LocationBatchUpdateRequest, LocationCreateRequest, LocationImageUrlRequest, LocationListRequest, LocationUpdateRequest, LoyaltyProgramCreateRequest, LoyaltyProgramListRequest, LoyaltyProgramStatus, LoyaltyProgramUpdateRequest, LoyaltyRewardType, LoyaltyRuleType, MailboxUpdateRequest, MembershipCreateRequest, MembershipEmailInviteRequest, MembershipListRequest, MembershipRoleUpdateRequest, NotificationListRequest, PaginateBusinessRequest, PaginateTransactionRequest, PaginationRequest, PaymentMethodListRequest, PresignedUploadFileRequest, PresignedUploadFileResponse, PresignedUploadRequest, PresignedUploadResponse, ProductListRequest, ReceiptCreateRequest, ReceiptListRequest, ReceiptOCRCreateRequest, ReceiptUpdateRequest, RefundCheckoutPaymentRequest, ReportDateRange, ReportingRequest, RequestOptions, SBAddress, SBAppInstallation, SBApprobationSummary, SBAttachment, SBAuthorizedSender, SBBatchResponse, SBBill, SBBillApproval, SBBillApprovalHistoryItem, SBBillAttachment, SBBillBulkActionResponse, SBBillLineItem, SBBillStatusSummary, SBBillTax, SBBillTransitionResponse, SBBillingAddress, SBBillingPaymentMethod, SBBillingPlan, SBBillingUsage, SBBulkActionResponse, SBBulkActionResult, SBBusiness, SBBusinessBrand, SBBusinessPlan, SBCategory, SBCategoryRuleData, SBCheckoutLineItem, SBCheckoutPayment, SBCheckoutPaymentDispute, SBCheckoutPaymentRefund, SBCheckoutTax, SBCheckoutTransactionResponse, SBConnectAccount, SBConnectAccountRequirements, SBConnectDashboardResponse, SBConnectOnboardingResponse, SBCoordinate, SBCreateCheckoutPaymentIntentResponse, SBCustomer, SBDepartment, SBDepartmentMember, SBDowngradeValidation, SBEmailAccount, SBEmailAccountAuthorizeResponse, SBEmailForwardingConfig, SBEmployee, SBEmployeeCategoryBreakdownReport, SBEmployeeDepartment, SBEmployeeLocation, SBEmployeeManager, SBEntity, SBExpenseBulkActionResponse, SBExpenseByCategoryReport, SBExpenseByDayReport, SBExpenseByEmployeeReport, SBExpenseByVendorReport, SBExpenseJob, SBExpenseMonthlySummary, SBExpenseOverTimeDataPoint, SBExpenseOverTimeReport, SBExpenseReport, SBExpenseReportAuditLogEntry, SBExpenseReportBulkActionResponse, SBExpenseReportComment, SBExpenseReportItem, SBExpenseReportSummary, SBExpenseReportTimelineEntry, SBExpenseValidateResponse, SBFileDownloadResponse, SBHistoricalSyncResponse, SBIntegration, SBIntegrationAuthorizeResponse, SBInvitation, SBInvoice, SBInvoiceLine, SBItemVariationRuleData, SBListResponse, SBLocation, SBLocationImage, SBLoyaltyProgram, SBLoyaltyRule, SBLoyaltyRuleBase, SBMailbox, SBMarketplaceApp, SBMembership, SBMerchantLedger, SBMoney, SBNotification, SBPagination, SBPaymentMethod, SBPaymentMethodBillingDetails, SBPaymentMethodSetupIntentResponse, SBPortalSession, SBProduct, SBPromoCode, SBReceipt, SBReceiptBarcode, SBReceiptBusiness, SBReceiptCustomer, SBReceiptDiscount, SBReceiptDocument, SBReceiptFee, SBReceiptLineItem, SBReceiptPayment, SBReceiptPaymentCard, SBReceiptRefund, SBReceiptTax, SBReceiptTransaction, SBReceiptVendor, SBSessionTokenResponse, SBSetupIntent, SBSharedMailbox, SBSpendRuleData, SBSubscription, SBSyncSession, SBTable, SBTableColumn, SBTableRow, SBTax, SBTaxByCategoryReport, SBTaxByTypeReport, SBTaxByVendorReport, SBTaxSummaryReport, SBTimestamps, SBTransaction, SBTransactionAttachment, SBTransactionMerchant, SBTransactionTax, SBTransactionUploadResponse, SBTransactionVendor, SBUpcomingInvoice, SBUserAccount, SBValidateEmailResponse, SBValidateSharedMailboxResponse, SBVendor, SBVendorBulkActionResponse, SBVendorConnectResponse, SBVendorConnection, SBVendorImportResult, SBVisitRuleData, SBWorkflow, SBWorkflowCondition, SBWorkflowStep, SBWorkflowTestResponse, SmartbillsClientOptions, SmartbillsFieldError, SubmitDisputeEvidenceRequest, SyncSessionListRequest, TableCreateRequest, TableListRequest, TableUpdateRequest, TaxListRequest, TransactionBatchUpdateRequest, TransactionUpdateRequest, UpdateInstallationStatusRequest, UpgradeSubscriptionRequest, UsageHistoryRequest, UserUpdateRequest, VendorBatchUpdateRequest, VendorConnectRequest, VendorCreateRequest, VendorListRequest, VendorMergeRequest, VendorUpdateRequest, WorkflowCreateRequest, WorkflowListRequest, WorkflowTestRequest, WorkflowUpdateRequest };
|