imperituroard 1.1.7 → 1.1.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/.idea/runConfigurations/autovpn.xml +21 -0
  3. data/.idea/runConfigurations/dabrab_proced.xml +21 -0
  4. data/.idea/runConfigurations/test9_dab.xml +21 -0
  5. data/imperituroard.gemspec +1 -1
  6. data/lib/.DS_Store +0 -0
  7. data/lib/imperituroard.rb +57 -5
  8. data/lib/imperituroard/.DS_Store +0 -0
  9. data/lib/imperituroard/add_functions/logger/any_functions.rb +4 -2
  10. data/lib/imperituroard/platforms/iwag/get_iwag_data.rb +90 -0
  11. data/lib/imperituroard/platforms/iwag/iwag_database_worker.rb +24 -0
  12. data/lib/imperituroard/platforms/iwag/iwag_telnet_connector.rb +112 -0
  13. data/lib/imperituroard/platforms/staros/staros_automation.rb +1 -1
  14. data/lib/imperituroard/projects/autovpn.rb +27 -0
  15. data/lib/imperituroard/projects/{vpn/ezuev_fun → autovpn}/functions_ezuev.rb +0 -0
  16. data/lib/imperituroard/projects/autovpn/mongo_vpn.rb +56 -0
  17. data/lib/imperituroard/projects/iot.rb +1 -1
  18. data/lib/imperituroard/projects/iot/hua_oceanconnect_adapter.rb +25 -21
  19. data/lib/imperituroard/projects/iot/internal_functions.rb +5 -4
  20. data/lib/imperituroard/projects/mhub.rb +68 -14
  21. data/lib/imperituroard/projects/mhub/gms.rb +96 -0
  22. data/lib/imperituroard/projects/mhub/sk.rb +26 -18
  23. data/lib/imperituroard/projects/mhub/subs/dabrab/dabrab_platform.rb +5 -4
  24. data/lib/imperituroard/projects/mhub/subs/dabrab/dabrab_proced.rb +162 -100
  25. data/lib/imperituroard/projects/mhub/subs/evrotorg/gms_connector.rb +69 -0
  26. data/lib/imperituroard/projects/ukaz60.rb +4 -2
  27. data/lib/imperituroard/projects/ukaz60/belgim.rb +1 -1
  28. data/lib/imperituroard/projects/ukaz60/fortigate.rb +1 -1
  29. data/lib/imperituroard/projects/ukaz60/staros.rb +5 -5
  30. data/lib/imperituroard/projects/ukaz60/ukaz60_add_func.rb +50 -4
  31. data/lib/imperituroard/projects/wttx/updatepostcps.rb +7 -7
  32. data/lib/imperituroard/version.rb +1 -1
  33. metadata +17 -7
@@ -0,0 +1,27 @@
1
+ require 'imperituroard/projects/autovpn/mongo_vpn'
2
+
3
+ class Autovpn
4
+
5
+ attr_accessor :mongo_client
6
+
7
+ def initialize(mongo_vpn_ip, mongo_vpn_port, mongo_vpn_database)
8
+ @mongo_client = MongoVpn.new(mongo_vpn_ip, mongo_vpn_port, mongo_vpn_database)
9
+ end
10
+
11
+ def vpn_add_msisdn_by_example_2(new_msisdn, example_msisdn)
12
+
13
+ end
14
+
15
+ def test
16
+ mongo_client.get_mongo_msisdn("375298766719")
17
+ end
18
+
19
+ end
20
+
21
+
22
+ vvv = Autovpn.new("172.24.210.177",
23
+ "27017",
24
+ "autovpn"
25
+ )
26
+
27
+ vvv.test
@@ -0,0 +1,56 @@
1
+ require 'mongo'
2
+
3
+ require 'json'
4
+ require 'rubygems'
5
+ require 'nokogiri'
6
+ require 'rails'
7
+
8
+ require 'imperituroard/add_functions/logger/any_functions'
9
+
10
+ class MongoVpn
11
+
12
+ attr_accessor :mongo_vpn_ip, :mongo_vpn_port, :client_vpn, :mongo_vpn_database, :internal_vpn_func, :logger_any
13
+
14
+ def initialize(mongo_vpn_ip, mongo_vpn_port, mongo_vpn_database)
15
+ @mongo_vpn_database = mongo_vpn_database
16
+ @mongo_vpn_ip = mongo_vpn_ip
17
+ @mongo_vpn_port = mongo_vpn_port
18
+ client_vpn_host = [mongo_vpn_ip + ":" + mongo_vpn_port]
19
+ @client_vpn = Mongo::Client.new(client_vpn_host, :database => mongo_vpn_database)
20
+ @logger_any = LogAddFunctions_2.new
21
+ end
22
+
23
+ #get data by msisdn. Validate data from collection msisdn_list
24
+ def get_mongo_msisdn(msisdn)
25
+ out_resp = {}
26
+ begin
27
+ msisdn_data = []
28
+ collection = client_vpn[:msisdn_list]
29
+ collection.find({:msisdn => msisdn.to_s}).each {|row|
30
+ msisdn_data = row
31
+ }
32
+ if msisdn_data != [] && msisdn_data["msisdn"] != nil && msisdn_data["msisdn"] != ""
33
+ if msisdn_data["group_id"] != [] && msisdn_data["group_id"] != nil && msisdn_data["group_id"] != ""
34
+ if msisdn_data["profile_id"] != [] && msisdn_data["profile_id"] != nil && msisdn_data["profile_id"] != ""
35
+ out_resp = {:code => 200, :result => "get_mongo_msisdn: Request completed successfully", :body => msisdn_data}
36
+ else
37
+ out_resp = {:code => 406, :result => "get_mongo_msisdn: invalid data. profile_id not found"}
38
+ end
39
+ else
40
+ out_resp = {:code => 405, :result => "get_mongo_msisdn: invalid data. organization_id not found"}
41
+ end
42
+ else
43
+ out_resp = {:code => 404, :result => "get_mongo_msisdn: login not found in database"}
44
+ end
45
+ rescue
46
+ out_resp = {:code => 507, :result => "get_mongo_msisdn: Unknown SDK error"}
47
+ end
48
+ logger_any.printer_texter(out_resp, "debug")
49
+ out_resp
50
+ end
51
+
52
+
53
+
54
+ end
55
+
56
+
@@ -1427,6 +1427,6 @@ class IotFunctions_2
1427
1427
  p "yyyyy"
1428
1428
 
1429
1429
  #fff = HuaIot.new("134.17.93.4", "443", "/Users/imperituroard/Desktop/cert.crt", "/Users/imperituroard/Desktop/key.pem")
1430
- p hua_aceanconnect_connector.querying_device_id("Jy5KpoBUOScZEcrO2bRZhzfaIOUa", "VFFWTOb9k3_cQhzrGsRWT4HE8Z0a", "123456789876543")
1430
+ p hua_aceanconnect_connector.querying_device_id("Jy5KpoBUOScZEcrO2bRZhzfaIOUa", "VFFWTOb9k3_cQhzrGsRWT4HE8Z0a", "123412341284999")
1431
1431
  end
1432
1432
  end
@@ -82,6 +82,7 @@ class HuaIot
82
82
  request.content_type = 'application/x-www-form-urlencoded'
83
83
  request.body = URI.encode_www_form(data)
84
84
  res = https.request(request)
85
+ p "get_token"
85
86
  p res.code
86
87
  p res.message
87
88
  p res.body.to_s
@@ -293,27 +294,30 @@ class HuaIot
293
294
 
294
295
  #2.2.44 Querying the Device ID
295
296
  def querying_device_id(app_id, secret, node_id)
