Modules@robinpath/xero
xero

@robinpath/xero

0.1.1Node.jsPublic

Xero 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.listInvoices to perform this operation
  • getInvoice -- Use xero.getInvoice to perform this operation
  • createInvoice -- Use xero.createInvoice to perform this operation
  • updateInvoice -- Use xero.updateInvoice to perform this operation
  • sendInvoice -- Use xero.sendInvoice to perform this operation

Quick Reference

FunctionDescriptionReturns
setCredentialsConfigure xero credentials.object
listInvoiceslistInvoicesobject
getInvoicegetInvoiceobject
createInvoicecreateInvoiceobject
updateInvoiceupdateInvoiceobject
sendInvoicesendInvoiceobject
voidInvoicevoidInvoiceobject
listContactslistContactsobject
getContactgetContactobject
createContactcreateContactobject
updateContactupdateContactobject
listAccountslistAccountsobject
getAccountgetAccountobject
listBankTransactionslistBankTransactionsobject
createBankTransactioncreateBankTransactionobject
listPaymentslistPaymentsobject
createPaymentcreatePaymentobject
listItemslistItemsobject
createItemcreateItemobject
getOrganizationgetOrganizationobject
getReportgetReportobject

Functions

setCredentials

Configure xero credentials.

Module: xero | Returns: object -- API response.

xero.setCredentials
ParameterTypeRequiredDescription
accessTokenstringYesaccessToken
tenantIdstringYestenantId

listInvoices

listInvoices

Module: xero | Returns: object -- API response.

xero.listInvoices
ParameterTypeRequiredDescription
inputstringNoInput parameter

getInvoice

getInvoice

Module: xero | Returns: object -- API response.

xero.getInvoice
ParameterTypeRequiredDescription
inputstringNoInput parameter

createInvoice

createInvoice

Module: xero | Returns: object -- API response.

xero.createInvoice
ParameterTypeRequiredDescription
inputstringNoInput parameter

updateInvoice

updateInvoice

Module: xero | Returns: object -- API response.

xero.updateInvoice
ParameterTypeRequiredDescription
inputstringNoInput parameter

sendInvoice

sendInvoice

Module: xero | Returns: object -- API response.

xero.sendInvoice
ParameterTypeRequiredDescription
inputstringNoInput parameter

voidInvoice

voidInvoice

Module: xero | Returns: object -- API response.

xero.voidInvoice
ParameterTypeRequiredDescription
inputstringNoInput parameter

listContacts

listContacts

Module: xero | Returns: object -- API response.

xero.listContacts
ParameterTypeRequiredDescription
inputstringNoInput parameter

getContact

getContact

Module: xero | Returns: object -- API response.

xero.getContact
ParameterTypeRequiredDescription
inputstringNoInput parameter

createContact

createContact

Module: xero | Returns: object -- API response.

xero.createContact
ParameterTypeRequiredDescription
inputstringNoInput parameter

updateContact

updateContact

Module: xero | Returns: object -- API response.

xero.updateContact
ParameterTypeRequiredDescription
inputstringNoInput parameter

listAccounts

listAccounts

Module: xero | Returns: object -- API response.

xero.listAccounts
ParameterTypeRequiredDescription
inputstringNoInput parameter

getAccount

getAccount

Module: xero | Returns: object -- API response.

xero.getAccount
ParameterTypeRequiredDescription
inputstringNoInput parameter

listBankTransactions

listBankTransactions

Module: xero | Returns: object -- API response.

xero.listBankTransactions
ParameterTypeRequiredDescription
inputstringNoInput parameter

createBankTransaction

createBankTransaction

Module: xero | Returns: object -- API response.

xero.createBankTransaction
ParameterTypeRequiredDescription
inputstringNoInput parameter

listPayments

listPayments

Module: xero | Returns: object -- API response.

xero.listPayments
ParameterTypeRequiredDescription
inputstringNoInput parameter

createPayment

createPayment

Module: xero | Returns: object -- API response.

xero.createPayment
ParameterTypeRequiredDescription
inputstringNoInput parameter

listItems

listItems

Module: xero | Returns: object -- API response.

xero.listItems
ParameterTypeRequiredDescription
inputstringNoInput parameter

createItem

createItem

Module: xero | Returns: object -- API response.

xero.createItem
ParameterTypeRequiredDescription
inputstringNoInput parameter

getOrganization

getOrganization

Module: xero | Returns: object -- API response.

xero.getOrganization
ParameterTypeRequiredDescription
inputstringNoInput parameter

getReport

getReport

Module: xero | Returns: object -- API response.

xero.getReport
ParameterTypeRequiredDescription
inputstringNoInput parameter

Error Handling

All functions throw on failure. Common errors:

ErrorCause
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)

VersionTagPublished
0.1.1latest1 months ago
Install
$ robinpath add @robinpath/xero

Collaborators

Dumitru Balaban
Dumitru Balaban
@dumitru
View all @robinpath modules
Version0.1.1
LicenseMIT
Unpacked Size4.9 KB
Versions1
Weekly Downloads21
Total Downloads21
Stars0
Last Publish1 months ago
Created1 months ago

Keywords

Category

sales