-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
29 lines (27 loc) · 835 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
'use strict';
let core, config, logger, _ = require('lodash'),
uuApi = require('./uuapi'),
uuwise = module.exports, serviceName = 'uuwise';
let funAssert = (error) => {
if (error) {
logger.error(error);
throw '[' + serviceName + '] ' + error;
}
};
uuwise.init = (name, c, callback) => {
serviceName = name;
core = c;
logger = core.getLogger(serviceName);
config = core.getConfig(serviceName);
uuApi.setSoftInfo(config.softid, config.softkey);
uuApi.userLogin(config.user, config.password)
.then((uid) => callback())
.catch((error) => funAssert(error));
};
uuwise.getCode = (imagePath, codeType, callback) => {
let code, error;
uuApi.autoRecognition(imagePath, codeType)
.then((response) => code = response)
.catch((err) => error = err)
.finally(() => callback(error, code));
}