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.
24 lines (23 loc) • 681 B
JavaScript
/**
* Get Bill by ID
* @param this - The Bill API
* @param id - The ID of the bill
* @returns The Bill
*/
export async function getBillById(id) {
// Get the Query Builder
const queryBuilder = await this.getQueryBuilder();
// Setup ID Filter
queryBuilder.whereId(id);
// Setup the URL
const url = queryBuilder.build();
// Get the Bill
const response = await this.apiClient.runRequest(url, { method: 'GET' });
// Check if the Response Failed to find an Bill
if (!response)
throw new Error('Bill not found');
// Format the Response
const bills = this.formatResponse(response);
// Return the Bill
return bills[0];
}