Enlite Client Library
Download
https://www.npmjs.com/package/enlite-client
Example
const Enlite = require('enlite-client');
async function test() {
const enlite = new Enlite({
url: `https://enlite-service-broker.darkpos.io`
})
// session
console.log(`>> SESSION >>`);
const session = await enlite.session.login('employee@domain.com', 'mypassword');
console.log(`User Id: ${session.data.user.user_id}`);
// store
console.log(`\n>> STORE >>`);
const store = await enlite.store.getStore(session.data.user.firm_id, session.data.user.store_id);
console.log(`Store Name: ${store.data.store.name}`);
// customer
console.log(`\n>> CUSTOMER >>`);
console.log(`\n>> Create Customer >>`);
const created = await enlite.customer.createCustomer(session.data.user.store_id, {
first_name: "Clark",
last_name: "Kent"
}, session.data.user.user_id);
console.log(`Id: ${created.data.id}`);
console.log(`Name: ${created.data.first_name} ${created.data.last_name}`);
console.log(`\n>> Update Customer >>`);
const updated = await enlite.customer.updateCustomer(session.data.user.store_id, created.data.id, {
last_name: "Kent II"
}, session.data.user.user_id);
console.log(`Id: ${updated.data.id}`);
console.log(`\n>> Get Customer >>`);
const customer = await enlite.customer.getCustomer(session.data.user.store_id, updated.data.id);
console.log(`Id: ${customer.data.info.id}`);
console.log(`Name: ${customer.data.info.first_name} ${customer.data.info.last_name}`);
console.log(`Tickets: ${customer.data.tickets.length}`);
console.log(`\n>> Search Customer >>`);
const customers = await enlite.customer.searchCustomer(session.data.user.store_id, 'kent');
console.log(`Matches: ${customers.data.length}`);
}
test()Install
const enlite = require('enlite-client');Session
Login
Method used to authenticate with Enlite using a valid username and password.
const enlite = new Enlite({url: `https://enlite-service-broker.darkpos.io`})
const username = 'employee@domain.com';
const password = 'mypassword';
const session = await enlite.session.login(username, password);Stores
Get Store
Method used for getting a store information.
const firm_id = 100001; const store_id = 200001; const store = await enlite.store.getStore(firm_id, store_id); console.log(store.data);
Get Store Route
Method uses for getting a route and invoices.
const firm_id = 100001; const store_id = 200001; const route_id = 300001; const routes = await enlite.store.getStoreRoute(firm_id, store_id, route_id); console.log(routes.data);
Customers
Get Customer
Method uses for getting a customer information in the specified store scope.
const store_id = 200001; const customer_id = 400001; const response = await enlite.customer.getCustomer(store_id,customer_id);
Tickets
Put Ticket Note
Method used for updating a ticket note.
const store_id = 200001; const ticket_id = 500001; const employee_id = 600001; const note = 'This is a note on the ticket'; const response = await enlite.ticket.addTicketNote(store_id,ticket_id,note,employee_id);
Invoices
Put Invoice Note
Method used for updating an invoice note.
const store_id = 200001; const invoice_id = 70001; const employee_id = 600001; const note = 'This is a note on the invoice'; const response = await enlite.ticket.addInvoiceNote(store_id,invoice_id,note,employee_id);