workplus
Version:
sdk of workplus
60 lines (55 loc) • 1.7 kB
JavaScript
;
const assert = require("assert");
const cfg = require("./config/server");
const tool = require("./lib/common");
const defaultServer = cfg.adminServer.url;
const initAppModule = function(adminServer) {
adminServer = adminServer || defaultServer;
const putOnToShelf = function(param) {
assert.ok(param.domainId, "domain id can't be null");
assert.ok(param.downloadLink, "downloadLink id can't be null");
assert.ok(param.fileName, "fileName id can't be null");
assert.ok(param.appName, "appName id can't be null");
assert.ok(param.iconUrl, "iconUrl id can't be null");
const options = {
method: "POST",
url: `${adminServer}/public/releases/url-upload?domainId=${param.domainId}&profile=${param.profile}`,
json: true,
body: {
appUrl: param.downloadLink,
fileName: param.fileName,
intro: param.intro,
appName: param.appName,
iconUrl: param.iconUrl,
pkgName: param.pkgName,
buildNo: param.buildNo,
appVersion: param.appVersion,
platform: param.platform.toUpperCase()
}
};
console.log("上架的options是", options);
return tool.sendRequestToAdminServer(options);
};
const registApp = function(param) {
assert.ok(param.appName, "appName id can't be null");
assert.ok(param.iconUrl, "iconUrl id can't be null");
const options = {
method: "POST",
url: `${adminServer}/public/releases/url-upload?domainId=${param.domainId}`,
json: true,
body: {
appName: param.appName,
iconUrl: param.iconUrl
}
};
console.log("注册app的options是", options);
return tool.sendRequestToAdminServer(options);
};
return {
putOnToShelf,
registApp
};
};
module.exports = {
app: initAppModule
};