lib/imperituroard/projects/mhub.rb in imperituroard-1.1.20 vs lib/imperituroard/projects/mhub.rb in imperituroard-1.1.21

- old
+ new

@@ -208,26 +208,47 @@ end #for bank dabrabyt def rec_deliv_report_2(params, ip_src, ip_real, ip_vip, crm_slice_num=2) + internal_func.printer_texter({:mess => 'started function rec_deliv_report_2'}, log_level) input_params = {:params => params, :ip_src => ip_src, :ip_real => ip_real, :ip_vip => ip_vip} output_params = {} hub_resp = {} + result = {} + internal_func.printer_texter({:mess => 'rec_deliv_report_2 step1'}, log_level) begin mes_report = dabrab_connecter.delivery_report_transform(params)[:body][:report_to_recip] - result = crm_connector.crm_status_2(mes_report, crm_slice_num) - if result[:body][:res_body]["GetReportsResult"]=="" - output_params = {"code": 200, "result": "Data processed", "body": {"answer": {"code": 200, "status": "Success"}, "sender": {"ip_src": ip_src, "ip_real": ip_real, "ip_vip": ip_vip}}} + internal_func.printer_texter({:mess => 'rec_deliv_report_2 step2'}, log_level) + + begin + internal_func.printer_texter({:mess => 'rec_deliv_report_2 step2.1'}, log_level) + result = crm_connector.crm_status_2(mes_report, crm_slice_num) + internal_func.printer_texter({:mess => 'rec_deliv_report_2 step2.2'}, log_level) + rescue + result = {:code => 505505, :result => 'Error', :body => {:res_body => 'Error communication with crm'}} + end + + internal_func.printer_texter({:mess => 'rec_deliv_report_2 step3'}, log_level) + if result[:body][:res_body] == '' + internal_func.printer_texter({:mess => 'rec_deliv_report_2 step4'}, log_level) + output_params = {'code': 200, 'result': 'Data processed', 'body': {'answer': {'code': 200, 'status': 'Success'}, 'sender': {'ip_src': ip_src, 'ip_real': ip_real, 'ip_vip': ip_vip}}} + internal_func.printer_texter({:mess => 'rec_deliv_report_2 step5'}, log_level) + elsif result[:code] == 505505 + internal_func.printer_texter({:mess => 'rec_deliv_report_2 step5.1'}, log_level) + output_params = {'code': 505, 'result': 'Data processed', 'body': {'answer': {'code': 505, 'status': 'Error communicate with dabrabyt'}, 'sender': {'ip_src': ip_src, 'ip_real': ip_real, 'ip_vip': ip_vip}}} + internal_func.printer_texter({:mess => 'rec_deliv_report_2 step5.2'}, log_level) else - output_params = {"code": 202, "result": "CRM returned error #{result[:body][:res_body]["GetReportsResult"].to_s}", "body": {"answer": {"code": 200, "status": "Success"}, "sender": {"ip_src": ip_src, "ip_real": ip_real, "ip_vip": ip_vip}}} + internal_func.printer_texter({:mess => 'rec_deliv_report_2 step6'}, log_level) + output_params = {'code': 202, 'result': "CRM returned error #{result[:body][:res_body]['GetReportsResult'].to_s}", 'body': {'answer': {'code': 200, 'status': 'Success'}, 'sender': {'ip_src': ip_src, 'ip_real': ip_real, 'ip_vip': ip_vip}}} + internal_func.printer_texter({:mess => 'rec_deliv_report_2 step7'}, log_level) end rescue - output_params = {"code": 500, "result": "MhubFunctions_2.rec_deliv_report_2: Unknown SDK error", "body": {"answer": {}, "sender": {"ip_src": ip_src, "ip_real": ip_real, "ip_vip": ip_vip}}} + output_params = {'code': 500, 'result': 'MhubFunctions_2.rec_deliv_report_2: Unknown SDK error', 'body': {'answer': {}, 'sender': {'ip_src': ip_src, 'ip_real': ip_real, 'ip_vip': ip_vip}}} telegram_connector.telegram_message(output_params) end - internal_func.printer_texter({:input => input_params, :output => output_params, :hub_resp => hub_resp, :procedure => "Mhub_2.recieve_delivery_report"}, log_level) + internal_func.printer_texter({:input => input_params, :output => output_params, :hub_resp => hub_resp, :procedure => 'Mhub_2.recieve_delivery_report'}, log_level) output_params end end