xero-node
Advanced tools
Comparing version 2.5.2 to 2.5.3
@@ -6,3 +6,3 @@ The following examples explain the Contacts section of the SDK. The API documentation on Contacts can be found [here](https://developer.xero.com/documentation/api/contacts). | ||
* Create New Contacts | ||
* Retrieve Contacts (all, paginated, by ID, with 'where' clause) | ||
* Retrieve Contacts (all, paginated, by ID, by List of IDs, or with 'where' clause) | ||
* Update Contacts | ||
@@ -121,2 +121,24 @@ | ||
### Retrieving Contacts by list of IDs | ||
This example shows how to retrieve a list of contacts using their Xero supplied GUIDs. | ||
```javascript | ||
let myContactIDs = ['id1', 'id2', ...ids]; | ||
xeroClient.core.contacts.getContacts({ | ||
params: { | ||
IDs: myContactIDs.toString() | ||
} | ||
}) | ||
.then(function(contacts) { | ||
//We've got our contacts so do something useful | ||
contacts.forEach(function(contact){ | ||
//do something useful | ||
console.log(contact.Name); | ||
}); | ||
}); | ||
``` | ||
### Retrieving Contacts with filters | ||
@@ -123,0 +145,0 @@ |
@@ -6,3 +6,3 @@ The following examples explain the Invoices section of the SDK. The API documentation on Invoices can be found [here](https://developer.xero.com/documentation/api/invoices). | ||
* Create New Invoices | ||
* Retrieve Invoices (all, paginated, by ID, with 'where' clause) | ||
* Retrieve Invoices (all, paginated, by ID, by Contact IDs/Invoice Numbers/Statuses, or with 'where' clause) | ||
* Update Invoices | ||
@@ -120,2 +120,86 @@ | ||
### Retrieving Invoice by Invoice IDs List | ||
This example shows how to retrieve a list of invoices using their Xero supplied GUIDs. | ||
```javascript | ||
var myInvoiceIDs = ['id1', 'id2', ...ids]; | ||
xeroClient.core.invoices.getInvoices({ | ||
params: { | ||
IDs: myInvoiceIDs.toString() | ||
} | ||
}) | ||
.then(function(invoices) { | ||
invoices.forEach(function(invoice){ | ||
//do something useful | ||
console.log(invoice.Type); //ACCPAY | ||
}); | ||
}); | ||
``` | ||
### Retrieving Invoice by Contact IDs List | ||
This example shows how to retrieve a list of invoices using their associated Contact GUIDs. | ||
```javascript | ||
var myContactIDs = ['id1', 'id2', ...ids]; | ||
xeroClient.core.invoices.getInvoices({ | ||
params: { | ||
ContactIDs: myContactIDs.toString() | ||
} | ||
}) | ||
.then(function(invoices) { | ||
invoices.forEach(function(invoice){ | ||
//do something useful | ||
console.log(invoice.Type); //ACCPAY | ||
}); | ||
}); | ||
``` | ||
### Retrieving Invoice by Invoice Numbers List | ||
This example shows how to retrieve a list of invoices using their associated Invoice Numbers. | ||
```javascript | ||
var myInvoiceNumbers = ['ORC1001', 'ORC1002', ...numbers]; | ||
xeroClient.core.invoices.getInvoices({ | ||
params: { | ||
InvoiceNumbers: myInvoiceNumbers.toString() | ||
} | ||
}) | ||
.then(function(invoices) { | ||
invoices.forEach(function(invoice){ | ||
//do something useful | ||
console.log(invoice.Type); //ACCPAY | ||
}); | ||
}); | ||
``` | ||
### Retrieving Invoices by Statuses | ||
This example shows how to retrieve a list of invoices using their statuses without requiring a 'Where' clause. | ||
```javascript | ||
var myStatuses = ['PAID', 'VOIDED']; | ||
xeroClient.core.invoices.getInvoices({ | ||
params: { | ||
Statuses: myStatuses.toString() | ||
} | ||
}) | ||
.then(function(invoices) { | ||
invoices.forEach(function(invoice){ | ||
//do something useful | ||
console.log(invoice.Type); //ACCPAY | ||
}); | ||
}); | ||
``` | ||
### Retrieving Invoices with filters | ||
@@ -122,0 +206,0 @@ |
@@ -13,2 +13,3 @@ ## Welcome to the Xero-Node Docs! | ||
* [Accounts](./Accounts.md) | ||
* [Attachments](./Attachments.md) | ||
* [Bank Transactions](./Bank-Transactions.md) | ||
@@ -24,4 +25,6 @@ * [Bank Transfers](./Bank-Transfers.md) | ||
* [Journals](./Journals.md) | ||
* [Manual Journals](./Manual-Journals.md) | ||
* [Organisations](./Organisations.md) | ||
* [Payments](./Payments.md) | ||
* [Repeating Invoices](./Repeating-Invoices.md) | ||
* [Reports (except BAS/GST)](./Reports.md) | ||
@@ -34,3 +37,2 @@ * [Tax Rates](./Tax-Rates.md) | ||
* Attachments | ||
* Contact Groups | ||
@@ -40,3 +42,2 @@ * Employees (not Payroll) | ||
* Linked Transactions | ||
* Manual Journals | ||
* Overpayments | ||
@@ -47,3 +48,2 @@ * Prepayments | ||
* Receipts | ||
* Repeating Invoices | ||
* Setup | ||
@@ -50,0 +50,0 @@ |
{ | ||
"name": "xero-node", | ||
"version": "2.5.2", | ||
"version": "2.5.3", | ||
"description": "Xero API Wrapper for all application types", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -34,2 +34,3 @@ xero-node (alpha) | ||
* Payments | ||
* Repeating Invoices | ||
* Reports | ||
@@ -216,2 +217,5 @@ * Tax Rates | ||
* 2.5.3 | ||
- Merged [PR#76](https://github.com/XeroAPI/xero-node/pull/76) - Updated the docs to add repeating invoices (missed from PR#72). | ||
- Merged [PR#75](https://github.com/XeroAPI/xero-node/pull/75) - Added documentation about invoice/contact filters. | ||
* 2.5.2 | ||
@@ -218,0 +222,0 @@ - Merged [PR#72](https://github.com/XeroAPI/xero-node/pull/72) - Fix for Issue#71 to add support for the repeating invoices endpoint. |
@@ -19,2 +19,4 @@ 'use strict'; | ||
let contactIDsList = []; | ||
const newName = `Updated ${Math.random()}`; | ||
@@ -45,3 +47,3 @@ | ||
}); | ||
it.skip('get - modifiedAfter', done => { | ||
it('get - modifiedAfter', done => { | ||
const modifiedAfter = new Date(); | ||
@@ -71,2 +73,6 @@ | ||
expect(contact.ContactID).to.not.equal(undefined); | ||
if(contactIDsList.length < 5) { | ||
contactIDsList.push(contact.ContactID); | ||
} | ||
}); | ||
@@ -116,2 +122,23 @@ done(); | ||
}); | ||
it('get list of IDs', done => { | ||
currentApp.core.contacts | ||
.getContacts({ | ||
params: { | ||
IDs: contactIDsList.toString() | ||
} | ||
}) | ||
.then(contacts => { | ||
contacts.forEach(contact => { | ||
expect(contact.ContactID).to.be.oneOf(contactIDsList); | ||
}); | ||
done(); | ||
}) | ||
.catch(err => { | ||
console.error(util.inspect(err, null, null)); | ||
done(wrapError(err)); | ||
}); | ||
}); | ||
it('get - invalid modified date', done => { | ||
@@ -118,0 +145,0 @@ currentApp.core.contacts |
@@ -34,2 +34,6 @@ 'use strict'; | ||
let salesAccountCode = ''; | ||
let invoiceIDsList = []; | ||
let invoiceNumbersList = []; | ||
let statusesList = []; | ||
let contactIDsList = []; | ||
@@ -93,2 +97,14 @@ before('create a sales account for testing', () => | ||
expect(validateInvoice(invoice)).to.equal(true); | ||
if(invoiceIDsList.length < 5) { | ||
invoiceIDsList.push(invoice.InvoiceID); | ||
} | ||
if(invoiceNumbersList.length < 5) { | ||
invoiceNumbersList.push(invoice.InvoiceNumber); | ||
} | ||
if(contactIDsList.length < 5) { | ||
contactIDsList.push(invoice.Contact.ContactID); | ||
} | ||
}); | ||
@@ -115,2 +131,74 @@ | ||
}); | ||
it('get invoices by invoiceIDs', done => { | ||
currentApp.core.invoices | ||
.getInvoices({ | ||
params: { | ||
IDs: invoiceIDsList.toString() | ||
} | ||
}) | ||
.then(invoices => { | ||
invoices.forEach(invoice => { | ||
expect(invoice.InvoiceID).to.be.oneOf(invoiceIDsList); | ||
}); | ||
done(); | ||
}) | ||
.catch(err => { | ||
console.error(util.inspect(err, null, null)); | ||
done(wrapError(err)); | ||
}); | ||
}); | ||
it('get invoices by invoice numbers', done => { | ||
currentApp.core.invoices | ||
.getInvoices({ | ||
params: { | ||
InvoiceNumbers: invoiceNumbersList.toString() | ||
} | ||
}) | ||
.then(invoices => { | ||
invoices.forEach(invoice => { | ||
expect(invoice.InvoiceNumber).to.be.oneOf(invoiceNumbersList); | ||
}); | ||
done(); | ||
}) | ||
.catch(err => { | ||
console.error(util.inspect(err, null, null)); | ||
done(wrapError(err)); | ||
}); | ||
}); | ||
it('get invoices by contact ids', done => { | ||
currentApp.core.invoices | ||
.getInvoices({ | ||
params: { | ||
ContactIDs: contactIDsList.toString() | ||
} | ||
}) | ||
.then(invoices => { | ||
invoices.forEach(invoice => { | ||
expect(invoice.Contact.ContactID).to.be.oneOf(contactIDsList); | ||
}); | ||
done(); | ||
}) | ||
.catch(err => { | ||
console.error(util.inspect(err, null, null)); | ||
done(wrapError(err)); | ||
}); | ||
}); | ||
it('get invoices by statuses', done => { | ||
currentApp.core.invoices | ||
.getInvoices({ | ||
params: { | ||
Statuses: "PAID,VOIDED" | ||
} | ||
}) | ||
.then(invoices => { | ||
invoices.forEach(invoice => { | ||
expect(invoice.Status).to.be.oneOf(["PAID","VOIDED"]); | ||
}); | ||
done(); | ||
}) | ||
.catch(err => { | ||
console.error(util.inspect(err, null, null)); | ||
done(wrapError(err)); | ||
}); | ||
}); | ||
it('get invoice with filter', done => { | ||
@@ -117,0 +205,0 @@ const filter = 'Status != "AUTHORISED"'; |
Sorry, the diff of this file is not supported yet
583420
129
8890
438