lib/imperituroard.rb in imperituroard-0.4.9 vs lib/imperituroard.rb in imperituroard-0.5.0

- old
+ new

@@ -14,10 +14,11 @@ require "imperituroard/projects/iot/internal_functions" require 'imperituroard/projects/mhub/infobip' require 'imperituroard/projects/mhub/sk' require 'imperituroard/projects/mhub/subs/dabrab/dabrab_proced' require 'imperituroard/projects/mhub/subs/dabrab/dabrab_platform' +require 'imperituroard/projects/mhub' require 'imperituroard/projects/iot' require 'imperituroard/platforms/cps/qps_connector' require 'json' require 'ipaddr' require 'date' @@ -272,10 +273,11 @@ @internal_func = InternalFunc.new @dabrab_connecter = Dabrab.new @add_functions_connector = AdditionalFunc.new(telegram_api_url, telegram_chat_id) @static_callback = static_callback @crm_connector = Crm_1.new(crm_callback_url, crm_login, crm_password) + @mhub_connector = MhubFunctions_2.new(sk_url_simple, sk_login, sk_password, telegram_api_url, telegram_chat_id, sk_url_broadcast, static_callback, crm_callback_url, crm_login, crm_password) end #{"destinations"=>[{"to"=>{"phoneNumber"=>"375297116638", "emailAddress"=>nil}}], # "scenarioKey"=>"1", "viber"=>nil, "sms"=>{"text"=>"карточка готова"}, @@ -286,106 +288,15 @@ # "notifyUrl"=>"https://bpmonline.bankdabrabyt.by:444/0/ServiceModel/ScGetReports.svc/GetReports", # "notifyContentType"=>"application/json"}} def get_send_message(params, ip_src, ip_real, ip_vip) - - input_params = {:params => params} - output_params = {} - hub_resp = {} - null_statement = [nil, "nil", "", "null"] - - begin - - # if params["destinations"].length == 1 - # msisdn = params["destinations"][0]["to"]["phoneNumber"] - # if null_statement.include?(params["viber"]) && !null_statement.include?(params["sms"]) - # hub_resp = mhub_connector.sk_send_sms_one(msisdn, params["notifyUrl"], params["sms"]["text"], "TEST") - # elsif !null_statement.include?(params["viber"]) && null_statement.include?(params["sms"]) - # hub_resp = mhub_connector.sk_send_viber_one(msisdn, params["notifyUrl"], params["viber"]["text"]) - # elsif !null_statement.include?(params["viber"]) && !null_statement.include?(params["sms"]) - # hub_resp = mhub_connector.sk_send_viber_sms_one(msisdn, params["notifyUrl"], params["sms"]["text"], params["viber"]["text"], "TEST") - # else - # output_params = {"code": 501, "result": "Invalid input data st1", "answer": {}, "sender": {"ip_src": ip_src, "ip_real": ip_real, "ip_vip": ip_vip}} - # end - # elsif params["destinations"].length > 1 - # - # msisdn2 = dabrab_connecter.num_formatter(params["destinations"], params["notifyUrl"].split(":")[2]) - # - # if null_statement.include?(params["viber"]) && !null_statement.include?(params["sms"]) - # hub_resp = mhub_connector.sk_send_sms_list(msisdn2, params["notifyUrl"], params["sms"]["text"], "TEST") - # elsif !null_statement.include?(params["viber"]) && null_statement.include?(params["sms"]) - # hub_resp = mhub_connector.sk_send_viber_list(msisdn2, params["notifyUrl"], params["viber"]["text"]) - # elsif !null_statement.include?(params["viber"]) && !null_statement.include?(params["sms"]) - # hub_resp = mhub_connector.sk_send_viber_sms_list(msisdn2, params["notifyUrl"], params["sms"]["text"], params["viber"]["text"], "TEST") - # else - # output_params = {"code": 502, "result": "Invalid input data st2", "answer": {}, "sender": {"ip_src": ip_src, "ip_real": ip_real, "ip_vip": ip_vip}} - # end - # else - # output_params = {"code": 503, "result": "Invalid recipients", "answer": {}, "sender": {"ip_src": ip_src, "ip_real": ip_real, "ip_vip": ip_vip}} - # end - - if params["destinations"].length >= 1 - - msisdn2 = dabrab_connecter.num_formatter(params["destinations"], params["notifyUrl"].split(":")[2]) - - if null_statement.include?(params["viber"]) && !null_statement.include?(params["sms"]) - hub_resp = mhub_connector.sk_send_sms_list(msisdn2, static_callback, params["sms"]["text"], "TEST") - elsif !null_statement.include?(params["viber"]) && null_statement.include?(params["sms"]) - hub_resp = mhub_connector.sk_send_viber_list(msisdn2, static_callback, params["viber"]["text"]) - elsif !null_statement.include?(params["viber"]) && !null_statement.include?(params["sms"]) - p "vibersms" - p msisdn2 - hub_resp = mhub_connector.sk_send_viber_sms_list(msisdn2, static_callback, params["sms"]["text"], params["viber"]["text"], "TEST") - else - output_params = {"code": 502, "result": "Invalid input data st2", "body": {"answer": {}, "sender": {"ip_src": ip_src, "ip_real": ip_real, "ip_vip": ip_vip}}} - end - else - output_params = {"code": 503, "result": "Invalid recipients", "body": {"answer": {}, "sender": {"ip_src": ip_src, "ip_real": ip_real, "ip_vip": ip_vip}}} - end - - mes_data = dabrab_connecter.send_responce_formatter(hub_resp) - p hub_resp - - output_params = {"code": 200, "result": "Data processed", "body": {"answer": mes_data[:body][:mess_to_recip], "sender": {"ip_src": ip_src, "ip_real": ip_real, "ip_vip": ip_vip}}} - - rescue - output_params = {"code": 500, "result": "Unknown SDK error", "body": {"answer": {}, "sender": {"ip_src": ip_src, "ip_real": ip_real, "ip_vip": ip_vip}}} - end - - internal_func.printer_texter({:input => input_params, :output => output_params, :hub_resp => hub_resp, :procedure => "Mhub_2.get_send_message"}, "debug") - output_params - + mhub_connector.get_send_message_2(params, ip_src, ip_real, ip_vip) end def recieve_delivery_report(params, ip_src, ip_real, ip_vip) - input_params = {:params => params, :ip_src => ip_src, :ip_real => ip_real, :ip_vip => ip_vip} - output_params = {} - hub_resp = {} - null_statement = [nil, "nil", "", "null"] - - begin - - mes_report = dabrab_connecter.delivery_report_transform(params)[:body][:report_to_recip] - - result = crm_connector.crm_status_1(mes_report) - - 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}}} - - rescue - output_params = {"code": 500, "result": "Unknown SDK error", "body": {"answer": {}, "sender": {"ip_src": ip_src, "ip_real": ip_real, "ip_vip": ip_vip}}} - end - - internal_func.printer_texter({:input => input_params, :output => output_params, :hub_resp => hub_resp, :procedure => "Mhub_2.recieve_delivery_report"}, "debug") - output_params - - end - - - def test2 - hh = Infobip_1.new - hh.test + mhub_connector.rec_deliv_report_2(params, ip_src, ip_real, ip_vip) end end \ No newline at end of file