UNPKG

@pipedream/quickbooks

Version:

Pipedream Quickbooks Components

79 lines (70 loc) 1.87 kB
import { ConfigurationError } from "@pipedream/platform"; import quickbooks from "../../quickbooks.app.mjs"; export default { key: "quickbooks-search-customers", name: "Search Customers", description: "Searches for customers. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/customer#query-a-customer)", version: "0.1.13", annotations: { destructiveHint: false, openWorldHint: true, readOnlyHint: true, }, 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 Customer where ${this.whereClause}${orderClause}${startPosition}${maxResults}`; const response = await this.quickbooks.query({ $, params: { query, }, }); if (response) { $.export("summary", "Successfully retrieved customers"); } return response; }, };