space-invoices
Advanced tools
Comparing version 0.2.2 to 0.3.0
@@ -7,4 +7,11 @@ | ||
Accounts: require('./lib/models/account'), | ||
Clients: require('./lib/models/client'), | ||
Companies: require('./lib/models/companies'), | ||
Currency: require('./lib/models/currency'), | ||
Documents: require('./lib/models/document'), | ||
Organizations: require('./lib/models/organization') | ||
Items: require('./lib/models/item'), | ||
Organizations: require('./lib/models/organization'), | ||
Payments: require('./lib/models/payments'), | ||
Recurrences: require('./lib/models/recurrence'), | ||
Taxes: require('./lib/models/tax'), | ||
} | ||
@@ -11,0 +18,0 @@ |
@@ -22,6 +22,6 @@ | ||
edit: function(id, data) { | ||
return requestService.send('patch', this.path, data) | ||
return requestService.send('PUT', this.path + '/' + id, data) | ||
}, | ||
delete: function(id) { | ||
return requestService.send('delete', this.path, data) | ||
return requestService.send('delete', this.path + '/' + id) | ||
}, | ||
@@ -28,0 +28,0 @@ } |
module.exports = require('../baseService').extend({ | ||
path: 'accounts', | ||
includeMethods: [], | ||
includeMethods: ['getById'], | ||
@@ -6,0 +6,0 @@ create: function(data) { |
{ | ||
"name": "space-invoices", | ||
"version": "0.2.2", | ||
"version": "0.3.0", | ||
"description": "A NodeJS wrapper module for Space Invoices API", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
179
test.js
var SpaceInvoices = require('./index'); | ||
var organizationId = '5b17f904790e5d162c9966cd'; | ||
var spaceInvoices = new SpaceInvoices('8GcDCZTJEewzDRSEQz9gDuEN2ykdC0M9Nc1XHAbQ9ZHkUQQcxgJh6D9L3gGRsP5R'); | ||
var spaceInvoices = new SpaceInvoices('Df2pSDXQjAzpRyYlqi7WgIxmUUppYt97SjbFRR6V7XvmwBGUVDNmi8Oe2FoOjJE2') | ||
var accountId = '5b17da80f3ef8c449aac20cf' | ||
var accountId = "5b1907e2bb75a457ee90c139"; | ||
var organizationId = "5b191681bb75a46ee490c13c"; | ||
var taxId = "5b1e82c3078114d1c060b136"; | ||
var documentId = '5b1a6e55078114c20360b10e'; | ||
var itemId = '5b1e8a59078114336660b13f'; | ||
var paymentId = '5b1e9d190aca3579cd8f005f'; | ||
var recurrenceId = '5b1f7c010aca3515178f0062'; | ||
// 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.documents.create(organizationId, { | ||
_documentClient: { | ||
name: "Rocket Man", | ||
country: "USA", | ||
city: "Nekje", | ||
ZIP: "1234", | ||
address: "Somewhere over the rainbow" | ||
}, | ||
_documentItems: [ | ||
{ | ||
name: "Space suit", | ||
quantity: 1, | ||
unit: "Item", | ||
price: 1000, | ||
description: "A formal suit that the Rocket Man uses for parties in space." | ||
}, | ||
{ | ||
name: "Black Space suit", | ||
quantity: 2, | ||
unit: "Item", | ||
price: 3000, | ||
description: "Klavdija pls use your memes power to think of smth memes related", | ||
"totalWithTax": 3900, | ||
} | ||
], | ||
currencyId: 'EUR' | ||
spaceInvoices.recurrences.listByDocumentId(documentId) | ||
.then(function(recurrences) { | ||
console.log(recurrences); | ||
}) | ||
.then(function(invoice) { | ||
spaceInvoices.documents.send(invoice.id, { | ||
subject: 'Invoice number: ' + invoice.number, | ||
message: "Please find attached an invoice", | ||
recipients: 'david.r@studio404.si', | ||
}) | ||
}) | ||
.catch(err => console.error(err)); | ||
// spaceInvoices.organization.create(accountId, { | ||
// name: "Space Exploration Technologies corp", | ||
// address: "Rocket Road", | ||
// city: "Hawthorne", | ||
// zip: "CA 90250", | ||
// country: "USA", | ||
// IBAN: "123454321 123454321", | ||
// bank: "Bank Of America" | ||
// }) | ||
// .then(function(organization) { | ||
// console.log(organization); | ||
// }) | ||
// .catch(function(error) { | ||
// console.error(error); | ||
// }); | ||
// spaceInvoices.document.create(organisation.id, { | ||
// _documentClient: { | ||
// name: "Rocket Man", | ||
// country: "USA" | ||
// }, | ||
// _documentItems: [ | ||
// { | ||
// name: "Space suit", | ||
// quantity: 2, | ||
// unit: "Item", | ||
// price: 1000 | ||
// } | ||
// ] | ||
// }) | ||
// .then(function(document) { | ||
// console.log(document) | ||
// }) | ||
// var queryParams = { | ||
// filter: { | ||
// where: { | ||
// type: "invoice", | ||
// } | ||
// } | ||
// } | ||
// spaceInvoices.document.list(organizationId, queryParams) | ||
// .then(function(documents) { | ||
// console.log(documents); | ||
// }) | ||
// .catch(function(error) { | ||
// console.error(error); | ||
// }); | ||
// spaceInvoices.documents.getById(documentId, queryParams) | ||
// .then(function(document) { | ||
// console.log(document); | ||
// }) | ||
// .catch(function(error) { | ||
// console.error(error); | ||
// }) | ||
// 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); | ||
// }); | ||
// return spaceInvoices.accounts.isUnique('rocketman@example.com') | ||
// .then(function(res) { | ||
// console.log(res); | ||
// }) | ||
// .catch(e => { | ||
// console.error(e); | ||
// }) | ||
// // #POST https://api.spaceinvoices.com/api/v1/accounts | ||
// spaceInvoices.register('test@test.com', '123') | ||
// .then(res => { | ||
// console.log("RES"); | ||
// console.log(res.body) | ||
// }) | ||
// .catch(err => { | ||
// console.log(err) | ||
// console.log(err.status); | ||
// console.log(err.message); | ||
// }) | ||
.catch(function(error) { | ||
console.error(error); | ||
}) |
21
19754
563