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.
Files changed (149) hide show
  1. package/docs/.DS_Store +0 -0
  2. package/docs/client-utils.toml +5 -0
  3. package/docs/command_needs/auth.toml +1 -1
  4. package/docs/optional-import.toml +10 -0
  5. package/docs/plugin-loader.toml +4 -0
  6. package/docs/serve/server/index.toml +4 -0
  7. package/docs/serve/server/lib/web_client/server.toml +4 -0
  8. package/lib/apig-utils.js +2 -1
  9. package/lib/authentication/login.js +10 -12
  10. package/lib/client-utils.js +8 -6
  11. package/lib/command_needs/auth.js +2 -2
  12. package/lib/commands/client/delete.js +2 -1
  13. package/lib/commands/ds/status.js +5 -5
  14. package/lib/commands/event/generate/index.js +4 -13
  15. package/lib/commands/functions/delete.js +2 -2
  16. package/lib/commands/functions/shell.js +5 -2
  17. package/lib/commands/iac/import.js +37 -10
  18. package/lib/commands/init.js +1 -1
  19. package/lib/commands/pull.js +1 -1
  20. package/lib/commands/serve.js +2 -1
  21. package/lib/endpoints/lib/sdk.js +2 -2
  22. package/lib/error.js +16 -13
  23. package/lib/errorOut.js +2 -2
  24. package/lib/fn-utils/lib/common.js +4 -4
  25. package/lib/fn-utils/lib/java.js +6 -4
  26. package/lib/fn-utils/lib/node.js +2 -2
  27. package/lib/init/dependencies/npm-install.js +10 -10
  28. package/lib/init/features/client/index.js +47 -0
  29. package/lib/init/features/client/initializers/angular.js +104 -0
  30. package/lib/init/features/client/initializers/basic.js +50 -0
  31. package/lib/init/features/client/initializers/lyte.js +56 -0
  32. package/lib/init/features/client/initializers/react.js +78 -0
  33. package/lib/init/features/functions/index.js +14 -5
  34. package/lib/init/features/functions/languages/node.js +3 -1
  35. package/lib/init/features/index.js +10 -3
  36. package/lib/init/features/project.js +1 -1
  37. package/lib/init/util/client.js +89 -4
  38. package/lib/internal/command.js +4 -1
  39. package/lib/internal/config.js +2 -1
  40. package/lib/optional-import.js +27 -26
  41. package/lib/plugin-loader.js +27 -10
  42. package/lib/port-resolver.js +4 -2
  43. package/lib/prompt/index.js +1 -1
  44. package/lib/pull/features/functions/index.js +1 -1
  45. package/lib/serve/index.js +6 -1
  46. package/lib/serve/server/index.js +52 -8
  47. package/lib/serve/server/lib/java/JavaaioServer.java +3 -2
  48. package/lib/serve/server/lib/master.js +22 -24
  49. package/lib/serve/server/lib/web_client/index.js +30 -0
  50. package/lib/serve/server/lib/web_client/server.js +174 -0
  51. package/lib/shell/dependencies/invoker/bio/java/JavabioInvoker.java +7 -1
  52. package/lib/shell/dependencies/invoker/bio/node.js +5 -2
  53. package/lib/shell/index.js +10 -6
  54. package/lib/util_modules/char.js +1 -1
  55. package/lib/util_modules/config/lib/apig.js +2 -1
  56. package/lib/util_modules/config/lib/client.js +18 -21
  57. package/lib/util_modules/constants/index.js +3 -1
  58. package/lib/util_modules/constants/lib/placeholders.js +1 -0
  59. package/lib/util_modules/constants/lib/plugin.js +28 -0
  60. package/lib/util_modules/constants/lib/template.js +11 -1
  61. package/lib/util_modules/constants/lib/urls.js +29 -13
  62. package/lib/util_modules/{contextHelp.js → context-help.js} +0 -0
  63. package/lib/util_modules/env.js +13 -12
  64. package/lib/util_modules/fs/index.js +1 -9
  65. package/lib/util_modules/fs/lib/async.js +3 -3
  66. package/lib/util_modules/fs/utils.js +8 -0
  67. package/lib/util_modules/global-space.js +2 -0
  68. package/lib/util_modules/option.js +5 -1
  69. package/lib/util_modules/server.js +53 -0
  70. package/lib/util_modules/shell.js +10 -6
  71. package/lib/winston.js +1 -1
  72. package/package.json +8 -5
  73. package/templates/.DS_Store +0 -0
  74. package/templates/init/.DS_Store +0 -0
  75. package/templates/init/client/.DS_Store +0 -0
  76. package/templates/init/client/{client-package.json → basic/client-package.json} +0 -0
  77. package/templates/init/client/{index.html → basic/index.html} +0 -0
  78. package/templates/init/client/{main.css → basic/main.css} +0 -0
  79. package/templates/init/client/{main.js → basic/main.js} +0 -0
  80. package/templates/init/client/lyte/build/build.js +301 -0
  81. package/templates/init/client/lyte/build/scripts/cliDownloadScript.js +54 -0
  82. package/templates/init/client/lyte/client-package.json +5 -0
  83. package/templates/init/client/lyte/components/javascript/welcome-comp.js +13 -0
  84. package/templates/init/client/lyte/components/styles/welcome-comp.css +0 -0
  85. package/templates/init/client/lyte/components/templates/welcome-comp.html +8 -0
  86. package/templates/init/client/lyte/data-store/adapters/.gitkeep +0 -0
  87. package/templates/init/client/lyte/data-store/models/.gitkeep +0 -0
  88. package/templates/init/client/lyte/data-store/serializers/.gitkeep +0 -0
  89. package/templates/init/client/lyte/index.html +17 -0
  90. package/templates/init/client/lyte/package.json +12 -0
  91. package/templates/init/client/lyte/router.js +14 -0
  92. package/templates/init/client/lyte/routes/index.js +54 -0
  93. package/templates/init/client/react/.DS_Store +0 -0
  94. package/templates/init/client/react/react_js/package.json +11 -0
  95. package/templates/init/client/react/react_js/template/README.md +70 -0
  96. package/templates/init/client/react/react_js/template/client-package.json +5 -0
  97. package/templates/init/client/react/react_js/template/gitignore +23 -0
  98. package/templates/init/client/react/react_js/template/public/favicon.ico +0 -0
  99. package/templates/init/client/react/react_js/template/public/index.html +43 -0
  100. package/templates/init/client/react/react_js/template/public/logo192.png +0 -0
  101. package/templates/init/client/react/react_js/template/public/logo512.png +0 -0
  102. package/templates/init/client/react/react_js/template/public/manifest.json +25 -0
  103. package/templates/init/client/react/react_js/template/public/robots.txt +3 -0
  104. package/templates/init/client/react/react_js/template/src/App.css +38 -0
  105. package/templates/init/client/react/react_js/template/src/App.js +25 -0
  106. package/templates/init/client/react/react_js/template/src/App.test.js +8 -0
  107. package/templates/init/client/react/react_js/template/src/index.css +13 -0
  108. package/templates/init/client/react/react_js/template/src/index.js +17 -0
  109. package/templates/init/client/react/react_js/template/src/logo.svg +1 -0
  110. package/templates/init/client/react/react_js/template/src/reportWebVitals.js +13 -0
  111. package/templates/init/client/react/react_js/template/src/setupTests.js +5 -0
  112. package/templates/init/client/react/react_js/template.json +13 -0
  113. package/templates/init/client/react/react_ts/package.json +11 -0
  114. package/templates/init/client/react/react_ts/template/README.md +46 -0
  115. package/templates/init/client/react/react_ts/template/client-package.json +5 -0
  116. package/templates/init/client/react/react_ts/template/gitignore +23 -0
  117. package/templates/init/client/react/react_ts/template/public/favicon.ico +0 -0
  118. package/templates/init/client/react/react_ts/template/public/index.html +43 -0
  119. package/templates/init/client/react/react_ts/template/public/logo192.png +0 -0
  120. package/templates/init/client/react/react_ts/template/public/logo512.png +0 -0
  121. package/templates/init/client/react/react_ts/template/public/manifest.json +25 -0
  122. package/templates/init/client/react/react_ts/template/public/robots.txt +3 -0
  123. package/templates/init/client/react/react_ts/template/src/App.css +38 -0
  124. package/templates/init/client/react/react_ts/template/src/App.test.tsx +9 -0
  125. package/templates/init/client/react/react_ts/template/src/App.tsx +26 -0
  126. package/templates/init/client/react/react_ts/template/src/index.css +13 -0
  127. package/templates/init/client/react/react_ts/template/src/index.tsx +17 -0
  128. package/templates/init/client/react/react_ts/template/src/logo.svg +1 -0
  129. package/templates/init/client/react/react_ts/template/src/reportWebVitals.ts +15 -0
  130. package/templates/init/client/react/react_ts/template/src/setupTests.ts +5 -0
  131. package/templates/init/client/react/react_ts/template.json +18 -0
  132. package/templates/init/functions/java/integ/cliq/com/handlers/BotHandler.java +116 -113
  133. package/templates/init/functions/java/integ/cliq/com/handlers/CommandHandler.java +20 -27
  134. package/templates/init/functions/java/integ/cliq/com/handlers/FunctionHandler.java +143 -112
  135. package/templates/init/functions/java/integ/cliq/com/handlers/InstallationHandler.java +4 -7
  136. package/templates/init/functions/java/integ/cliq/com/handlers/InstallationValidator.java +4 -7
  137. package/templates/init/functions/java/integ/cliq/com/handlers/MessageActionHandler.java +10 -12
  138. package/templates/init/functions/java/integ/cliq/com/handlers/WidgetHandler.java +100 -66
  139. package/templates/init/functions/java/integ/cliq/sample.java +5 -7
  140. package/templates/init/functions/node/integ/cliq/.DS_Store +0 -0
  141. package/templates/init/functions/node/integ/cliq/handlers/bot-handler.js +23 -8
  142. package/templates/init/functions/node/integ/cliq/handlers/command-handler.js +3 -4
  143. package/templates/init/functions/node/integ/cliq/handlers/function-handler.js +46 -0
  144. package/templates/init/functions/node/integ/cliq/handlers/widget-handler.js +31 -0
  145. package/templates/init/functions/node/integ/cliq/package.json +2 -1
  146. package/templates/init/functions/node/integ/cliq/sample.js +3 -1
  147. package/templates/web-socket.txt +21 -0
  148. package/lib/init/features/client.js +0 -50
  149. 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.MessageBuilder;
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
- MessageBuilder msg = MessageBuilder.getInstance(text);
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
- String message = req.getMessage();
52
- Map<String, Object> resp = new HashMap<String, Object>();
53
-
54
- String text;
55
- if(message == null){
56
- text = "Please enable 'Message' in bot settings";
57
- }
58
- else if(message.equalsIgnoreCase("hi") || message.equalsIgnoreCase("hey")){
59
- text = "Hi " + req.getUser().getFirstName() + " :smile: How are you doing?";
60
- BotSuggestion suggestion = BotSuggestion.getInstance();
61
- suggestion.addSuggestion("Good");
62
- suggestion.addSuggestion("Not bad");
63
- suggestion.addSuggestion("Meh");
64
- suggestion.addSuggestion("Worst");
65
- resp.put("suggestions", suggestion);
66
- }
67
- else if(message.equalsIgnoreCase("Good") || message.equalsIgnoreCase("Not bad")){
68
- text = "That's glad to hear :smile:";
69
- }
70
- else if(message.equalsIgnoreCase("Meh") || message.equalsIgnoreCase("Worst")){
71
- text = "Oops! Don't you worry. Your day is definitely going to get better. :grinning:";
72
- }
73
- else if(message.equalsIgnoreCase("details")){
74
- text = "Welcome to details collection center :wink:";
75
-
76
- BotContext context = BotContext.getInstance();
77
- context.setId("personal_details");
78
- context.setTimeout(300);
79
-
80
- BotContextParam param1 = BotContextParam.getInstance();
81
- param1.setName("name");
82
- param1.setQuestion("Please enter your name: ");
83
-
84
- BotContextParam param2 = BotContextParam.getInstance();
85
- param2.setName("dept");
86
- param2.setQuestion("Please enter your department: ");
87
- param2.addSuggestion("CSE");
88
- param2.addSuggestion("IT");
89
- param2.addSuggestion("MECH");
90
-
91
- context.setParams(param1, param2);
92
- resp.put("context", context);
93
- }
94
- else if(message.equalsIgnoreCase("button")){
95
-
96
- MessageBuilder msg = MessageBuilder.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
- }
109
- else{
110
- text = "Sorry, I'm not programmed yet to do this :sad:";
111
- }
112
-
113
- resp.put("text", text);
114
- return resp;
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: ").append(answers.get("name")).append("\n");
131
- str.append("Department: ").append(answers.get("dept")).append("\n");
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
- .append("\n*Subject*: ").append(reqBody.getString("subject"))
173
- .append("\n*Content*: ").append((summary=reqBody.getString("summary")).length() > 100 ? summary.substring(0, 100) : summary).toString();
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://seekicon.com/free-icon-download/mail-icon_18.svg");
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 = new 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>(){{add("https://media.giphy.com/media/efyEShk2FJ9X2Kpd7V/giphy.gif");}};
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
- MessageBuilder msg = MessageBuilder.getInstance(text);
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
  }