paypal-v2-sdk
Advanced tools
Comparing version 1.1.6 to 1.1.7
@@ -6,3 +6,3 @@ { | ||
"name": "paypal-v2-sdk", | ||
"version": "1.1.6", | ||
"version": "1.1.7", | ||
"description": "Unofficial promise-based PayPal API v2 SDK for node.js", | ||
@@ -9,0 +9,0 @@ "main": "index.js", |
@@ -24,2 +24,19 @@ const PayPalClass = require("../../PayPal"); | ||
/** | ||
* | ||
* @param {Object} query | ||
*/ | ||
async list(query) { | ||
const response = await this.PayPal.Axios.get( | ||
"https://api.paypal.com/v2/invoicing/invoices", | ||
{ | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
params: query, | ||
} | ||
); | ||
return response.data; | ||
} | ||
async create(json) { | ||
@@ -26,0 +43,0 @@ const response = await this.PayPal.Axios.post( |
@@ -33,2 +33,4 @@ const PayPalClass = require("../../PayPal"); | ||
const LinkDescription = require("../../Types/General/LinkDescription"); | ||
const ListInvoicesQuery = require("../../Types/Queries/ListInvoices"); | ||
const ListInvoicesResponse = require("../../Types/Responses/ListInvoices"); | ||
@@ -472,2 +474,17 @@ class Invoices extends InvoicesAPI { | ||
/** | ||
* | ||
* @param {ListInvoicesQuery} query | ||
* @returns {ListInvoicesResponse} | ||
*/ | ||
async list(query) { | ||
const data = await super.list(query.toAttributeObject()); | ||
const listInvoicesResponse = new ListInvoicesResponse(this) | ||
.setItems(data.items?.map((x) => this.constructInvoice(x))) | ||
.setTotalItems(x.total_items) | ||
.setTotalPages(x.total_pages) | ||
.setLinks(x.links); | ||
return listInvoicesResponse; | ||
} | ||
// create new invoice | ||
@@ -506,3 +523,16 @@ // returns invoice object (type) | ||
// uses same builder as create BY ID (can also update via invoice object) | ||
async fullUpdate() {} | ||
/** | ||
* | ||
* @param {Invoice|object} invoiceBuilder | ||
* @returns {Invoice} | ||
*/ | ||
async fullUpdate(invoiceBuilder) { | ||
const data = await super.create( | ||
invoiceBuilder instanceof Invoice | ||
? invoiceBuilder.toJson() | ||
: invoiceBuilder | ||
); | ||
const invoice = this.constructInvoice(data); | ||
return invoice; | ||
} | ||
@@ -509,0 +539,0 @@ // cancel a SENT invoice BY ID (can also cancel via invoice object) |
@@ -33,2 +33,4 @@ const BasePayPal = require("./BasePayPal"); | ||
const InvoicePaymentTerm = require("./Types/Invoices/InvoicePaymentTerm"); | ||
const ListInvoicesQuery = require("./Types/Queries/ListInvoices"); | ||
const ListInvoicesResponse = require("./Types/Responses/ListInvoices"); | ||
@@ -84,2 +86,8 @@ // handlers | ||
}, | ||
queries: { | ||
ListInvoices: ListInvoicesQuery.bind(null, this), | ||
}, | ||
responses: { | ||
ListInvoices: ListInvoicesResponse.bind(null, this), | ||
}, | ||
}; | ||
@@ -86,0 +94,0 @@ } |
@@ -11,2 +11,3 @@ const PayPalClass = require("../../PayPal"); | ||
} | ||
toJson() { | ||
@@ -13,0 +14,0 @@ return JSON.stringify(this.toAttributeObject()); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
87067
43
2972