💻 Interact programmatically with 📃Fattura24 APIs with node.js.
This module exposes an object you can interact to with all the supported methods of Fattura24's api.
var fattura24 = new Fattura24({ apiKey: 'weejeighaGushuz7Megeisheij6oogh3' });
fattura24.saveCustomer({
CustomerName: 'MARIO ROSSI',
CustomerAddress: 'Via Alberti 8',
CustomerPostcode: '06122',
CustomerCity: 'Perugia',
CustomerProvince: 'PG',
CustomerCountry: '',
CustomerFiscalCode: 'MARROS66C44G217W',
CustomerVatCode: '03912377542',
CustomerCellPhone: '335123456789',
CustomerEmail: '[email protected]'
}).then(function( customer ) {
console.log( customer );
}).catch(function( error ) {
console.error( error );
});
In case of special chars, like the ampersand (&) Fattura24 requires to escape them in an XML cdata. One way to do it is to pass a subobject with the _cdata field to the properties.
Right now the project automatically converts the _cdata returning from the xml, but doesn't autoconvert properties while sending them, therefore it's advised to add the _cdata in all needed fields.
Example:
var fattura24 = new Fattura24({ apiKey: 'weejeighaGushuz7Megeisheij6oogh3' });
fattura24.saveCustomer({
CustomerName: { _cdata: 'MARIO ROSSI & Figli' },
CustomerAddress: { _cdata: 'Via Alberti 8' },
CustomerPostcode: '06122',
CustomerCity: 'Perugia',
CustomerProvince: 'PG',
CustomerCountry: '',
CustomerFiscalCode: 'MARROS66C44G217W',
CustomerVatCode: '03912377542',
CustomerCellPhone: '335123456789',
CustomerEmail: '[email protected]'
}).then(function( customer ) {
console.log( customer );
}).catch(function( error ) {
console.error( error );
});
var fattura24 = new Fattura24({ apiKey: 'weejeighaGushuz7Megeisheij6oogh3' });
fattura24.saveDocument({
TotalWithoutTax: 29.10,
VatAmount: 0,
DocumentType: 'FE',
SendEmail: false,
FeVatNature: 'N4',
Object: 'Handmade products export',
Total: 29.10,
Payments: {
Payment: {
Date: '2018-12-14',
Paid: true,
Amount: 29.10
}
},
CustomerName: 'John Doe',
CustomerAddress: '29, 5th Avenue',
CustomerPostcode: 'AA12345',
CustomerCity: 'NYC',
CustomerCountry: 'USA',
CustomerCellPhone: '+15551234567',
CustomerEmail: '[email protected]',
FootNotes: 'Grazie per aver acquistato da noi',
Rows: [
{
Row: {
Code: '001',
Description: 'Wooden Chair',
Price: 29.10,
VatCode: 0,
VatDescription: '0%',
Qty: 1
},
},
],
})
.then(console.log)
.catch(console.log);
This module reflects API version v0.3.3 methods. Further details are available on official documentation.
Method | Purpose |
---|---|
testKey | Verify that the ApiKey is valid |
saveCustomer | Create a new customer |
saveDocument | Create a document |
getFile | Retrieve a document as PDF |
getTemplate | Get a list of available custom document templates |
getPdc | Get the chart of accounts |
getNumerator | Get accounting branches |
getProduct | Get a product or a service |
saveItem | Create a credit |
Fix for non-xml parameters such as in /getFile and /GetProduct
Support for <![CDATA[ fields
New License added.
Update README.
Update dependencies with security fixes.
Do not throw error when unknown method is invoked.
Fixed an issue with npm publication.
Transpile es6 to es5 for wider nodejs compatibility (babel targeted to 4.0.0).
Initial release.