UNPKG

@pipedream/quickbooks

Version:

Pipedream Quickbooks Components

74 lines (65 loc) 1.76 kB
import { ConfigurationError } from "@pipedream/platform"; import quickbooks from "../../quickbooks.app.mjs"; export default { key: "quickbooks-search-accounts", name: "Search Accounts", description: "Search for accounts. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/account#query-an-account)", version: "0.2.10", type: "action", props: { quickbooks, maxResults: { propDefinition: [ quickbooks, "maxResults", ], }, orderClause: { propDefinition: [ quickbooks, "orderClause", ], }, startPosition: { description: "The starting count of the response for pagination.", label: "Start Position", optional: true, type: "string", }, whereClause: { propDefinition: [ quickbooks, "whereClause", ], optional: false, }, }, async run({ $ }) { if (!this.whereClause) { throw new ConfigurationError("Must provide whereClause parameter."); } let orderClause = ""; if (this.orderClause) { orderClause = ` ORDERBY ${this.orderClause}`; } let startPosition = ""; if (this.startPosition) { startPosition = ` STARTPOSITION ${this.startPosition}`; } let maxResults = ""; if (this.maxResults) { maxResults = ` MAXRESULTS ${this.maxResults}`; } const query = `select * from Account where ${this.whereClause}${orderClause}${startPosition}${maxResults}`; const response = await this.quickbooks.query({ $, params: { query, }, }); if (response) { $.export("summary", "Successfully retrieved accounts"); } return response; }, };