Skip to content

Commit

Permalink
CRS can now fetch internal and customer facing messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
brian-pond committed Feb 20, 2024
1 parent 44cfb72 commit 9f0905f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion temporal/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import json
from typing import NamedTuple

import frappe
from temporal import validate_datatype
from temporal.helpers import dict_to_dateless_dict

Expand Down Expand Up @@ -164,11 +165,17 @@ def get_warning_messages(self):
def get_info_messages(self):
return [ each for each in self._messages if each.message_level == 'Info'] # MessageLevel.INFO

def add_data_to_crs(self, crs_instance):
def add_result_to_crs(self, crs_instance):
"""
Add this result's data to a Common Response Schmea for the FTP Middleware.
"""
converted_dict = dict_to_dateless_dict(self.get_data()) # NOTE: function already handles a deepcopy

for key, value in converted_dict.items():
crs_instance.add_data(key, value) # important to send as JSON, to convert things like Date and DateTime to string.

for each_message in self.get_all_messages():
if each_message.audience in (MessageAudience.ALL, MessageAudience.INTERNAL):
crs_instance.add_internal_message(str(each_message))
if each_message.audience in (MessageAudience.ALL, MessageAudience.CUSTOMER):
crs_instance.add_customer_message(str(each_message))

0 comments on commit 9f0905f

Please sign in to comment.