Socket
Socket
Sign inDemoInstall

xero-node

Package Overview
Dependencies
233
Maintainers
1
Versions
165
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.2.0 to 2.2.1

39

docs/Payments.md

@@ -19,5 +19,6 @@ The following examples explain the Payments section of the SDK. The API documentation on Payments can be found [here](https://developer.xero.com/documentation/api/payments).

* `createPayment(data[, options])`
* `newPayment(data[, options])`
* `getPayments([options])`
* `getPayment(id[, modifiedAfter])`
* `savePayments(data[, options])`

@@ -101,3 +102,3 @@ ### Creating a new payment

//filter payments that are type ACCREC
var filter = 'PaymentType == ACCRECPAYMENT';
var filter = 'PaymentType == "ACCRECPAYMENT'';

@@ -152,2 +153,34 @@ xeroClient.core.payments.getPayments({where: filter})

});
```
```
### Creating multiple payments in one go
You can use the helper function `savePayments` to save an array of payments in one go.
The following code provides guidance on how to set this up:
```javascript
var samplePayment1 = {
//some item...
};
var samplePayment2 = {
//some item...
};
var payments = [];
payments.push(xeroClient.core.payments.newPayment(samplePayment1));
payments.push(xeroClient.core.payments.newPayment(samplePayment));
xeroClient.core.items.savePayments(payments)
.then(function(payments) {
//Payments have been created
var payment1 = payments.entities[0];
var payment2 = payments.entities[1];
})
.catch(function(err) {
//Some error occurred
});
```

2

lib/entities/accounting/payment.js

@@ -30,3 +30,3 @@ var _ = require('lodash'),

entityConstructor: function(data) {
return self.application.core.payments.createPayment(data);
return self.application.core.payments.newPayment(data);
}

@@ -33,0 +33,0 @@ });

@@ -11,3 +11,3 @@ var _ = require('lodash'),

},
createPayment: function(data, options) {
newPayment: function(data, options) {
return new Payment(this.application, data, options);

@@ -21,7 +21,17 @@ },

},
savePayments: function(payments, options) {
return this.saveEntities(payments, this.setUpOptions(options));
},
getPayments: function(options) {
var self = this;
var clonedOptions = _.clone(options || {});
clonedOptions.entityConstructor = function(data) { return self.createPayment(data) };
clonedOptions.entityConstructor = function(data) { return self.newPayment(data) };
return this.getEntities(clonedOptions)
},
setUpOptions: function(options) {
var self = this;
var clonedOptions = _.clone(options || {});
clonedOptions.entityPath = 'Payments.Payment';
clonedOptions.entityConstructor = function(data) { return self.newPayment(data) };
return clonedOptions;
}

@@ -28,0 +38,0 @@ })

{
"name": "xero-node",
"version": "2.2.0",
"version": "2.2.1",
"description": "Xero API Wrapper for all application types",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -199,2 +199,4 @@ xero-node (alpha)

* 2.2.1
- Merged [PR#49](https://github.com/XeroAPI/xero-node/pull/49) - Merge PR#49 to change `createPayment` method to be `newPayment` in line with other entities, and introduce a new savePayments method for creating multiple payments in one call.
* 2.2.0

@@ -201,0 +203,0 @@ - Merged [PR#46](https://github.com/XeroAPI/xero-node/pull/46) - Merge PR#45 and provide library level support for boolean values (formerly this required string conversion).

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc