lib/imperituroard/projects/mhub.rb in imperituroard-1.1.9 vs lib/imperituroard/projects/mhub.rb in imperituroard-1.1.10
- old
+ new
@@ -22,23 +22,25 @@
:internal_func,
:dabrab_connecter,
:static_callback,
:crm_connector,
:telegram_connector,
- :sms_alphaname
+ :sms_alphaname,
+ :log_level
- def initialize(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, sms_alphaname)
+ def initialize(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, sms_alphaname, log_level)
@sk_url = sk_url_simple
@sk_login = sk_login
@sk_password = sk_password
+ @log_level = log_level
@internal_func = InternalFunc.new
- @mhub_connector = Sksk_2.new(sk_url_simple, sk_login, sk_password, sk_url_broadcast, telegram_api_url, telegram_chat_id)
+ @mhub_connector = Sksk_2.new(sk_url_simple, sk_login, sk_password, sk_url_broadcast, telegram_api_url, telegram_chat_id, log_level)
@internal_func = InternalFunc.new
@dabrab_connecter = Dabrab.new
@telegram_connector = Telegram_2.new(telegram_api_url, telegram_chat_id)
@static_callback = static_callback
- @crm_connector = Crm_2.new(crm_callback_url, crm_login, crm_password, telegram_api_url, telegram_chat_id)
+ @crm_connector = Crm_2.new(crm_callback_url, crm_login, crm_password, telegram_api_url, telegram_chat_id, log_level)
@sms_alphaname = sms_alphaname
end
#{"destinations"=>[{"to"=>{"phoneNumber"=>"375297116638", "emailAddress"=>nil}}],
@@ -56,10 +58,11 @@
input_params = {:params => params}
output_params = {}
hub_resp = {}
null_statement = [nil, "nil", "", "null"]
+ mes_data = {}
begin
# if params["destinations"].length == 1
# msisdn = params["destinations"][0]["to"]["phoneNumber"]
@@ -87,14 +90,20 @@
# end
# else
# output_params = {"code": 503, "result": "Invalid recipients", "answer": {}, "sender": {"ip_src": ip_src, "ip_real": ip_real, "ip_vip": ip_vip}}
# end
+ p params
if params["destinations"].length >= 1
+ p params["destinations"]
+ p "eeee"
msisdn2 = dabrab_connecter.num_formatter(params["destinations"], params["notifyUrl"].split(":")[2])
+ splitted_parts = msisdn2.each_slice(1).to_a
+
+
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"], sms_alphaname)
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"])
@@ -102,30 +111,88 @@
p msisdn2
hub_resp = mhub_connector.sk_send_viber_sms_list(msisdn2, static_callback, params["sms"]["text"], params["viber"]["text"], sms_alphaname)
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
+ mes_data = dabrab_connecter.send_responce_formatter(hub_resp)
+
+
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
+ p mes_data
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": "MhubFunctions_2.get_send_message_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.get_send_message"}, "debug")
+ internal_func.printer_texter({:input => input_params, :output => output_params, :hub_resp => hub_resp, :procedure => "Mhub_2.get_send_message"}, log_level)
output_params
end
+ #for bank dabrabyt for massive nums
+ def get_send_message_mass_2(params, ip_src, ip_real, ip_vip)
+
+ input_params = {:params => params}
+ output_params = {}
+
+ null_statement = [nil, "nil", "", "null"]
+ mes_data_answ = []
+
+ begin
+ internal_func.printer_texter({:input => params, :procedure => "Mhub_2.get_send_message_mass_2"}, log_level)
+ if params["destinations"].length >= 1
+ msisdn2 = dabrab_connecter.num_formatter(params["destinations"], params["notifyUrl"].split(":")[2])
+ splitted_parts = msisdn2.each_slice(100).to_a
+ for part_list in splitted_parts
+
+ internal_func.printer_texter({:input => part_list, :procedure => "Mhub_2.get_send_message_mass_2"}, log_level)
+
+ hub_resp = {}
+
+ if null_statement.include?(params["viber"]) && !null_statement.include?(params["sms"])
+ hub_resp = mhub_connector.sk_send_sms_list(part_list, static_callback, params["sms"]["text"], sms_alphaname)
+ elsif !null_statement.include?(params["viber"]) && null_statement.include?(params["sms"])
+ hub_resp = mhub_connector.sk_send_viber_list(part_list, static_callback, params["viber"]["text"])
+ elsif !null_statement.include?(params["viber"]) && !null_statement.include?(params["sms"])
+ hub_resp = mhub_connector.sk_send_viber_sms_list(part_list, static_callback, params["sms"]["text"], params["viber"]["text"], sms_alphaname)
+ 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
+ mes_data = dabrab_connecter.send_responce_formatter(hub_resp)
+
+ internal_func.printer_texter({:input => mes_data, :procedure => "Mhub_2.get_send_message_mass_2"}, log_level)
+
+ mes_data_answ = mes_data_answ + mes_data[:body][:mess_to_recip][:messages]
+
+ 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
+
+ output_params = {"code": 200, "result": "Data processed", "body": {"answer": {"bulkId": "00000000-0000-0000-0000-000000000000", "messages": mes_data_answ}, "sender": {"ip_src": ip_src, "ip_real": ip_real, "ip_vip": ip_vip}}}
+
+ rescue
+ output_params = {"code": 500, "result": "MhubFunctions_2.get_send_message_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 => {}, :procedure => "Mhub_2.get_send_message"}, log_level)
+ output_params
+
+ end
+
+
#for bank dabrabyt
def rec_deliv_report_2(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 = {}
@@ -140,10 +207,10 @@
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}}}
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"}, "debug")
+ 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
def test2
hh = Infobip_1.new