0.0.2 • Published 6 years ago
@axolo/egg-dingtalk v0.0.2
egg-dingtalk
node-dingtalk plugin for Egg.js.
Install
npm i @axolo/egg-dingtalk --saveUsage
// {app_root}/config/plugin.js
exports.dingtalk = {
enable: true,
package: '@axolo/egg-dingtalk',
};Configuration
// {app_root}/config/config.default.js
exports.dingtalk = {};see https://github.com/axolo/node-dingtalk for more help. see config/config.default.js for more detail.
Config client or clients as you like:
dingtalk corp app:
{ client: { appKey, appSecret, agentId } }dingtalk isv suite with single app:
{ client: { suiteKey, suiteSecret, appId } }dingtalk isv suite with multiple apps:
{
client: {
suiteKey,
suiteSecret,
apps: [ { appId }, { appId } ],
}
}dingtalk isv suite with multiple apps per app:
{
clients: {
app1: { suiteKey, suiteSecret, appId },
app2: { suiteKey, suiteSecret, appId },
},
}Example
const Controller = require('egg').Controller;
class DingtalkController extends Controller {
async index() {
const { app, ctx } = this;
const { dingtalk } = app;
const corpId = 'CORP_ID';
const params = { id: 1 };
const result = await dingtalk.execute('/department/get', { params }, { corpId });
ctx.body = result;
}
}
module.exports = DingtalkController;Questions & Suggestions
Please open an issue here.