@robinpath/xero
0.1.1Node.jsPublicXero module for RobinPath.
Xero
Xero module for RobinPath.
Package: @robinpath/xero | Category: Finance | Type: Integration
Authentication
xero.setCredentials "your-credentials"
Call this once at the start of your script before using any other function. Credentials persist for the duration of the script execution.
Use Cases
Use the xero module when you need to:
- listInvoices -- Use
xero.listInvoicesto perform this operation - getInvoice -- Use
xero.getInvoiceto perform this operation - createInvoice -- Use
xero.createInvoiceto perform this operation - updateInvoice -- Use
xero.updateInvoiceto perform this operation - sendInvoice -- Use
xero.sendInvoiceto perform this operation
Quick Reference
| Function | Description | Returns |
|---|---|---|
setCredentials | Configure xero credentials. | object |
listInvoices | listInvoices | object |
getInvoice | getInvoice | object |
createInvoice | createInvoice | object |
updateInvoice | updateInvoice | object |
sendInvoice | sendInvoice | object |
voidInvoice | voidInvoice | object |
listContacts | listContacts | object |
getContact | getContact | object |
createContact | createContact | object |
updateContact | updateContact | object |
listAccounts | listAccounts | object |
getAccount | getAccount | object |
listBankTransactions | listBankTransactions | object |
createBankTransaction | createBankTransaction | object |
listPayments | listPayments | object |
createPayment | createPayment | object |
listItems | listItems | object |
createItem | createItem | object |
getOrganization | getOrganization | object |
getReport | getReport | object |
Functions
setCredentials
Configure xero credentials.
Module: xero | Returns: object -- API response.
xero.setCredentials
| Parameter | Type | Required | Description |
|---|---|---|---|
accessToken | string | Yes | accessToken |
tenantId | string | Yes | tenantId |
listInvoices
listInvoices
Module: xero | Returns: object -- API response.
xero.listInvoices
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
getInvoice
getInvoice
Module: xero | Returns: object -- API response.
xero.getInvoice
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
createInvoice
createInvoice
Module: xero | Returns: object -- API response.
xero.createInvoice
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
updateInvoice
updateInvoice
Module: xero | Returns: object -- API response.
xero.updateInvoice
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
sendInvoice
sendInvoice
Module: xero | Returns: object -- API response.
xero.sendInvoice
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
voidInvoice
voidInvoice
Module: xero | Returns: object -- API response.
xero.voidInvoice
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
listContacts
listContacts
Module: xero | Returns: object -- API response.
xero.listContacts
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
getContact
getContact
Module: xero | Returns: object -- API response.
xero.getContact
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
createContact
createContact
Module: xero | Returns: object -- API response.
xero.createContact
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
updateContact
updateContact
Module: xero | Returns: object -- API response.
xero.updateContact
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
listAccounts
listAccounts
Module: xero | Returns: object -- API response.
xero.listAccounts
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
getAccount
getAccount
Module: xero | Returns: object -- API response.
xero.getAccount
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
listBankTransactions
listBankTransactions
Module: xero | Returns: object -- API response.
xero.listBankTransactions
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
createBankTransaction
createBankTransaction
Module: xero | Returns: object -- API response.
xero.createBankTransaction
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
listPayments
listPayments
Module: xero | Returns: object -- API response.
xero.listPayments
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
createPayment
createPayment
Module: xero | Returns: object -- API response.
xero.createPayment
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
listItems
listItems
Module: xero | Returns: object -- API response.
xero.listItems
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
createItem
createItem
Module: xero | Returns: object -- API response.
xero.createItem
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
getOrganization
getOrganization
Module: xero | Returns: object -- API response.
xero.getOrganization
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
getReport
getReport
Module: xero | Returns: object -- API response.
xero.getReport
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
Error Handling
All functions throw on failure. Common errors:
| Error | Cause |
|---|---|
Xero API error (${res.status}): ${t} | Check the error message for details |
xero.setCredentials requires accessToken, tenantId. | Check the error message for details |
xero.updateInvoice requires an ID. | Check the error message for details |
xero.voidInvoice requires an ID. | Check the error message for details |
xero.updateContact requires an ID. | Check the error message for details |
Xero: "..." not configured. Call xero.setCredentials first. | Check the error message for details |
@desc "List invoices and validate result"
do
set $result as xero.listInvoices
if $result != null
print "Success"
else
print "No result"
end
enddo
Recipes
1. List and iterate Invoices
Retrieve all items and loop through them.
@desc "Setup authentication"
do
xero.setCredentials $token
enddo
@desc "List invoices and iterate results"
do
set $result as xero.listInvoices
each $item in $result
print $item
end
enddo
2. Create a new item with createInvoice
Create a new resource and capture the result.
@desc "Setup authentication"
do
xero.setCredentials $token
enddo
@desc "Create invoice"
do
set $result as xero.createInvoice
print "Created: " + $result
enddo
3. Create and update workflow
Create an item and then update it.
@desc "Setup authentication"
do
xero.setCredentials $token
enddo
@desc "Create invoice and update invoice"
do
set $created as xero.createInvoice
# Update the created item
xero.updateInvoice
enddo
4. Check before creating
List existing items and only create if needed.
@desc "Setup authentication"
do
xero.setCredentials $token
enddo
@desc "List invoices and create invoice"
do
set $existing as xero.listInvoices
if $existing == null
xero.createInvoice
print "Item created"
else
print "Item already exists"
end
enddo
5. Multi-step Xero workflow
Chain multiple xero operations together.
@desc "Setup authentication"
do
xero.setCredentials $token
enddo
@desc "List invoices, get invoice, and more"
do
set $r_listInvoices as xero.listInvoices
set $r_getInvoice as xero.getInvoice
set $r_createInvoice as xero.createInvoice
print "All operations complete"
enddo
6. Safe listInvoices with validation
Check results before proceeding.
@desc "Setup authentication"
do
xero.setCredentials $token
enddo
@desc "List invoices and validate result"
do
set $result as xero.listInvoices
if $result != null
print "Success: " + $result
else
print "Operation returned no data"
end
enddo
Related Modules
- quickbooks -- QuickBooks module for complementary functionality
- freshbooks -- FreshBooks module for complementary functionality
- invoice -- Invoice module for complementary functionality
- json -- JSON module for complementary functionality
Versions (1)
| Version | Tag | Published |
|---|---|---|
| 0.1.1 | latest | 1 months ago |
$ robinpath add @robinpath/xero
