space-invoices
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -32,3 +32,3 @@ var request = require('superagent'); | ||
} | ||
req | ||
@@ -50,8 +50,13 @@ .then(function(response) { | ||
function errorHandler(error) { | ||
var err; | ||
// var err; | ||
// console.log(JSON.parse(error.response.text).error.message); | ||
if(error.response) { | ||
err = error.response.error; | ||
err.message = responseCodeText(error.status); | ||
err.name = responseCodeName(error.status); | ||
err.details = JSON.parse(error.response.text).error.message | ||
// err.details = JSON.parse(error.response.text).error.message); | ||
delete err.text | ||
err.errorCodeName = responseCodeName(error.status); | ||
err.errorCodeText = responseCodeText(error.status); | ||
} else { | ||
@@ -58,0 +63,0 @@ err = error; |
{ | ||
"name": "space-invoices", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "A NodeJS wrapper module for Space Invoices API", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
96
test.js
@@ -11,55 +11,57 @@ var SpaceInvoices = require('./index'); | ||
// spaceInvoices.account.create({ | ||
// email: 'test7@studio404.si', | ||
// password: 'testpassword' | ||
// }) | ||
// .then(account => { | ||
// console.log('registered') | ||
// return spaceInvoices.account.login({ | ||
// email: 'test7@studio404.si', | ||
// password: 'testpassword' | ||
spaceInvoices.account.create({ | ||
email: 'test7@studio404.si', | ||
password: 'testpassword' | ||
}) | ||
.then(account => { | ||
console.log('registered') | ||
// return spaceInvoices.account.login({ | ||
// email: 'test7@studio404.si', | ||
// password: 'testpassword' | ||
// }); | ||
}) | ||
.then(account => { | ||
console.log(account) | ||
}) | ||
.catch(err => { | ||
console.error(err); | ||
}) | ||
// spaceInvoices.organization.create(accountId, { | ||
// name: 'Studio404', | ||
// country: "USA" | ||
// } | ||
// ) | ||
// .then(function(organisation) { | ||
// organizationId = organisation.id; | ||
// var _documentClient = {}; | ||
// var _documentItems = [{}]; | ||
// _documentClient.name = "Rocket Man"; | ||
// _documentClient.country = "USA"; | ||
// _documentItems[0]['name'] = "Space suit" | ||
// _documentItems[0]['quantity'] = 2 | ||
// _documentItems[0]['unit'] = "Item" | ||
// _documentItems[0]['price'] = "1000" | ||
// return spaceInvoices.document.create(organisation.id, { | ||
// _documentClient: _documentClient, | ||
// _documentItems: _documentItems | ||
// }); | ||
// }) | ||
// .then(account => { | ||
// console.log(account) | ||
// .then(function(document) { | ||
// documentId = document.id; | ||
// return spaceInvoices.document.list(organizationId); | ||
// }) | ||
// .catch(err => { | ||
// console.error(err); | ||
// .then(function(documents) { | ||
// return spaceInvoices.document.getById(documentId) | ||
// }) | ||
// .then(function(document) { | ||
// console.log(document); | ||
// }) | ||
// .catch(function(error) { | ||
// console.error(error); | ||
// }); | ||
spaceInvoices.organization.create(accountId, { | ||
name: 'Studio404', | ||
country: "USA" | ||
} | ||
) | ||
.then(function(organisation) { | ||
organizationId = organisation.id; | ||
var _documentClient = {}; | ||
var _documentItems = [{}]; | ||
_documentClient.name = "Rocket Man"; | ||
_documentClient.country = "USA"; | ||
_documentItems[0]['name'] = "Space suit" | ||
_documentItems[0]['quantity'] = 2 | ||
_documentItems[0]['unit'] = "Item" | ||
_documentItems[0]['price'] = "1000" | ||
return spaceInvoices.document.create(organisation.id, { | ||
_documentClient: _documentClient, | ||
_documentItems: _documentItems | ||
}); | ||
}) | ||
.then(function(document) { | ||
documentId = document.id; | ||
return spaceInvoices.document.list(organizationId); | ||
}) | ||
.then(function(documents) { | ||
return spaceInvoices.document.getById(documentId) | ||
}) | ||
.then(function(document) { | ||
console.log(document); | ||
}) | ||
.catch(function(error) { | ||
console.error(error); | ||
}); | ||
@@ -79,4 +81,2 @@ | ||
// // #POST https://api.spaceinvoices.com/api/v1/accounts | ||
@@ -83,0 +83,0 @@ // spaceInvoices.register('test@test.com', '123') |
18418
551