@krknet/suitesyncer
v1.0.0
Published
NetSuite Restlet API
Downloads
21
Readme
SuiteSyncer
Oracle NetSuite Restlet API Connector
Peerdependency: @krknet/profiler
Usage
const SuiteSyncer = require('@krknet/suitesyncer')
const suiteSyncer = new SuiteSyncer({
isSyncEnabled: true,
queue: {
captureException: Sentry.captureException
},
restlet: {
accountID: '000000_SB1',
scriptNr: 1,
deployNr: 1,
consumerID: 'consumerID',
consumerSecret: 'consumerSecret',
tokenID: 'tokenID',
tokenSecret: 'tokenSecret'
},
syncers: [
{
key: 'getTest',
isActive: true,
isAutostarting: false,
interval: 5, // Minutes
runner: async (endpoint, profiler) => {
try {
const result = await endpoint.get({
mode: 'test',
before: Date.now()
})
profiler.succeed(`${result.length} results`)
} catch (err) {
profiler.fail(err.message)
}
}
},
{
key: 'pushTest',
action: async (endpoint, profiler, payload = {}) => {
try {
const answer = await endpoint.post({ mode: 'test', ...payload })
profiler.succeed()
return answer
} catch (err) {
profiler.fail(err.message)
}
}
}
]
})
await suiteSyncer.start()
console.log(await suiteSyncer.call('pushTest', { test: 2 }))
await suiteSyncer.stop()
Options
{
isSyncEnabled: false,
queue: { // completely optional
captureException: console.log // Gracefull Error Handling
},
restlet: { // required
accountID: null, // required
scriptNr: 0, // required
deployNr: 0, // required
consumerID: null, // required
consumerSecret: null, // required
tokenID: null, // required
tokenSecret: null // required
},
syncers: null // path to Syncers or Array of Syncers
}
Functions
async start ()
get isActive ()
async call (action, payload)
async stop ()