1.0.24 • Published 5 years ago
@commandalkon/connex-sdk v1.0.24
CONNEX by Command Alkon
CONNEX is the Supplier Collaboration Platform For Construction's Heavy Work!
Quick Start
Install via npm:
npm -i @commandalkon/connex-sdk
Verify your configuration
In the main index.js file, initialize the CONNEX SDK.
const CONNEX = require('@commandalkon/connex-sdk');
const params = {
appId: 'Your App ID',
apiKey: 'Your API Key',
};
CONNEX.Config.initialize(params);
// If the following code generates an error, your appId and apiKey
// settings are probably invalid.
new CONNEX.App().getApp()
.then(app => console.log(app))
.catch(err => console.error(err))
// Displays the following
{"appId": "Your App ID","version": "Your App Version"}
Write a CONNEX Ticket Search Hook
Create a folder named hooks with a single file in it named data-ticket-search-after.js with the code shown below.
// Transform the original ticket into UDM 1.0 (universal data model)
const transformToUDM = (ticket) => {
return {
id: 'id-' + ticket.id // Ticket Number
}
};
// Transaform all tickets in the ticket response to UDM format
async function handleEvent(params) {
const {input: ticketRs} = params;
for (let i = 0; i < ticketRs.items.length; i++) {
ticketRs.items[i] = transformToUDM(ticketRs.items[i])
}
return ticketRs;
}
module.exports = {
handleEvent,
};
Deploy CONNEX Ticket Search Hook
In the main index.js file, write a utility to deploy all code hooks using CONNEX Tools
const CONNEX = require('@commandalkon/connex-sdk');
const params = {
appId: 'Your App ID',
apiKey: 'Your API Key',
};
CONNEX.Config.initialize(params);
// Register all hooks in the ./hooks sub-folder
CONNEX.Tools.registerHooks('hooks')
.then(rs => console.log(rs))
.catch(err => console.error(err.message));
// If successful, you should see something like the following in the console.
1 App Hooks Registered
{
"items": [
{
"modifyDate": "2019-07-23T20:11:48.470Z",
"code": "const transform = (ticket) => {\n return {\n id: 'id-' + ticket.id,\n }\n};\n\nasync function handleEvent(params) {\n const {input: ticketRs} = params;\n\n for (let i = 0; i < ticketRs.items.length; i++) {\n ticketRs.items[i] = transform(ticketRs.items[i])\n }\n\n return ticketRs;\n}\n\nmodule.exports = {\n handleEvent,\n};\n",
"createDate": "2019-07-23T20:11:48.470Z",
"typeId": "hook",
"pk": "[your appId]-hook",
"crn": "data-ticket-search-after"
}
],
"pageToken": null
}
1.0.25-beta.2
5 years ago
1.0.25-beta.1
5 years ago
1.0.25-beta.0
5 years ago
1.0.24
5 years ago
1.0.22
5 years ago
1.0.21
5 years ago
1.0.20
5 years ago
1.0.19
5 years ago
1.0.18
5 years ago
1.0.17
5 years ago
1.0.16
5 years ago
1.0.15
5 years ago
1.0.14
5 years ago
1.0.13
5 years ago
1.0.12
5 years ago
1.0.11
5 years ago
1.0.10
5 years ago
1.0.9
5 years ago
1.0.8
5 years ago
1.0.6
5 years ago
1.0.5
5 years ago
1.0.4
5 years ago
1.0.3
5 years ago
1.0.2
5 years ago
1.0.1
5 years ago
1.0.0
5 years ago