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.
27 lines (26 loc) • 842 B
JavaScript
/**
* Get Account by ID
* @param this - The Account API
* @param id - The ID of the account
* @returns The Account
*/
export async function getAccountById(id, options = {}) {
// Get the Query Builder
const queryBuilder = await this.getQueryBuilder();
// Setup ID Filter
queryBuilder.whereId(id);
// Setup the Search Options (if provided)
if (options.searchOptions)
queryBuilder.setSearchOptions(options.searchOptions);
// Setup the URL
const url = queryBuilder.build();
// Get the Account
const response = await this.apiClient.runRequest(url, { method: 'GET' });
// Check if the Response Failed to find an Account
if (!response)
return null;
// Format the Response
const accounts = this.formatResponse(response);
// Return the Account
return accounts[0];
}