296
- token = get_token(app_id, secret)[:body]["accessToken"]
297
- p token
298
- path = "/iocm/app/dm/v1.1.0/queryDeviceIdByNodeId?nodeId=" + node_id + "&appId=Jy5KpoBUOScZEcrO2bRZhzfaIOUa"
299
- p path
300
- p path
301
- url_string = "https://" + platformip + ":" + platformport + path
302
- p url_string
303
- uri = URI.parse url_string
304
- https = Net::HTTP.new(uri.host, uri.port)
305
- https.use_ssl = true
306
- https.cert = OpenSSL::X509::Certificate.new(File.read(cert_file))
307
- https.key = OpenSSL::PKey::RSA.new(File.read(key_file))
308
- https.verify_mode = OpenSSL::SSL::VERIFY_NONE
309
- request = Net::HTTP::Get.new(uri.path)
310
- request.content_type = 'application/json'
311
- request['Authorization'] = 'Bearer ' + token
312
- request['app_key'] = app_id
313
- res = https.request(request)
314
- p res.body.to_s
315
- p res.code
316
- {:code => res.code, :message => res.message, :body => valid_json?(res.body.to_s)}
297
+ get_token_data = get_token(app_id, secret)
298
+ if get_token_data[:code]=="200"
299
+ token = get_token_data[:body]["accessToken"]
300
+ uri1 = URI("https://134.17.93.4:8743/iocm/app/dm/v1.1.0/queryDeviceIdByNodeId?nodeId=" + node_id + "&" + app_id)
301
+ https = Net::HTTP.new(uri1.host, uri1.port)
302
+ https.use_ssl = true
303
+ https.cert = OpenSSL::X509::Certificate.new(File.read(cert_file))
304
+ https.key = OpenSSL::PKey::RSA.new(File.read(key_file))
305
+ https.verify_mode = OpenSSL::SSL::VERIFY_NONE
306
+ request = Net::HTTP::Get.new(uri1)
307
+ request.content_type = 'application/json'
308
+ request['app_key'] = app_id
309
+ request['Authorization'] = 'Bearer ' + token
310
+ #request.set_form_data( params )
311
+ #request['node-id'] = node_id
312
+ bbb = {"nodeId": node_id, "appId": "Jy5KpoBUOScZEcrO2bRZhzfaIOUa"}.to_json
313
+ #request.body = bbb
314
+ res = https.request(request)
315
+ #p res.body.to_s
316
+ #p res.code
317
+ {:code => res.code, :message => res.message, :body => valid_json?(res.body.to_s)}
318
+ else
319
+ {:code => "500", :message => "Something wrong", :body => {}}
320
+ end
317
321
  end
318
322
 
319
323
  #2.2.14 Querying Device Activation Status
@@ -21,8 +21,10 @@ class InternalFunc
21
21
  end
22
22
 
23
23
  def printer_texter(text, log_level)
24
- mess = {:datetime => datetimenow, :sdk => "imperituroard", :sdk_version => Imperituroard::VERSION, :message => text}
25
- p mess
24
+ if log_level == "debug"
25
+ mess = {:datetime => datetimenow, :sdk => "imperituroard", :sdk_version => Imperituroard::VERSION, :message => text}
26
+ p mess
27
+ end
26
28
  end
27
29
 
28
30
  def prof_id_list_transform_mongo(id_list)
@@ -176,7 +178,7 @@ class InternalFunc
176
178
  end
177
179
  end
178
180
  out_data = res
179
- printer_texter({:out_data => out_data, :inp_fun => inp_fun, :fun => "delete_key_hash" }, "debug")
181
+ printer_texter({:out_data => out_data, :inp_fun => inp_fun, :fun => "delete_key_hash"}, "debug")
180
182
  out_data
181
183
  end
182
184
 
@@ -191,7 +193,6 @@ class InternalFunc
191
193
  end
192
194
 
193
195
 
194
-
195
196
  def test()
196
197
  p "eeeeeeeeeeeeeeeeeeeeeeee"
197
198
  end
@@ -24,19 +24,21 @@ class MhubFunctions_2
24
24
  :static_callback,
25
25
  :crm_connector,
26
26
  :telegram_connector,
27
- :sms_alphaname
27
+ :sms_alphaname,
28
+ :log_level
28
29
 
29
- 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)
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)
30
31
  @sk_url = sk_url_simple
31
32
  @sk_login = sk_login
32
33
  @sk_password = sk_password
