This is a Node.js client SDK for service-payrollchecks-node microservice. It provides an easy to use abstraction over communication protocols:
- Direct client
- HTTP client
- Seneca client (see http://www.senecajs.org)
- AWS Lambda client (see https://aws.amazon.com/lambda)
Add dependency to the client SDK into package.json file of your project
{
...
"dependencies": {
....
"client-payrollchecks-node": "^1.0.*",
...
}
}
Then install the dependency using npm tool
# Install new dependencies
npm install
# Update already installed dependencies
npm update
Inside your code get the reference to the client SDK
let sdk = new require('client-payrollchecks-node');
Define client configuration parameters that match configuration of the microservice external API
// Client configuration
let config = {
connection: {
protocol: 'http',
host: 'localhost',
port: 8080
}
};
Instantiate the client and open connection to the microservice
// Create the client instance
let client = sdk.PayrollChecksHttpClientV1(config);
// Connect to the microservice
await client.open(null);
// Work with the microservice
...
Now the client is ready to perform operations
// Create a new payroll check
let payrollCheck = {
id: '2',
party_id: '2',
income: [
{
description: 'task 3',
total: 700,
hours: 50,
rate: 14
},
{
description: 'task 4',
total: 1680,
hours: 120,
rate: 14
},
],
deductions: [
{
description: 'commission 5',
total: 35,
ytd_total: 5
}
],
state: PayrollCheckStateV1.New,
income_total: 0,
net_total: 2340
};
payrollCheck = await client.createCheck(
null,
payrollCheck
);
// Get the list of payroll checks
let page = await client.getChecks(
null,
{
party_id: '1',
state: 'new'
},
{
total: true,
skip: 0,
take: 10
}
);
This client SDK was created and currently maintained by Denis Kuznetsov.