0.0.26 • Published 5 years ago
@rayan-waapi/vos_factures v0.0.26
VOS FACTURES
Package to help with the API from "vosFactures"
Authentication
To start you'll need to give to the API your credentials from vosFactures.
import vosFacturesAPI from "@rayan-waapi/vos_factures";
if (await vosFacturesAPI.authenticate(API_TOKEN)) {
// The package is initialized
} else {
// We've got an error
}Client
To create a client
import vosFacturesAPI from "@rayan-waapi/vos_factures";
// vosFacturesAPI is initialized
const client = new vosFacturesAPI.Clients.Client();
client.name = "John Smith";
// Equal to
const client = new vosFacturesAPI.Clients.Client({ name: "John Smith" });
// Then save it
await client.save();
console.log(client.id);To update a client
import vosFacturesAPI from "@rayan-waapi/vos_factures";
// vosFacturesAPI is initialized
const client = new vosFacturesAPI.Clients.Client({ name: "John Smith" });
// Then save it
await client.save();
client.name = "John Doe";
await client.update();To delete a client
import vosFacturesAPI from "@rayan-waapi/vos_factures";
// vosFacturesAPI is initialized
const client = new vosFacturesAPI.Clients.Client({ name: "John Smith" });
// Then save it
await client.save();
await client.remove();To retrieve a client
import vosFacturesAPI from "@rayan-waapi/vos_factures";
// vosFacturesAPI is initialized
const client = await vosFacturesAPI.Clients.Client.findById(clientId);To retrieve many clients
import vosFacturesAPI from "@rayan-waapi/vos_factures";
// vosFacturesAPI is initialized
const clients = await vosFacturesAPI.Clients.Client.findBy({name: "John"}); // array of ClientTo retrieve all clients
import vosFacturesAPI from "@rayan-waapi/vos_factures";
// vosFacturesAPI is initialized
const clients = await vosFacturesAPI.Clients.Client.findAll(); // array of ClientTo retrieve invoices from a client
import vosFacturesAPI from "@rayan-waapi/vos_factures";
// vosFacturesAPI is initialized
const client = await vosFacturesAPI.Clients.Client.findById(clientId);
await client.getInvoices();Products
Create a product
import vosFacturesAPI from "@rayan-waapi/vos_factures";
// vosFacturesAPI is initialized
const product = new vosFacturesAPI.Products.Product({
name: "MY_CAKE",
code: "CAKEISLIE",
priceGross: "200.00",
currency: "EUR",
tax: "20"
});
await product.save()To update a product
import vosFacturesAPI from "@rayan-waapi/vos_factures";
// vosFacturesAPI is initialized
const product = new vosFacturesAPI.Products.Product({
name: "MY_CAKE",
code: "CAKEISLIE",
priceGross: "200.00",
currency: "EUR",
tax: "20"
});
// Then save it
await product.save();
product.name = "OUR_CAKE";
await product.update();To delete a product
import vosFacturesAPI from "@rayan-waapi/vos_factures";
// vosFacturesAPI is initialized
const product = new vosFacturesAPI.Products.Product({
name: "MY_CAKE",
code: "CAKEISLIE",
priceGross: "200.00",
currency: "EUR",
tax: "20"
});
// Then save it
await product.save();
await product.remove();To retrieve a product
import vosFacturesAPI from "@rayan-waapi/vos_factures";
// vosFacturesAPI is initialized
const product = await vosFacturesAPI.Products.Product.findById(productId);To retrieve many products
import vosFacturesAPI from "@rayan-waapi/vos_factures";
// vosFacturesAPI is initialized
const products = await vosFacturesAPI.Products.Product.findBy({currency: "EUR"}); // array of ProductTo retrieve all products
import vosFacturesAPI from "@rayan-waapi/vos_factures";
// vosFacturesAPI is initialized
const products = await vosFacturesAPI.Products.Product.findAll(); // array of ProductInvoices
Create a invoice
import vosFacturesAPI from "@rayan-waapi/vos_factures";
// vosFacturesAPI is initialized
const invoice = new vosFacturesAPI.Invoices.Invoice({
clientId,
kind: "estimate"
});
invoice.addProduct(product)
await invoice.save()To update a invoice
import vosFacturesAPI from "@rayan-waapi/vos_factures";
//....
await invoice.update();To delete a invoice
import vosFacturesAPI from "@rayan-waapi/vos_factures";
//....
await invoice.remove();To retrieve a invoice
import vosFacturesAPI from "@rayan-waapi/vos_factures";
// vosFacturesAPI is initialized
const invoice = await vosFacturesAPI.Invoices.Invoice.findById(invoiceId);To retrieve the client object from an invoice
import vosFacturesAPI from "@rayan-waapi/vos_factures";
// vosFacturesAPI is initialized
const invoice = await vosFacturesAPI.Invoices.Invoice.findById(invoiceId);
await invoice.getClient(); // will return a ClientTo retrieve many invoices
import vosFacturesAPI from "@rayan-waapi/vos_factures";
// vosFacturesAPI is initialized
const invoices = await vosFacturesAPI.Invoices.Invoice.findBy({clientId: clientId}); // array of InvoiceTo retrieve all invoices
import vosFacturesAPI from "@rayan-waapi/vos_factures";
// vosFacturesAPI is initialized
const invoices = await vosFacturesAPI.Invoices.Invoice.findAll(); // array of InvoiceTo create an invoice from an other invoice
import vosFacturesAPI from "@rayan-waapi/vos_factures";
// vosFacturesAPI is initialized
const invoice = await vosFacturesAPI.Invoices.Invoice.findById(invoiceId);
const newInvoice = invoice.duplicateAs("vat")
await newInvoice.save();TESTS
You can run test thanks to npm test inside the package folder, before that you have to complete the .env file
0.0.26
5 years ago
0.0.25
5 years ago
0.0.22
5 years ago
0.0.21
5 years ago
0.0.20
6 years ago
0.0.18
6 years ago
0.0.19
6 years ago
0.0.17
6 years ago
0.0.16
6 years ago
0.0.15
6 years ago
0.0.13
6 years ago
0.0.14
6 years ago
0.0.12
6 years ago
0.0.11
6 years ago
0.0.10
6 years ago
0.0.9
6 years ago
0.0.8
6 years ago
0.0.7
6 years ago
0.0.6
6 years ago
0.0.5
6 years ago
0.0.4
6 years ago