34
+ @log_level = log_level
33
35
  @internal_func = InternalFunc.new
34
- @mhub_connector = Sksk_2.new(sk_url_simple, sk_login, sk_password, sk_url_broadcast, telegram_api_url, telegram_chat_id)
36
+ @mhub_connector = Sksk_2.new(sk_url_simple, sk_login, sk_password, sk_url_broadcast, telegram_api_url, telegram_chat_id, log_level)
35
37
  @internal_func = InternalFunc.new
36
38
  @dabrab_connecter = Dabrab.new
37
39
  @telegram_connector = Telegram_2.new(telegram_api_url, telegram_chat_id)
38
40
  @static_callback = static_callback
39
- @crm_connector = Crm_2.new(crm_callback_url, crm_login, crm_password, telegram_api_url, telegram_chat_id)
41
+ @crm_connector = Crm_2.new(crm_callback_url, crm_login, crm_password, telegram_api_url, telegram_chat_id, log_level)
40
42
  @sms_alphaname = sms_alphaname
41
43
  end
42
44
 
@@ -58,6 +60,7 @@ class MhubFunctions_2
58
60
  output_params = {}
59
61
  hub_resp = {}
60
62
  null_statement = [nil, "nil", "", "null"]
63
+ mes_data = {}
61
64
 
62
65
  begin
63
66
 
@@ -93,6 +96,7 @@ class MhubFunctions_2
93
96
 
94
97
  msisdn2 = dabrab_connecter.num_formatter(params["destinations"], params["notifyUrl"].split(":")[2])
95
98
 
99
+
96
100
  if null_statement.include?(params["viber"]) && !null_statement.include?(params["sms"])
97
101
  hub_resp = mhub_connector.sk_send_sms_list(msisdn2, static_callback, params["sms"]["text"], sms_alphaname)
98
102
  elsif !null_statement.include?(params["viber"]) && null_statement.include?(params["sms"])
@@ -104,13 +108,13 @@ class MhubFunctions_2
104
108
  else
105
109
  output_params = {"code": 502, "result": "Invalid input data st2", "body": {"answer": {}, "sender": {"ip_src": ip_src, "ip_real": ip_real, "ip_vip": ip_vip}}}
106
110
  end
111
+ mes_data = dabrab_connecter.send_responce_formatter(hub_resp)
112
+
113
+
107
114
  else
108
115
  output_params = {"code": 503, "result": "Invalid recipients", "body": {"answer": {}, "sender": {"ip_src": ip_src, "ip_real": ip_real, "ip_vip": ip_vip}}}
109
116
  end
110
117
 
111
- mes_data = dabrab_connecter.send_responce_formatter(hub_resp)
112
- p hub_resp
113
-
114
118
  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}}}
115
119
 
116
120
  rescue
@@ -118,7 +122,61 @@ class MhubFunctions_2
118
122
  telegram_connector.telegram_message(output_params)
119
123
  end
120
124
 
121
- internal_func.printer_texter({:input => input_params, :output => output_params, :hub_resp => hub_resp, :procedure => "Mhub_2.get_send_message"}, "debug")
125
+ internal_func.printer_texter({:input => input_params, :output => output_params, :hub_resp => hub_resp, :procedure => "Mhub_2.get_send_message"}, log_level)
126
+ output_params
127
+
128
+ end
129
+
130
+
131
+ #for bank dabrabyt for massive nums
132
+ def get_send_message_mass_2(params, ip_src, ip_real, ip_vip, slice_number, time_pause_minutes)
133
+
134
+ input_params = {:params => params}
135
+ output_params = {}
136
+
137
+ null_statement = [nil, "nil", "", "null"]
138
+ mes_data_answ = []
139
+
140
+ begin
141
+ internal_func.printer_texter({:input => params, :procedure => "Mhub_2.get_send_message_mass_2"}, log_level)
142
+ if params["destinations"].length >= 1
143
+ msisdn2 = dabrab_connecter.num_formatter(params["destinations"], params["notifyUrl"].split(":")[2])
144
+ splitted_parts = msisdn2.each_slice(slice_number).to_a
145
+ for part_list in splitted_parts
146
+
147
+ internal_func.printer_texter({:input => part_list, :procedure => "Mhub_2.get_send_message_mass_2"}, log_level)
148
+
149
+ hub_resp = {}
150
+
151
+ if null_statement.include?(params["viber"]) && !null_statement.include?(params["sms"])
152
+ hub_resp = mhub_connector.sk_send_sms_list(part_list, static_callback, params["sms"]["text"], sms_alphaname, time_pause_minutes)
153
+ elsif !null_statement.include?(params["viber"]) && null_statement.include?(params["sms"])
154
+ hub_resp = mhub_connector.sk_send_viber_list(part_list, static_callback, params["viber"]["text"], time_pause_minutes)
155
+ elsif !null_statement.include?(params["viber"]) && !null_statement.include?(params["sms"])
156
+ hub_resp = mhub_connector.sk_send_viber_sms_list(part_list, static_callback, params["sms"]["text"], params["viber"]["text"], sms_alphaname, time_pause_minutes)
157
+ else
158
+ output_params = {"code": 502, "result": "Invalid input data st2", "body": {"answer": {}, "sender": {"ip_src": ip_src, "ip_real": ip_real, "ip_vip": ip_vip}}}
159
+ end
160
+ mes_data = dabrab_connecter.send_responce_formatter(hub_resp)
161
+
162
+ internal_func.printer_texter({:input => mes_data, :procedure => "Mhub_2.get_send_message_mass_2"}, log_level)
163
+
164
+ mes_data_answ = mes_data_answ + mes_data[:body][:mess_to_recip][:messages]
165
+
166
+ end
167
+
168
+ else
169
+ output_params = {"code": 503, "result": "Invalid recipients", "body": {"answer": {}, "sender": {"ip_src": ip_src, "ip_real": ip_real, "ip_vip": ip_vip}}}
170
+ end
171
+
172
+ 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}}}
173
+
174
+ rescue
175
+ 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}}}
176
+ telegram_connector.telegram_message(output_params)
177
+ end
178
+
179
+ internal_func.printer_texter({:input => input_params, :output => output_params, :hub_resp => {}, :procedure => "Mhub_2.get_send_message"}, log_level)
122
180
  output_params
123
181
 
124
182
  end
@@ -142,15 +200,11 @@ class MhubFunctions_2
142
200
  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}}}
143
201
  telegram_connector.telegram_message(output_params)
144
202
  end
145
- internal_func.printer_texter({:input => input_params, :output => output_params, :hub_resp => hub_resp, :procedure => "Mhub_2.recieve_delivery_report"}, "debug")
203
+ internal_func.printer_texter({:input => input_params, :output => output_params, :hub_resp => hub_resp, :procedure => "Mhub_2.recieve_delivery_report"}, log_level)
146
204
  output_params
147
205
  end
148
206
 
149
207
 
150
- def test2
151
- hh = Infobip_1.new
152
- hh.test
153
- end
208
+ end
154
209
 
155
210
 
156
- end
@@ -0,0 +1,96 @@
1
+ require 'imperituroard/projects/mhub/subs/evrotorg/gms_connector'
2
+
3
+
4
+ class Gmsgms_2
5
+
6
+ attr_accessor :gms_t_login, :gms_t_password, :gms_r_login, :gms_r_password, :gms_t_connector, :gms_r_connector
7
+
8
+
9
+ def initialize(gms_t_login, gms_t_password, gms_r_login, gms_r_password, telegram_api_url, telegram_chat_id)
10
+ @gms_t_login = gms_t_login
11
+ @gms_t_password = gms_t_password
12
+ @gms_r_login = gms_r_login
13
+ @gms_r_password = gms_r_password
14
+
15
+ @gms_t_connector = Gms_2.new(gms_t_login, gms_t_password, telegram_api_url, telegram_chat_id)
16
+ @gms_r_connector = Gms_2.new(gms_r_login, gms_r_password, telegram_api_url, telegram_chat_id)
17
+
18
+ @internal_func = InternalFunc.new
19
+ @telegram_connector = Telegram_2.new(telegram_api_url, telegram_chat_id)
20
+
21
+ end
22
+
23
+ def gms_parsing(gms_answer)
24
+ output = {}
25
+
26
+ status_dic = {
27
+ 12033 => "Sent to Viber",
28
+ 36013 => "Viber internal failure",
29
+ 36023 => "Viber invalid service id",
30
+ 36033 => "Viber invalid data",
31
+ 36043 => "Viber blocked message type",
32
+ 36053 => "Viber bad message type",
33
+ 36063 => "Viber bad parameters",
34
+ 36073 => "Viber timeout",
35
+ 36083 => "Viber user blocked",
36
+ 36093 => "Viber not viber user",
37
+ 36103 => "Viber no suitable device",
38
+ 36113 => "Viber unauthorized ip",
39
+ 36123 => "Viber already sent",
40
+ 36133 => "Viber not permitted",
41
+ 36143 => "Viber billing failure",
42
+ 36153 => "Viber word in black list",
43
+ 36163 => "Viber internal process error",
44
+ 36173 => "Viber wrong or missing Label",
45
+ 36183 => "Viber invalid TTL value",
46
+ 23033 => "Viber delivered",
47
+ 35015 => "Viber expired",
48
+ 24013 => "Viber delivered(seen)",
49
+ 28013 => "Viber delivered(overdue)",
50
+ -1 => "in progress"
51
+ }
52
+
53
+ if gms_answer[:code] == 200
54
+ dt1 = gms_answer[:body][:res_body]["reports"][0]
55
+ hyber_status = dt1["hyber_status"]
56
+ output = {:code => 200, :result => "Processed", :body => {"status_code": hyber_status, "status": status_dic[hyber_status], "phone_number": dt1["phone_number"], "message_id": dt1["extra_id"]}}
57
+ elsif gms_answer[:code] == 404
58
+ output = {:code => 404, :result => "Not found", :body => {"status_code": "", "status": "", "phone_number": "", "message_id": gms_answer[:body][:request_message][:external_id]}}
59
+ else
60
+ output = {:code => gms_answer[:code], :result => gms_answer[:result], :body => {"status_code": "", "status": "", "phone_number": "", "message_id": gms_answer[:body][:request_message][:external_id]}}
61
+ end
62
+ output
63
+ end
64
+
65
+
66
+ def get_t_status_external_2(external_id)
67
+ output = {}
68
+ begin
69
+ ans = gms_t_connector.get_advanced_by_external(external_id)
70
+ parsed = gms_parsing(ans)
71
+ output = {:gms_answer => ans, :parsed_answer => parsed}
72
+ rescue
73
+ pars = {:code => "505", :result => "Failed", :body => {"status_code": "", "status": "", "phone_number": "", "message_id": ""}}
74
+ output = {:gms_answer => ans, :parsed_answer => pars}
75
+ end
76
+ output
77
+ end
78
+
79
+
80
+ def get_r_status_external_2(external_id)
81
+ output = {}
82
+ begin
83
+ ans = gms_r_connector.get_advanced_by_external(external_id)
84
+ parsed = gms_parsing(ans)
85
+ output = {:gms_answer => ans, :parsed_answer => parsed}
86
+ rescue
87
+ pars = {:code => "505", :result => "Failed", :body => {"status_code": "", "status": "", "phone_number": "", "message_id": ""}}
88
+ output = {:gms_answer => ans, :parsed_answer => pars}
89
+ end
90
+ output
91
+ end
92
+
93
+ end
94
+
95
+
96
+
@@ -1,14 +1,16 @@
1
1
  require 'imperituroard/projects/iot/internal_functions'
2
2
  require 'imperituroard/projects/mhub/subs/dabrab/dabrab_proced'
3
+ require 'date'
3
4
 
4
5
  class Sksk_2
5
6
 
6
- attr_accessor :sk_url, :sk_url_broadcast, :sk_login, :sk_password, :internal_func, :telegram_connector, :dabrab_add_func
7
+ attr_accessor :sk_url, :sk_url_broadcast, :sk_login, :sk_password, :internal_func, :telegram_connector, :dabrab_add_func, :log_level
7
8
 
