Class: Sksk_2
- Inherits:
-
Object
- Object
- Sksk_2
- Defined in:
- lib/imperituroard/projects/mhub/sk.rb
Instance Attribute Summary collapse
-
#dabrab_add_func ⇒ Object
Returns the value of attribute dabrab_add_func.
-
#internal_func ⇒ Object
Returns the value of attribute internal_func.
-
#log_level ⇒ Object
Returns the value of attribute log_level.
-
#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.
-
#sk_url_broadcast ⇒ Object
Returns the value of attribute sk_url_broadcast.
-
#telegram_connector ⇒ Object
Returns the value of attribute telegram_connector.
Instance Method Summary collapse
- #get_start_date(addit_min) ⇒ Object
-
#initialize(sk_url, sk_login, sk_password, sk_url_broadcast, telegram_api_url, telegram_chat_id, log_level) ⇒ Sksk_2
constructor
A new instance of Sksk_2.
- #sk_send_sms_list(msisdn_list, callback_url, text, alphaname, time_pause_minutes = 1, smsttl) ⇒ Object
- #sk_send_sms_one(msisdn, callback_url, text, alphaname) ⇒ Object
- #sk_send_viber_list(msisdn_list, callback_url, text, time_pause_minutes, viberttl) ⇒ Object
- #sk_send_viber_one(msisdn, callback_url, text) ⇒ Object
- #sk_send_viber_sms_list(msisdn_list, callback_url, sms_text, viber_text, alphaname, time_pause_minutes, viberttl, smsttl) ⇒ Object
- #sk_send_viber_sms_one(msisdn, callback_url, sms_text, viber_txt, alphaname, smsttl = 600) ⇒ Object
Constructor Details
#initialize(sk_url, sk_login, sk_password, sk_url_broadcast, telegram_api_url, telegram_chat_id, log_level) ⇒ Sksk_2
Returns a new instance of Sksk_2.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/imperituroard/projects/mhub/sk.rb', line 9 def initialize(sk_url, sk_login, sk_password, sk_url_broadcast, telegram_api_url, telegram_chat_id, log_level) @sk_url = sk_url @sk_login = sk_login @sk_password = sk_password @log_level = log_level @internal_func = InternalFunc.new @sk_url_broadcast = sk_url_broadcast @telegram_connector = Telegram_2.new(telegram_api_url, telegram_chat_id) @dabrab_add_func = Dabrab.new(log_level) end |
Instance Attribute Details
#dabrab_add_func ⇒ Object
Returns the value of attribute dabrab_add_func.
7 8 9 |
# File 'lib/imperituroard/projects/mhub/sk.rb', line 7 def dabrab_add_func @dabrab_add_func end |
#internal_func ⇒ Object
Returns the value of attribute internal_func.
7 8 9 |
# File 'lib/imperituroard/projects/mhub/sk.rb', line 7 def internal_func @internal_func end |
#log_level ⇒ Object
Returns the value of attribute log_level.
7 8 9 |
# File 'lib/imperituroard/projects/mhub/sk.rb', line 7 def log_level @log_level end |
#sk_login ⇒ Object
Returns the value of attribute sk_login.
7 8 9 |
# File 'lib/imperituroard/projects/mhub/sk.rb', line 7 def sk_login @sk_login end |
#sk_password ⇒ Object
Returns the value of attribute sk_password.
7 8 9 |
# File 'lib/imperituroard/projects/mhub/sk.rb', line 7 def sk_password @sk_password end |
#sk_url ⇒ Object
Returns the value of attribute sk_url.
7 8 9 |
# File 'lib/imperituroard/projects/mhub/sk.rb', line 7 def sk_url @sk_url end |
#sk_url_broadcast ⇒ Object
Returns the value of attribute sk_url_broadcast.
7 8 9 |
# File 'lib/imperituroard/projects/mhub/sk.rb', line 7 def sk_url_broadcast @sk_url_broadcast end |
#telegram_connector ⇒ Object
Returns the value of attribute telegram_connector.
7 8 9 |
# File 'lib/imperituroard/projects/mhub/sk.rb', line 7 def telegram_connector @telegram_connector end |
Instance Method Details
#get_start_date(addit_min) ⇒ Object
21 22 23 24 |
# File 'lib/imperituroard/projects/mhub/sk.rb', line 21 def get_start_date(addit_min) date_b = Time.now (date_b + addit_min * 60).strftime("%Y-%m-%d %H:%M:%S") end |
#sk_send_sms_list(msisdn_list, callback_url, text, alphaname, time_pause_minutes = 1, smsttl) ⇒ Object
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 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 |
# File 'lib/imperituroard/projects/mhub/sk.rb', line 223 def sk_send_sms_list(msisdn_list, callback_url, text, alphaname, time_pause_minutes=1, smsttl) input_params = {:msisdn_list => msisdn_list, :callback_url => callback_url, :text => text, :alphaname => alphaname} output_params = {} = {} begin thr_sk_send_sms_list = Thread.new do uri = URI(sk_url_broadcast) #8 - client id https = Net::HTTP.new(uri.host, uri.port) https.use_ssl = true https.verify_mode = OpenSSL::SSL::VERIFY_NONE req = Net::HTTP::Post.new(uri.path, initheader = {:"Content-Type" => 'application/json'}) req.basic_auth sk_login, sk_password req["Content-Type"] = "application/json" req["Accept"] = "application/json" # [{"phone_number": 375298766719}, {"phone_number": 375295730878}] = { "recipients": msisdn_list, "callback_url": callback_url, "start_time": get_start_date(time_pause_minutes), "tag": "Dabrab_custom_api_1", "channels": [ "sms" ], "channel_options": { "sms": { "alpha_name": alphaname, "text": text, "ttl": smsttl } } } req.body = .to_json res = https.request(req) output_params = {:code => 200, :result => "Sksk_2.sk_send_sms_list: Request processed", :body => {:request_message => , :res_code => res.code, :res_body => JSON.parse(res.body.to_s)}} end thr_sk_send_sms_list.join rescue output_params = {:code => 500, :result => "Sksk_2.sk_send_sms_list: Something wrong"} telegram_connector.(output_params) end internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Sksk_2.sk_send_sms_list"}, log_level) output_params end |
#sk_send_sms_one(msisdn, callback_url, text, alphaname) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 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 |
# File 'lib/imperituroard/projects/mhub/sk.rb', line 28 def sk_send_sms_one(msisdn, callback_url, text, alphaname) input_params = {:msisdn => msisdn, :callback_url => callback_url, :text => text, :alphaname => alphaname} output_params = {} = {} begin thr_sk_send_sms_one = Thread.new do uri = URI(sk_url) #8 - client id https = Net::HTTP.new(uri.host, uri.port) https.use_ssl=true https.verify_mode = OpenSSL::SSL::VERIFY_NONE req = Net::HTTP::Post.new(uri.path, initheader = {:"Content-Type" => 'application/json'}) req.basic_auth sk_login, sk_password req["Content-Type"] = "application/json" req["Accept"] = "application/json" = { "phone_number": msisdn, #"extra_id": "4232j4h89932kjhs", "callback_url": callback_url, #"start_time": "2019-08-16 09:59:10", "tag": "Dabrab_custom_api_1", "channels": [ "sms" ], "channel_options": { "sms": { "text": text, "alpha_name": alphaname, "ttl": 600 } } } req.body = .to_json res = https.request(req) output_params = {:code => 200, :result => "Sksk_2.sk_send_sms_one: Request processed", :body => {:request_message => , :res_code => res.code, :res_body => JSON.parse(res.body.to_s)}} end thr_sk_send_sms_one.join rescue output_params = {:code => 500, :result => "Sksk_2.sk_send_sms_one: Something wrong", :body => {:request_message => }} telegram_connector.(output_params) end internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Sksk_1.sk_send_sms_one"}, log_level) output_params end |
#sk_send_viber_list(msisdn_list, callback_url, text, time_pause_minutes, viberttl) ⇒ Object
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 |
# File 'lib/imperituroard/projects/mhub/sk.rb', line 285 def sk_send_viber_list(msisdn_list, callback_url, text, time_pause_minutes, viberttl) internal_func.printer_texter({:input => "Fun started", :output => {}, :procedure => "Sksk_2.sk_send_viber_list"}, log_level) input_params = {:msisdn_list => msisdn_list, :callback_url => callback_url, :text => text} output_params = {} = {} begin thr_sk_send_viber_list = Thread.new do viber_mess_ans = dabrab_add_func.dabrabyt_text_field_parse(text, viberttl) if viber_mess_ans[:code] == 200 uri = URI(sk_url_broadcast) #8 - client id https = Net::HTTP.new(uri.host, uri.port) https.use_ssl = true https.verify_mode = OpenSSL::SSL::VERIFY_NONE req = Net::HTTP::Post.new(uri.path, initheader = {:"Content-Type" => 'application/json'}) req["Content-Type"] = "application/json" req["Accept"] = "application/json" req.basic_auth sk_login, sk_password # [{"phone_number": 375298766719}, {"phone_number": 375295730878}] = { "recipients": msisdn_list, "callback_url": callback_url, "start_time": get_start_date(time_pause_minutes), "tag": "Dabrab_custom_api_1", "channels": [ "viber" ], "channel_options": { "viber": viber_mess_ans[:body][:to_sk_format] } } req.body = .to_json res = https.request(req) output_params = {:code => 200, :result => "Sksk_2.sk_send_viber_list: Request processed", :body => {:request_message => , :res_code => res.code, :res_body => JSON.parse(res.body.to_s)}} else output_params = {:code => 508, :result => "Sksk_2.sk_send_viber_list: Something wrong with dabrabyt_text_field_parse"} end end thr_sk_send_viber_list.join rescue output_params = {:code => 500, :result => "Sksk_2.sk_send_viber_list: Something wrong"} telegram_connector.(output_params) end internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Sksk_2.sk_send_viber_list"}, log_level) output_params end |
#sk_send_viber_one(msisdn, callback_url, text) ⇒ Object
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 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/imperituroard/projects/mhub/sk.rb', line 89 def sk_send_viber_one(msisdn, callback_url, text) input_params = {:msisdn => msisdn, :callback_url => callback_url, :text => text} output_params = {} = {} begin thr_sk_send_viber_one = Thread.new do viber_mess_ans = dabrab_add_func.dabrabyt_text_field_parse(text) if viber_mess_ans[:code] == 200 uri = URI(sk_url) #8 - client id https = Net::HTTP.new(uri.host, uri.port) https.use_ssl=true https.verify_mode = OpenSSL::SSL::VERIFY_NONE req = Net::HTTP::Post.new(uri.path, initheader = {:"Content-Type" => 'application/json'}) req.basic_auth sk_login, sk_password req["Content-Type"] = "application/json" req["Accept"] = "application/json" = { "phone_number": msisdn, #"extra_id": "4232j4h89932kjhs", "callback_url": callback_url, #"start_time": "2019-08-16 09:59:10", "tag": "Dabrab_custom_api_1", "channels": [ "viber" ], "channel_options": { "viber": viber_mess_ans[:body][:to_sk_format] } } req.body = .to_json res = https.request(req) output_params = {:code => 200, :result => "Sksk_2.sk_send_viber_one: Request processed", :body => {:request_message => , :res_code => res.code, :res_body => JSON.parse(res.body.to_s)}} else output_params = {:code => 508, :result => "Sksk_2.sk_send_viber_one: Something wrong with dabrabyt_text_field_parse"} end end thr_sk_send_viber_one.join rescue output_params = {:code => 500, :result => "Sksk_2.sk_send_viber_one: Something wrong"} telegram_connector.(output_params) end internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Sksk_2.sk_send_viber_one"}, log_level) output_params end |
#sk_send_viber_sms_list(msisdn_list, callback_url, sms_text, viber_text, alphaname, time_pause_minutes, viberttl, smsttl) ⇒ Object
352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 |
# File 'lib/imperituroard/projects/mhub/sk.rb', line 352 def sk_send_viber_sms_list(msisdn_list, callback_url, sms_text, viber_text, alphaname, time_pause_minutes, viberttl, smsttl) input_params = {:msisdn_list => msisdn_list, :callback_url => callback_url, :sms_text => sms_text, :viber_text => viber_text, :alphaname => alphaname} output_params = {} = {} begin thr_sk_send_viber_sms_list = Thread.new do viber_mess_ans = dabrab_add_func.dabrabyt_text_field_parse(viber_text, viberttl) if viber_mess_ans[:code] == 200 uri = URI(sk_url_broadcast) #8 - client id https = Net::HTTP.new(uri.host, uri.port) https.use_ssl = true https.verify_mode = OpenSSL::SSL::VERIFY_NONE req = Net::HTTP::Post.new(uri.path, initheader = {:"Content-Type" => 'application/json'}) req.basic_auth sk_login, sk_password req["Content-Type"] = "application/json" req["Accept"] = "application/json" # [{"phone_number": 375298766719}, {"phone_number": 375295730878}] = { "recipients": msisdn_list, "callback_url": callback_url, "start_time": get_start_date(time_pause_minutes), "tag": "Dabrab_custom_api_1", "channels": [ "viber", "sms" ], "channel_options": { "sms": { "alpha_name": alphaname, "text": sms_text, "ttl": smsttl }, "viber": viber_mess_ans[:body][:to_sk_format] } } req.body = .to_json res = https.request(req) output_params = {:code => 200, :result => "Sksk_2.sk_send_viber_sms_list: Request processed", :body => {:request_message => , :res_code => res.code, :res_body => JSON.parse(res.body.to_s)}} else output_params = {:code => 508, :result => "Sksk_2.sk_send_viber_sms_list: Something wrong with dabrabyt_text_field_parse"} end end thr_sk_send_viber_sms_list.join rescue output_params = {:code => 500, :result => "Sksk_2.sk_send_viber_sms_list: Something wrong"} telegram_connector.(output_params) end internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Sksk_2.sk_send_viber_sms_list"}, log_level) output_params end |
#sk_send_viber_sms_one(msisdn, callback_url, sms_text, viber_txt, alphaname, smsttl = 600) ⇒ Object
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 209 210 211 212 213 214 215 216 217 218 219 220 |
# File 'lib/imperituroard/projects/mhub/sk.rb', line 151 def sk_send_viber_sms_one(msisdn, callback_url, sms_text, viber_txt, alphaname, smsttl=600) input_params = {:msisdn => msisdn, :callback_url => callback_url, :sms_text => sms_text, :viber_txt => viber_txt, :alphaname => alphaname} output_params = {} = {} begin thr_sk_send_viber_sms_one = Thread.new do viber_mess_ans = dabrab_add_func.dabrabyt_text_field_parse(viber_txt) if viber_mess_ans[:code] == 200 uri = URI(sk_url) #8 - client id https = Net::HTTP.new(uri.host, uri.port) https.use_ssl=true https.verify_mode = OpenSSL::SSL::VERIFY_NONE req = Net::HTTP::Post.new(uri.path, initheader = {:"Content-Type" => 'application/json'}) req.basic_auth sk_login, sk_password req["Content-Type"] = "application/json" req["Accept"] = "application/json" = { "phone_number": msisdn, #"extra_id": "4232j4h89932kjhs", "callback_url": callback_url, #"start_time": "2019-08-16 09:59:10", "tag": "Dabrab_custom_api_1", "channels": [ "viber", "sms" ], "channel_options": { "sms": { "text": sms_text, "alpha_name": alphaname, "ttl": smsttl }, "viber": viber_mess_ans[:body][:to_sk_format] } } req.body = .to_json res = https.request(req) output_params = {:code => 200, :result => "Sksk_2.sk_send_viber_sms_one: Request processed", :body => {:request_message => , :res_code => res.code, :res_body => JSON.parse(res.body.to_s)}} else output_params = {:code => 508, :result => "Sksk_2.sk_send_viber_sms_one: Something wrong with dabrabyt_text_field_parse"} end end thr_sk_send_viber_sms_one.join rescue output_params = {:code => 500, :result => "Sksk_2.sk_send_viber_sms_one: Something wrong"} telegram_connector.(output_params) end internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Sksk_2.sk_send_viber_sms_one"}, log_level) output_params end |