@burgan-tech/morph-touch-runtime 0.0.2
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/LICENSE +21 -0
- package/burgan-tech-morph-touch-runtime-0.0.2.tgz +0 -0
- package/package.json +21 -0
- package/touch/Extensions/.gitkeep +0 -0
- package/touch/Functions/.gitkeep +0 -0
- package/touch/Functions/check-livekit-room-access.1.0.0.json +28 -0
- package/touch/Functions/check-livekit-room-access.http +44 -0
- package/touch/Functions/get-absence-entry.1.0.0.json +28 -0
- package/touch/Functions/get-advisor-stats.1.0.0.json +27 -0
- package/touch/Functions/get-available-slots.1.0.0.json +30 -0
- package/touch/Functions/get-available-slots.http +29 -0
- package/touch/Functions/get-chat-rooms.1.0.0.json +28 -0
- package/touch/Functions/get-chat-rooms.http +62 -0
- package/touch/Functions/get-customer-info.1.0.0.json +27 -0
- package/touch/Functions/get-matrix-sync.1.0.0.json +28 -0
- package/touch/Functions/get-rezervations.1.0.0.json +26 -0
- package/touch/Functions/get-rezervations.http +59 -0
- package/touch/Functions/get-room-messages.1.0.0.json +29 -0
- package/touch/Functions/get-room-messages.http +45 -0
- package/touch/Functions/rezervation-transfer.http +118 -0
- package/touch/Functions/send-room-message.1.0.0.json +29 -0
- package/touch/Functions/src/CheckLivekitRoomAccessMapping.csx +238 -0
- package/touch/Functions/src/GetAbsenceEntryMapping.csx +225 -0
- package/touch/Functions/src/GetAdvisorStatsMapping.csx +190 -0
- package/touch/Functions/src/GetAvailableSlotsMapping.csx +468 -0
- package/touch/Functions/src/GetChatRoomsMapping.csx +202 -0
- package/touch/Functions/src/GetCustomerInfoMapping.csx +140 -0
- package/touch/Functions/src/GetMatrixSyncMapping.csx +197 -0
- package/touch/Functions/src/GetRezervationsMapping.csx +162 -0
- package/touch/Functions/src/GetRoomMessagesMapping.csx +165 -0
- package/touch/Functions/src/SendCancelNotificationMapping.csx +63 -0
- package/touch/Functions/src/SendRoomMessageMapping.csx +131 -0
- package/touch/Schemas/.gitkeep +0 -0
- package/touch/Schemas/absence-entry.1.0.0.json +232 -0
- package/touch/Schemas/advisor-chat-rooms.1.0.0.json +62 -0
- package/touch/Schemas/chat-room.1.0.0.json +110 -0
- package/touch/Schemas/notification-sender.1.0.0.json +159 -0
- package/touch/Schemas/portfolio-manager.1.0.0.json +63 -0
- package/touch/Schemas/rezervation.1.0.0.json +102 -0
- package/touch/Tasks/.gitkeep +0 -0
- package/touch/Tasks/cancel-absence-entry-for-rezervation.1.0.0.json +21 -0
- package/touch/Tasks/check-already-completed-chat-room.1.0.0.json +24 -0
- package/touch/Tasks/check-duplicate-portfolio-manager.1.0.0.json +23 -0
- package/touch/Tasks/check-duplicate-rezervation.1.0.0.json +23 -0
- package/touch/Tasks/check-existing-permanent-chat-room.1.0.0.json +21 -0
- package/touch/Tasks/check-randevu-time.1.0.0.json +17 -0
- package/touch/Tasks/create-permanent-chat-room.1.0.0.json +28 -0
- package/touch/Tasks/determine-transfer-type.1.0.0.json +16 -0
- package/touch/Tasks/enrich-rezervations-for-transfer.1.0.0.json +23 -0
- package/touch/Tasks/execute-permanent-chatroom-update.1.0.0.json +21 -0
- package/touch/Tasks/execute-rez-chatroom-transfer.1.0.0.json +21 -0
- package/touch/Tasks/execute-rezervation-transfer.1.0.0.json +19 -0
- package/touch/Tasks/fetch-absence-entries-for-transfer.1.0.0.json +23 -0
- package/touch/Tasks/fetch-advisors-for-transfer.1.0.0.json +23 -0
- package/touch/Tasks/fetch-permanent-chatrooms-for-transfer.1.0.0.json +23 -0
- package/touch/Tasks/fetch-rez-chatrooms-for-transfer.1.0.0.json +23 -0
- package/touch/Tasks/fetch-rezervations-for-transfer.1.0.0.json +22 -0
- package/touch/Tasks/get-absence-entry-task.1.0.0.json +23 -0
- package/touch/Tasks/get-available-slots-http.1.0.0.json +27 -0
- package/touch/Tasks/get-available-slots.1.0.0.json +24 -0
- package/touch/Tasks/get-chat-room-data-for-rezervation.1.0.0.json +23 -0
- package/touch/Tasks/get-chat-token.1.0.0.json +27 -0
- package/touch/Tasks/get-matrix-room-messages.1.0.0.json +25 -0
- package/touch/Tasks/get-matrix-sync.1.0.0.json +25 -0
- package/touch/Tasks/get-rezervation-data-task.1.0.0.json +22 -0
- package/touch/Tasks/get-rezervation-state-task.1.0.0.json +22 -0
- package/touch/Tasks/get-rezervations-task.1.0.0.json +21 -0
- package/touch/Tasks/get-user-info-for-rezervation.1.0.0.json +24 -0
- package/touch/Tasks/get-video-call-url.1.0.0.json +17 -0
- package/touch/Tasks/invite-user-to-rezervation-room.1.0.0.json +27 -0
- package/touch/Tasks/join-chat-room-for-rezervation.1.0.0.json +28 -0
- package/touch/Tasks/join-matrix-room.1.0.0.json +27 -0
- package/touch/Tasks/join-user-to-room.1.0.0.json +27 -0
- package/touch/Tasks/merge-invited-user.1.0.0.json +17 -0
- package/touch/Tasks/merge-rezervation-update.1.0.0.json +16 -0
- package/touch/Tasks/merge-target-advisor-for-transfer.1.0.0.json +17 -0
- package/touch/Tasks/merge-update-body-for-randevu-update.1.0.0.json +16 -0
- package/touch/Tasks/merge-video-call-urls.1.0.0.json +17 -0
- package/touch/Tasks/query-chat-room-instances.1.0.0.json +23 -0
- package/touch/Tasks/remove-member-from-room.1.0.0.json +28 -0
- package/touch/Tasks/send-matrix-room-message.1.0.0.json +26 -0
- package/touch/Tasks/send-push-notification.1.0.0.json +26 -0
- package/touch/Tasks/send-sms-notification.1.0.0.json +26 -0
- package/touch/Tasks/set-chat-room-status-active.1.0.0.json +16 -0
- package/touch/Tasks/set-chat-room-status-deactive.1.0.0.json +16 -0
- package/touch/Tasks/set-previous-advisor.1.0.0.json +16 -0
- package/touch/Tasks/set-user-from-headers-for-rezervation.1.0.0.json +17 -0
- package/touch/Tasks/start-absence-entry-for-rezervation.1.0.0.json +21 -0
- package/touch/Tasks/start-chat-room-for-rezervation.1.0.0.json +20 -0
- package/touch/Tasks/start-notification-sender.1.0.0.json +20 -0
- package/touch/Tasks/start-permanent-chat-room.1.0.0.json +21 -0
- package/touch/Tasks/start-transfer-from-absence-entry.1.0.0.json +19 -0
- package/touch/Tasks/start-video-call.1.0.0.json +22 -0
- package/touch/Tasks/trigger-chat-room-deactivate.1.0.0.json +21 -0
- package/touch/Tasks/trigger-chat-room-transfer.1.0.0.json +21 -0
- package/touch/Tasks/trigger-chat-room-update.1.0.0.json +20 -0
- package/touch/Tasks/trigger-rezervation-add-invited-participant.1.0.0.json +20 -0
- package/touch/Tasks/trigger-rezervation-apply-update.1.0.0.json +20 -0
- package/touch/Tasks/trigger-rezervation-to-in-meet.1.0.0.json +20 -0
- package/touch/Tasks/trigger-rezervation-video-call-update.1.0.0.json +21 -0
- package/touch/Tasks/validate-date-for-rezervation.1.0.0.json +18 -0
- package/touch/Tasks/validate-slot-for-rezervation.1.0.0.json +24 -0
- package/touch/Tasks/validate-transfer-availability.1.0.0.json +23 -0
- package/touch/Views/.gitkeep +0 -0
- package/touch/Workflows/.gitkeep +0 -0
- package/touch/Workflows/absence-entry.http +458 -0
- package/touch/Workflows/absence-entry.json +179 -0
- package/touch/Workflows/add-participant-to-rezervation.http +47 -0
- package/touch/Workflows/add-participant-to-rezervation.json +340 -0
- package/touch/Workflows/chat-room.http +207 -0
- package/touch/Workflows/chat-room.json +452 -0
- package/touch/Workflows/investment-advisor.json +367 -0
- package/touch/Workflows/notification-sender.http +299 -0
- package/touch/Workflows/notification-sender.json +262 -0
- package/touch/Workflows/portfolio-manager.json +367 -0
- package/touch/Workflows/randevu-update.http +87 -0
- package/touch/Workflows/rezervation-start.json +467 -0
- package/touch/Workflows/rezervation-transfer.json +512 -0
- package/touch/Workflows/rezervation-update.http +87 -0
- package/touch/Workflows/rezervation-update.json +485 -0
- package/touch/Workflows/rezervation.http +214 -0
- package/touch/Workflows/rezervation.json +726 -0
- package/touch/Workflows/src/AllChatRoomsSuccessRule.csx +65 -0
- package/touch/Workflows/src/AlwaysTrueRule.csx +13 -0
- package/touch/Workflows/src/AnyChatRoomFailedRule.csx +64 -0
- package/touch/Workflows/src/AutoProcessRule.csx +38 -0
- package/touch/Workflows/src/BuildRezChatRoomPlanMapping.csx +160 -0
- package/touch/Workflows/src/CanStartRezervationTimerMapping.csx +48 -0
- package/touch/Workflows/src/CanStartTransferMapping.csx +14 -0
- package/touch/Workflows/src/CancelAbsenceEntryForRezervationMapping.csx +48 -0
- package/touch/Workflows/src/CancelAbsenceForRandevuUpdateMapping.csx +62 -0
- package/touch/Workflows/src/ChatRoomCreatedFailedRule.csx +54 -0
- package/touch/Workflows/src/ChatRoomCreatedSuccessRule.csx +54 -0
- package/touch/Workflows/src/ChatRoomRemoveMapping.csx +104 -0
- package/touch/Workflows/src/ChatRoomTransferInviteMapping.csx +109 -0
- package/touch/Workflows/src/ChatRoomTransferRemoveMapping.csx +71 -0
- package/touch/Workflows/src/ChatRoomUpdateMapping.csx +107 -0
- package/touch/Workflows/src/CheckAlreadyCompletedChatRoomMapping.csx +100 -0
- package/touch/Workflows/src/CheckDuplicatePortfolioManagerMapping.csx +119 -0
- package/touch/Workflows/src/CheckDuplicateRezervationMapping.csx +150 -0
- package/touch/Workflows/src/CheckExistingPermanentChatRoomMapping.csx +169 -0
- package/touch/Workflows/src/CheckRandevuTimeMapping.csx +67 -0
- package/touch/Workflows/src/CheckRezervationStateActiveOrInMeetRule.csx +14 -0
- package/touch/Workflows/src/CreateAbsenceEntryForRezervationMapping.csx +111 -0
- package/touch/Workflows/src/CreateAbsenceForRandevuUpdateMapping.csx +108 -0
- package/touch/Workflows/src/CreateChatRoomForRezervationMapping.csx +122 -0
- package/touch/Workflows/src/CreatePermanentChatRoomMapping.csx +140 -0
- package/touch/Workflows/src/CustomerControlToEndRule.csx +14 -0
- package/touch/Workflows/src/DetermineTransferTypeMapping.csx +92 -0
- package/touch/Workflows/src/EnrichRezervationsForTransferMapping.csx +495 -0
- package/touch/Workflows/src/ExecutePermanentChatRoomUpdateMapping.csx +124 -0
- package/touch/Workflows/src/ExecuteRezChatRoomTransferMapping.csx +95 -0
- package/touch/Workflows/src/ExecuteTransferMapping.csx +152 -0
- package/touch/Workflows/src/FetchAbsenceEntriesForTransferMapping.csx +116 -0
- package/touch/Workflows/src/FetchAdvisorsForTransferMapping.csx +145 -0
- package/touch/Workflows/src/FetchPermanentChatRoomsMapping.csx +128 -0
- package/touch/Workflows/src/FetchRezervationsForTransferMapping.csx +124 -0
- package/touch/Workflows/src/GetChatRoomDataForRezervationMapping.csx +100 -0
- package/touch/Workflows/src/GetChatTokenMapping.csx +85 -0
- package/touch/Workflows/src/GetRezervationDataForAddParticipantMapping.csx +105 -0
- package/touch/Workflows/src/GetRezervationDataForRandevuUpdateMapping.csx +110 -0
- package/touch/Workflows/src/GetRezervationDataMapping.csx +111 -0
- package/touch/Workflows/src/GetRezervationStateForRandevuUpdateMapping.csx +80 -0
- package/touch/Workflows/src/GetRezervationStateMapping.csx +92 -0
- package/touch/Workflows/src/GetUserInfoForRezervationMapping.csx +63 -0
- package/touch/Workflows/src/GetVideoCallUrlMapping.csx +62 -0
- package/touch/Workflows/src/HasChangedAdvisorRule.csx +28 -0
- package/touch/Workflows/src/HasChatIntegrationRule.csx +41 -0
- package/touch/Workflows/src/HasExistingPermanentRoomRule.csx +28 -0
- package/touch/Workflows/src/InviteAdvisorForRandevuUpdateMapping.csx +86 -0
- package/touch/Workflows/src/InviteNewAdvisorToRezervationRoomMapping.csx +78 -0
- package/touch/Workflows/src/InviteNewParticipantToRandevuRoomMapping.csx +88 -0
- package/touch/Workflows/src/InvitedUserMergeMapping.csx +77 -0
- package/touch/Workflows/src/InvitedUserNotAllowedRule.csx +71 -0
- package/touch/Workflows/src/InvitedUserNotInMeetRule.csx +19 -0
- package/touch/Workflows/src/IsNotfSentRule.csx +36 -0
- package/touch/Workflows/src/JoinChatRoomForAddParticipantMapping.csx +118 -0
- package/touch/Workflows/src/JoinChatRoomForRandevuStartMapping.csx +119 -0
- package/touch/Workflows/src/JoinChatRoomForRezervationMapping.csx +118 -0
- package/touch/Workflows/src/JoinMatrixRoomMapping.csx +100 -0
- package/touch/Workflows/src/JoinUserToRoomMapping.csx +118 -0
- package/touch/Workflows/src/LoginForAddParticipantChatMapping.csx +102 -0
- package/touch/Workflows/src/LoginForRandevuStartChatMapping.csx +96 -0
- package/touch/Workflows/src/MergeRezervationUpdateMapping.csx +82 -0
- package/touch/Workflows/src/MergeTargetAdvisorForTransferMapping.csx +79 -0
- package/touch/Workflows/src/MergeUpdateBodyForRandevuUpdateMapping.csx +91 -0
- package/touch/Workflows/src/NoExistingPermanentRoomRule.csx +23 -0
- package/touch/Workflows/src/NotificationCompleteAlwaysRule.csx +14 -0
- package/touch/Workflows/src/NotificationCompleteFromPendingRule.csx +41 -0
- package/touch/Workflows/src/NotificationCompleteFromSmsRule.csx +36 -0
- package/touch/Workflows/src/NotificationPushFromPendingRule.csx +42 -0
- package/touch/Workflows/src/NotificationPushFromSmsRule.csx +36 -0
- package/touch/Workflows/src/NotificationSmsPendingRule.csx +32 -0
- package/touch/Workflows/src/PermanentDoneRule.csx +44 -0
- package/touch/Workflows/src/PermanentProcessNextRule.csx +44 -0
- package/touch/Workflows/src/RezChatRoomProcessNextRule.csx +44 -0
- package/touch/Workflows/src/RezChatRoomsDoneRule.csx +44 -0
- package/touch/Workflows/src/SendPushNotificationMapping.csx +146 -0
- package/touch/Workflows/src/SendSmsNotificationMapping.csx +138 -0
- package/touch/Workflows/src/SetChatRoomStatusActiveMapping.csx +22 -0
- package/touch/Workflows/src/SetChatRoomStatusDeactiveMapping.csx +22 -0
- package/touch/Workflows/src/SetPreviousAdvisorMapping.csx +28 -0
- package/touch/Workflows/src/SetUserFromHeadersForRezervationMapping.csx +24 -0
- package/touch/Workflows/src/SlotAvailableRule.csx +33 -0
- package/touch/Workflows/src/SlotUnavailableRule.csx +33 -0
- package/touch/Workflows/src/StartChatRoomForRezervationMapping.csx +100 -0
- package/touch/Workflows/src/StartGetChatTokenForRezervationMapping.csx +71 -0
- package/touch/Workflows/src/StartNotificationForAdvisorMapping.csx +117 -0
- package/touch/Workflows/src/StartNotificationForRezervationFromUserInfoMapping.csx +128 -0
- package/touch/Workflows/src/StartNotificationForUserMapping.csx +117 -0
- package/touch/Workflows/src/StartPermanentChatRoomMapping.csx +92 -0
- package/touch/Workflows/src/StartTransferFromAbsenceEntryMapping.csx +94 -0
- package/touch/Workflows/src/StartVideoCallCustomerSubFlowMapping.csx +37 -0
- package/touch/Workflows/src/StartVideoCallForInvitedParticipantMapping.csx +54 -0
- package/touch/Workflows/src/StartVideoCallForRandevuStartMapping.csx +70 -0
- package/touch/Workflows/src/StartVideoCallStaffSubFlowMapping.csx +37 -0
- package/touch/Workflows/src/StateActiveForUpdateRule.csx +14 -0
- package/touch/Workflows/src/StateActiveRule.csx +14 -0
- package/touch/Workflows/src/StateInMeetRule.csx +14 -0
- package/touch/Workflows/src/StateNotActiveForUpdateRule.csx +14 -0
- package/touch/Workflows/src/StateNotActiveOrInMeetRule.csx +14 -0
- package/touch/Workflows/src/StatusCustomerEnterRule.csx +25 -0
- package/touch/Workflows/src/StatusStaffEnterRule.csx +25 -0
- package/touch/Workflows/src/SyncWorkingHoursRule.csx +46 -0
- package/touch/Workflows/src/TokenSuccessRule.csx +24 -0
- package/touch/Workflows/src/TransferAllDoneRule.csx +50 -0
- package/touch/Workflows/src/TransferHasInvalidRule.csx +34 -0
- package/touch/Workflows/src/TransferProcessNextRule.csx +50 -0
- package/touch/Workflows/src/TriggerChatRoomDeactivateMapping.csx +77 -0
- package/touch/Workflows/src/TriggerChatRoomTransferMapping.csx +93 -0
- package/touch/Workflows/src/TriggerChatRoomUpdateMapping.csx +99 -0
- package/touch/Workflows/src/TriggerRezervationAddInvitedParticipantMapping.csx +77 -0
- package/touch/Workflows/src/TriggerRezervationApplyUpdateMapping.csx +66 -0
- package/touch/Workflows/src/TriggerRezervationToInMeetMapping.csx +69 -0
- package/touch/Workflows/src/TriggerRezervationVideoCallUpdateMapping.csx +67 -0
- package/touch/Workflows/src/ValidateDateForRezervationMapping.csx +60 -0
- package/touch/Workflows/src/ValidateSlotForRandevuUpdateMapping.csx +211 -0
- package/touch/Workflows/src/ValidateSlotForRezervationMapping.csx +246 -0
- package/touch/Workflows/src/ValidateTransferMapping.csx +243 -0
- package/touch/Workflows/src/VideoCallUrlUpdateMergeMapping.csx +141 -0
- package/touch/Workflows/start-chat.json +217 -0
- package/touch/Workflows/start-video-call.http +93 -0
- package/touch/Workflows/start-video-call.json +206 -0
- package/vnext.config.json +58 -0
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using System.Threading.Tasks;
|
|
4
|
+
using BBT.Workflow.Scripting;
|
|
5
|
+
using BBT.Workflow.Definitions;
|
|
6
|
+
|
|
7
|
+
/// <summary>
|
|
8
|
+
/// Mapping for fetch-rezervations-for-transfer task (DaprServiceTask - Type 3).
|
|
9
|
+
/// Reads advisorId, startDate, endDate from instance data and calls get-rezervations function.
|
|
10
|
+
/// OutputHandler stores the resulting reservation items in instance data.
|
|
11
|
+
///
|
|
12
|
+
/// Reference: https://github.com/burgan-tech/vnext-runtime/blob/main/doc/en/flow/tasks/dapr-service.md
|
|
13
|
+
/// </summary>
|
|
14
|
+
public class FetchRezervationsForTransferMapping : ScriptBase, IMapping
|
|
15
|
+
{
|
|
16
|
+
public Task<ScriptResponse> InputHandler(WorkflowTask task, ScriptContext context)
|
|
17
|
+
{
|
|
18
|
+
var serviceTask = task as DaprServiceTask;
|
|
19
|
+
if (serviceTask == null)
|
|
20
|
+
throw new InvalidOperationException("Task must be a DaprServiceTask");
|
|
21
|
+
|
|
22
|
+
var appId = GetConfigValue("DAPR_APP_ID");
|
|
23
|
+
if (!string.IsNullOrEmpty(appId))
|
|
24
|
+
serviceTask.SetAppId(appId);
|
|
25
|
+
|
|
26
|
+
var data = context.Instance?.Data;
|
|
27
|
+
if (data == null)
|
|
28
|
+
throw new InvalidOperationException("Instance data is required");
|
|
29
|
+
|
|
30
|
+
var sourceAdvisorId = GetString(data, "sourceAdvisorId");
|
|
31
|
+
var startDate = GetString(data, "startDate");
|
|
32
|
+
var endDate = GetString(data, "endDate");
|
|
33
|
+
|
|
34
|
+
if (string.IsNullOrEmpty(sourceAdvisorId))
|
|
35
|
+
throw new ArgumentException("sourceAdvisorId is required.", "sourceAdvisorId");
|
|
36
|
+
if (string.IsNullOrEmpty(startDate))
|
|
37
|
+
throw new ArgumentException("startDate is required.", "startDate");
|
|
38
|
+
if (string.IsNullOrEmpty(endDate))
|
|
39
|
+
endDate = "2099-12-31";
|
|
40
|
+
|
|
41
|
+
var queryParams = new List<string>
|
|
42
|
+
{
|
|
43
|
+
"advisorId=" + Uri.EscapeDataString(sourceAdvisorId),
|
|
44
|
+
"startDate=" + Uri.EscapeDataString(startDate),
|
|
45
|
+
"endDate=" + Uri.EscapeDataString(endDate)
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
serviceTask.SetQueryString(string.Join("&", queryParams));
|
|
49
|
+
return Task.FromResult(new ScriptResponse());
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
public Task<ScriptResponse> OutputHandler(ScriptContext context)
|
|
53
|
+
{
|
|
54
|
+
try
|
|
55
|
+
{
|
|
56
|
+
var body = context.Body;
|
|
57
|
+
var data = context.Instance?.Data;
|
|
58
|
+
|
|
59
|
+
if (body != null && body.isSuccess == false)
|
|
60
|
+
{
|
|
61
|
+
var errorMessage = body.errorMessage?.ToString() ?? "Failed to fetch reservations";
|
|
62
|
+
throw new ArgumentException(errorMessage, "");
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
var dataNode = body?.data ?? body?.Data;
|
|
66
|
+
var items = dataNode?.getRezervations?.items;
|
|
67
|
+
|
|
68
|
+
var result = new Dictionary<string, object>();
|
|
69
|
+
CopyIfPresent(result, data, "sourceAdvisorId");
|
|
70
|
+
CopyIfPresent(result, data, "advisorType");
|
|
71
|
+
CopyIfPresent(result, data, "transferType");
|
|
72
|
+
CopyIfPresent(result, data, "startDate");
|
|
73
|
+
var endDate = GetString(data, "endDate");
|
|
74
|
+
result["endDate"] = string.IsNullOrEmpty(endDate) ? "2099-12-31" : endDate;
|
|
75
|
+
result["rezervations"] = items;
|
|
76
|
+
|
|
77
|
+
return Task.FromResult(new ScriptResponse
|
|
78
|
+
{
|
|
79
|
+
Data = result
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
catch (Exception ex)
|
|
83
|
+
{
|
|
84
|
+
return Task.FromResult(new ScriptResponse
|
|
85
|
+
{
|
|
86
|
+
Key = "fetch-error",
|
|
87
|
+
Data = new
|
|
88
|
+
{
|
|
89
|
+
error = "Failed to fetch reservations for transfer",
|
|
90
|
+
errorDescription = ex.Message
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
private void CopyIfPresent(Dictionary<string, object> target, dynamic source, string name)
|
|
97
|
+
{
|
|
98
|
+
if (source == null) return;
|
|
99
|
+
try
|
|
100
|
+
{
|
|
101
|
+
if (HasProperty(source, name))
|
|
102
|
+
{
|
|
103
|
+
var v = GetPropertyValue(source, name);
|
|
104
|
+
if (v != null) target[name] = v;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
catch { }
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
private string GetString(dynamic obj, string name)
|
|
111
|
+
{
|
|
112
|
+
if (obj == null) return null;
|
|
113
|
+
try
|
|
114
|
+
{
|
|
115
|
+
if (HasProperty(obj, name))
|
|
116
|
+
{
|
|
117
|
+
var v = GetPropertyValue(obj, name);
|
|
118
|
+
return v?.ToString();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
catch { }
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using System.Threading.Tasks;
|
|
4
|
+
using BBT.Workflow.Scripting;
|
|
5
|
+
using BBT.Workflow.Definitions;
|
|
6
|
+
|
|
7
|
+
/// <summary>
|
|
8
|
+
/// Mapping for get-chat-room-data-for-rezervation DaprServiceTask.
|
|
9
|
+
/// Calls api/v1/touch/workflows/chat-room/instances/{chatRoomInstanceKey}/functions/data
|
|
10
|
+
/// to get chat-room instance data (e.g. chatIntegration). Merges chatIntegration into flow instance for trigger-rezervation-to-in-meet.
|
|
11
|
+
/// </summary>
|
|
12
|
+
public class GetChatRoomDataForRezervationMapping : ScriptBase, IMapping
|
|
13
|
+
{
|
|
14
|
+
public Task<ScriptResponse> InputHandler(WorkflowTask task, ScriptContext context)
|
|
15
|
+
{
|
|
16
|
+
var serviceTask = task as DaprServiceTask;
|
|
17
|
+
if (serviceTask == null)
|
|
18
|
+
throw new InvalidOperationException("Task must be a DaprServiceTask");
|
|
19
|
+
|
|
20
|
+
var appId = GetConfigValue("DAPR_APP_ID");
|
|
21
|
+
if (!string.IsNullOrEmpty(appId))
|
|
22
|
+
serviceTask.SetAppId(appId);
|
|
23
|
+
|
|
24
|
+
var data = context.Instance?.Data;
|
|
25
|
+
var chatRoomInstanceKey = GetString(data, "chatRoomInstanceKey");
|
|
26
|
+
if (string.IsNullOrWhiteSpace(chatRoomInstanceKey))
|
|
27
|
+
throw new InvalidOperationException("chatRoomInstanceKey is required (set by previous start-chat-room-for-rezervation task)");
|
|
28
|
+
|
|
29
|
+
var path = $"api/v1/touch/workflows/chat-room/instances/{Uri.EscapeDataString(chatRoomInstanceKey)}/functions/data";
|
|
30
|
+
serviceTask.SetMethodName(path);
|
|
31
|
+
|
|
32
|
+
return Task.FromResult(new ScriptResponse());
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public Task<ScriptResponse> OutputHandler(ScriptContext context)
|
|
36
|
+
{
|
|
37
|
+
var response = context.Body;
|
|
38
|
+
if (response?.isSuccess != true)
|
|
39
|
+
{
|
|
40
|
+
return Task.FromResult(new ScriptResponse
|
|
41
|
+
{
|
|
42
|
+
Key = "chat-room-data-not-found",
|
|
43
|
+
Data = new
|
|
44
|
+
{
|
|
45
|
+
error = response?.errorMessage?.ToString() ?? "Failed to get chat-room data",
|
|
46
|
+
errorCode = "CHAT_ROOM_DATA_NOT_FOUND"
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
var apiResponse = response?.data ?? response?.Data ?? response;
|
|
52
|
+
var instanceData = GetValue(apiResponse, "data") ?? apiResponse;
|
|
53
|
+
var chatIntegration = GetValue(instanceData, "chatIntegration");
|
|
54
|
+
|
|
55
|
+
var data = context.Instance?.Data;
|
|
56
|
+
var result = new Dictionary<string, object>();
|
|
57
|
+
if (chatIntegration != null)
|
|
58
|
+
result["chatIntegration"] = chatIntegration;
|
|
59
|
+
if (data != null)
|
|
60
|
+
{
|
|
61
|
+
var randevuKey = GetString(data, "randevuKey");
|
|
62
|
+
if (!string.IsNullOrEmpty(randevuKey)) result["randevuKey"] = randevuKey;
|
|
63
|
+
var participantType = GetString(data, "participantType");
|
|
64
|
+
if (!string.IsNullOrEmpty(participantType)) result["participantType"] = participantType;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return Task.FromResult(new ScriptResponse
|
|
68
|
+
{
|
|
69
|
+
Key = "chat-room-data-success",
|
|
70
|
+
Data = result
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
private string GetString(dynamic obj, string name)
|
|
75
|
+
{
|
|
76
|
+
if (obj == null) return null;
|
|
77
|
+
try
|
|
78
|
+
{
|
|
79
|
+
if (HasProperty(obj, name))
|
|
80
|
+
{
|
|
81
|
+
var v = GetPropertyValue(obj, name);
|
|
82
|
+
return v?.ToString();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
catch { }
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
private object GetValue(dynamic obj, string name)
|
|
90
|
+
{
|
|
91
|
+
if (obj == null) return null;
|
|
92
|
+
try
|
|
93
|
+
{
|
|
94
|
+
if (HasProperty(obj, name))
|
|
95
|
+
return GetPropertyValue(obj, name);
|
|
96
|
+
}
|
|
97
|
+
catch { }
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Threading.Tasks;
|
|
3
|
+
using BBT.Workflow.Scripting;
|
|
4
|
+
using BBT.Workflow.Definitions;
|
|
5
|
+
|
|
6
|
+
/// <summary>
|
|
7
|
+
/// Mapping for get-chat-token HttpTask (Type 6).
|
|
8
|
+
/// Calls get-token API with roomName and participantName.
|
|
9
|
+
/// participantName = user when status is customer-enter, advisor when status is staff-enter.
|
|
10
|
+
/// </summary>
|
|
11
|
+
public class GetChatTokenMapping : ScriptBase, IMapping
|
|
12
|
+
{
|
|
13
|
+
public Task<ScriptResponse> InputHandler(WorkflowTask task, ScriptContext context)
|
|
14
|
+
{
|
|
15
|
+
var httpTask = task as HttpTask;
|
|
16
|
+
if (httpTask == null)
|
|
17
|
+
throw new InvalidOperationException("Task must be an HttpTask");
|
|
18
|
+
|
|
19
|
+
var data = context.Instance?.Data;
|
|
20
|
+
var roomName = data?.roomName?.ToString()?.Trim();
|
|
21
|
+
var status = data?.status?.ToString()?.Trim();
|
|
22
|
+
var user = data?.user?.ToString()?.Trim();
|
|
23
|
+
var advisor = data?.advisor?.ToString()?.Trim();
|
|
24
|
+
|
|
25
|
+
var participantName = status == "customer-enter" ? user : advisor;
|
|
26
|
+
if (string.IsNullOrEmpty(roomName) || string.IsNullOrEmpty(participantName))
|
|
27
|
+
{
|
|
28
|
+
return Task.FromResult(new ScriptResponse { Data = new { getTokenError = "Missing roomName or participantName" } });
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
var body = new
|
|
32
|
+
{
|
|
33
|
+
roomName,
|
|
34
|
+
participantName
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
httpTask.SetBody(body);
|
|
38
|
+
|
|
39
|
+
return Task.FromResult(new ScriptResponse());
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public Task<ScriptResponse> OutputHandler(ScriptContext context)
|
|
43
|
+
{
|
|
44
|
+
var result = new ScriptResponse();
|
|
45
|
+
var response = context.Body;
|
|
46
|
+
|
|
47
|
+
if (response?.isSuccess == true)
|
|
48
|
+
{
|
|
49
|
+
dynamic data = response.data;
|
|
50
|
+
string token = GetString(data, "token") ?? GetString(data, "Token");
|
|
51
|
+
result.Data = new
|
|
52
|
+
{
|
|
53
|
+
chatToken = token,
|
|
54
|
+
getTokenSuccess = true
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
else
|
|
58
|
+
{
|
|
59
|
+
string errorMessage = response?.errorMessage?.ToString() ?? "Get token failed";
|
|
60
|
+
result.Data = new
|
|
61
|
+
{
|
|
62
|
+
chatToken = (string)null,
|
|
63
|
+
getTokenSuccess = false,
|
|
64
|
+
getTokenError = errorMessage
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return Task.FromResult(result);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
private string GetString(dynamic obj, string name)
|
|
72
|
+
{
|
|
73
|
+
if (obj == null) return null;
|
|
74
|
+
try
|
|
75
|
+
{
|
|
76
|
+
if (HasProperty(obj, name))
|
|
77
|
+
{
|
|
78
|
+
var v = GetPropertyValue(obj, name);
|
|
79
|
+
return v?.ToString();
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
catch { }
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using System.Threading.Tasks;
|
|
4
|
+
using BBT.Workflow.Scripting;
|
|
5
|
+
using BBT.Workflow.Definitions;
|
|
6
|
+
|
|
7
|
+
/// <summary>
|
|
8
|
+
/// Mapping for get-rezervation-data-task when used in add-participant-to-rezervation flow.
|
|
9
|
+
/// Same as GetRezervationDataMapping but preserves randevuKey and newUserId from instance.
|
|
10
|
+
/// </summary>
|
|
11
|
+
public class GetRezervationDataForAddParticipantMapping : ScriptBase, IMapping
|
|
12
|
+
{
|
|
13
|
+
public Task<ScriptResponse> InputHandler(WorkflowTask task, ScriptContext context)
|
|
14
|
+
{
|
|
15
|
+
var serviceTask = task as DaprServiceTask;
|
|
16
|
+
if (serviceTask == null)
|
|
17
|
+
throw new InvalidOperationException("Task must be a DaprServiceTask");
|
|
18
|
+
|
|
19
|
+
var appId = GetConfigValue("DAPR_APP_ID");
|
|
20
|
+
if (!string.IsNullOrEmpty(appId))
|
|
21
|
+
serviceTask.SetAppId(appId);
|
|
22
|
+
|
|
23
|
+
var data = context.Instance?.Data;
|
|
24
|
+
var randevuKey = GetString(data, "randevuKey");
|
|
25
|
+
if (string.IsNullOrWhiteSpace(randevuKey))
|
|
26
|
+
throw new InvalidOperationException("randevuKey is required");
|
|
27
|
+
|
|
28
|
+
var path = $"api/v1/touch/workflows/rezervation/instances/{Uri.EscapeDataString(randevuKey)}/functions/data";
|
|
29
|
+
serviceTask.SetMethodName(path);
|
|
30
|
+
|
|
31
|
+
return Task.FromResult(new ScriptResponse());
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
public Task<ScriptResponse> OutputHandler(ScriptContext context)
|
|
35
|
+
{
|
|
36
|
+
var response = context.Body;
|
|
37
|
+
if (response?.isSuccess != true)
|
|
38
|
+
{
|
|
39
|
+
return Task.FromResult(new ScriptResponse
|
|
40
|
+
{
|
|
41
|
+
Key = "rezervation-data-not-found",
|
|
42
|
+
Data = new
|
|
43
|
+
{
|
|
44
|
+
error = response?.errorMessage?.ToString() ?? "Failed to get rezervation data",
|
|
45
|
+
errorCode = "REZERVATION_DATA_NOT_FOUND"
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
var apiResponse = response?.data ?? response?.Data ?? response;
|
|
51
|
+
var instanceData = GetValue(apiResponse, "data") ?? apiResponse;
|
|
52
|
+
|
|
53
|
+
var startDateTime = GetString(instanceData, "startDateTime");
|
|
54
|
+
var endDateTime = GetString(instanceData, "endDateTime");
|
|
55
|
+
var user = GetValue(instanceData, "user");
|
|
56
|
+
var advisor = GetValue(instanceData, "advisor");
|
|
57
|
+
var chatIntegration = GetValue(instanceData, "chatIntegration");
|
|
58
|
+
|
|
59
|
+
var data = context.Instance?.Data;
|
|
60
|
+
var result = new Dictionary<string, object>();
|
|
61
|
+
if (!string.IsNullOrEmpty(startDateTime)) result["startDateTime"] = startDateTime;
|
|
62
|
+
if (!string.IsNullOrEmpty(endDateTime)) result["endDateTime"] = endDateTime;
|
|
63
|
+
if (user != null) result["user"] = user;
|
|
64
|
+
if (advisor != null) result["advisor"] = advisor;
|
|
65
|
+
if (chatIntegration != null) result["chatIntegration"] = chatIntegration;
|
|
66
|
+
|
|
67
|
+
var randevuKey = GetString(data, "randevuKey");
|
|
68
|
+
var newUserId = GetString(data, "newUserId");
|
|
69
|
+
if (!string.IsNullOrEmpty(randevuKey)) result["randevuKey"] = randevuKey;
|
|
70
|
+
if (!string.IsNullOrEmpty(newUserId)) result["newUserId"] = newUserId;
|
|
71
|
+
|
|
72
|
+
return Task.FromResult(new ScriptResponse
|
|
73
|
+
{
|
|
74
|
+
Key = "rezervation-data-success",
|
|
75
|
+
Data = result
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
private string GetString(dynamic obj, string name)
|
|
80
|
+
{
|
|
81
|
+
if (obj == null) return null;
|
|
82
|
+
try
|
|
83
|
+
{
|
|
84
|
+
if (HasProperty(obj, name))
|
|
85
|
+
{
|
|
86
|
+
var v = GetPropertyValue(obj, name);
|
|
87
|
+
return v?.ToString();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
catch { }
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
private object GetValue(dynamic obj, string name)
|
|
95
|
+
{
|
|
96
|
+
if (obj == null) return null;
|
|
97
|
+
try
|
|
98
|
+
{
|
|
99
|
+
if (HasProperty(obj, name))
|
|
100
|
+
return GetPropertyValue(obj, name);
|
|
101
|
+
}
|
|
102
|
+
catch { }
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Threading.Tasks;
|
|
3
|
+
using BBT.Workflow.Scripting;
|
|
4
|
+
using BBT.Workflow.Definitions;
|
|
5
|
+
|
|
6
|
+
/// <summary>
|
|
7
|
+
/// Mapping for get-rezervation-data-task in randevu-update flow.
|
|
8
|
+
/// Same logic as GetRezervationDataMapping - gets data by randevuKey.
|
|
9
|
+
/// </summary>
|
|
10
|
+
public class GetRezervationDataForRandevuUpdateMapping : ScriptBase, IMapping
|
|
11
|
+
{
|
|
12
|
+
public Task<ScriptResponse> InputHandler(WorkflowTask task, ScriptContext context)
|
|
13
|
+
{
|
|
14
|
+
var serviceTask = task as DaprServiceTask;
|
|
15
|
+
if (serviceTask == null)
|
|
16
|
+
throw new InvalidOperationException("Task must be a DaprServiceTask");
|
|
17
|
+
|
|
18
|
+
var appId = GetConfigValue("DAPR_APP_ID");
|
|
19
|
+
if (!string.IsNullOrEmpty(appId))
|
|
20
|
+
serviceTask.SetAppId(appId);
|
|
21
|
+
|
|
22
|
+
var data = context.Instance?.Data;
|
|
23
|
+
var randevuKey = GetString(data, "randevuKey");
|
|
24
|
+
if (string.IsNullOrWhiteSpace(randevuKey))
|
|
25
|
+
throw new InvalidOperationException("randevuKey is required");
|
|
26
|
+
|
|
27
|
+
var path = $"api/v1/touch/workflows/rezervation/instances/{Uri.EscapeDataString(randevuKey)}/functions/data";
|
|
28
|
+
serviceTask.SetMethodName(path);
|
|
29
|
+
|
|
30
|
+
return Task.FromResult(new ScriptResponse());
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public Task<ScriptResponse> OutputHandler(ScriptContext context)
|
|
34
|
+
{
|
|
35
|
+
var response = context.Body;
|
|
36
|
+
if (response?.isSuccess != true)
|
|
37
|
+
{
|
|
38
|
+
return Task.FromResult(new ScriptResponse
|
|
39
|
+
{
|
|
40
|
+
Key = "rezervation-data-not-found",
|
|
41
|
+
Data = new
|
|
42
|
+
{
|
|
43
|
+
error = response?.errorMessage?.ToString() ?? "Failed to get rezervation data",
|
|
44
|
+
errorCode = "REZERVATION_DATA_NOT_FOUND"
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
var apiResponse = response?.data ?? response?.Data ?? response;
|
|
50
|
+
var instanceData = GetValue(apiResponse, "data") ?? apiResponse;
|
|
51
|
+
|
|
52
|
+
var startDateTime = GetString(instanceData, "startDateTime");
|
|
53
|
+
var endDateTime = GetString(instanceData, "endDateTime");
|
|
54
|
+
var user = GetValue(instanceData, "user");
|
|
55
|
+
var advisor = GetValue(instanceData, "advisor");
|
|
56
|
+
var chatIntegration = GetValue(instanceData, "chatIntegration");
|
|
57
|
+
var absenceEntryKey = GetString(instanceData, "absenceEntryKey");
|
|
58
|
+
|
|
59
|
+
var flowData = context.Instance?.Data;
|
|
60
|
+
var targetAdvisor = GetString(flowData, "targetAdvisor");
|
|
61
|
+
var result = new System.Collections.Generic.Dictionary<string, object>();
|
|
62
|
+
if (!string.IsNullOrEmpty(startDateTime)) { result["startDateTimeOld"] = startDateTime; result["startDateTime"] = startDateTime; }
|
|
63
|
+
if (!string.IsNullOrEmpty(endDateTime)) { result["endDateTimeOld"] = endDateTime; result["endDateTime"] = endDateTime; }
|
|
64
|
+
if (user != null) result["user"] = user;
|
|
65
|
+
// For transfer: use targetAdvisor as advisor when present; otherwise use existing advisor
|
|
66
|
+
var effectiveAdvisor = !string.IsNullOrEmpty(targetAdvisor) ? targetAdvisor : (advisor?.ToString());
|
|
67
|
+
if (!string.IsNullOrEmpty(effectiveAdvisor)) result["advisor"] = effectiveAdvisor;
|
|
68
|
+
if (advisor != null) result["originalAdvisor"] = advisor;
|
|
69
|
+
if (chatIntegration != null) result["chatIntegration"] = chatIntegration;
|
|
70
|
+
if (!string.IsNullOrEmpty(absenceEntryKey)) result["absenceEntryKey"] = absenceEntryKey;
|
|
71
|
+
if (!string.IsNullOrEmpty(GetString(flowData, "randevuKey"))) result["randevuKey"] = GetString(flowData, "randevuKey");
|
|
72
|
+
if (!string.IsNullOrEmpty(GetString(flowData, "state"))) result["state"] = GetString(flowData, "state");
|
|
73
|
+
if (!string.IsNullOrEmpty(targetAdvisor)) result["targetAdvisor"] = targetAdvisor;
|
|
74
|
+
var autoProcess = GetString(flowData, "autoProcess");
|
|
75
|
+
if (!string.IsNullOrEmpty(autoProcess)) result["autoProcess"] = autoProcess;
|
|
76
|
+
|
|
77
|
+
return Task.FromResult(new ScriptResponse
|
|
78
|
+
{
|
|
79
|
+
Key = "rezervation-data-success",
|
|
80
|
+
Data = result
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
private string GetString(dynamic obj, string name)
|
|
85
|
+
{
|
|
86
|
+
if (obj == null) return null;
|
|
87
|
+
try
|
|
88
|
+
{
|
|
89
|
+
if (HasProperty(obj, name))
|
|
90
|
+
{
|
|
91
|
+
var v = GetPropertyValue(obj, name);
|
|
92
|
+
return v?.ToString();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
catch { }
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
private object GetValue(dynamic obj, string name)
|
|
100
|
+
{
|
|
101
|
+
if (obj == null) return null;
|
|
102
|
+
try
|
|
103
|
+
{
|
|
104
|
+
if (HasProperty(obj, name))
|
|
105
|
+
return GetPropertyValue(obj, name);
|
|
106
|
+
}
|
|
107
|
+
catch { }
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using System.Threading.Tasks;
|
|
4
|
+
using BBT.Workflow.Scripting;
|
|
5
|
+
using BBT.Workflow.Definitions;
|
|
6
|
+
|
|
7
|
+
/// <summary>
|
|
8
|
+
/// Mapping for get-rezervation-data-task DaprServiceTask.
|
|
9
|
+
/// Calls api/v1/touch/workflows/rezervation/instances/{randevuKey}/functions/data
|
|
10
|
+
/// to get user, advisor, startDateTime, chatIntegration. Merges into flow instance.
|
|
11
|
+
/// </summary>
|
|
12
|
+
public class GetRezervationDataMapping : ScriptBase, IMapping
|
|
13
|
+
{
|
|
14
|
+
public Task<ScriptResponse> InputHandler(WorkflowTask task, ScriptContext context)
|
|
15
|
+
{
|
|
16
|
+
var serviceTask = task as DaprServiceTask;
|
|
17
|
+
if (serviceTask == null)
|
|
18
|
+
throw new InvalidOperationException("Task must be a DaprServiceTask");
|
|
19
|
+
|
|
20
|
+
var appId = GetConfigValue("DAPR_APP_ID");
|
|
21
|
+
if (!string.IsNullOrEmpty(appId))
|
|
22
|
+
serviceTask.SetAppId(appId);
|
|
23
|
+
|
|
24
|
+
var data = context.Instance?.Data;
|
|
25
|
+
var randevuKey = GetString(data, "randevuKey");
|
|
26
|
+
if (string.IsNullOrWhiteSpace(randevuKey))
|
|
27
|
+
throw new InvalidOperationException("randevuKey is required");
|
|
28
|
+
|
|
29
|
+
var path = $"api/v1/touch/workflows/rezervation/instances/{Uri.EscapeDataString(randevuKey)}/functions/data";
|
|
30
|
+
serviceTask.SetMethodName(path);
|
|
31
|
+
|
|
32
|
+
return Task.FromResult(new ScriptResponse());
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public Task<ScriptResponse> OutputHandler(ScriptContext context)
|
|
36
|
+
{
|
|
37
|
+
var response = context.Body;
|
|
38
|
+
if (response?.isSuccess != true)
|
|
39
|
+
{
|
|
40
|
+
return Task.FromResult(new ScriptResponse
|
|
41
|
+
{
|
|
42
|
+
Key = "rezervation-data-not-found",
|
|
43
|
+
Data = new
|
|
44
|
+
{
|
|
45
|
+
error = response?.errorMessage?.ToString() ?? "Failed to get rezervation data",
|
|
46
|
+
errorCode = "REZERVATION_DATA_NOT_FOUND"
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// functions/data response: { "data": { "user", "advisor", "startDateTime", "endDateTime", "chatIntegration", ... }, "etag", "extensions" }
|
|
52
|
+
var apiResponse = response?.data ?? response?.Data ?? response;
|
|
53
|
+
var instanceData = GetValue(apiResponse, "data") ?? apiResponse;
|
|
54
|
+
|
|
55
|
+
var startDateTime = GetString(instanceData, "startDateTime");
|
|
56
|
+
var endDateTime = GetString(instanceData, "endDateTime");
|
|
57
|
+
var user = GetValue(instanceData, "user");
|
|
58
|
+
var advisor = GetValue(instanceData, "advisor");
|
|
59
|
+
var chatIntegration = GetValue(instanceData, "chatIntegration");
|
|
60
|
+
|
|
61
|
+
var data = context.Instance?.Data;
|
|
62
|
+
var result = new Dictionary<string, object>();
|
|
63
|
+
if (!string.IsNullOrEmpty(startDateTime)) result["startDateTime"] = startDateTime;
|
|
64
|
+
if (!string.IsNullOrEmpty(endDateTime)) result["endDateTime"] = endDateTime;
|
|
65
|
+
if (user != null) result["user"] = user;
|
|
66
|
+
if (advisor != null) result["advisor"] = advisor;
|
|
67
|
+
if (chatIntegration != null) result["chatIntegration"] = chatIntegration;
|
|
68
|
+
var participantType = GetString(data, "participantType");
|
|
69
|
+
if (!string.IsNullOrEmpty(participantType))
|
|
70
|
+
result["participantType"] = participantType;
|
|
71
|
+
var invitedUserId = GetString(data, "invitedUserId");
|
|
72
|
+
if (!string.IsNullOrEmpty(invitedUserId))
|
|
73
|
+
result["invitedUserId"] = invitedUserId;
|
|
74
|
+
var invitedUser = GetValue(instanceData, "invitedUser") ?? GetValue(GetValue(instanceData, "attributes"), "invitedUser");
|
|
75
|
+
if (invitedUser != null)
|
|
76
|
+
result["invitedUser"] = invitedUser;
|
|
77
|
+
|
|
78
|
+
return Task.FromResult(new ScriptResponse
|
|
79
|
+
{
|
|
80
|
+
Key = "rezervation-data-success",
|
|
81
|
+
Data = result
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
private string GetString(dynamic obj, string name)
|
|
86
|
+
{
|
|
87
|
+
if (obj == null) return null;
|
|
88
|
+
try
|
|
89
|
+
{
|
|
90
|
+
if (HasProperty(obj, name))
|
|
91
|
+
{
|
|
92
|
+
var v = GetPropertyValue(obj, name);
|
|
93
|
+
return v?.ToString();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
catch { }
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
private object GetValue(dynamic obj, string name)
|
|
101
|
+
{
|
|
102
|
+
if (obj == null) return null;
|
|
103
|
+
try
|
|
104
|
+
{
|
|
105
|
+
if (HasProperty(obj, name))
|
|
106
|
+
return GetPropertyValue(obj, name);
|
|
107
|
+
}
|
|
108
|
+
catch { }
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
}
|