8
- def initialize(sk_url, sk_login, sk_password, sk_url_broadcast, telegram_api_url, telegram_chat_id)
9
+ def initialize(sk_url, sk_login, sk_password, sk_url_broadcast, telegram_api_url, telegram_chat_id, log_level)
9
10
  @sk_url = sk_url
10
11
  @sk_login = sk_login
11
12
  @sk_password = sk_password
13
+ @log_level = log_level
12
14
  @internal_func = InternalFunc.new
13
15
  @sk_url_broadcast = sk_url_broadcast
14
16
  @telegram_connector = Telegram_2.new(telegram_api_url, telegram_chat_id)
@@ -16,6 +18,13 @@ class Sksk_2
16
18
  end
17
19
 
18
20
 
21
+ def get_start_date(addit_min)
22
+ date_b = Time.now
23
+ (date_b + addit_min * 60).strftime("%Y-%m-%d %H:%M:%S")
24
+ end
25
+
26
+
27
+
19
28
  def sk_send_sms_one(msisdn, callback_url, text, alphaname)
20
29
 
21
30
  input_params = {:msisdn => msisdn, :callback_url => callback_url, :text => text, :alphaname => alphaname}
@@ -72,7 +81,7 @@ class Sksk_2
72
81
  output_params = {:code => 500, :result => "Sksk_2.sk_send_sms_one: Something wrong", :body => {:request_message => request_message}}
73
82
  telegram_connector.telegram_message(output_params)
74
83
  end
75
- internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Sksk_1.sk_send_sms_one"}, "debug")
84
+ internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Sksk_1.sk_send_sms_one"}, log_level)
76
85
  output_params
77
86
  end
78
87
 
@@ -131,12 +140,11 @@ class Sksk_2
131
140
 
132
141
  thr_sk_send_viber_one.join
133
142
 
134
-
135
143
  rescue
136
144
  output_params = {:code => 500, :result => "Sksk_2.sk_send_viber_one: Something wrong"}
137
145
  telegram_connector.telegram_message(output_params)
138
146
  end
139
- internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Sksk_2.sk_send_viber_one"}, "debug")
147
+ internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Sksk_2.sk_send_viber_one"}, log_level)
140
148
  output_params
141
149
  end
142
150
 
@@ -198,7 +206,6 @@ class Sksk_2
198
206
  else
199
207
  output_params = {:code => 508, :result => "Sksk_2.sk_send_viber_sms_one: Something wrong with dabrabyt_text_field_parse"}
200
208
  end
201
-
202
209
  end
203
210
 
204
211
  thr_sk_send_viber_sms_one.join
@@ -207,13 +214,13 @@ class Sksk_2
207
214
  output_params = {:code => 500, :result => "Sksk_2.sk_send_viber_sms_one: Something wrong"}
208
215
  telegram_connector.telegram_message(output_params)
209
216
  end
210
- internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Sksk_2.sk_send_viber_sms_one"}, "debug")
217
+ internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Sksk_2.sk_send_viber_sms_one"}, log_level)
211
218
  output_params
212
219
 
213
220
  end
214
221
 
215
222
 
216
- def sk_send_sms_list(msisdn_list, callback_url, text, alphaname)
223
+ def sk_send_sms_list(msisdn_list, callback_url, text, alphaname, time_pause_minutes=1)
217
224
 
218
225
  input_params = {:msisdn_list => msisdn_list, :callback_url => callback_url, :text => text, :alphaname => alphaname}
219
226
  output_params = {}
