lib/imperituroard/projects/mhub/sk.rb in imperituroard-1.1.9 vs lib/imperituroard/projects/mhub/sk.rb in imperituroard-1.1.10
- old
+ new
@@ -1,16 +1,17 @@
require 'imperituroard/projects/iot/internal_functions'
require 'imperituroard/projects/mhub/subs/dabrab/dabrab_proced'
class Sksk_2
- attr_accessor :sk_url, :sk_url_broadcast, :sk_login, :sk_password, :internal_func, :telegram_connector, :dabrab_add_func
+ attr_accessor :sk_url, :sk_url_broadcast, :sk_login, :sk_password, :internal_func, :telegram_connector, :dabrab_add_func, :log_level
- def initialize(sk_url, sk_login, sk_password, sk_url_broadcast, telegram_api_url, telegram_chat_id)
+ 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
end
@@ -70,11 +71,11 @@
rescue
output_params = {:code => 500, :result => "Sksk_2.sk_send_sms_one: Something wrong", :body => {:request_message => request_message}}
telegram_connector.telegram_message(output_params)
end
- internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Sksk_1.sk_send_sms_one"}, "debug")
+ internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Sksk_1.sk_send_sms_one"}, log_level)
output_params
end
def sk_send_viber_one(msisdn, callback_url, text)
@@ -129,16 +130,15 @@
end
thr_sk_send_viber_one.join
-
rescue
output_params = {:code => 500, :result => "Sksk_2.sk_send_viber_one: Something wrong"}
telegram_connector.telegram_message(output_params)
end
- internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Sksk_2.sk_send_viber_one"}, "debug")
+ internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Sksk_2.sk_send_viber_one"}, log_level)
output_params
end
def sk_send_viber_sms_one(msisdn, callback_url, sms_text, viber_txt, alphaname)
@@ -196,20 +196,19 @@
: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.telegram_message(output_params)
end
- internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Sksk_2.sk_send_viber_sms_one"}, "debug")
+ internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Sksk_2.sk_send_viber_sms_one"}, log_level)
output_params
end
@@ -267,11 +266,11 @@
rescue
output_params = {:code => 500, :result => "Sksk_2.sk_send_sms_list: Something wrong"}
telegram_connector.telegram_message(output_params)
end
- internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Sksk_2.sk_send_sms_list"}, "debug")
+ internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Sksk_2.sk_send_sms_list"}, log_level)
output_params
end
def sk_send_viber_list(msisdn_list, callback_url, text)
@@ -330,11 +329,11 @@
thr_sk_send_viber_list.join
rescue
output_params = {:code => 500, :result => "Sksk_2.sk_send_viber_list: Something wrong"}
telegram_connector.telegram_message(output_params)
end
- internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Sksk_2.sk_send_viber_list"}, "debug")
+ internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Sksk_2.sk_send_viber_list"}, log_level)
output_params
end
def sk_send_viber_sms_list(msisdn_list, callback_url, sms_text, viber_text, alphaname)
@@ -343,10 +342,11 @@
request_message = {}
begin
thr_sk_send_viber_sms_list = Thread.new do
+
viber_mess_ans = dabrab_add_func.dabrabyt_text_field_parse(viber_text)
if viber_mess_ans[:code] == 200
uri = URI(sk_url_broadcast)
@@ -357,11 +357,10 @@
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}]
request_message = {
@@ -388,23 +387,19 @@
output_params = {:code => 200,
:result => "Sksk_2.sk_send_viber_sms_list: Request processed",
:body => {:request_message => 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.telegram_message(output_params)
end
- internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Sksk_2.sk_send_viber_sms_list"}, "debug")
+ internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Sksk_2.sk_send_viber_sms_list"}, log_level)
output_params
end
end
\ No newline at end of file