quickbooks-api
Version:
A modular TypeScript SDK for seamless integration with Intuit QuickBooks APIs. Provides robust authentication handling and future-ready foundation for accounting, payments, and commerce operations.
34 lines (33 loc) • 1.21 kB
JavaScript
/**
* Get Estimates for a Date Range
* @param this - The Estimate API
* @param startDate - The start date
* @param endDate - The end date
* @returns The Estimates
*/
export async function getEstimatesForDateRange(startDate, endDate, options = {}) {
// Ensure the Start Date is Before the End Date
if (startDate > endDate)
throw new Error('Start date must be before end date');
// Get the Query Builder
const queryBuilder = await this.getQueryBuilder();
// Setup the Date Range Filters
queryBuilder.whereLastUpdatedAfter(startDate);
queryBuilder.whereLastUpdatedBefore(endDate);
// Setup the Search Options (if provided)
if (options.searchOptions)
queryBuilder.setSearchOptions(options.searchOptions);
// Setup the URL
const url = queryBuilder.build();
// Get the Estimates
const response = await this.apiClient.runRequest(url, { method: 'GET' });
// Format the Response
const estimates = this.formatResponse(response);
// Setup the Search Response
const searchResponse = {
results: estimates,
hasNextPage: await this.hasNextPage(queryBuilder),
};
// Return the Estimates
return searchResponse;
}