This repository was archived by the owner on Dec 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathcd-badges.js
60 lines (54 loc) · 3.19 KB
/
cd-badges.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
'use strict';
var listBadges = require('./list-badges');
var getBadge = require('./get-badge');
var deleteBadge = require('./delete-badge');
var updateBadge = require('./update-badge');
var createBadge = require('./create-badge');
var awardBadge = require('./award-badge');
var acceptBadge = require('./accept-badge');
var loadUserBadges = require('./load-user-badges');
var loadBadgeCategories = require('./load-badge-categories');
var loadBadgeByCode = require('./load-badge-by-code');
var claimBadge = require('./claim-badge');
var addBadgeToProfile = require('./add-badge-to-profile');
var exportBadges = require('./export-badges');
var verifyBadge = require('./verify-badge');
var assignRecurrentBadges = require('./assign-recurrent-badges');
// KPIs
var kpiNumberOfBadgesAwarded = require('./kpi-number-of-badges-awarded');
var kpiNumberOfBadgesPublished = require('./kpi-number-of-badges-published');
// Perms
var ownBadge = require('./perm/own-badge');
module.exports = function () {
var seneca = this;
var plugin = 'cd-badges';
var options = seneca.export('options');
seneca.add({role: plugin, cmd: 'listBadges'}, listBadges({ apiBaseUrl: options.apiBaseUrl, apiSecret: options.apiSecret, claimCodePrefix: options.claimCodePrefix }));
seneca.add({role: plugin, cmd: 'getBadge'}, getBadge({ apiBaseUrl: options.apiBaseUrl, apiSecret: options.apiSecret }));
seneca.add({role: plugin, cmd: 'deleteBadge'}, deleteBadge({ apiBaseUrl: options.apiBaseUrl, apiSecret: options.apiSecret }));
seneca.add({role: plugin, cmd: 'updateBadge'}, updateBadge({ apiBaseUrl: options.apiBaseUrl, apiSecret: options.apiSecret }));
seneca.add({role: plugin, cmd: 'createBadge'}, createBadge({ apiBaseUrl: options.apiBaseUrl, apiSecret: options.apiSecret }));
seneca.add({role: plugin, cmd: 'awardBadge'}, awardBadge.bind(seneca));
// Legacy, used for accepting old badges && to support old code
// Do not remove until the rest is refactored/ensured not-used anymore
seneca.add({role: plugin, cmd: 'sendBadgeApplication'}, awardBadge.bind(seneca));
seneca.add({role: plugin, cmd: 'acceptBadge'}, acceptBadge.bind(seneca));
seneca.add({role: plugin, cmd: 'loadUserBadges'}, loadUserBadges.bind(seneca));
seneca.add({role: plugin, cmd: 'loadBadgeCategories'}, loadBadgeCategories);
seneca.add({role: plugin, cmd: 'loadBadgeByCode'}, loadBadgeByCode({ apiBaseUrl: options.apiBaseUrl, apiSecret: options.apiSecret}));
seneca.add({role: plugin, cmd: 'claimBadge'}, claimBadge.bind(seneca));
seneca.add({role: plugin, cmd: 'addBadgeToProfile'}, addBadgeToProfile.bind(seneca));
seneca.add({role: plugin, cmd: 'exportBadges'}, exportBadges.bind(seneca));
seneca.add({role: plugin, cmd: 'verifyBadge'}, verifyBadge.bind(seneca));
seneca.add({role: plugin, cmd: 'assignRecurrentBadges'}, assignRecurrentBadges.bind(seneca));
// KPIs
seneca.add({role: plugin, cmd: 'kpiNumberOfBadgesAwarded'}, kpiNumberOfBadgesAwarded.bind(seneca));
seneca.add({role: plugin, cmd: 'kpiNumberOfBadgesPublished'}, kpiNumberOfBadgesPublished.bind(seneca));
// Perms
seneca.add({role: plugin, cmd: 'ownBadge'}, ownBadge.bind(seneca));
// System
seneca.add({ role: plugin, cmd: 'ping' }, require('./ping'));
return {
name: plugin
};
};