xeroapi / xero-node Goto Github PK
View Code? Open in Web Editor NEWXero Node SDK for OAuth 2.0 generated from XeroAPI/Xero-OpenAPI
Home Page: http://developer.xero.com/
License: MIT License
Xero Node SDK for OAuth 2.0 generated from XeroAPI/Xero-OpenAPI
Home Page: http://developer.xero.com/
License: MIT License
Hello,
I am not receiving any response while using 'Retrieving invoices by using Invoice numbers':
```
var myInvoiceNumbers = ['TC-001','INV000044'];
xeroClient.core.invoices.getInvoices({
params: {
InvoiceNumbers: myInvoiceNumbers.toString()
}
}).then(function(invoices) {
console.log(invoices);
invoices.forEach(function(invoice){
//do something useful
console.log(invoice); //ACCPAY
});
}).catch(function(err) {
//Some error occurred
console.log(err);
});
I am not getting any response . please let me know the solution.
Hello,
when i have blank contactID in invoice , i am not getting proper error in xero node:
i am receiving exception like this :(node:1014) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property '0' of undefined
please let me know , how can i get proper error in catch block. its very urgent issue,which i am facing.
I imagine this is true for any of the hashing in _createSignature, but specifically line 224-227 of lib/oauth/oauth.js will completely swallow the error thrown back from Crypto, rather than returning an error:
} else if (this._signatureMethod == "RSA-SHA1") {
key = this._privateKey || "";
hash = crypto.createSign("RSA-SHA1").update(signatureBase).sign(key, 'base64');
Specifically Crypto is expecting the RSA Key to be surrounded with:
-----BEGIN RSA PRIVATE KEY-----
-----END RSA PRIVATE KEY-----
This is relatively clear if you get the message from Crypto:
error:0906D06C:PEM routines:PEM_read_bio:no start line
As it is now though, you get no output and nothing happens. This isn't too helpful.
Reproduction Steps:
NOTE: Nothing happens and no error is returned to explain why.
Full stack of the error that is lost (Line numbers might be slightly off since I added some debugging to find this. The original line number listed above should be the offending code:
Error: error:0906D06C:PEM routines:PEM_read_bio:no start line
at Error (native)
at Sign.sign (crypto.js:282:26)
at exports.OAuth._createSignature (\node_modules\xero-node\lib\oauth\oauth.js:228:70)
at exports.OAuth._getSignature (\node_modules\xero-node\lib\oauth\oauth.js:105:17)
at exports.OAuth._prepareParameters (\node_modules\xero-node\lib\oauth\oauth.js:319:20)
at exports.OAuth._performSecureRequest (\node_modules\xero-node\lib\oauth\oauth.js:329:34)
at exports.OAuth.get (\node_modules\xero-node\lib\oauth\oauth.js:509:17)
at getResource (\node_modules\xero-node\lib\application.js:313:25)
at \node_modules\xero-node\lib\application.js:275:25
at process._tickCallback (internal/process/next_tick.js:103:7)
I was already discombobulated after I learned that there is no way to send invoices per email via the API. (Are you sure this is not an absolute core functionality you should offer these days?)
Is there a way to at least download the branded invoice as a PDF via the API so that I can use a mail service to send the invoice?
The application.js does not initialize a private client properly (var xeroClient = new xero.PrivateApplication(config);). It looks like _consumerSecret contains the privatekey.pem.
var PrivateApplication = Application.extend({
constructor: function(config) {
console.log('-- ---- --- --- ---');
console.log(config);
Application.call(this, Object.assign({}, config, { type: 'private' }));
},
init: function() {
Application.prototype.init.apply(this, arguments);
console.log('arguments');
console.log(arguments)
var rsaPrivateKey = this.options.privateKey;
this.oa = new OAuth(
null,
null,
this.options.consumerKey,
rsaPrivateKey,
"1.0a",
null,
"RSA-SHA1",
null, { 'User-Agent': this.options.userAgent }
);
this.options.accessToken = this.options.consumerKey;
this.accessSecret = this.options.consumerSecret;
console.log('---- ---- ---- ---');
console.log(this);
}
oa:
2|CF | { _isEcho: false,
2|CF | _requestUrl: null,
2|CF | _accessUrl: null,
2|CF | __consumerKey: 'NEZT1VOJFPUYHNUS4107NPIHE0DWUT',
2|CF | consumerSecret: '-----BEGIN%20RSA%20PRIVATE%20KEY-----%0AMIICXQIBAAKBgQCc9IfBmPpDFBpQn%2B5dqdy6m8I3XrCci8nD1YY9cTTVNzKGNYmI%0A2X0h3UiK1miXffzGoeVRdF3Oxp3BVxCOCRdRob4k%2BFeYpKC%2FWET9lyr%2F0Hi2MvOH%0A37VT5ezGjxcwYvkSZud0s4JYZqmAuGkj4a9zwMWhVUJ3vOZY9Qe5fROfewIDAQAB%0AAoGAOrTYBliy2t4tDZUUcmIzlnTmCxHW22cJ278FC%2FxI96tCsaJaxB4dSMpc9NlH%0Am8pa%2FuzVOkddQxdVMFjhb08FMkRgK5AZ6TwqvAR2bizqgewmoQLY7BeypwC2MScQ%0A52J852iSxZ6Y10Ad5vsnaURz0o6%2Be0uOcuNvF%2FO5%2FfypREkCQQDNHgRch0xwGN%2Bn%0A9Idf5dc9yUx0X0blZiob8FKTlwoYSBHbO2N2sgsk3ZUnWY9NAjLQb4I9WnnLEOkI%0Aacoa7f1NAkEAw%2BP6ois0TKJwoZLtd0VWdF9iIE871%2FP2vNik2DYsixUn4Yvw%2BVLI%0AoDQiXN7zi1w7vhUJnF%2BbQWGwRKfb%2FljL5wJAHqABtLL6xa3hDtmisL3HYlFA2gsz%0AsaKMXPmHysN9XVy9VcdLNXil005GK8bib3QJlDdh8bklgB05PelVpKmt7QJBAImB%0AmwoDMe8ph86jiLXUol%2BGJSdw9x0cT%2FM4UF7FiHcJHrmgtkMN7W8nqYdvqZ4F3JoN%0AwnVWV3GJ1WYcPr1IL7kCQQCVElTqboxrBbckERsT3Ws8JK%2FGQdlHPckqi4D4hS6z%0AZ2GPaVKE1mmj6MPXaxdW2D0q1YG%2FhPo%2BDTLXj%2FRpyQWr%0A-----END%20RSA%20PRIVATE%20KEY-----%0A',
2|CF | _privateKey: <Buffer 2d 2d 2d 2d 2d 42 45 47 49 4e 20 52 53 41 20 50 52 49 56 41 54 45 20 4b 45 59 2d 2d 2d 2d 2d 0a 4d 49 49 43 58 51 49 42 41 41 4b 42 67 51 43 63 39 49 ... >,
2|CF | _version: '1.0a',
2|CF | _authorize_callback: 'oob',
2|CF | _signatureMethod: 'RSA-SHA1',
2|CF | _nonceSize: 32,
2|CF | _headers:
When I use the Public Application and invoke the following code:
xeroClient.core.invoices.getInvoice(invoiceID)
.then(function(invoice) {
invoice.getAttachments()
.then(function(attachments) {
//Get the reference to the attachment object
var myAttachment = attachments[0];
//Create a local writestream
var wstream = fs.createWriteStream('temp.pdf', { defaultEncoding: 'binary' });
wstream.on('finish', function() {
//Data has been written successfully
res.send('done');
});
wstream.on('error', function(err) {
console.log('data writing failed',err);
wstream.close();
});
myAttachment.getContent(wstream)
.catch(function(err) {
console.log('Some error occurred: ', err);
});
});
Everything works fine and the invoice's attachment is written locally.
However when I upgrade to a Partner Application. The file is empty. It's strange because I can log the file size and that is correct, it's just the actual file that is empty.
Maybe I'm missing something?
When saving attachments if the filename for the attachment has an &
in it, the attachment will not be able to be retrieved from Xero.
Workaround: modify the filename prior to uploading so that all ampersand characters are removed.
I don't know if this is best here, or if there is another way to give feedback for documentation to be updated. This is really for the API in general, and not specifically the node-js implementation, but it does impact things here.
The API Docs state that SentToContact is a Boolean.
This is half-true. It is set to "True" if the Invoice/Payable has been sent to the contact. It is not set at all if it hasn't been set.
As a result the following will not give you the expected results:
xero.core.invoices.getInvoices(
{
where: 'Type="ACCREC" AND SentToContact=false'
}
And you instead need:
xero.core.invoices.getInvoices(
{
where: 'Type="ACCREC" AND SentToContact!=true'
}
At a bare minimum it would be good if there were some examples in the sample app that showed how to do this so it could be looked up. Right now its not covered.
on xero-node/lib/entities/shared.js you have:
module.exports.AddressSchema = Entity.SchemaObject({ Address: { type: AddressDetailsSchema, toObject: 'always' } });
However this additional object "Address" breaks the GET/POST with Xero. To get it to work I did:
module.exports.AddressSchema = AddressDetailsSchema;
Bypassing this extra Address object. I didn't sent a PR as I don't know if this breaks other components such as "employees" in the payroll. But definitely to create/update/retrieve Contacts, this was the way to make it work. Hope this helps.
I think @dupski (Briggs) has been looking into a CI tool.
@dupski or @jordanwalsh23 do you have any thoughts?
Then we could have the tool run against each PR
Hello,
I wrote addresses according to the url you provided me.
https://github.com/XeroAPI/xero-node/blob/master/test/core/contacts_tests.js
but I am getting error like 'error:TypeError: Converting circular structure to JSON'. please provide me the solution.
I just took a look for the library source code and wondering why the code-style is so strange, mixed and outdated. Your node
version requirement in package.json
is current LTS (6.0) and that's great, but platform/language features usage seems to be targeting something like node 0.12.
For example: https://github.com/XeroAPI/xero-node/blob/master/lib/application.js - you have const
within function declarations, but missing use strict
anywhere and top level variables declared as var
.
Question is: will you accept refactoring pull requests? I'm particularly interesting in getting rid of lodash
as it's huge stone age dependency...
Hi,
Thanks for this library. I have a client rendered app and a node backend, and I've gotten to a point where I can follow the example app to the point of getting a session authenticated.
However, I'm using firebase cloud functions and working from realtime database triggers, and so don't have anything the equivalent of an express session.
My question is can I call these helper methods and pass them the oauth token each time as an additional parameter, rather than assuming an authenticated session?
This may be documented somewhere, but as of yet I haven't been able to find it so i thought I'd ask.
Thanks
Have been trying to structure the JSON correctly to submit a TrackingCategory option on a LineItem as part of a .newInvoice()
call, but can not seem to make anything work. Adhering to the Schemas makes it look like it expects a format like:
{
...
LineItems: [{
...
Tracking: [{
TrackingCategory: {
Name: 'Region',
Option: 'Eastside',
TrackingCategoryID: (UUID),
}
}]
}]
}
The request is being accepted and the invoice appears in Xero, but the Tracking information is missing, there are no errors or status messages being returned.
Not sure if the issue is just on my end with this problem, but I'd be happy to submit a PR adding to the documentation if I could get some help on this one.
I'm wondering if this is possibly linked to #22 ? Is it a limitation to be able to send Tracking?
I'm trying to use the attachment endpoints which are in this wrapper, and I'm posting this with the understanding they're not properly supported yet โ but thought someone might be able to help.
I can't seem to get around this error:
I've read the code and am posting like this:
let stats = fs.statSync(`/tmp/myfile.pdf`);
// upload the attachment
let attachment = xeroClient.core.attachments.newAttachment({
MimeType: 'application/pdf',
FileName: `myfile.pdf`,
ContentLength: stats.size
})
return attachment.save(`/Invoices/${invoice.response.Id}`, `/tmp/myfile.pdf`)
The return is consistently this:
{ Error: POST call failed with: 401
at /user_code/node_modules/xero-node/lib/application.js:129:42
at passBackControl (/user_code/node_modules/xero-node/lib/oauth/oauth.js:400:25)
at IncomingMessage.<anonymous> (/user_code/node_modules/xero-node/lib/oauth/oauth.js:416:17)
at emitNone (events.js:91:20)
at IncomingMessage.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickDomainCallback (internal/process/next_tick.js:122:9)
data:
{ oauth_problem: 'signature_invalid',
oauth_problem_advice: 'Failed to validate signature' } }
I've tried the endpoint using another wrapper (npm/xero) and I'm getting the same error, I'm wondering if neither support signing for attachments โ or am I doing something wrong?
Add support to the SDK to access the 'RepeatingInvoices' endpoint and associated functionality.
Get Call fails with error:
This is the error response.
{ Error: GET call failed with: 404 at self.oa.get.stream (/home/keyur/Documents/Git/xeroAPI/node_modules/xero-node/lib/application.js:327:38) at passBackControl (/home/keyur/Documents/Git/xeroAPI/node_modules/xero-node/lib/oauth/oauth.js:406:25) at IncomingMessage.<anonymous> (/home/keyur/Documents/Git/xeroAPI/node_modules/xero-node/lib/oauth/oauth.js:422:17) at emitNone (events.js:91:20) at IncomingMessage.emit (events.js:188:7) at endReadableNT (_stream_readable.js:975:12) at _combinedTickCallback (internal/process/next_tick.js:80:11) at process._tickCallback (internal/process/next_tick.js:104:9) data: { 'The resource you\'re looking for cannot be found': '' } }
I'm receiving the following error after trying to use the client to get all items. Here is the following error stack trace.
SyntaxError: Unexpected token o in JSON at position 0
at Object.parse (native)
at self.oa.get.stream (/user_code/node_modules/xero-node/lib/application.js:303:33)
at passBackControl (/user_code/node_modules/xero-node/lib/oauth/oauth.js:406:25)
at IncomingMessage.<anonymous> (/user_code/node_modules/xero-node/lib/oauth/oauth.js:422:17)
at emitNone (events.js:91:20)
at IncomingMessage.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickDomainCallback (internal/process/next_tick.js:128:9)
Line 304 in 910dd1a
@jordanwalsh23 I have been playing around with Payments this morning and just had a couple of questions happy to put in a PR to solve any of the issues listed:
createPayment
instead of what seams the standard, and documented newPayment
, which is preferred? Happy to do a PR to either fix the Docs or bring the payment entity to align with the docs - assuming though createPayment
might still need to be kept in case people are using it?savePayments
function to bulk save payments, I have got this working for me, happy to do a PR, probably just need to above question answered first though..Thanks,
Josh
Add support for Employees endpoint (accounting api)
Hi, I just started integration with Xero in my node app, wondering does this package include OAuth process?
Hello,
I tried to fetch a contact (XeroClient.core.contacts.getContact(ContactId) ) and it worked locally. I uploaded this code to AWS Lambda and I got the error below:
2017-10-19T19:35:05.722Z 9ac66835-b504-11e7-a7a9-bb98e4bdb519 SyntaxError: Unexpected token ... at exports.runInThisContext (vm.js:53:16) at Module._compile (module.js:373:25) at Object.Module._extensions..js (module.js:416:10) at Module.load (module.js:343:32) at Function.Module._load (module.js:300:12) at Module.require (module.js:353:17) at require (internal/module.js:12:17) at Object.<anonymous> (/var/task/node_modules/xero-node/lib/entity_helpers/accounting/organisations.js:3:20) at Module._compile (module.js:409:26) at Object.Module._extensions..js (module.js:416:10) at Module.load (module.js:343:32) at Function.Module._load (module.js:300:12) at Module.require (module.js:353:17) at require (internal/module.js:12:17) at /var/task/node_modules/xero-node/lib/core.js:43:27 at /var/task/node_modules/xero-node/node_modules/lodash/lodash.js:4944:15 at baseForOwn (/var/task/node_modules/xero-node/node_modules/lodash/lodash.js:3001:24) at /var/task/node_modules/xero-node/node_modules/lodash/lodash.js:4913:18 at Function.forEach (/var/task/node_modules/xero-node/node_modules/lodash/lodash.js:9359:14) at new Core (/var/task/node_modules/xero-node/lib/core.js:42:5) at Application (/var/task/node_modules/xero-node/lib/application.js:43:16) at new Application.extend.constructor (/var/task/node_modules/xero-node/lib/application.js:562:21) at module.exports.handler.client.core.contacts.getContact.then.data.catch (/var/task/lambda/notifications/request_test.js:18:15)
The function provided by the BankTransactions helper newBankTransactions
creates a map of BankTransaction objects and the save()
function needs to be called on each.
For efficiency, this should instead provide a saveAll()
function that allows multiple BankTransactions to be saved in a single API call.
Currently for objects that have a nested schema (e.g. TaxRate -> TaxComponent, or Invoice -> Payments), the nested schema isn't being translated from the XML into it's appropriate type.
e.g.
//Tax Component Schema
var TaxComponentSchema = new Entity.SchemaObject({
Name: { type: String, toObject: 'always' },
Rate: { type: String, toObject: 'always' },
IsCompound: { type: Boolean }
});
//Get TaxComponents Test
currentApp.core.taxrates.getTaxRates()
.then(function(taxRates) {
var taxRate = taxRates[0];
_.each(taxRate.TaxComponents, function(taxComponent) {
//This test fails as taxComponent.IsCompound is a 'String' not a 'Boolean'.
expect(taxComponent.IsCompound).to.be.oneOf([true, false]);
});
});
Fix is to ensure that the marshalling respects the types for nested objects.
The Xero API documentation lists "createdByMyApp" as an optional parameter.
However, I can't seem to figure out the proper syntax for using it. The following throws an error:
xero.core.invoices.getInvoices({
where: 'Status="DRAFT" AND createdByMyApp=true',
})
The error:
{ ErrorNumber: 16,
Type: 'QueryParseException',
Message: 'No property or field \'createdByMyApp\' exists in type \'Invoice\'' } }
(node:20984) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: GET call failed with: 400
While the following doesn't do anything:
xero.core.invoices.getInvoices({
where: 'Status="DRAFT"',
createdByMyApp: true
})
Multi item push fails with the following error:
Mongoose model 'error' event fired on 'Invoice' with error:
entity.toXml is not a function TypeError: entity.toXml is not a function
at /Users/joshuacalder/Development/xero-ucrm-sync/node_modules/xero-node/lib/entity_helpers/entity_helper.js:29:27
at arrayMap (/Users/joshuacalder/Development/xero-ucrm-sync/node_modules/lodash/lodash.js:660:23)
at Function.map (/Users/joshuacalder/Development/xero-ucrm-sync/node_modules/lodash/lodash.js:9571:14)
at constructor.saveEntities (/Users/joshuacalder/Development/xero-ucrm-sync/node_modules/xero-node/lib/entity_helpers/entity_helper.js:28:29)
at constructor.saveInvoices (/Users/joshuacalder/Development/xero-ucrm-sync/node_modules/xero-node/lib/entity_helpers/accounting/invoices.js:30:21)
I'm having the same issue as outlined here: NaturalNode/natural#320
Looks like log4js has a bunch of require statements but does not have the dependancies in package.json
Looks like log4js got a major overhaul since NZTim was working on the module and is now log4js-node but has the same npm name (log4js).
I tried updating to the latest version (2.2.0) but this broke the build as there was a/some API changes.
Making an Issue to track the bug. I have not done any active work on getting 2.2.0 to work in the project. Anyone else is welcome to give it a go.
Webpack output:
` ERROR in ./node_modules/log4js/lib/appenders/loggly.js
Module not found: Error: Can't resolve 'loggly' in 'C:\Users\phil.alsford\Desktop\project\node_modules\log4js\lib\appenders'
@ ./node_modules/log4js/lib/appenders/loggly.js 3:11-28
@ ./node_modules/log4js/lib/appenders ^./.*$
@ ./node_modules/log4js/lib/log4js.js
@ ./node_modules/xero-node/lib/logger.js
@ ./node_modules/xero-node/lib/index.js
@ ./src/server.ts
ERROR in ./node_modules/log4js/lib/appenders/mailgun.js
Module not found: Error: Can't resolve 'mailgun-js' in 'C:\Users\phil.alsford\Desktop\project\node_modules\log4js\lib\appenders'
@ ./node_modules/log4js/lib/appenders/mailgun.js 34:14-35
@ ./node_modules/log4js/lib/appenders ^\.\/.*$
@ ./node_modules/log4js/lib/log4js.js
@ ./node_modules/xero-node/lib/logger.js
@ ./node_modules/xero-node/lib/index.js
@ ./src/server.ts
ERROR in ./node_modules/log4js/lib/appenders/slack.js
Module not found: Error: Can't resolve 'slack-node' in 'C:\Users\phil.alsford\Desktop\project\node_modules\log4js\lib\appenders'
@ ./node_modules/log4js/lib/appenders/slack.js 2:12-33
@ ./node_modules/log4js/lib/appenders ^\.\/.*$
@ ./node_modules/log4js/lib/log4js.js
@ ./node_modules/xero-node/lib/logger.js
@ ./node_modules/xero-node/lib/index.js
@ ./src/server.ts
ERROR in ./node_modules/log4js/lib/appenders/smtp.js
Module not found: Error: Can't resolve 'nodemailer' in 'C:\Users\phil.alsford\Desktop\project\node_modules\log4js\lib\appenders'
@ ./node_modules/log4js/lib/appenders/smtp.js 4:13-34
@ ./node_modules/log4js/lib/appenders ^\.\/.*$
@ ./node_modules/log4js/lib/log4js.js
@ ./node_modules/xero-node/lib/logger.js
@ ./node_modules/xero-node/lib/index.js
@ ./src/server.ts
`
Hello Team,
I am creating credit note with creditnotenumber but it is creating a new creditnotenumber in xero ,below is the sample of creditsample, which i am posting to xero. please check and let me know the solution:
var sampleCreditNote= {
Type: 'ACCRECCREDIT',
Contact: { ContactID: 'f24bcab4-e610-4543-bfe1-b881a2bcdc35' },
Date: '2017-09-20',
CurrencyCode: 'AUD',
CreditNoteNumber:'CRN000003',
SentToContact: true,
Status: 'SUBMITTED',
LineItems:
[ { Description: '4 Jul 2007 AUD013915 FFS AV's & SM Kelly',
Quantity: 1,
UnitAmount: 0,
AccountCode: '010',
TaxType: 'OUTPUT',
TaxAmount: '0.00' },
{ Description: '1 Aug 2014 AUD000075 FFS Bruno Cuda[1]',
Quantity: 1,
UnitAmount: 0,
AccountCode: '010',
TaxType: 'OUTPUT',
TaxAmount: '0.00' },
{ Description: '3 Jan 2017 AUD000152 FFS Alandale Fruits',
Quantity: 1,
UnitAmount: 0,
AccountCode: '010',
TaxType: 'OUTPUT',
TaxAmount: '0.00' },
{ Description: '21 Mar 2017 AUD000179 FFS Imperial Produce Pty Ltd',
Quantity: 1,
UnitAmount: 0,
AccountCode: '010',
TaxType: 'OUTPUT',
TaxAmount: '0.00' },
{ Description: 'desc',
Quantity: 1,
UnitAmount: 0,
AccountCode: '010',
TaxType: 'OUTPUT',
TaxAmount: '0.00' },
{ Description: 'azva',
Quantity: 1,
UnitAmount: 0,
AccountCode: '054',
TaxType: 'OUTPUT',
TaxAmount: '0.00' },
{ Description: 'ada',
Quantity: 1,
UnitAmount: 0,
AccountCode: '054',
TaxType: 'OUTPUT',
TaxAmount: '0.00' },
{ Description: 'sb',
Quantity: 1,
UnitAmount: 0,
AccountCode: '054',
TaxType: 'OUTPUT',
TaxAmount: '0.00' },
{ Description: 'sb',
Quantity: 1,
UnitAmount: 0,
AccountCode: '054',
TaxType: 'OUTPUT',
TaxAmount: '0.00' },
{ Description: 'snsb',
Quantity: 1,
UnitAmount: 0,
AccountCode: '010',
TaxType: 'OUTPUT',
TaxAmount: '0.00' },
{ Description: 'dfnd',
Quantity: 1,
UnitAmount: 0,
AccountCode: '260',
TaxType: 'OUTPUT',
TaxAmount: '0.00' } ] }
please test it, I really need help.
Thankyou
Just thinking about the reason for validating the objects returned from Xero against a schema.
Is it just to know if there has been an error?
Could there just be a check on the status code returned/validation key in the response, then then throw if not 2xx or if validation value != null ?
Eg.. The Accounts class could still (I think) have all it's functionality without having to maintain/create schemas.
Just wondering your thoughts. Cheers.
It's impossible to create a Bank Account if the BankAccountNumber attribute can't be converted to xml.
Hi there!
I was trying to integrate xero to Meteor app which is using old Node version (v4.8.4) and got an errors because of modern syntax like this:
https://github.com/XeroAPI/xero-node/blob/master/lib/entities/accounting/organisation.js#L49.
Does it possible to compile lates version of package to es5?
Hi,
Here is my environment
Node version: v6.11.1
npm version: v3.10.10
xero-node: v2.5.2
Based on API doc of Contacts, the GET method should be able to retrieve a specific set of contacts in a single call with parameter 'IDs'.
So it should be work like this
xeroClient.core.contacts.getContacts({
IDs: "contact-uuid-1,contact-uuid-2"
});
But this call return all contacts to me.
So I tried the following call
xeroClient.core.contacts.getContacts({
IDs: [
"contact-uuid-1",
"contact-uuid-2"
]
});
And it still return all the contacts.
I've lost some reasonable time on this.
On: lib/entities/accounting/contact.js
At: var ContactSchema = new Entity.SchemaObject
A lot of fields does not contain the 'toObject' property. I was trying to create a contact with EmailAddress and I could not until I've added the "toObject: 'hasValue'" to it. Looks like all fields requires this property.
I'm getting Xero internal error while trying to Void unallocated credit note (that's possible via web). Tried POST to /CreditNotes/{creditNoteId} with { Status: 'VOIDED' } or { Status: 'DELETED' } in both cases got validation error as response with Xero internal error as text...
Is I'm doing something wrong or API?
Node version: 6.10.2
npm version: 3.10.10
What I did
xeroClient.core.invoices.getInvoices({
where: 'Status!="PAID" AND Status!="VOIDED" AND Type=="ACCREC"',
pager: {
start: 1,
callback: (err, response, cb) => {
if (err) { throw err; }
cb(response.data);
},
},
})
What I got
[...
{...
LineItems: [...
{...
Tracking: [{}]
}
]
}
]
What I get on Xero API Preview for same request & invoice & line item
<Tracking>
<TrackingCategory>
<Name>Customer Contract</Name>
<Option>***</Option>
<TrackingCategoryID>***</TrackingCategoryID>
</TrackingCategory>
<TrackingCategory>
<Name>Department</Name>
<Option>Engineering</Option>
<TrackingCategoryID>***</TrackingCategoryID>
</TrackingCategory>
</Tracking>
Is there a way to reverse payments on an invoice through this SDK? Tried to do the following:
let paymentId = invoice.Payments[0].PaymentID
let payment = await accountingClient.core.payments.getPayment(paymentId)
payment.Status = 'DELETED'
payment.save()
but that's returning a ValidationError: "Message":"Only Status accepted for updates."
Add support for the ContactGroups endpoint.
Hello,
Please help , how to add address in xero add contact api.
When calling xeroClient.core.bankTransactions.newBankTransactions(bankTransactions) I am receiving the following error TypeError: xeroClient.core.bankTransactions.newBankTransactions is not a function
Hello,
I am not able to create invoice. I am getting response like below:
{ Error: PUT call failed with: 400
at /Users/macmini/Documents/myds-node/node_modules/xero-node/lib/application.js:145:42
at passBackControl (/Users/macmini/Documents/myds-node/node_modules/xero-node/lib/oauth/oauth.js:406:25)
at IncomingMessage. (/Users/macmini/Documents/myds-node/node_modules/xero-node/lib/oauth/oauth.js:422:17)
at emitNone (events.js:91:20)
at IncomingMessage.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickCallback (internal/process/next_tick.js:104:9)
data:
{ ErrorNumber: 10,
Type: 'ValidationException',
Message: 'A validation exception occurred',
Elements: [ [Object] ] } }
Please provide solution.
Hello,
I want to add lineitem using invoice id ,please let me know how can i do this. Please provide a simple sample for it.
Thankyou
Hello,
when i am calling create contacts api with same data , i am getting response like:
{ Error: GET call failed with: 404
at self.oa.get.stream (/Users/macmini/Documents/myds-node/node_modules/xero-node/lib/application.js:327:36)
at passBackControl (/Users/macmini/Documents/myds-node/node_modules/xero-node/lib/oauth/oauth.js:406:25)
at IncomingMessage. (/Users/macmini/Documents/myds-node/node_modules/xero-node/lib/oauth/oauth.js:422:17)
at emitNone (events.js:91:20)
at IncomingMessage.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickCallback (internal/process/next_tick.js:104:9)
data: { 'The resource you're looking for cannot be found': '' } }
I know, why it is coming but i don't want see any other information on terminal[mac] except data part['The resource you're looking for cannot be found']. please help me.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.