@@ -240,6 +247,7 @@ class Sksk_2
240
247
  request_message = {
241
248
  "recipients": msisdn_list,
242
249
  "callback_url": callback_url,
250
+ "start_time": get_start_date(time_pause_minutes),
243
251
  "tag": "Dabrab_custom_api_1",
244
252
  "channels": [
245
253
  "sms"
@@ -269,12 +277,12 @@ class Sksk_2
269
277
  output_params = {:code => 500, :result => "Sksk_2.sk_send_sms_list: Something wrong"}
270
278
  telegram_connector.telegram_message(output_params)
271
279
  end
272
- internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Sksk_2.sk_send_sms_list"}, "debug")
280
+ internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Sksk_2.sk_send_sms_list"}, log_level)
273
281
  output_params
274
282
  end
275
283
 
276
284
 
277
- def sk_send_viber_list(msisdn_list, callback_url, text)
285
+ def sk_send_viber_list(msisdn_list, callback_url, text, time_pause_minutes)
278
286
 
279
287
  input_params = {:msisdn_list => msisdn_list, :callback_url => callback_url, :text => text}
280
288
  output_params = {}
@@ -305,6 +313,7 @@ class Sksk_2
305
313
  request_message = {
306
314
  "recipients": msisdn_list,
307
315
  "callback_url": callback_url,
316
+ "start_time": get_start_date(time_pause_minutes),
308
317
  "tag": "Dabrab_custom_api_1",
309
318
  "channels": [
310
319
  "viber"
@@ -332,12 +341,12 @@ class Sksk_2
332
341
  output_params = {:code => 500, :result => "Sksk_2.sk_send_viber_list: Something wrong"}
333
342
  telegram_connector.telegram_message(output_params)
334
343
  end
335
- internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Sksk_2.sk_send_viber_list"}, "debug")
344
+ internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Sksk_2.sk_send_viber_list"}, log_level)
336
345
  output_params
337
346
  end
338
347
 
339
348
 
340
- def sk_send_viber_sms_list(msisdn_list, callback_url, sms_text, viber_text, alphaname)
349
+ def sk_send_viber_sms_list(msisdn_list, callback_url, sms_text, viber_text, alphaname, time_pause_minutes)
341
350
  input_params = {:msisdn_list => msisdn_list, :callback_url => callback_url, :sms_text => sms_text, :viber_text => viber_text, :alphaname => alphaname}
342
351
  output_params = {}
343
352
  request_message = {}
@@ -345,10 +354,13 @@ class Sksk_2
345
354
  begin
346
355
  thr_sk_send_viber_sms_list = Thread.new do
347
356
 
357
+
348
358
  viber_mess_ans = dabrab_add_func.dabrabyt_text_field_parse(viber_text)
349
359
 
350
360
  if viber_mess_ans[:code] == 200
351
361
 
362
+
363
+
352
364
  uri = URI(sk_url_broadcast)
353
365
  #8 - client id
354
366
 
@@ -359,7 +371,6 @@ class Sksk_2
359
371
 
360
372
  req.basic_auth sk_login, sk_password
361
373
 
362
-
363
374
  req["Content-Type"] = "application/json"
364
375
  req["Accept"] = "application/json"
365
376
 
@@ -367,6 +378,7 @@ class Sksk_2
367
378
  request_message = {
368
379
  "recipients": msisdn_list,
369
380
  "callback_url": callback_url,
381
+ "start_time": get_start_date(time_pause_minutes),
370
382
  "tag": "Dabrab_custom_api_1",
371
383
  "channels": [
372
384
  "viber",
@@ -390,20 +402,16 @@ class Sksk_2
390
402
  :body => {:request_message => request_message,
391
403
  :res_code => res.code,
392
404
  :res_body => JSON.parse(res.body.to_s)}}
393
-
394
405
  else
395
406
  output_params = {:code => 508, :result => "Sksk_2.sk_send_viber_sms_list: Something wrong with dabrabyt_text_field_parse"}
396
407
  end
397
-
398
408
  end
399
-
400
409
  thr_sk_send_viber_sms_list.join
401
-
402
410
  rescue
403
411
  output_params = {:code => 500, :result => "Sksk_2.sk_send_viber_sms_list: Something wrong"}
404
412
  telegram_connector.telegram_message(output_params)
405
413
  end
406
- internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Sksk_2.sk_send_viber_sms_list"}, "debug")
414
+ internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Sksk_2.sk_send_viber_sms_list"}, log_level)
407
415
  output_params
408
416
  end
409
417