43 lines
1.5 KiB
Python
43 lines
1.5 KiB
Python
from src.config.objects import TargetObject
|
|
from src.converter.converter import CSVStringConverter
|
|
from src.error.exceptions import DataConvertException
|
|
from src.system_var.constants import CONV_JP_NAME
|
|
from src.util.logger import logger_instance as logger
|
|
|
|
|
|
def convert_crm_csv_data_process(target_object: TargetObject, crm_data_response: dict):
|
|
"""CSV変換処理
|
|
|
|
Args:
|
|
target_object (TargetObject): 取得対象オブジェクト情報インスタンス
|
|
crm_data_response (dict): Salesforceオブジェクトデータ
|
|
|
|
Raises:
|
|
DataConvertException: データ変換が失敗した場合
|
|
|
|
Returns:
|
|
csv_string: csvデータ
|
|
"""
|
|
|
|
# ① CSV変換処理の開始ログを出力する
|
|
target_object_name = target_object.object_name
|
|
|
|
logger.info(f'I-CONV-01 [{target_object_name}] のCSV変換処理を開始します')
|
|
|
|
try:
|
|
# ② CSV変換
|
|
csv_string_converter = CSVStringConverter(target_object, crm_data_response)
|
|
csv_string = csv_string_converter.convert()
|
|
|
|
logger.debug(f'D-CONV-02 [{target_object_name}] のCSV変換処理 正常終了')
|
|
|
|
except Exception as e:
|
|
raise DataConvertException(
|
|
'E-CONV-01', CONV_JP_NAME, f'[{target_object_name}] CSV変換に失敗しました エラー内容:[{e}]')
|
|
|
|
# ③ CSV変換処理の終了ログを出力する
|
|
logger.info(f'I-CONV-03 [{target_object_name}] のCSV変換処理を終了します')
|
|
|
|
# ④ 次の処理へ移行する
|
|
return csv_string
|