Skip to content

Add per-endpoint methods#11

Open
damonmcminn wants to merge 5 commits intothallium205:masterfrom
damonmcminn:master
Open

Add per-endpoint methods#11
damonmcminn wants to merge 5 commits intothallium205:masterfrom
damonmcminn:master

Conversation

@damonmcminn
Copy link
Copy Markdown

Endpoint methods

  • Have implemented per-endpoint methods:
    • Xero[endpoint].find
    • Xero[endpoint].findOne
  • find optionally accepts a plain filter string e.g. AmountDue > 1000 AND DueDate > DateTime(1970-1-1) and handles encoding and appending to Xero API path.
  • findOne accepts a Xero ID e.g. xero.Invoices.findOne('foobar, callback) executes Xero.call with a path of /Invoices/foobar

Helper methods

  • Helper methods can be found on Xero.helpers. Have initially implemented dateToXeroDateTimeString(date) which accepts a Date object and returns a string as expected by the Xero API e.g. DateTime(2015-5-26)

What is not included

More work is required for conditional endpoint methods i.e. there is no check for whether an endpoint accepts an id in GET requests so all endpoints receive the findOne method regardless.

Need to implement save method.

Tests

  • npm test validates that the methods forward API calls to Xero.call
  • npm run test-xero-api validates method integration with Xero API. Requires keys as outlined in L7-8 of test/xero-api.js

Cheers!

@atinux
Copy link
Copy Markdown

atinux commented Dec 3, 2015

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants