zcatalyst-cli 1.18.0-beta.10 → 1.18.0-beta.11-slate

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 (100) hide show
  1. package/docs/commands/slate/unlink.toml +9 -0
  2. package/docs/option-filter.toml +5 -0
  3. package/docs/serve/server/lib/slate/index.toml +14 -0
  4. package/docs/slate-utils.toml +4 -0
  5. package/lib/archiver.js +18 -9
  6. package/lib/command_needs/auth.js +1 -1
  7. package/lib/command_needs/rc.js +40 -3
  8. package/lib/commands/deploy/index.js +6 -1
  9. package/lib/commands/deploy/slate.js +58 -0
  10. package/lib/commands/index.js +3 -0
  11. package/lib/commands/init.js +4 -0
  12. package/lib/commands/slate/create.js +60 -0
  13. package/lib/commands/slate/link.js +60 -0
  14. package/lib/commands/slate/unlink.js +74 -0
  15. package/lib/deploy/features/index.js +3 -0
  16. package/lib/deploy/features/slate.js +123 -0
  17. package/lib/endpoints/index.js +8 -1
  18. package/lib/endpoints/lib/slate.js +91 -0
  19. package/lib/fn-utils/lib/common.js +1 -1
  20. package/lib/init/features/appsail/index.js +1 -1
  21. package/lib/init/features/index.js +15 -2
  22. package/lib/init/features/project.js +1 -1
  23. package/lib/init/features/slate/index.js +308 -0
  24. package/lib/internal/api.js +1 -1
  25. package/lib/internal/command.js +9 -5
  26. package/lib/option-filter.js +8 -2
  27. package/lib/port-resolver.js +7 -0
  28. package/lib/prompt/types/file-path.js +8 -5
  29. package/lib/serve/features/index.js +8 -1
  30. package/lib/serve/features/slate.js +47 -0
  31. package/lib/serve/index.js +19 -0
  32. package/lib/serve/server/index.js +61 -1
  33. package/lib/serve/server/lib/appsail/index.js +1 -1
  34. package/lib/serve/server/lib/master/index.js +25 -21
  35. package/lib/serve/server/lib/master/slate.js +45 -0
  36. package/lib/serve/server/lib/master/utils.js +2 -2
  37. package/lib/serve/server/lib/slate/index.js +144 -0
  38. package/lib/serve/server/lib/slate/static-server.js +193 -0
  39. package/lib/slate-utils.js +212 -0
  40. package/lib/util_modules/config/index.js +3 -1
  41. package/lib/util_modules/config/lib/slate.js +94 -0
  42. package/lib/util_modules/constants/lib/cliq-handlers.js +18 -10
  43. package/lib/util_modules/constants/lib/default.js +4 -0
  44. package/lib/util_modules/constants/lib/file-names.js +7 -1
  45. package/lib/util_modules/constants/lib/folder-names.js +1 -0
  46. package/lib/util_modules/constants/lib/scopes.js +3 -1
  47. package/lib/util_modules/context-help.js +2 -2
  48. package/lib/util_modules/fs/lib/async.js +8 -1
  49. package/lib/util_modules/fs/lib/sync.js +6 -1
  50. package/lib/util_modules/parser/toml.js +20 -5
  51. package/package.json +2 -2
  52. package/templates/event/integ/cliq/bot/action_handler.json +13 -4
  53. package/templates/event/integ/cliq/bot/call_handler.json +41 -0
  54. package/templates/event/integ/cliq/bot/context_handler.json +11 -3
  55. package/templates/event/integ/cliq/bot/incomingwebhook_handler.json +11 -3
  56. package/templates/event/integ/cliq/bot/mention_handler.json +12 -4
  57. package/templates/event/integ/cliq/bot/message_handler.json +13 -4
  58. package/templates/event/integ/cliq/bot/participation_handler.json +13 -3
  59. package/templates/event/integ/cliq/bot/welcome_handler.json +12 -8
  60. package/templates/event/integ/cliq/command/execution_handler.json +12 -3
  61. package/templates/event/integ/cliq/command/suggestion_handler.json +18 -4
  62. package/templates/event/integ/cliq/{installation → extension}/installation_handler.json +13 -4
  63. package/templates/event/integ/cliq/{installation → extension}/installation_validator.json +13 -5
  64. package/templates/event/integ/cliq/extension/uninstallation_handler.json +37 -0
  65. package/templates/event/integ/cliq/function/button_handler.json +13 -5
  66. package/templates/event/integ/cliq/function/form_change_handler.json +9 -3
  67. package/templates/event/integ/cliq/function/form_handler.json +11 -3
  68. package/templates/event/integ/cliq/function/form_values_handler.json +9 -3
  69. package/templates/event/integ/cliq/function/form_view_handler.json +26 -0
  70. package/templates/event/integ/cliq/function/widget_button_handler.json +14 -5
  71. package/templates/event/integ/cliq/link_preview/action_handler.json +54 -0
  72. package/templates/event/integ/cliq/link_preview/after_send_handler.json +47 -0
  73. package/templates/event/integ/cliq/link_preview/menu_handler.json +47 -0
  74. package/templates/event/integ/cliq/link_preview/preview_handler.json +47 -0
  75. package/templates/event/integ/cliq/messageaction/execution_handler.json +11 -3
  76. package/templates/event/integ/cliq/widget/view_handler.json +12 -4
  77. package/templates/init/functions/java/integ/cliq/com/handlers/BotHandler.java +29 -23
  78. package/templates/init/functions/java/integ/cliq/com/handlers/CommandHandler.java +14 -17
  79. package/templates/init/functions/java/integ/cliq/com/handlers/ExtensionHandler.java +41 -0
  80. package/templates/init/functions/java/integ/cliq/com/handlers/FunctionHandler.java +74 -22
  81. package/templates/init/functions/java/integ/cliq/com/handlers/LinkPreviewHandler.java +108 -0
  82. package/templates/init/functions/java/integ/cliq/com/handlers/MessageActionHandler.java +6 -8
  83. package/templates/init/functions/java/integ/cliq/sample.java +10 -0
  84. package/templates/init/functions/node/integ/cliq/handlers/bot-handler.js +4 -0
  85. package/templates/init/functions/node/integ/cliq/handlers/command-handler.js +3 -5
  86. package/templates/init/functions/node/integ/cliq/handlers/{installation-validator.js → extension-handler.js} +20 -3
  87. package/templates/init/functions/node/integ/cliq/handlers/function-handler.js +42 -0
  88. package/templates/init/functions/node/integ/cliq/handlers/link-preview-handler.js +73 -0
  89. package/templates/init/functions/python/integ/cliq/handlers/bot_handler.py +13 -3
  90. package/templates/init/functions/python/integ/cliq/handlers/command_handler.py +7 -7
  91. package/templates/init/functions/python/integ/cliq/handlers/extension_handler.py +25 -0
  92. package/templates/init/functions/python/integ/cliq/handlers/function_handler.py +54 -10
  93. package/templates/init/functions/python/integ/cliq/handlers/link_preview_handler.py +76 -0
  94. package/templates/init/functions/python/integ/cliq/handlers/widget_handler.py +10 -9
  95. package/templates/init/functions/python/integ/cliq/sample.py +2 -2
  96. package/templates/init/functions/java/integ/cliq/com/handlers/InstallationHandler.java +0 -20
  97. package/templates/init/functions/java/integ/cliq/com/handlers/InstallationValidator.java +0 -22
  98. package/templates/init/functions/node/integ/cliq/handlers/installation-handler.js +0 -15
  99. package/templates/init/functions/python/integ/cliq/handlers/installation_handler.py +0 -12
  100. package/templates/init/functions/python/integ/cliq/handlers/installation_validator.py +0 -16
@@ -3,15 +3,21 @@
3
3
  "handler": {
4
4
  "type": "form_change_handler"
5
5
  },
6
- "response_url": "https://cliq.zoho.com/v2/extensions/2980/responses/17202823900615741410013820",
7
6
  "type": "function",
8
7
  "timestamp": 1569520690703,
9
8
  "params" : {
10
9
  "environment" : {
11
- "data_center": "us"
10
+ "tld": ".com",
11
+ "data_center": "US",
12
+ "base_url": "https://cliq.zoho.com/company/123456456"
12
13
  },
13
14
  "access": {
14
- "user_id": "651652091",
15
+ "user_id": "130720038",
16
+ "zoho_user_id": "130720038",
17
+ "organization": {
18
+ "type": "company",
19
+ "id": "123456456"
20
+ },
15
21
  "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:69.0) Gecko/20100101 Firefox/69.0",
16
22
  "chat_id": "CT_2243226337559778047_661211447-B2"
17
23
  },
@@ -8,10 +8,17 @@
8
8
  "timestamp": 1569520690703,
9
9
  "params" : {
10
10
  "environment" : {
11
- "data_center": "us"
11
+ "tld": ".com",
12
+ "data_center": "US",
13
+ "base_url": "https://cliq.zoho.com/company/123456456"
12
14
  },
13
15
  "access": {
14
- "user_id": "651652091",
16
+ "user_id": "130720038",
17
+ "zoho_user_id": "130720038",
18
+ "organization": {
19
+ "type": "company",
20
+ "id": "123456456"
21
+ },
15
22
  "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:69.0) Gecko/20100101 Firefox/69.0",
16
23
  "chat_id": "CT_2243226337559778047_661211447-B2"
17
24
  },
@@ -24,7 +31,8 @@
24
31
  "id": "123456",
25
32
  "email": "scott.fisher@zylcal.com",
26
33
  "admin" : true,
27
- "organization_id" : "123456456"
34
+ "organization_id" : "123456456",
35
+ "zoho_user_id": "130720038"
28
36
  },
29
37
  "chat": {
30
38
  "owner": "123456",
@@ -3,15 +3,21 @@
3
3
  "handler": {
4
4
  "type": "form_values_handler"
5
5
  },
6
- "response_url": "https://cliq.zoho.com/v2/extensions/2980/responses/17202823900615741410013820",
7
6
  "type": "function",
8
7
  "timestamp": 1569520690703,
9
8
  "params" : {
10
9
  "environment" : {
11
- "data_center": "us"
10
+ "tld": ".com",
11
+ "data_center": "US",
12
+ "base_url": "https://cliq.zoho.com/company/123456456"
12
13
  },
13
14
  "access": {
14
- "user_id": "651652091",
15
+ "user_id": "130720038",
16
+ "zoho_user_id": "130720038",
17
+ "organization": {
18
+ "type": "company",
19
+ "id": "123456456"
20
+ },
15
21
  "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:69.0) Gecko/20100101 Firefox/69.0",
16
22
  "chat_id": "CT_2243226337559778047_661211447-B2"
17
23
  },
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "Sample",
3
+ "handler": {
4
+ "type": "form_view_handler"
5
+ },
6
+ "type": "function",
7
+ "timestamp": 1569520690703,
8
+ "params" : {
9
+ "environment" : {
10
+ "tld": ".com",
11
+ "data_center": "US",
12
+ "base_url": "https://cliq.zoho.com/company/123456456"
13
+ },
14
+ "access": {
15
+ "user_id": "130720038",
16
+ "zoho_user_id": "130720038",
17
+ "organization": {
18
+ "type": "company",
19
+ "id": "123456456"
20
+ },
21
+ "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:69.0) Gecko/20100101 Firefox/69.0",
22
+ "chat_id": "CT_2243226337559778047_661211447-B2"
23
+ },
24
+ "params": {}
25
+ }
26
+ }
@@ -7,10 +7,17 @@
7
7
  "timestamp": 1569520690703,
8
8
  "params" : {
9
9
  "environment" : {
10
- "data_center": "us"
10
+ "tld": ".com",
11
+ "data_center": "US",
12
+ "base_url": "https://cliq.zoho.com/company/123456456"
11
13
  },
12
- "access": {
13
- "user_id": "651652091",
14
+ "access": {
15
+ "user_id": "130720038",
16
+ "zoho_user_id": "130720038",
17
+ "organization": {
18
+ "type": "company",
19
+ "id": "123456456"
20
+ },
14
21
  "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:69.0) Gecko/20100101 Firefox/69.0",
15
22
  "chat_id": "CT_2243226337559778047_661211447-B2"
16
23
  },
@@ -23,12 +30,14 @@
23
30
  "id": "123456",
24
31
  "email": "scott.fisher@zylcal.com",
25
32
  "admin" : true,
26
- "organization_id" : "123456456"
33
+ "organization_id" : "123456456",
34
+ "zoho_user_id": "130720038"
27
35
  },
28
36
  "target": {
29
37
  "label": "click",
30
38
  "section_id": "1",
31
- "id": ""
39
+ "id": "",
40
+ "tab_id":""
32
41
  }
33
42
  }
34
43
  }
@@ -0,0 +1,54 @@
1
+ {
2
+ "handler": {
3
+ "type": "unfurl_button_action_handler"
4
+ },
5
+ "type": "link_preview",
6
+ "timestamp": 1569520690703,
7
+ "params" : {
8
+ "url": "https://www.zohowebstatic.com/sites/default/files/styles/product-home-page/public/catalyst-icon.png",
9
+ "domain": "zohowebstatic.com",
10
+ "environment" : {
11
+ "tld": ".com",
12
+ "data_center": "US",
13
+ "base_url": "https://cliq.zoho.com/company/123456456"
14
+ },
15
+ "access": {
16
+ "user_id": "130720038",
17
+ "zoho_user_id": "130720038",
18
+ "organization": {
19
+ "type": "company",
20
+ "id": "123456456"
21
+ },
22
+ "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:69.0) Gecko/20100101 Firefox/69.0",
23
+ "chat_id": "CT_2243226337559778047_661211447-B2"
24
+ },
25
+ "user": {
26
+ "country": "us",
27
+ "timezone": "Asia/calcutta",
28
+ "last_name": "Fisher",
29
+ "first_name": "Scott",
30
+ "language": "en",
31
+ "id": "123456",
32
+ "email": "scott.fisher@zylcal.com",
33
+ "admin" : true,
34
+ "organization_id" : "123456456",
35
+ "zoho_user_id": "130720038"
36
+ },
37
+ "chat": {
38
+ "owner": "123456",
39
+ "chat_type": "channel",
40
+ "id": "CD_1256246524399772951_1741337",
41
+ "channel_id":"O3261041256000451268",
42
+ "type": "channel",
43
+ "channel_unique_name": "sample",
44
+ "title": "Sample"
45
+ },
46
+ "target": {
47
+ "label": "Delete",
48
+ "params": {
49
+ "action": "delete_note"
50
+ },
51
+ "hint": "Delete"
52
+ }
53
+ }
54
+ }
@@ -0,0 +1,47 @@
1
+ {
2
+ "handler": {
3
+ "type": "unfurl_post_message_handler"
4
+ },
5
+ "type": "link_preview",
6
+ "timestamp": 1569520690703,
7
+ "params" : {
8
+ "url": "https://www.zohowebstatic.com/sites/default/files/styles/product-home-page/public/catalyst-icon.png",
9
+ "domain": "zohowebstatic.com",
10
+ "environment" : {
11
+ "tld": ".com",
12
+ "data_center": "US",
13
+ "base_url": "https://cliq.zoho.com/company/123456456"
14
+ },
15
+ "access": {
16
+ "user_id": "130720038",
17
+ "zoho_user_id": "130720038",
18
+ "organization": {
19
+ "type": "company",
20
+ "id": "123456456"
21
+ },
22
+ "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:69.0) Gecko/20100101 Firefox/69.0",
23
+ "chat_id": "CT_2243226337559778047_661211447-B2"
24
+ },
25
+ "user": {
26
+ "country": "us",
27
+ "timezone": "Asia/calcutta",
28
+ "last_name": "Fisher",
29
+ "first_name": "Scott",
30
+ "language": "en",
31
+ "id": "123456",
32
+ "email": "scott.fisher@zylcal.com",
33
+ "admin" : true,
34
+ "organization_id" : "123456456",
35
+ "zoho_user_id": "130720038"
36
+ },
37
+ "chat": {
38
+ "owner": "123456",
39
+ "chat_type": "channel",
40
+ "id": "CD_1256246524399772951_1741337",
41
+ "channel_id":"O3261041256000451268",
42
+ "type": "channel",
43
+ "channel_unique_name": "sample",
44
+ "title": "Sample"
45
+ }
46
+ }
47
+ }
@@ -0,0 +1,47 @@
1
+ {
2
+ "handler": {
3
+ "type": "unfurl_dynamic_action_handler"
4
+ },
5
+ "type": "link_preview",
6
+ "timestamp": 1569520690703,
7
+ "params" : {
8
+ "url": "https://www.zohowebstatic.com/sites/default/files/styles/product-home-page/public/catalyst-icon.png",
9
+ "domain": "zohowebstatic.com",
10
+ "environment" : {
11
+ "tld": ".com",
12
+ "data_center": "US",
13
+ "base_url": "https://cliq.zoho.com/company/123456456"
14
+ },
15
+ "access": {
16
+ "user_id": "130720038",
17
+ "zoho_user_id": "130720038",
18
+ "organization": {
19
+ "type": "company",
20
+ "id": "123456456"
21
+ },
22
+ "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:69.0) Gecko/20100101 Firefox/69.0",
23
+ "chat_id": "CT_2243226337559778047_661211447-B2"
24
+ },
25
+ "user": {
26
+ "country": "us",
27
+ "timezone": "Asia/calcutta",
28
+ "last_name": "Fisher",
29
+ "first_name": "Scott",
30
+ "language": "en",
31
+ "id": "123456",
32
+ "email": "scott.fisher@zylcal.com",
33
+ "admin" : true,
34
+ "organization_id" : "123456456",
35
+ "zoho_user_id": "130720038"
36
+ },
37
+ "chat": {
38
+ "owner": "123456",
39
+ "chat_type": "channel",
40
+ "id": "CD_1256246524399772951_1741337",
41
+ "channel_id":"O3261041256000451268",
42
+ "type": "channel",
43
+ "channel_unique_name": "sample",
44
+ "title": "Sample"
45
+ }
46
+ }
47
+ }
@@ -0,0 +1,47 @@
1
+ {
2
+ "handler": {
3
+ "type": "unfurl_handler"
4
+ },
5
+ "type": "link_preview",
6
+ "timestamp": 1569520690703,
7
+ "params" : {
8
+ "url": "https://www.zohowebstatic.com/sites/default/files/styles/product-home-page/public/catalyst-icon.png",
9
+ "domain": "zohowebstatic.com",
10
+ "environment" : {
11
+ "tld": ".com",
12
+ "data_center": "US",
13
+ "base_url": "https://cliq.zoho.com/company/123456456"
14
+ },
15
+ "access": {
16
+ "user_id": "130720038",
17
+ "zoho_user_id": "130720038",
18
+ "organization": {
19
+ "type": "company",
20
+ "id": "123456456"
21
+ },
22
+ "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:69.0) Gecko/20100101 Firefox/69.0",
23
+ "chat_id": "CT_2243226337559778047_661211447-B2"
24
+ },
25
+ "user": {
26
+ "country": "us",
27
+ "timezone": "Asia/calcutta",
28
+ "last_name": "Fisher",
29
+ "first_name": "Scott",
30
+ "language": "en",
31
+ "id": "123456",
32
+ "email": "scott.fisher@zylcal.com",
33
+ "admin" : true,
34
+ "organization_id" : "123456456",
35
+ "zoho_user_id": "130720038"
36
+ },
37
+ "chat": {
38
+ "owner": "123456",
39
+ "chat_type": "channel",
40
+ "id": "CD_1256246524399772951_1741337",
41
+ "channel_id":"O3261041256000451268",
42
+ "type": "channel",
43
+ "channel_unique_name": "sample",
44
+ "title": "Sample"
45
+ }
46
+ }
47
+ }
@@ -8,10 +8,17 @@
8
8
  "timestamp": 1569520690703,
9
9
  "params" : {
10
10
  "environment" : {
11
- "data_center": "us"
11
+ "tld": ".com",
12
+ "data_center": "US",
13
+ "base_url": "https://cliq.zoho.com/company/123456456"
12
14
  },
13
15
  "access": {
14
- "user_id": "651652091",
16
+ "user_id": "130720038",
17
+ "zoho_user_id": "130720038",
18
+ "organization": {
19
+ "type": "company",
20
+ "id": "123456456"
21
+ },
15
22
  "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:69.0) Gecko/20100101 Firefox/69.0",
16
23
  "chat_id": "CT_2243226337559778047_661211447-B2"
17
24
  },
@@ -44,7 +51,8 @@
44
51
  "id": "123456",
45
52
  "email": "scott.fisher@zylcal.com",
46
53
  "admin" : true,
47
- "organization_id" : "123456456"
54
+ "organization_id" : "123456456",
55
+ "zoho_user_id": "130720038"
48
56
  },
49
57
  "mentions": [],
50
58
  "message": {
@@ -7,14 +7,21 @@
7
7
  "timestamp": 1569520690703,
8
8
  "params" : {
9
9
  "environment" : {
10
- "data_center": "us"
10
+ "tld": ".com",
11
+ "data_center": "US",
12
+ "base_url": "https://cliq.zoho.com/company/123456456"
11
13
  },
12
14
  "access": {
13
- "user_id": "651652091",
15
+ "user_id": "130720038",
16
+ "zoho_user_id": "130720038",
17
+ "organization": {
18
+ "type": "company",
19
+ "id": "123456456"
20
+ },
14
21
  "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:69.0) Gecko/20100101 Firefox/69.0",
15
22
  "chat_id": "CT_2243226337559778047_661211447-B2"
16
23
  },
17
- "user": {
24
+ "user": {
18
25
  "country": "us",
19
26
  "timezone": "Asia/calcutta",
20
27
  "last_name": "Fisher",
@@ -23,7 +30,8 @@
23
30
  "id": "123456",
24
31
  "email": "scott.fisher@zylcal.com",
25
32
  "admin" : true,
26
- "organization_id" : "123456456"
33
+ "organization_id" : "123456456",
34
+ "zoho_user_id": "130720038"
27
35
  },
28
36
  "target": {},
29
37
  "event": "load",
@@ -23,6 +23,7 @@ import com.zc.cliq.objects.ButtonObject;
23
23
  import com.zc.cliq.objects.CardDetails;
24
24
  import com.zc.cliq.objects.Message;
25
25
  import com.zc.cliq.objects.Slide;
26
+ import com.zc.cliq.requests.BotCallHandlerRequest;
26
27
  import com.zc.cliq.requests.BotContextHandlerRequest;
27
28
  import com.zc.cliq.requests.BotMentionHandlerRequest;
28
29
  import com.zc.cliq.requests.BotMenuActionHandlerRequest;
@@ -30,6 +31,8 @@ import com.zc.cliq.requests.BotMessageHandlerRequest;
30
31
  import com.zc.cliq.requests.BotParticipationHandlerRequest;
31
32
  import com.zc.cliq.requests.BotWebhookHandlerRequest;
32
33
  import com.zc.cliq.requests.BotWelcomeHandlerRequest;
34
+ import com.zc.cliq.responses.CoreResponse;
35
+ import com.zc.cliq.responses.WebhookHandlerResponse;
33
36
  import com.zc.cliq.util.ZCCliqUtil;
34
37
  import com.zc.component.cache.ZCCache;
35
38
 
@@ -37,18 +40,18 @@ public class BotHandler implements com.zc.cliq.interfaces.BotHandler {
37
40
  Logger LOGGER = Logger.getLogger(BotHandler.class.getName());
38
41
 
39
42
  @Override
40
- public Map<String, Object> welcomeHandler(BotWelcomeHandlerRequest req) {
43
+ public Message welcomeHandler(BotWelcomeHandlerRequest req) {
41
44
  String uName = req.getUser() != null ? req.getUser().getFirstName() : "user";
42
45
  String text = "Hello " + uName + ". Thank you for subscribing :smile:";
43
46
  Message msg = Message.getInstance(text);
44
- return ZCCliqUtil.toMap(msg);
47
+ return msg;
45
48
  }
46
49
 
47
50
  @Override
48
- public Map<String, Object> messageHandler(BotMessageHandlerRequest req) {
51
+ public CoreResponse messageHandler(BotMessageHandlerRequest req) throws Exception {
49
52
  try {
50
53
  String message = req.getMessage();
51
- Map<String, Object> resp = new HashMap<String, Object>();
54
+ Message resp = Message.getInstance();
52
55
 
53
56
  String text;
54
57
  if (message == null) {
@@ -60,7 +63,7 @@ public class BotHandler implements com.zc.cliq.interfaces.BotHandler {
60
63
  suggestion.addSuggestion("Not bad");
61
64
  suggestion.addSuggestion("Meh");
62
65
  suggestion.addSuggestion("Worst");
63
- resp.put("suggestions", suggestion);
66
+ resp.setSuggestion(suggestion);
64
67
  } else if (message.equalsIgnoreCase("Good") || message.equalsIgnoreCase("Not bad")) {
65
68
  text = "That's glad to hear :smile:";
66
69
  } else if (message.equalsIgnoreCase("Meh") || message.equalsIgnoreCase("Worst")) {
@@ -90,7 +93,7 @@ public class BotHandler implements com.zc.cliq.interfaces.BotHandler {
90
93
  param3.addSuggestion("NO");
91
94
 
92
95
  context.setParams(param1, param2, param3);
93
- resp.put("context", context);
96
+ resp.setContext(context);
94
97
  } else if (message.equalsIgnoreCase("button")) {
95
98
 
96
99
  Message msg = Message.getInstance("Here's your button");
@@ -104,12 +107,12 @@ public class BotHandler implements com.zc.cliq.interfaces.BotHandler {
104
107
  action.setData(actionData);
105
108
  btnObj.setAction(action);
106
109
  msg.addButton(btnObj);
107
- return ZCCliqUtil.toMap(msg);
110
+ return msg;
108
111
  } else {
109
112
  text = "Sorry, I'm not programmed yet to do this :sad:";
110
113
  }
111
114
 
112
- resp.put("text", text);
115
+ resp.setText(text);
113
116
  return resp;
114
117
 
115
118
  } catch (Exception ex) {
@@ -119,8 +122,8 @@ public class BotHandler implements com.zc.cliq.interfaces.BotHandler {
119
122
  }
120
123
 
121
124
  @Override
122
- public Map<String, Object> contextHandler(BotContextHandlerRequest req) {
123
- Map<String, Object> resp = new HashMap<String, Object>();
125
+ public CoreResponse contextHandler(BotContextHandlerRequest req) throws Exception {
126
+ JSONObject resp = new JSONObject();
124
127
  if (req.getContextId().equals("personal_details")) {
125
128
  Map<String, String> answers = req.getAnswers();
126
129
  StringBuilder str = new StringBuilder();
@@ -140,20 +143,18 @@ public class BotHandler implements com.zc.cliq.interfaces.BotHandler {
140
143
 
141
144
  resp.put("text", "Nice ! I have collected your info: \n" + str.toString());
142
145
  }
143
- return resp;
146
+ return ZCCliqUtil.mapper.readValue(resp.toString(), Message.class);
144
147
  }
145
148
 
146
149
  @Override
147
- public Map<String, Object> mentionHandler(BotMentionHandlerRequest req) {
150
+ public CoreResponse mentionHandler(BotMentionHandlerRequest req) {
148
151
  String text = "Hey *" + req.getUser().getFirstName() + "*, thanks for mentioning me here. I'm from Catalyst city";
149
- Map<String, Object> resp = new HashMap<String, Object>();
150
- resp.put("text", text);
151
- return resp;
152
+ Message msg = Message.getInstance(text);
153
+ return msg;
152
154
  }
153
155
 
154
156
  @Override
155
- public Map<String, Object> menuActionHandler(BotMenuActionHandlerRequest req) {
156
- Map<String, Object> resp = new HashMap<String, Object>();
157
+ public CoreResponse menuActionHandler(BotMenuActionHandlerRequest req) {
157
158
  String text;
158
159
  if (req.getActionName().equals("Say Hi")) {
159
160
  text = "Hi";
@@ -162,12 +163,12 @@ public class BotHandler implements com.zc.cliq.interfaces.BotHandler {
162
163
  } else {
163
164
  text = "Menu action triggered :fist:";
164
165
  }
165
- resp.put("text", text);
166
- return resp;
166
+ Message msg = Message.getInstance(text);
167
+ return msg;
167
168
  }
168
169
 
169
170
  @Override
170
- public Map<String, Object> webhookHandler(BotWebhookHandlerRequest req) throws Exception {
171
+ public WebhookHandlerResponse webhookHandler(BotWebhookHandlerRequest req) throws Exception {
171
172
  // Sample handler class for incoming mails in ZohoMail
172
173
  // Please configure the bot in ZohoMail's outgoing webhooks
173
174
  JSONObject reqBody = req.getBody();
@@ -205,11 +206,11 @@ public class BotHandler implements com.zc.cliq.interfaces.BotHandler {
205
206
 
206
207
  msg.addSlide(gifSlide);
207
208
 
208
- return ZCCliqUtil.toMap(msg);
209
+ return msg;
209
210
  }
210
211
 
211
212
  @Override
212
- public Map<String, Object> participationHandler(BotParticipationHandlerRequest req) throws Exception {
213
+ public CoreResponse participationHandler(BotParticipationHandlerRequest req) throws Exception {
213
214
  String text;
214
215
  if (req.getOperation().equals(CHANNEL_OPERATION.ADDED)) {
215
216
  text = "Hi. Thanks for adding me to the channel :smile:";
@@ -219,6 +220,11 @@ public class BotHandler implements com.zc.cliq.interfaces.BotHandler {
219
220
  text = "I'm too a participant of this chat :wink:";
220
221
  }
221
222
  Message msg = Message.getInstance(text);
222
- return ZCCliqUtil.toMap(msg);
223
+ return msg;
224
+ }
225
+
226
+ @Override
227
+ public void callHandler(BotCallHandlerRequest req) throws Exception {
228
+ // Logic for bot call post handling
223
229
  }
224
230
  }
@@ -2,24 +2,23 @@
2
2
  package com.handlers;
3
3
 
4
4
  import java.util.ArrayList;
5
- import java.util.HashMap;
6
5
  import java.util.List;
7
- import java.util.Map;
6
+
8
7
  import com.zc.cliq.enums.FORM_FIELD_TEXT_FORMAT;
9
8
  import com.zc.cliq.enums.FORM_FIELD_TYPE;
10
9
  import com.zc.cliq.objects.CommandSuggestion;
11
10
  import com.zc.cliq.objects.Form;
12
- import com.zc.cliq.objects.FormActionsObject;
11
+ import com.zc.cliq.objects.FormAction;
13
12
  import com.zc.cliq.objects.FormInput;
14
13
  import com.zc.cliq.objects.FormValue;
14
+ import com.zc.cliq.objects.Message;
15
15
  import com.zc.cliq.requests.CommandHandlerRequest;
16
- import com.zc.cliq.util.ZCCliqUtil;
16
+ import com.zc.cliq.responses.CoreResponse;
17
17
 
18
18
  public class CommandHandler implements com.zc.cliq.interfaces.CommandHandler {
19
19
  @Override
20
- public Map<String, Object> executionHandler(CommandHandlerRequest req) throws Exception {
20
+ public CoreResponse executionHandler(CommandHandlerRequest req) throws Exception {
21
21
 
22
- Map<String, Object> resp = new HashMap<String, Object>();
23
22
  String text;
24
23
  String commandName = req.getName();
25
24
  if (commandName.equals("catalystresource")) {
@@ -42,8 +41,8 @@ public class CommandHandler implements com.zc.cliq.interfaces.CommandHandler {
42
41
  text = "Command executed successfully!";
43
42
  }
44
43
 
45
- resp.put("text", text);
46
- return resp;
44
+ Message msg = Message.getInstance(text);
45
+ return msg;
47
46
  }
48
47
 
49
48
  @Override
@@ -60,7 +59,7 @@ public class CommandHandler implements com.zc.cliq.interfaces.CommandHandler {
60
59
  return suggestionList;
61
60
  }
62
61
 
63
- private static Map<String, Object> getForm() {
62
+ private static Form getForm() {
64
63
  Form form = Form.getInstance();
65
64
  form.setTitle("Asset Request");
66
65
  form.setHint("Raise your asset request");
@@ -68,12 +67,10 @@ public class CommandHandler implements com.zc.cliq.interfaces.CommandHandler {
68
67
  form.setButtonLabel("Raise Request");
69
68
  form.setVersion(1);
70
69
 
71
- FormActionsObject actions = FormActionsObject.getInstance();
72
- actions.setSubmitAction("formFunctionLatest"); // ** ENTER YOUR FORM FUNCTION NAME HERE **
73
-
74
- form.setActions(actions);
70
+ FormAction action = FormAction.getInstance("formFunctionLatest"); // ** ENTER YOUR FORM FUNCTION NAME HERE **
71
+ form.setAction(action);
75
72
 
76
- FormInput username = FormInput.getIntance();
73
+ FormInput username = FormInput.getInstance();
77
74
  username.setType(FORM_FIELD_TYPE.TEXT);
78
75
  username.setName("username");
79
76
  username.setLabel("Name");
@@ -83,7 +80,7 @@ public class CommandHandler implements com.zc.cliq.interfaces.CommandHandler {
83
80
  username.setValue("Harold Finch");
84
81
  form.addFormInput(username);
85
82
 
86
- FormInput email = FormInput.getIntance();
83
+ FormInput email = FormInput.getInstance();
87
84
  email.setType(FORM_FIELD_TYPE.TEXT);
88
85
  email.setFormat(FORM_FIELD_TEXT_FORMAT.EMAIL);
89
86
  email.setName("email");
@@ -94,7 +91,7 @@ public class CommandHandler implements com.zc.cliq.interfaces.CommandHandler {
94
91
  email.setValue("haroldfinch@samaritan.com");
95
92
  form.addFormInput(email);
96
93
 
97
- FormInput assetType = FormInput.getIntance();
94
+ FormInput assetType = FormInput.getInstance();
98
95
  assetType.setType(FORM_FIELD_TYPE.SELECT);
99
96
  assetType.setTriggerOnChange(true);
100
97
  assetType.setName("asset-type");
@@ -106,6 +103,6 @@ public class CommandHandler implements com.zc.cliq.interfaces.CommandHandler {
106
103
  assetType.addOption(new FormValue("Mobile", "mobile"));
107
104
  form.addFormInput(assetType);
108
105
 
109
- return ZCCliqUtil.toMap(form);
106
+ return form;
110
107
  }
111
108
  }