zcatalyst-cli 1.10.1 → 1.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/.DS_Store +0 -0
- package/docs/client-utils.toml +5 -0
- package/docs/command_needs/auth.toml +1 -1
- package/docs/optional-import.toml +10 -0
- package/docs/plugin-loader.toml +4 -0
- package/docs/serve/server/index.toml +4 -0
- package/docs/serve/server/lib/web_client/server.toml +4 -0
- package/lib/apig-utils.js +2 -1
- package/lib/authentication/login.js +10 -12
- package/lib/client-utils.js +8 -6
- package/lib/command_needs/auth.js +2 -2
- package/lib/commands/client/delete.js +2 -1
- package/lib/commands/ds/status.js +5 -5
- package/lib/commands/event/generate/index.js +4 -13
- package/lib/commands/functions/delete.js +2 -2
- package/lib/commands/functions/shell.js +5 -2
- package/lib/commands/iac/import.js +37 -10
- package/lib/commands/init.js +1 -1
- package/lib/commands/pull.js +1 -1
- package/lib/commands/serve.js +2 -1
- package/lib/endpoints/lib/sdk.js +2 -2
- package/lib/error.js +16 -13
- package/lib/errorOut.js +2 -2
- package/lib/fn-utils/lib/common.js +4 -4
- package/lib/fn-utils/lib/java.js +6 -4
- package/lib/fn-utils/lib/node.js +2 -2
- package/lib/init/dependencies/npm-install.js +10 -10
- package/lib/init/features/client/index.js +47 -0
- package/lib/init/features/client/initializers/angular.js +104 -0
- package/lib/init/features/client/initializers/basic.js +50 -0
- package/lib/init/features/client/initializers/lyte.js +56 -0
- package/lib/init/features/client/initializers/react.js +78 -0
- package/lib/init/features/functions/index.js +14 -5
- package/lib/init/features/functions/languages/node.js +3 -1
- package/lib/init/features/index.js +10 -3
- package/lib/init/features/project.js +1 -1
- package/lib/init/util/client.js +89 -4
- package/lib/internal/command.js +4 -1
- package/lib/internal/config.js +2 -1
- package/lib/optional-import.js +27 -26
- package/lib/plugin-loader.js +27 -10
- package/lib/port-resolver.js +4 -2
- package/lib/prompt/index.js +1 -1
- package/lib/pull/features/functions/index.js +1 -1
- package/lib/serve/index.js +6 -1
- package/lib/serve/server/index.js +52 -8
- package/lib/serve/server/lib/java/JavaaioServer.java +3 -2
- package/lib/serve/server/lib/master.js +22 -24
- package/lib/serve/server/lib/web_client/index.js +30 -0
- package/lib/serve/server/lib/web_client/server.js +174 -0
- package/lib/shell/dependencies/invoker/bio/java/JavabioInvoker.java +7 -1
- package/lib/shell/dependencies/invoker/bio/node.js +5 -2
- package/lib/shell/index.js +10 -6
- package/lib/util_modules/char.js +1 -1
- package/lib/util_modules/config/lib/apig.js +2 -1
- package/lib/util_modules/config/lib/client.js +18 -21
- package/lib/util_modules/constants/index.js +3 -1
- package/lib/util_modules/constants/lib/placeholders.js +1 -0
- package/lib/util_modules/constants/lib/plugin.js +28 -0
- package/lib/util_modules/constants/lib/template.js +11 -1
- package/lib/util_modules/constants/lib/urls.js +29 -13
- package/lib/util_modules/{contextHelp.js → context-help.js} +0 -0
- package/lib/util_modules/env.js +13 -12
- package/lib/util_modules/fs/index.js +1 -9
- package/lib/util_modules/fs/lib/async.js +3 -3
- package/lib/util_modules/fs/utils.js +8 -0
- package/lib/util_modules/global-space.js +2 -0
- package/lib/util_modules/option.js +5 -1
- package/lib/util_modules/server.js +53 -0
- package/lib/util_modules/shell.js +10 -6
- package/lib/winston.js +1 -1
- package/package.json +8 -5
- package/templates/.DS_Store +0 -0
- package/templates/init/.DS_Store +0 -0
- package/templates/init/client/.DS_Store +0 -0
- package/templates/init/client/{client-package.json → basic/client-package.json} +0 -0
- package/templates/init/client/{index.html → basic/index.html} +0 -0
- package/templates/init/client/{main.css → basic/main.css} +0 -0
- package/templates/init/client/{main.js → basic/main.js} +0 -0
- package/templates/init/client/lyte/build/build.js +301 -0
- package/templates/init/client/lyte/build/scripts/cliDownloadScript.js +54 -0
- package/templates/init/client/lyte/client-package.json +5 -0
- package/templates/init/client/lyte/components/javascript/welcome-comp.js +13 -0
- package/templates/init/client/lyte/components/styles/welcome-comp.css +0 -0
- package/templates/init/client/lyte/components/templates/welcome-comp.html +8 -0
- package/templates/init/client/lyte/data-store/adapters/.gitkeep +0 -0
- package/templates/init/client/lyte/data-store/models/.gitkeep +0 -0
- package/templates/init/client/lyte/data-store/serializers/.gitkeep +0 -0
- package/templates/init/client/lyte/index.html +17 -0
- package/templates/init/client/lyte/package.json +12 -0
- package/templates/init/client/lyte/router.js +14 -0
- package/templates/init/client/lyte/routes/index.js +54 -0
- package/templates/init/client/react/.DS_Store +0 -0
- package/templates/init/client/react/react_js/package.json +11 -0
- package/templates/init/client/react/react_js/template/README.md +70 -0
- package/templates/init/client/react/react_js/template/client-package.json +5 -0
- package/templates/init/client/react/react_js/template/gitignore +23 -0
- package/templates/init/client/react/react_js/template/public/favicon.ico +0 -0
- package/templates/init/client/react/react_js/template/public/index.html +43 -0
- package/templates/init/client/react/react_js/template/public/logo192.png +0 -0
- package/templates/init/client/react/react_js/template/public/logo512.png +0 -0
- package/templates/init/client/react/react_js/template/public/manifest.json +25 -0
- package/templates/init/client/react/react_js/template/public/robots.txt +3 -0
- package/templates/init/client/react/react_js/template/src/App.css +38 -0
- package/templates/init/client/react/react_js/template/src/App.js +25 -0
- package/templates/init/client/react/react_js/template/src/App.test.js +8 -0
- package/templates/init/client/react/react_js/template/src/index.css +13 -0
- package/templates/init/client/react/react_js/template/src/index.js +17 -0
- package/templates/init/client/react/react_js/template/src/logo.svg +1 -0
- package/templates/init/client/react/react_js/template/src/reportWebVitals.js +13 -0
- package/templates/init/client/react/react_js/template/src/setupTests.js +5 -0
- package/templates/init/client/react/react_js/template.json +13 -0
- package/templates/init/client/react/react_ts/package.json +11 -0
- package/templates/init/client/react/react_ts/template/README.md +46 -0
- package/templates/init/client/react/react_ts/template/client-package.json +5 -0
- package/templates/init/client/react/react_ts/template/gitignore +23 -0
- package/templates/init/client/react/react_ts/template/public/favicon.ico +0 -0
- package/templates/init/client/react/react_ts/template/public/index.html +43 -0
- package/templates/init/client/react/react_ts/template/public/logo192.png +0 -0
- package/templates/init/client/react/react_ts/template/public/logo512.png +0 -0
- package/templates/init/client/react/react_ts/template/public/manifest.json +25 -0
- package/templates/init/client/react/react_ts/template/public/robots.txt +3 -0
- package/templates/init/client/react/react_ts/template/src/App.css +38 -0
- package/templates/init/client/react/react_ts/template/src/App.test.tsx +9 -0
- package/templates/init/client/react/react_ts/template/src/App.tsx +26 -0
- package/templates/init/client/react/react_ts/template/src/index.css +13 -0
- package/templates/init/client/react/react_ts/template/src/index.tsx +17 -0
- package/templates/init/client/react/react_ts/template/src/logo.svg +1 -0
- package/templates/init/client/react/react_ts/template/src/reportWebVitals.ts +15 -0
- package/templates/init/client/react/react_ts/template/src/setupTests.ts +5 -0
- package/templates/init/client/react/react_ts/template.json +18 -0
- package/templates/init/functions/java/integ/cliq/com/handlers/BotHandler.java +116 -113
- package/templates/init/functions/java/integ/cliq/com/handlers/CommandHandler.java +20 -27
- package/templates/init/functions/java/integ/cliq/com/handlers/FunctionHandler.java +143 -112
- package/templates/init/functions/java/integ/cliq/com/handlers/InstallationHandler.java +4 -7
- package/templates/init/functions/java/integ/cliq/com/handlers/InstallationValidator.java +4 -7
- package/templates/init/functions/java/integ/cliq/com/handlers/MessageActionHandler.java +10 -12
- package/templates/init/functions/java/integ/cliq/com/handlers/WidgetHandler.java +100 -66
- package/templates/init/functions/java/integ/cliq/sample.java +5 -7
- package/templates/init/functions/node/integ/cliq/.DS_Store +0 -0
- package/templates/init/functions/node/integ/cliq/handlers/bot-handler.js +23 -8
- package/templates/init/functions/node/integ/cliq/handlers/command-handler.js +3 -4
- package/templates/init/functions/node/integ/cliq/handlers/function-handler.js +46 -0
- package/templates/init/functions/node/integ/cliq/handlers/widget-handler.js +31 -0
- package/templates/init/functions/node/integ/cliq/package.json +2 -1
- package/templates/init/functions/node/integ/cliq/sample.js +3 -1
- package/templates/web-socket.txt +21 -0
- package/lib/init/features/client.js +0 -50
- package/lib/serve/server/lib/client.js +0 -30
|
@@ -21,7 +21,7 @@ import com.zc.cliq.objects.BotContextParam;
|
|
|
21
21
|
import com.zc.cliq.objects.BotSuggestion;
|
|
22
22
|
import com.zc.cliq.objects.ButtonObject;
|
|
23
23
|
import com.zc.cliq.objects.CardDetails;
|
|
24
|
-
import com.zc.cliq.objects.
|
|
24
|
+
import com.zc.cliq.objects.Message;
|
|
25
25
|
import com.zc.cliq.objects.Slide;
|
|
26
26
|
import com.zc.cliq.requests.BotContextHandlerRequest;
|
|
27
27
|
import com.zc.cliq.requests.BotMentionHandlerRequest;
|
|
@@ -31,113 +31,120 @@ import com.zc.cliq.requests.BotParticipationHandlerRequest;
|
|
|
31
31
|
import com.zc.cliq.requests.BotWebhookHandlerRequest;
|
|
32
32
|
import com.zc.cliq.requests.BotWelcomeHandlerRequest;
|
|
33
33
|
import com.zc.cliq.util.ZCCliqUtil;
|
|
34
|
+
import com.zc.component.cache.ZCCache;
|
|
34
35
|
|
|
35
|
-
public class BotHandler implements com.zc.cliq.interfaces.BotHandler
|
|
36
|
-
{
|
|
36
|
+
public class BotHandler implements com.zc.cliq.interfaces.BotHandler {
|
|
37
37
|
Logger LOGGER = Logger.getLogger(BotHandler.class.getName());
|
|
38
|
-
|
|
38
|
+
|
|
39
39
|
@Override
|
|
40
|
-
public Map<String,Object> welcomeHandler(BotWelcomeHandlerRequest req) {
|
|
40
|
+
public Map<String, Object> welcomeHandler(BotWelcomeHandlerRequest req) {
|
|
41
41
|
String uName = req.getUser() != null ? req.getUser().getFirstName() : "user";
|
|
42
42
|
String text = "Hello " + uName + ". Thank you for subscribing :smile:";
|
|
43
|
-
|
|
43
|
+
Message msg = Message.getInstance(text);
|
|
44
44
|
return ZCCliqUtil.toMap(msg);
|
|
45
45
|
}
|
|
46
|
-
|
|
46
|
+
|
|
47
47
|
@Override
|
|
48
|
-
public Map<String,Object> messageHandler(BotMessageHandlerRequest req) {
|
|
49
|
-
try{
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
catch(Exception ex){
|
|
48
|
+
public Map<String, Object> messageHandler(BotMessageHandlerRequest req) {
|
|
49
|
+
try {
|
|
50
|
+
String message = req.getMessage();
|
|
51
|
+
Map<String, Object> resp = new HashMap<String, Object>();
|
|
52
|
+
|
|
53
|
+
String text;
|
|
54
|
+
if (message == null) {
|
|
55
|
+
text = "Please enable 'Message' in bot settings";
|
|
56
|
+
} else if (message.equalsIgnoreCase("hi") || message.equalsIgnoreCase("hey")) {
|
|
57
|
+
text = "Hi " + req.getUser().getFirstName() + " :smile: How are you doing?";
|
|
58
|
+
BotSuggestion suggestion = BotSuggestion.getInstance();
|
|
59
|
+
suggestion.addSuggestion("Good");
|
|
60
|
+
suggestion.addSuggestion("Not bad");
|
|
61
|
+
suggestion.addSuggestion("Meh");
|
|
62
|
+
suggestion.addSuggestion("Worst");
|
|
63
|
+
resp.put("suggestions", suggestion);
|
|
64
|
+
} else if (message.equalsIgnoreCase("Good") || message.equalsIgnoreCase("Not bad")) {
|
|
65
|
+
text = "That's glad to hear :smile:";
|
|
66
|
+
} else if (message.equalsIgnoreCase("Meh") || message.equalsIgnoreCase("Worst")) {
|
|
67
|
+
text = "Oops! Don't you worry. Your day is definitely going to get better. :grinning:";
|
|
68
|
+
} else if (message.equalsIgnoreCase("details")) {
|
|
69
|
+
text = "Welcome to details collection center :wink:";
|
|
70
|
+
|
|
71
|
+
BotContext context = BotContext.getInstance();
|
|
72
|
+
context.setId("personal_details");
|
|
73
|
+
context.setTimeout(300);
|
|
74
|
+
|
|
75
|
+
BotContextParam param1 = BotContextParam.getInstance();
|
|
76
|
+
param1.setName("name");
|
|
77
|
+
param1.setQuestion("Please enter your name: ");
|
|
78
|
+
|
|
79
|
+
BotContextParam param2 = BotContextParam.getInstance();
|
|
80
|
+
param2.setName("dept");
|
|
81
|
+
param2.setQuestion("Please enter your department: ");
|
|
82
|
+
param2.addSuggestion("CSE");
|
|
83
|
+
param2.addSuggestion("IT");
|
|
84
|
+
param2.addSuggestion("MECH");
|
|
85
|
+
|
|
86
|
+
BotContextParam param3 = BotContextParam.getInstance();
|
|
87
|
+
param3.setName("cache");
|
|
88
|
+
param3.setQuestion("Do you wish to put this detail in Catalyst Cache ?");
|
|
89
|
+
param3.addSuggestion("YES");
|
|
90
|
+
param3.addSuggestion("NO");
|
|
91
|
+
|
|
92
|
+
context.setParams(param1, param2, param3);
|
|
93
|
+
resp.put("context", context);
|
|
94
|
+
} else if (message.equalsIgnoreCase("button")) {
|
|
95
|
+
|
|
96
|
+
Message msg = Message.getInstance("Here's your button");
|
|
97
|
+
ButtonObject btnObj = new ButtonObject();
|
|
98
|
+
btnObj.setType(BUTTON_TYPE.RED_OUTLINE);
|
|
99
|
+
btnObj.setLabel("Button1");
|
|
100
|
+
Action action = new Action();
|
|
101
|
+
action.setType(ACTION_TYPE.INVOKE_FUNCTION);
|
|
102
|
+
ActionData actionData = new ActionData();
|
|
103
|
+
actionData.setName("btnFunction");// ** ENTER YOUR BUTTON FUNCTION NAME HERE **
|
|
104
|
+
action.setData(actionData);
|
|
105
|
+
btnObj.setAction(action);
|
|
106
|
+
msg.addButton(btnObj);
|
|
107
|
+
return ZCCliqUtil.toMap(msg);
|
|
108
|
+
} else {
|
|
109
|
+
text = "Sorry, I'm not programmed yet to do this :sad:";
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
resp.put("text", text);
|
|
113
|
+
return resp;
|
|
114
|
+
|
|
115
|
+
} catch (Exception ex) {
|
|
118
116
|
LOGGER.log(Level.SEVERE, "Exception in message handler. ", ex);
|
|
119
117
|
throw ex;
|
|
120
118
|
}
|
|
121
119
|
}
|
|
122
|
-
|
|
120
|
+
|
|
123
121
|
@Override
|
|
124
122
|
public Map<String, Object> contextHandler(BotContextHandlerRequest req) {
|
|
125
|
-
|
|
126
123
|
Map<String, Object> resp = new HashMap<String, Object>();
|
|
127
|
-
if(req.getContextId().equals("personal_details")){
|
|
124
|
+
if (req.getContextId().equals("personal_details")) {
|
|
128
125
|
Map<String, String> answers = req.getAnswers();
|
|
129
126
|
StringBuilder str = new StringBuilder();
|
|
130
|
-
str.append("Name
|
|
131
|
-
str.append("Department
|
|
132
|
-
|
|
127
|
+
str.append("*Name*: ").append(answers.get("name")).append("\n");
|
|
128
|
+
str.append("*Department*: ").append(answers.get("dept")).append("\n");
|
|
129
|
+
|
|
130
|
+
if(answers.get("cache").equals("YES")) {
|
|
131
|
+
try {
|
|
132
|
+
ZCCache cache = ZCCache.getInstance();
|
|
133
|
+
cache.putCacheValue("Name", answers.get("name"), 1L);
|
|
134
|
+
cache.putCacheValue("Department", answers.get("dept"), 1L);
|
|
135
|
+
str.append("This data is now available in Catalyst Cache's default segment.");
|
|
136
|
+
} catch(Exception ex) {
|
|
137
|
+
System.out.print("Error putting the value to cache: " + ex.toString());
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
133
141
|
resp.put("text", "Nice ! I have collected your info: \n" + str.toString());
|
|
134
142
|
}
|
|
135
143
|
return resp;
|
|
136
144
|
}
|
|
137
145
|
|
|
138
146
|
@Override
|
|
139
|
-
public Map<String, Object> mentionHandler(BotMentionHandlerRequest req)
|
|
140
|
-
{
|
|
147
|
+
public Map<String, Object> mentionHandler(BotMentionHandlerRequest req) {
|
|
141
148
|
String text = "Hey *" + req.getUser().getFirstName() + "*, thanks for mentioning me here. I'm from Catalyst city";
|
|
142
149
|
Map<String, Object> resp = new HashMap<String, Object>();
|
|
143
150
|
resp.put("text", text);
|
|
@@ -148,13 +155,11 @@ public class BotHandler implements com.zc.cliq.interfaces.BotHandler
|
|
|
148
155
|
public Map<String, Object> menuActionHandler(BotMenuActionHandlerRequest req) {
|
|
149
156
|
Map<String, Object> resp = new HashMap<String, Object>();
|
|
150
157
|
String text;
|
|
151
|
-
if(req.getActionName().equals("Say Hi")){
|
|
158
|
+
if (req.getActionName().equals("Say Hi")) {
|
|
152
159
|
text = "Hi";
|
|
153
|
-
}
|
|
154
|
-
else if(req.getActionName().equals("Look Angry")){
|
|
160
|
+
} else if (req.getActionName().equals("Look Angry")) {
|
|
155
161
|
text = ":angry:";
|
|
156
|
-
}
|
|
157
|
-
else{
|
|
162
|
+
} else {
|
|
158
163
|
text = "Menu action triggered :fist:";
|
|
159
164
|
}
|
|
160
165
|
resp.put("text", text);
|
|
@@ -162,60 +167,58 @@ public class BotHandler implements com.zc.cliq.interfaces.BotHandler
|
|
|
162
167
|
}
|
|
163
168
|
|
|
164
169
|
@Override
|
|
165
|
-
public Map<String, Object> webhookHandler(BotWebhookHandlerRequest req) throws Exception
|
|
166
|
-
{
|
|
170
|
+
public Map<String, Object> webhookHandler(BotWebhookHandlerRequest req) throws Exception {
|
|
167
171
|
// Sample handler class for incoming mails in ZohoMail
|
|
168
172
|
// Please configure the bot in ZohoMail's outgoing webhooks
|
|
169
173
|
JSONObject reqBody = req.getBody();
|
|
170
174
|
String summary;
|
|
171
|
-
String bodyStr = new StringBuilder("*From*: ").append(reqBody.getString("fromAddress"))
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
MessageBuilder msg = MessageBuilder.getInstance(bodyStr);
|
|
175
|
-
msg.setBot("PostPerson", "https://previews.123rf.com/images/nastyatrel/nastyatrel2006/nastyatrel200600035/149438272-flat-vector-illustration-chat-bot-icon-flat-line-style-vector-.jpg");
|
|
175
|
+
String bodyStr = new StringBuilder("*From*: ").append(reqBody.getString("fromAddress")).append("\n*Subject*: ").append(reqBody.getString("subject")).append("\n*Content*: ").append((summary = reqBody.getString("summary")).length() > 100 ? summary.substring(0, 100) : summary).toString();
|
|
176
|
+
Message msg = Message.getInstance(bodyStr);
|
|
177
|
+
msg.setBot("PostPerson", "https://www.zoho.com/sites/default/files/catalyst/functions-images/icon-robot.jpg");
|
|
176
178
|
CardDetails card = CardDetails.getInstance();
|
|
177
179
|
card.setTitle("New Mail");
|
|
178
|
-
card.setThumbnail("https://
|
|
180
|
+
card.setThumbnail("https://www.zoho.com/sites/default/files/catalyst/functions-images/mail.svg");
|
|
179
181
|
msg.setCard(card);
|
|
180
|
-
|
|
182
|
+
|
|
181
183
|
ButtonObject button = new ButtonObject();
|
|
182
184
|
button.setLabel("Open mail");
|
|
183
185
|
button.setType(BUTTON_TYPE.GREEN_OUTLINE);
|
|
184
186
|
button.setHint("Click to open the mail in a new tab");
|
|
185
|
-
Action action
|
|
187
|
+
Action action = new Action();
|
|
186
188
|
action.setType(ACTION_TYPE.OPEN_URL);
|
|
187
189
|
ActionData actionData = new ActionData();
|
|
188
190
|
actionData.setWeb("https://mail.zoho.com/zm/#mail/folder/inbox/p/" + reqBody.getLong("messageId"));
|
|
189
191
|
action.setData(actionData);
|
|
190
192
|
button.setAction(action);
|
|
191
|
-
|
|
193
|
+
|
|
192
194
|
msg.addButton(button);
|
|
193
|
-
|
|
195
|
+
|
|
194
196
|
Slide gifSlide = Slide.getInstance();
|
|
195
197
|
gifSlide.setType(SLIDE_TYPE.IMAGES);
|
|
196
198
|
gifSlide.setTitle("");
|
|
197
|
-
List<String> obj = new ArrayList<String>(){
|
|
199
|
+
List<String> obj = new ArrayList<String>() {
|
|
200
|
+
{
|
|
201
|
+
add("https://media.giphy.com/media/efyEShk2FJ9X2Kpd7V/giphy.gif");
|
|
202
|
+
}
|
|
203
|
+
};
|
|
198
204
|
gifSlide.setData(obj);
|
|
199
|
-
|
|
205
|
+
|
|
200
206
|
msg.addSlide(gifSlide);
|
|
201
|
-
|
|
207
|
+
|
|
202
208
|
return ZCCliqUtil.toMap(msg);
|
|
203
209
|
}
|
|
204
210
|
|
|
205
211
|
@Override
|
|
206
|
-
public Map<String, Object> participationHandler(BotParticipationHandlerRequest req) throws Exception
|
|
207
|
-
{
|
|
212
|
+
public Map<String, Object> participationHandler(BotParticipationHandlerRequest req) throws Exception {
|
|
208
213
|
String text;
|
|
209
|
-
if(req.getOperation().equals(CHANNEL_OPERATION.ADDED)){
|
|
214
|
+
if (req.getOperation().equals(CHANNEL_OPERATION.ADDED)) {
|
|
210
215
|
text = "Hi. Thanks for adding me to the channel :smile:";
|
|
211
|
-
}
|
|
212
|
-
else if(req.getOperation().equals(CHANNEL_OPERATION.REMOVED)){
|
|
216
|
+
} else if (req.getOperation().equals(CHANNEL_OPERATION.REMOVED)) {
|
|
213
217
|
text = "Bye-Bye :bye-bye:";
|
|
214
|
-
}
|
|
215
|
-
else{
|
|
218
|
+
} else {
|
|
216
219
|
text = "I'm too a participant of this chat :wink:";
|
|
217
220
|
}
|
|
218
|
-
|
|
221
|
+
Message msg = Message.getInstance(text);
|
|
219
222
|
return ZCCliqUtil.toMap(msg);
|
|
220
223
|
}
|
|
221
224
|
}
|
|
@@ -15,39 +15,33 @@ import com.zc.cliq.objects.FormValue;
|
|
|
15
15
|
import com.zc.cliq.requests.CommandHandlerRequest;
|
|
16
16
|
import com.zc.cliq.util.ZCCliqUtil;
|
|
17
17
|
|
|
18
|
-
public class CommandHandler implements com.zc.cliq.interfaces.CommandHandler
|
|
19
|
-
{
|
|
18
|
+
public class CommandHandler implements com.zc.cliq.interfaces.CommandHandler {
|
|
20
19
|
@Override
|
|
21
|
-
public Map<String, Object> executionHandler(CommandHandlerRequest req) throws Exception{
|
|
22
|
-
|
|
20
|
+
public Map<String, Object> executionHandler(CommandHandlerRequest req) throws Exception {
|
|
21
|
+
|
|
23
22
|
Map<String, Object> resp = new HashMap<String, Object>();
|
|
24
23
|
String text;
|
|
25
24
|
String commandName = req.getName();
|
|
26
|
-
if(commandName.equals("catalystresource")){
|
|
25
|
+
if (commandName.equals("catalystresource")) {
|
|
27
26
|
List<CommandSuggestion> suggestions = req.getSelections();
|
|
28
|
-
if(suggestions == null || suggestions.isEmpty()){
|
|
27
|
+
if (suggestions == null || suggestions.isEmpty()) {
|
|
29
28
|
text = "Please select a suggestion from the command";
|
|
30
|
-
}
|
|
31
|
-
else{
|
|
29
|
+
} else {
|
|
32
30
|
String prefix = "Take a look at our ";
|
|
33
|
-
if(suggestions.get(0).getTitle().equals("API doc")){
|
|
31
|
+
if (suggestions.get(0).getTitle().equals("API doc")) {
|
|
34
32
|
text = prefix + "[API Documentation](https://www.zoho.com/catalyst/help/api/introduction/overview.html)";
|
|
35
|
-
}
|
|
36
|
-
else if(suggestions.get(0).getTitle().equals("CLI doc")){
|
|
33
|
+
} else if (suggestions.get(0).getTitle().equals("CLI doc")) {
|
|
37
34
|
text = prefix + "[CLI Documentation](https://www.zoho.com/catalyst/help/cli-command-reference.html)";
|
|
38
|
-
}
|
|
39
|
-
else{
|
|
35
|
+
} else {
|
|
40
36
|
text = prefix + "[help documentation](https://www.zoho.com/catalyst/help/)";
|
|
41
37
|
}
|
|
42
38
|
}
|
|
43
|
-
}
|
|
44
|
-
else if(commandName.equals("getform")){
|
|
39
|
+
} else if (commandName.equals("getform")) {
|
|
45
40
|
return getForm();
|
|
46
|
-
}
|
|
47
|
-
else{
|
|
41
|
+
} else {
|
|
48
42
|
text = "Command executed successfully!";
|
|
49
43
|
}
|
|
50
|
-
|
|
44
|
+
|
|
51
45
|
resp.put("text", text);
|
|
52
46
|
return resp;
|
|
53
47
|
}
|
|
@@ -55,7 +49,7 @@ public class CommandHandler implements com.zc.cliq.interfaces.CommandHandler
|
|
|
55
49
|
@Override
|
|
56
50
|
public List<CommandSuggestion> suggestionHandler(CommandHandlerRequest req) {
|
|
57
51
|
List<CommandSuggestion> suggestionList = new ArrayList<CommandSuggestion>();
|
|
58
|
-
if(req.getName().equals("catalystresource")){
|
|
52
|
+
if (req.getName().equals("catalystresource")) {
|
|
59
53
|
CommandSuggestion sugg1 = CommandSuggestion.getInstance("API doc", "Catalyst API documentation", "https://www.zohowebstatic.com/sites/default/files/styles/product-home-page/public/catalyst-icon.png");
|
|
60
54
|
CommandSuggestion sugg2 = CommandSuggestion.getInstance("CLI doc", "Catalyst CLI documentation", "https://www.zohowebstatic.com/sites/default/files/styles/product-home-page/public/catalyst-icon.png");
|
|
61
55
|
CommandSuggestion sugg3 = CommandSuggestion.getInstance("Help doc", "Catalyst Help documentation", "https://www.zohowebstatic.com/sites/default/files/styles/product-home-page/public/catalyst-icon.png");
|
|
@@ -66,20 +60,19 @@ public class CommandHandler implements com.zc.cliq.interfaces.CommandHandler
|
|
|
66
60
|
return suggestionList;
|
|
67
61
|
}
|
|
68
62
|
|
|
69
|
-
private static Map<String, Object> getForm()
|
|
70
|
-
{
|
|
63
|
+
private static Map<String, Object> getForm() {
|
|
71
64
|
Form form = Form.getInstance();
|
|
72
65
|
form.setTitle("Asset Request");
|
|
73
66
|
form.setHint("Raise your asset request");
|
|
74
67
|
form.setName("ID");
|
|
75
68
|
form.setButtonLabel("Raise Request");
|
|
76
69
|
form.setVersion(1);
|
|
77
|
-
|
|
70
|
+
|
|
78
71
|
FormActionsObject actions = FormActionsObject.getInstance();
|
|
79
72
|
actions.setSubmitAction("formFunctionLatest"); // ** ENTER YOUR FORM FUNCTION NAME HERE **
|
|
80
|
-
|
|
73
|
+
|
|
81
74
|
form.setActions(actions);
|
|
82
|
-
|
|
75
|
+
|
|
83
76
|
FormInput username = FormInput.getIntance();
|
|
84
77
|
username.setType(FORM_FIELD_TYPE.TEXT);
|
|
85
78
|
username.setName("username");
|
|
@@ -89,7 +82,7 @@ public class CommandHandler implements com.zc.cliq.interfaces.CommandHandler
|
|
|
89
82
|
username.setMandatory(true);
|
|
90
83
|
username.setValue("Harold Finch");
|
|
91
84
|
form.addFormInput(username);
|
|
92
|
-
|
|
85
|
+
|
|
93
86
|
FormInput email = FormInput.getIntance();
|
|
94
87
|
email.setType(FORM_FIELD_TYPE.TEXT);
|
|
95
88
|
email.setFormat(FORM_FIELD_TEXT_FORMAT.EMAIL);
|
|
@@ -100,7 +93,7 @@ public class CommandHandler implements com.zc.cliq.interfaces.CommandHandler
|
|
|
100
93
|
email.setMandatory(true);
|
|
101
94
|
email.setValue("haroldfinch@samaritan.com");
|
|
102
95
|
form.addFormInput(email);
|
|
103
|
-
|
|
96
|
+
|
|
104
97
|
FormInput assetType = FormInput.getIntance();
|
|
105
98
|
assetType.setType(FORM_FIELD_TYPE.SELECT);
|
|
106
99
|
assetType.setTriggerOnChange(true);
|
|
@@ -112,7 +105,7 @@ public class CommandHandler implements com.zc.cliq.interfaces.CommandHandler
|
|
|
112
105
|
assetType.addOption(new FormValue("Laptop", "laptop"));
|
|
113
106
|
assetType.addOption(new FormValue("Mobile", "mobile"));
|
|
114
107
|
form.addFormInput(assetType);
|
|
115
|
-
|
|
108
|
+
|
|
116
109
|
return ZCCliqUtil.toMap(form);
|
|
117
110
|
}
|
|
118
111
|
}
|