Skip to content

Commit

Permalink
add get-payment
Browse files Browse the repository at this point in the history
  • Loading branch information
michelle0927 committed Nov 22, 2024
1 parent 92a5c92 commit 01761c2
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 1 deletion.
44 changes: 44 additions & 0 deletions components/quickbooks/actions/get-payment/get-payment.mjs
Original file line number Diff line number Diff line change
@@ -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;
},
};
27 changes: 26 additions & 1 deletion components/quickbooks/quickbooks.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export default {
optional: true,
},
purchaseId: {
label: "purchase Id",
label: "Purchase Id",
type: "string",
description: "Id of the purchase.",
withLabel: true,
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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`,
Expand Down

0 comments on commit 01761c2

Please sign in to comment.