Coder Social home page Coder Social logo

node-xero's Introduction

DEPRECATED

Xero are now using this sdk as the base for the official nodejs SDK, so it's getting new love. https://github.com/XeroAPI/xero-node

node-xero

An API wrapper for xero (http://developer.xero.com).

Supports all three applications types:

  • Private

  • Public

  • Partner

This module will be completed to support ALL Core and Payroll operations by the end of February 2014.

Create an Issue for any suggestions, specifically how to tidily support Where in a simple fashion.

Features

Implemented/Planned

  • Support all API operations

  • Efficient paging

  • Support for Private, Public, and Partner applications (look at oauth_test/server.js for 3 stage support)

Installation

$ npm install node-xero

Private Usage

var PrivateApplication = require('node-xero').PrivateApplication;
var privateApp = new PrivateApplication({ consumerSecret: 'AAAAA', consumerKey: 'BBBBBB', privateKeyPath: './cert/privatekey.pem'});

Public Usage

var PublicApplication = require('node-xero').PublicApplication;
var publicApp = new PublicApplication({ consumerSecret: 'AAAAA', consumerKey: 'BBBBBB'});

Partner Usage

var ParnetApplication = require('node-xero').PartnerApplication;
var partnerApp = new PartnerApplication({ consumerSecret: 'AAAAA', consumerKey: 'BBBBBB', privateKeyPath: './cert/privatekey.pem', sslCertPath: './cert/ssl.crt'});

Examples

Efficient paging:

privateApp.core.contacts.getContacts({ pager: {start:1 /* page number */, callback:onContacts}})
    .fail(function(err)
    {
        console.log('Oh no, an error');
    })

/* Called per page */
function onContacts(err, response, cb)
{
    var contacts = response.data;
    if (response.finished) // finished paging
        ....
    cb(); // Async support
}

Filter support: Modified After

// No paging
publicApp.core.contacts.getContacts({ modifiedAfter: new Date(2013,1,1) })
    .then(function(contacts)
    {
        _.each(contacts,  function(contact)
        {
            // Do something with contact
        })
    })

Tests

npm test

Release History

  • 0.0.2
    • Added journals
    • modifiedAfter support
  • 0.0.1
    • Initial Release

Copyright (c) 2014 Tim Shnaider

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

node-xero's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

node-xero's Issues

Error when trying to create an invoice

I'm trying to create a new customer, and I get this error (line numbers might not be exact as I was doing some testing):

/Users/j/Dev/node-stripe-credit-card/node_modules/xeroed/node_modules/xml2js/lib/xml2js.js:188
element = element.ele(key, child.toString()).up();
^
TypeError: Cannot call method 'toString' of undefined
at Object. (/Users/j/Dev/node-stripe-credit-card/node_modules/xeroed/node_modules/xml2js/lib/xml2js.js:188:50)
at Object. (/Users/j/Dev/node-stripe-credit-card/node_modules/xeroed/node_modules/xml2js/lib/xml2js.js:186:37)
at Object. (/Users/j/Dev/node-stripe-credit-card/node_modules/xeroed/node_modules/xml2js/lib/xml2js.js:186:37)
at /Users/j/Dev/node-stripe-credit-card/node_modules/xeroed/node_modules/xml2js/lib/xml2js.js:186:37
at Builder.exports.Builder.Builder.buildObject (/Users/j/Dev/node-stripe-credit-card/node_modules/xeroed/node_modules/xml2js/lib/xml2js.js:198:14)
at _.extend.js2xml (/Users/j/Dev/node-stripe-credit-card/node_modules/xeroed/lib/application.js:318:24)
at Entity.extend.toXml (/Users/j/Dev/node-stripe-credit-card/node_modules/xeroed/lib/entities/contact.js:120:33)
at Entity.extend.save (/Users/j/Dev/node-stripe-credit-card/node_modules/xeroed/lib/entities/contact.js:132:39)
at Object. (/Users/j/Dev/node-stripe-credit-card/index.js:23:21)
at Module._compile (module.js:456:26)

Maybe because the object passed to xml2js has some keys with value undefined?

Wrong oAuth parameters

I'm trying to build a PrivateApp, and I'm always getting the error 'Token has not been provided'.

After digging a bit I found that in application.js the get and putOrPost functions you are sending as parameter this.options.accessToken and this.options.accessSecret, which are undefined.

As a quick fix I changed it to this.options.consumerKey, this.options.consumerSecret, and now the authorisation works.

Unsure if an issue but throwing Debug issues during start

HI, I have not yet got this working trying the public app approach, and working through what might be wrong. As I view the logs as the package starts it throws a long set of Debug warnings so I am not sure if these are part of the problem:
[2016-07-23 15:26:48.997] [DEBUG] PublicApplication::constructor
[2016-07-23 15:26:49.002] [DEBUG] RequireAuthorizationApplication::constructor
[2016-07-23 15:26:49.002] [DEBUG] Application::constructor
[2016-07-23 15:26:49.004] [DEBUG] Core::constructor
[2016-07-23 15:26:49.011] [DEBUG] EntityHelper::constructor
[2016-07-23 15:26:49.013] [DEBUG] EntityHelper::constructor
[2016-07-23 15:26:49.015] [DEBUG] EntityHelper::constructor
[2016-07-23 15:26:49.017] [DEBUG] EntityHelper::constructor
[2016-07-23 15:26:49.019] [DEBUG] EntityHelper::constructor
[2016-07-23 15:26:49.021] [DEBUG] EntityHelper::constructor
[2016-07-23 15:26:49.023] [DEBUG] EntityHelper::constructor
[2016-07-23 15:26:49.026] [DEBUG] EntityHelper::constructor
[2016-07-23 15:26:49.027] [DEBUG] EntityHelper::constructor
[2016-07-23 15:26:49.028] [DEBUG] Payroll::constructor
[2016-07-23 15:26:49.030] [DEBUG] EntityHelper::constructor
[2016-07-23 15:26:49.032] [DEBUG] EntityHelper::constructor
[2016-07-23 15:26:49.035] [DEBUG] EntityHelper::constructor

Note before installing this I did have a private app connecting to Xero that functioned fine using the xero 0.0.8 file in the https://github.com/XeroAPI/HeyXero package, so these are new issues since moving over to the xeroed package (also the docs have 'node-xero' but it installs as 'xeroed' - unsure if that may part of the issue too?)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.