From 01761c2870d7b5c3bbdbb5149cbd856a14f13f90 Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Fri, 22 Nov 2024 15:29:18 -0500 Subject: [PATCH] add get-payment --- .../actions/get-payment/get-payment.mjs | 44 +++++++++++++++++++ components/quickbooks/quickbooks.app.mjs | 27 +++++++++++- 2 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 components/quickbooks/actions/get-payment/get-payment.mjs diff --git a/components/quickbooks/actions/get-payment/get-payment.mjs b/components/quickbooks/actions/get-payment/get-payment.mjs new file mode 100644 index 0000000000000..bbfec932cf87a --- /dev/null +++ b/components/quickbooks/actions/get-payment/get-payment.mjs @@ -0,0 +1,44 @@ +import { ConfigurationError } from "@pipedream/platform"; +import quickbooks from "../../quickbooks.app.mjs"; + +export default { + key: "quickbooks-get-payment", + name: "Get Payment", + description: "Returns info about a payment. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/payment#read-a-payment)", + version: "0.0.1", + type: "action", + props: { + quickbooks, + paymentId: { + propDefinition: [ + quickbooks, + "paymentId", + ], + }, + minorVersion: { + propDefinition: [ + quickbooks, + "minorVersion", + ], + }, + }, + async run({ $ }) { + if (!this.paymentId) { + throw new ConfigurationError("Must provide paymentId parameter."); + } + + const response = await this.quickbooks.getPayment({ + $, + paymentId: this.paymentId, + params: { + minorversion: this.minorVersion, + }, + }); + + if (response) { + $.export("summary", `Successfully retrieved payment with id ${response.Payment.Id}`); + } + + return response; + }, +}; diff --git a/components/quickbooks/quickbooks.app.mjs b/components/quickbooks/quickbooks.app.mjs index 55d74558f571e..42461d42fa4eb 100644 --- a/components/quickbooks/quickbooks.app.mjs +++ b/components/quickbooks/quickbooks.app.mjs @@ -149,7 +149,7 @@ export default { optional: true, }, purchaseId: { - label: "purchase Id", + label: "Purchase Id", type: "string", description: "Id of the purchase.", withLabel: true, @@ -376,6 +376,23 @@ export default { }); }, }, + paymentId: { + type: "string", + label: "Payment Id", + description: "The identifier of a payment", + async options({ page }) { + return this.getPropOptions({ + page, + resource: "Payment", + mapper: ({ + Id: value, CustomerRef: customerRef, TotalAmt: totalAmt, TxnDate: txnDate, + }) => ({ + value, + label: `${customerRef.name} - Amount: ${totalAmt} - ${txnDate}`, + }), + }); + }, + }, }, methods: { _companyId() { @@ -535,6 +552,14 @@ export default { ...opts, }); }, + getPayment({ + paymentId, ...opts + }) { + return this._makeRequest({ + path: `company/${this._companyId()}/payment/${paymentId}`, + ...opts, + }); + }, query(opts = {}) { return this._makeRequest({ path: `company/${this._companyId()}/query`,