Class: MhubFunctions_2
- Inherits:
-
Object
- Object
- MhubFunctions_2
- Defined in:
- lib/imperituroard/projects/mhub.rb
Instance Attribute Summary collapse
-
#crm_connector ⇒ Object
Returns the value of attribute crm_connector.
-
#dabrab_connecter ⇒ Object
Returns the value of attribute dabrab_connecter.
-
#internal_func ⇒ Object
Returns the value of attribute internal_func.
-
#log_level ⇒ Object
Returns the value of attribute log_level.
-
#mhub_connector ⇒ Object
Returns the value of attribute mhub_connector.
-
#sk_login ⇒ Object
Returns the value of attribute sk_login.
-
#sk_password ⇒ Object
Returns the value of attribute sk_password.
-
#sk_url ⇒ Object
Returns the value of attribute sk_url.
-
#sms_alphaname ⇒ Object
Returns the value of attribute sms_alphaname.
-
#static_callback ⇒ Object
Returns the value of attribute static_callback.
-
#telegram_connector ⇒ Object
Returns the value of attribute telegram_connector.
Instance Method Summary collapse
-
#get_send_message_2(params, ip_src, ip_real, ip_vip) ⇒ Object
for bank dabrabyt.
-
#get_send_message_mass_2(params, ip_src, ip_real, ip_vip, slice_number, time_pause_minutes, viberttl, params_manual_set, smsttl) ⇒ Object
for bank dabrabyt for massive nums.
-
#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) ⇒ MhubFunctions_2
constructor
A new instance of MhubFunctions_2.
-
#rec_deliv_report_2(params, ip_src, ip_real, ip_vip, crm_slice_num = 2) ⇒ Object
for bank dabrabyt.
Constructor Details
#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) ⇒ MhubFunctions_2
Returns a new instance of MhubFunctions_2.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/imperituroard/projects/mhub.rb', line 30 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, log_level) @internal_func = InternalFunc.new @dabrab_connecter = Dabrab.new(log_level) @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, log_level) @sms_alphaname = sms_alphaname end |
Instance Attribute Details
#crm_connector ⇒ Object
Returns the value of attribute crm_connector.
18 19 20 |
# File 'lib/imperituroard/projects/mhub.rb', line 18 def crm_connector @crm_connector end |
#dabrab_connecter ⇒ Object
Returns the value of attribute dabrab_connecter.
18 19 20 |
# File 'lib/imperituroard/projects/mhub.rb', line 18 def dabrab_connecter @dabrab_connecter end |
#internal_func ⇒ Object
Returns the value of attribute internal_func.
18 19 20 |
# File 'lib/imperituroard/projects/mhub.rb', line 18 def internal_func @internal_func end |
#log_level ⇒ Object
Returns the value of attribute log_level.
18 19 20 |
# File 'lib/imperituroard/projects/mhub.rb', line 18 def log_level @log_level end |
#mhub_connector ⇒ Object
Returns the value of attribute mhub_connector.
18 19 20 |
# File 'lib/imperituroard/projects/mhub.rb', line 18 def mhub_connector @mhub_connector end |
#sk_login ⇒ Object
Returns the value of attribute sk_login.
18 19 20 |
# File 'lib/imperituroard/projects/mhub.rb', line 18 def sk_login @sk_login end |
#sk_password ⇒ Object
Returns the value of attribute sk_password.
18 19 20 |
# File 'lib/imperituroard/projects/mhub.rb', line 18 def sk_password @sk_password end |
#sk_url ⇒ Object
Returns the value of attribute sk_url.
18 19 20 |
# File 'lib/imperituroard/projects/mhub.rb', line 18 def sk_url @sk_url end |
#sms_alphaname ⇒ Object
Returns the value of attribute sms_alphaname.
18 19 20 |
# File 'lib/imperituroard/projects/mhub.rb', line 18 def sms_alphaname @sms_alphaname end |
#static_callback ⇒ Object
Returns the value of attribute static_callback.
18 19 20 |
# File 'lib/imperituroard/projects/mhub.rb', line 18 def static_callback @static_callback end |
#telegram_connector ⇒ Object
Returns the value of attribute telegram_connector.
18 19 20 |
# File 'lib/imperituroard/projects/mhub.rb', line 18 def telegram_connector @telegram_connector end |
Instance Method Details
#get_send_message_2(params, ip_src, ip_real, ip_vip) ⇒ Object
for bank dabrabyt
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/imperituroard/projects/mhub.rb', line 57 def (params, ip_src, ip_real, ip_vip) 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"] # 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"], 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"]) p "vibersms" 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 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.(output_params) end 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 |
#get_send_message_mass_2(params, ip_src, ip_real, ip_vip, slice_number, time_pause_minutes, viberttl, params_manual_set, smsttl) ⇒ Object
for bank dabrabyt for massive nums
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
# File 'lib/imperituroard/projects/mhub.rb', line 132 def (params, ip_src, ip_real, ip_vip, slice_number, time_pause_minutes, viberttl, params_manual_set, smsttl ) 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(slice_number).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 = {} viber_param = params["viber"] sms_param = params["sms"] if params_manual_set != 0 begin if params_manual_set[:viber] == 0 viber_param = nil end if params_manual_set[:sms] == 0 sms_param = nil end rescue nil end end if null_statement.include?(viber_param) && !null_statement.include?(sms_param) hub_resp = mhub_connector.sk_send_sms_list(part_list, static_callback, params["sms"]["text"], sms_alphaname, time_pause_minutes, smsttl) elsif !null_statement.include?(viber_param) && null_statement.include?(sms_param) hub_resp = mhub_connector.sk_send_viber_list(part_list, static_callback, params["viber"]["text"], time_pause_minutes, viberttl) elsif !null_statement.include?(viber_param) && !null_statement.include?(sms_param) hub_resp = mhub_connector.sk_send_viber_sms_list(part_list, static_callback, params["sms"]["text"], params["viber"]["text"], sms_alphaname, time_pause_minutes, viberttl, smsttl) 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.(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 |
#rec_deliv_report_2(params, ip_src, ip_real, ip_vip, crm_slice_num = 2) ⇒ Object
for bank dabrabyt
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
# File 'lib/imperituroard/projects/mhub.rb', line 212 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] 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 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}}} telegram_connector.(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) output_params end |