imperituroard 1.1.10 → 1.1.15

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 06a24d95016bbc1c495cb86ef3f2cbebd39bfa21
4
- data.tar.gz: 647278e86d5ec1f44cf808e8c3a63f7f1c4c7b64
3
+ metadata.gz: 2b88a1a03fcc8ffa9b104d37fc0167bbe99b3ee9
4
+ data.tar.gz: 991615ca54d1e743e64955b08fff8b45ff962f5d
5
5
  SHA512:
6
- metadata.gz: 74ae2cf7887f78b327956031bf5babab5ab78477b094b1f866ec6b43fd00796cf1a766cf21980507152434aafd9918917b3877f7adb62d15c7edee812c4deafa
7
- data.tar.gz: 144a7e259528a7fa57a6f4f81a558e0604d1957cf294cf7479d8bfa35b896849bc216180180c6e418bc8672d031674d97d6f9c1ff729b2adbc1f37a98be66624
6
+ metadata.gz: 4fa2c2c4ca77e55e585cde7c0c03d3fc757b43e134691d672560ec22f6533d974882fa45364353dab46582013e75e134397059de936c217e7c572c4ed5c21ec8
7
+ data.tar.gz: 9415cfc431b7be26a9fab465da942b6b9c1e46205c97d1a84361b2ec93538ae7a8744d697f68a36a25e3ef169808cd5e1428c1287ff64e61cce7f6bf5b2b154b
@@ -0,0 +1,21 @@
1
+ <component name="ProjectRunConfigurationManager">
2
+ <configuration default="false" name="dabrab_proced" type="RubyRunConfigurationType" factoryName="Ruby">
3
+ <module name="imperituroard" />
4
+ <RUBY_RUN_CONFIG NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
5
+ <RUBY_RUN_CONFIG NAME="WORK DIR" VALUE="$MODULE_DIR$/lib/imperituroard/projects/mhub/subs/dabrab" />
6
+ <RUBY_RUN_CONFIG NAME="SHOULD_USE_SDK" VALUE="false" />
7
+ <RUBY_RUN_CONFIG NAME="ALTERN_SDK_NAME" VALUE="" />
8
+ <RUBY_RUN_CONFIG NAME="myPassParentEnvs" VALUE="true" />
9
+ <envs />
10
+ <EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="true" />
11
+ <EXTENSION ID="JRubyRunConfigurationExtension" NailgunExecEnabled="false" />
12
+ <EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" track_test_folders="true" runner="rcov">
13
+ <COVERAGE_PATTERN ENABLED="true">
14
+ <PATTERN REGEXPS="/.rvm/" INCLUDED="false" />
15
+ </COVERAGE_PATTERN>
16
+ </EXTENSION>
17
+ <RUBY_RUN_CONFIG NAME="SCRIPT_PATH" VALUE="$MODULE_DIR$/lib/imperituroard/projects/mhub/subs/dabrab/dabrab_proced.rb" />
18
+ <RUBY_RUN_CONFIG NAME="SCRIPT_ARGS" VALUE="" />
19
+ <method />
20
+ </configuration>
21
+ </component>
@@ -0,0 +1,21 @@
1
+ <component name="ProjectRunConfigurationManager">
2
+ <configuration default="false" name="test9_dab" type="RubyRunConfigurationType" factoryName="Ruby">
3
+ <module name="imperituroard" />
4
+ <RUBY_RUN_CONFIG NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
5
+ <RUBY_RUN_CONFIG NAME="WORK DIR" VALUE="$MODULE_DIR$/test" />
6
+ <RUBY_RUN_CONFIG NAME="SHOULD_USE_SDK" VALUE="false" />
7
+ <RUBY_RUN_CONFIG NAME="ALTERN_SDK_NAME" VALUE="" />
8
+ <RUBY_RUN_CONFIG NAME="myPassParentEnvs" VALUE="true" />
9
+ <envs />
10
+ <EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="true" />
11
+ <EXTENSION ID="JRubyRunConfigurationExtension" NailgunExecEnabled="false" />
12
+ <EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" track_test_folders="true" runner="rcov">
13
+ <COVERAGE_PATTERN ENABLED="true">
14
+ <PATTERN REGEXPS="/.rvm/" INCLUDED="false" />
15
+ </COVERAGE_PATTERN>
16
+ </EXTENSION>
17
+ <RUBY_RUN_CONFIG NAME="SCRIPT_PATH" VALUE="$MODULE_DIR$/test/test9_dab.rb" />
18
+ <RUBY_RUN_CONFIG NAME="SCRIPT_ARGS" VALUE="" />
19
+ <method />
20
+ </configuration>
21
+ </component>
@@ -314,7 +314,7 @@ class Mhub_2
314
314
  :crm_connector,
315
315
  :log_level
316
316
 
317
- 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)
317
+ 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="error")
318
318
  @sk_url = sk_url_simple
319
319
  @sk_login = sk_login
320
320
  @sk_password = sk_password
@@ -322,7 +322,7 @@ class Mhub_2
322
322
  @internal_func = InternalFunc.new
323
323
  @mhub_connector = Sksk_2.new(sk_url_simple, sk_login, sk_password, sk_url_broadcast, telegram_api_url, telegram_chat_id, log_level)
324
324
  @internal_func = InternalFunc.new
325
- @dabrab_connecter = Dabrab.new
325
+ @dabrab_connecter = Dabrab.new(log_level)
326
326
  @static_callback = static_callback
327
327
  @crm_connector = Crm_2.new(crm_callback_url, crm_login, crm_password, telegram_api_url, telegram_chat_id, log_level)
328
328
  @mhub_connector = MhubFunctions_2.new(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)
@@ -341,12 +341,12 @@ class Mhub_2
341
341
  mhub_connector.get_send_message_2(params, ip_src, ip_real, ip_vip)
342
342
  end
343
343
 
344
- def get_send_message_mass(params, ip_src, ip_real, ip_vip)
345
- mhub_connector.get_send_message_mass_2(params, ip_src, ip_real, ip_vip)
344
+ def get_send_message_mass(params, ip_src, ip_real, ip_vip, slice_number=100, time_pause_minutes=5)
345
+ mhub_connector.get_send_message_mass_2(params, ip_src, ip_real, ip_vip, slice_number, time_pause_minutes)
346
346
  end
347
347
 
348
- def recieve_delivery_report(params, ip_src, ip_real, ip_vip)
349
- mhub_connector.rec_deliv_report_2(params, ip_src, ip_real, ip_vip)
348
+ def recieve_delivery_report(params, ip_src, ip_real, ip_vip, crm_slice_num)
349
+ mhub_connector.rec_deliv_report_2(params, ip_src, ip_real, ip_vip, crm_slice_num)
350
350
  end
351
351
 
352
352
  end
@@ -0,0 +1,112 @@
1
+ require 'net-telnet'
2
+ require 'net/ssh'
3
+ require 'date'
4
+
5
+ class CSRtelnet_1
6
+
7
+ attr_accessor :iwag1_host, :iwag_username, :iwag_password
8
+
9
+ def initialize(iwag1_host, iwag_username, iwag_password)
10
+ @iwag1_host = iwag1_host
11
+ @iwag_username = iwag_username
12
+ @iwag_password = iwag_password
13
+ end
14
+
15
+ def get_subs_mac2_1(ipaddress)
16
+
17
+ subscribers_mac = ""
18
+
19
+ #begin
20
+
21
+ dump =""
22
+ connection = Net::Telnet.new( "Host" => iwag1_host, "Timeout" => false, "Prompt" => /.*\#/ ) { |str| }
23
+ connection.login({ "Name" => iwag_username, "Password" => iwag_password, "LoginPrompt" => /Username:/ }) { |str| }
24
+ connection.cmd("show ip dhcp binding #{ipaddress}") {
25
+ |c|
26
+ p c
27
+ dump << c
28
+ }
29
+ connection.close
30
+ as = dump.split("\n")
31
+ p as
32
+ reer = as[4].split(" ")
33
+
34
+ ma = reer[1].to_s.upcase
35
+ pos = ma[0]+ma[1]
36
+ if pos=="01"
37
+ subscribers_mac = ma[2]+ma[3]+":"+ma[5]+ma[6]+":"+ma[7]+ma[8]+":"+ma[10]+ma[11]+":"+ma[12]+ma[13]+":"+ma[15]+ma[16]
38
+ else
39
+ subscribers_mac = ma[0]+ma[1]+":"+ma[2]+ma[3]+":"+ma[5]+ma[6]+":"+ma[7]+ma[8]+":"+ma[10]+ma[11]+":"+ma[12]+ma[13]
40
+ end
41
+
42
+
43
+ #rescue
44
+ # subscribers_mac = "unknown"
45
+ #end
46
+
47
+ return subscribers_mac
48
+
49
+ end
50
+
51
+
52
+ #test function. Not used
53
+ def get_iwag_info_ssh_1(ipaddress)
54
+ p DateTime.now
55
+ Net::SSH.start(iwag1_host, iwag_username, :password => iwag_password) do |ssh|
56
+ result = ssh.exec!("show ip dhcp binding #{ipaddress}\n")
57
+ p result
58
+ end
59
+ p DateTime.now
60
+ end
61
+
62
+
63
+
64
+ def return_iwag_access_interface_1(ipaddress)
65
+ host_iwag = iwag1_host
66
+ username_iwag = iwag_username
67
+ password_iwag = iwag_password
68
+ answer =""
69
+
70
+ dump =""
71
+ begin
72
+ connection = Net::Telnet.new("Host" => host_iwag, "Timeout" => false, "Prompt" => /.*\#/) {|str| print str}
73
+ connection.login({"Name" => username_iwag, "Password" => password_iwag, "LoginPrompt" => /Username:/}) {|str| print str}
74
+ connection.cmd("show ip dhcp binding #{ipaddress}") {
75
+ |c|
76
+ dump << c
77
+ }
78
+ connection.close
79
+ as = dump.split("\n")
80
+
81
+ if as[4] != nil && as[3] != ""
82
+ access_interface = as[4].gsub!(" ", "").split(" ").last
83
+ return access_interface
84
+ else
85
+ answer ="false"
86
+ return answer
87
+ end
88
+ rescue
89
+ begin
90
+ connection = Net::Telnet.new("Host" => host_iwag, "Timeout" => false, "Prompt" => /.*\#/) {|str| print str}
91
+ connection.login({"Name" => username_iwag, "Password" => password_iwag, "LoginPrompt" => /Username:/}) {|str| print str}
92
+ connection.cmd("show ip dhcp binding #{ipaddress}") {
93
+ |c|
94
+ dump << c
95
+ }
96
+ connection.close
97
+ as = dump.split("\n")
98
+ if as[4] != nil && as[3] != ""
99
+ access_interface = as[4].gsub!(" ", "").split(" ").last
100
+ return access_interface
101
+ else
102
+ answer ="false"
103
+ return answer
104
+ end
105
+ rescue
106
+ return "unknown"
107
+ end
108
+ end
109
+ end
110
+
111
+
112
+ end
@@ -35,7 +35,7 @@ class MhubFunctions_2
35
35
  @internal_func = InternalFunc.new
36
36
  @mhub_connector = Sksk_2.new(sk_url_simple, sk_login, sk_password, sk_url_broadcast, telegram_api_url, telegram_chat_id, log_level)
37
37
  @internal_func = InternalFunc.new
38
- @dabrab_connecter = Dabrab.new
38
+ @dabrab_connecter = Dabrab.new(log_level)
39
39
  @telegram_connector = Telegram_2.new(telegram_api_url, telegram_chat_id)
40
40
  @static_callback = static_callback
41
41
  @crm_connector = Crm_2.new(crm_callback_url, crm_login, crm_password, telegram_api_url, telegram_chat_id, log_level)
@@ -92,15 +92,10 @@ class MhubFunctions_2
92
92
  # output_params = {"code": 503, "result": "Invalid recipients", "answer": {}, "sender": {"ip_src": ip_src, "ip_real": ip_real, "ip_vip": ip_vip}}
93
93
  # end
94
94
 
95
- p params
96
95
  if params["destinations"].length >= 1
97
- p params["destinations"]
98
96
 
99
- p "eeee"
100
97
  msisdn2 = dabrab_connecter.num_formatter(params["destinations"], params["notifyUrl"].split(":")[2])
101
98
 
102
- splitted_parts = msisdn2.each_slice(1).to_a
103
-
104
99
 
105
100
  if null_statement.include?(params["viber"]) && !null_statement.include?(params["sms"])
106
101
  hub_resp = mhub_connector.sk_send_sms_list(msisdn2, static_callback, params["sms"]["text"], sms_alphaname)
@@ -120,10 +115,6 @@ class MhubFunctions_2
120
115
  output_params = {"code": 503, "result": "Invalid recipients", "body": {"answer": {}, "sender": {"ip_src": ip_src, "ip_real": ip_real, "ip_vip": ip_vip}}}
121
116
  end
122
117
 
123
-
124
- p hub_resp
125
- p mes_data
126
-
127
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}}}
128
119
 
129
120
  rescue
@@ -138,7 +129,7 @@ class MhubFunctions_2
138
129
 
139
130
 
140
131
  #for bank dabrabyt for massive nums
141
- def get_send_message_mass_2(params, ip_src, ip_real, ip_vip)
132
+ def get_send_message_mass_2(params, ip_src, ip_real, ip_vip, slice_number, time_pause_minutes)
142
133
 
143
134
  input_params = {:params => params}
144
135
  output_params = {}
@@ -150,7 +141,7 @@ class MhubFunctions_2
150
141
  internal_func.printer_texter({:input => params, :procedure => "Mhub_2.get_send_message_mass_2"}, log_level)
151
142
  if params["destinations"].length >= 1
152
143
  msisdn2 = dabrab_connecter.num_formatter(params["destinations"], params["notifyUrl"].split(":")[2])
153
- splitted_parts = msisdn2.each_slice(100).to_a
144
+ splitted_parts = msisdn2.each_slice(slice_number).to_a
154
145
  for part_list in splitted_parts
155
146
 
156
147
  internal_func.printer_texter({:input => part_list, :procedure => "Mhub_2.get_send_message_mass_2"}, log_level)
@@ -158,11 +149,11 @@ class MhubFunctions_2
158
149
  hub_resp = {}
159
150
 
160
151
  if null_statement.include?(params["viber"]) && !null_statement.include?(params["sms"])
161
- hub_resp = mhub_connector.sk_send_sms_list(part_list, static_callback, params["sms"]["text"], sms_alphaname)
152
+ hub_resp = mhub_connector.sk_send_sms_list(part_list, static_callback, params["sms"]["text"], sms_alphaname, time_pause_minutes)
162
153
  elsif !null_statement.include?(params["viber"]) && null_statement.include?(params["sms"])
163
- hub_resp = mhub_connector.sk_send_viber_list(part_list, static_callback, params["viber"]["text"])
154
+ hub_resp = mhub_connector.sk_send_viber_list(part_list, static_callback, params["viber"]["text"], time_pause_minutes)
164
155
  elsif !null_statement.include?(params["viber"]) && !null_statement.include?(params["sms"])
165
- hub_resp = mhub_connector.sk_send_viber_sms_list(part_list, static_callback, params["sms"]["text"], params["viber"]["text"], sms_alphaname)
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)
166
157
  else
167
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}}}
168
159
  end
@@ -192,14 +183,14 @@ class MhubFunctions_2
192
183
 
193
184
 
194
185
  #for bank dabrabyt
195
- def rec_deliv_report_2(params, ip_src, ip_real, ip_vip)
186
+ def rec_deliv_report_2(params, ip_src, ip_real, ip_vip, crm_slice_num=2)
196
187
  input_params = {:params => params, :ip_src => ip_src, :ip_real => ip_real, :ip_vip => ip_vip}
197
188
  output_params = {}
198
189
  hub_resp = {}
199
190
 
200
191
  begin
201
192
  mes_report = dabrab_connecter.delivery_report_transform(params)[:body][:report_to_recip]
202
- result = crm_connector.crm_status_2(mes_report)
193
+ result = crm_connector.crm_status_2(mes_report, crm_slice_num)
203
194
  if result[:body][:res_body]["GetReportsResult"]==""
204
195
  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}}}
205
196
  else
@@ -213,11 +204,6 @@ class MhubFunctions_2
213
204
  output_params
214
205
  end
215
206
 
216
- def test2
217
- hh = Infobip_1.new
218
- hh.test
219
- end
220
-
221
207
 
222
208
  end
223
209
 
@@ -1,5 +1,6 @@
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
 
@@ -13,10 +14,17 @@ class Sksk_2
13
14
  @internal_func = InternalFunc.new
14
15
  @sk_url_broadcast = sk_url_broadcast
15
16
  @telegram_connector = Telegram_2.new(telegram_api_url, telegram_chat_id)
16
- @dabrab_add_func = Dabrab.new
17
+ @dabrab_add_func = Dabrab.new(log_level)
17
18
  end
18
19
 
19
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
+
20
28
  def sk_send_sms_one(msisdn, callback_url, text, alphaname)
21
29
 
22
30
  input_params = {:msisdn => msisdn, :callback_url => callback_url, :text => text, :alphaname => alphaname}
@@ -212,7 +220,7 @@ class Sksk_2
212
220
  end
213
221
 
214
222
 
215
- 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)
216
224
 
217
225
  input_params = {:msisdn_list => msisdn_list, :callback_url => callback_url, :text => text, :alphaname => alphaname}
218
226
  output_params = {}
@@ -239,6 +247,7 @@ class Sksk_2
239
247
  request_message = {
240
248
  "recipients": msisdn_list,
241
249
  "callback_url": callback_url,
250
+ "start_time": get_start_date(time_pause_minutes),
242
251
  "tag": "Dabrab_custom_api_1",
243
252
  "channels": [
244
253
  "sms"
@@ -273,7 +282,7 @@ class Sksk_2
273
282
  end
274
283
 
275
284
 
276
- def sk_send_viber_list(msisdn_list, callback_url, text)
285
+ def sk_send_viber_list(msisdn_list, callback_url, text, time_pause_minutes)
277
286
 
278
287
  input_params = {:msisdn_list => msisdn_list, :callback_url => callback_url, :text => text}
279
288
  output_params = {}
@@ -304,6 +313,7 @@ class Sksk_2
304
313
  request_message = {
305
314
  "recipients": msisdn_list,
306
315
  "callback_url": callback_url,
316
+ "start_time": get_start_date(time_pause_minutes),
307
317
  "tag": "Dabrab_custom_api_1",
308
318
  "channels": [
309
319
  "viber"
@@ -336,7 +346,7 @@ class Sksk_2
336
346
  end
337
347
 
338
348
 
339
- 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)
340
350
  input_params = {:msisdn_list => msisdn_list, :callback_url => callback_url, :sms_text => sms_text, :viber_text => viber_text, :alphaname => alphaname}
341
351
  output_params = {}
342
352
  request_message = {}
@@ -349,6 +359,8 @@ class Sksk_2
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
 
@@ -366,6 +378,7 @@ class Sksk_2
366
378
  request_message = {
367
379
  "recipients": msisdn_list,
368
380
  "callback_url": callback_url,
381
+ "start_time": get_start_date(time_pause_minutes),
369
382
  "tag": "Dabrab_custom_api_1",
370
383
  "channels": [
371
384
  "viber",
@@ -14,7 +14,7 @@ class Crm_2
14
14
  @telegram_connector = Telegram_2.new(telegram_api_url, telegram_chat_id)
15
15
  end
16
16
 
17
- def crm_status_2(crm_payload)
17
+ def crm_status_2(crm_payload, slice_num)
18
18
 
19
19
  input_params = {:crm_payload => crm_payload}
20
20
  output_params = {}
@@ -22,29 +22,50 @@ class Crm_2
22
22
 
23
23
  begin
24
24
 
25
+ internal_func.printer_texter({:input => "Start process", :procedure => "Crm_2.crm_status_2"}, log_level)
26
+
27
+
25
28
  thr_crm_status_2 = Thread.new do
26
- uri = URI(crm_callback_url)
27
- #8 - client id
28
29
 
29
- https = Net::HTTP.new(uri.host, uri.port)
30
- https.use_ssl = true
31
- https.verify_mode = OpenSSL::SSL::VERIFY_NONE
32
- req = Net::HTTP::Post.new(uri.path, initheader = {:"Content-Type" => 'application/json'})
30
+ partnnn = crm_payload[:results].each_slice(slice_num).to_a
31
+
32
+ partnnn.each { |one_part_reports|
33
+
34
+ crm_payload2 = {:results => one_part_reports }
35
+
36
+
37
+ uri = URI(crm_callback_url)
38
+ #8 - client id
39
+
40
+ https = Net::HTTP.new(uri.host, uri.port)
41
+ https.use_ssl = true
42
+ https.verify_mode = OpenSSL::SSL::VERIFY_NONE
43
+ req = Net::HTTP::Post.new(uri.path, initheader = {:"Content-Type" => 'application/json'})
44
+
45
+ req.basic_auth crm_login, crm_password
46
+
47
+ req["Content-Type"] = "application/json"
48
+ req["Accept"] = "application/json"
49
+
50
+ internal_func.printer_texter({:input => {:crm_payload2 => crm_payload2}, :procedure => "Crm_2.crm_status_2"}, log_level)
51
+
52
+
53
+ req.body = crm_payload2.to_json
33
54
 
34
- req.basic_auth crm_login, crm_password
55
+ internal_func.printer_texter({:input => "Before send request to crm", :procedure => "Crm_2.crm_status_2"}, log_level)
35
56
 
36
- req["Content-Type"] = "application/json"
37
- req["Accept"] = "application/json"
57
+ res = https.request(req)
38
58
 
39
- req.body = crm_payload.to_json
40
- res = https.request(req)
59
+ internal_func.printer_texter({:input => "After send request to crm", :procedure => "Crm_2.crm_status_2"}, log_level)
60
+ internal_func.printer_texter({:input => {:res_code => res.code, :res_body => res.body.to_s}, :procedure => "Crm_2.crm_status_2"}, log_level)
41
61
 
62
+ }
42
63
 
43
64
  output_params = {:code => 200,
44
65
  :result => "Crm_2.crm_status_2: Request processed",
45
66
  :body => {:request_message => crm_payload,
46
- :res_code => res.code,
47
- :res_body => JSON.parse(res.body.to_s)}}
67
+ :res_code => "200",
68
+ :res_body => ""}}
48
69
  #p res.body
49
70
  end
50
71
  thr_crm_status_2.join
@@ -1,5 +1,14 @@
1
+ require 'imperituroard/projects/iot/internal_functions'
2
+
1
3
  class Dabrab
2
4
 
5
+ attr_accessor :internal_func, :log_level
6
+
7
+ def initialize(log_level)
8
+ @internal_func = InternalFunc.new
9
+ @log_level = log_level
10
+ end
11
+
3
12
  def dabrabyt_text_field_parse(stri)
4
13
  button_url = ""
5
14
  image = ""
@@ -190,10 +199,15 @@ class Dabrab
190
199
  end
191
200
 
192
201
 
193
- def delivery_report_transform(hub_report)
202
+ def delivery_report_transform(hub_report_in)
203
+
204
+ internal_func.printer_texter({:input => "Start delivery_report_transform", :procedure => "Dabrab.delivery_report_transform"}, log_level)
205
+
194
206
  #{"number"=>"375297116638", "time"=>1588673492000, "status"=>2, "substatus"=>23, "msg_status"=>23033, "message_id"=>"486649ba-a573-4ee9-8f58-018ed20ca6fd", "extra_id"=>"444/0/ServiceModel/ScGetReports.svc/GetReports", "sent_via"=>"viber", "controller"=>"reports", "action"=>"delivery", "report"=>{"number"=>"375297116638", "time"=>1588673492000, "status"=>2, "substatus"=>23, "msg_status"=>23033, "message_id"=>"486649ba-a573-4ee9-8f58-018ed20ca6fd", "extra_id"=>"444/0/ServiceModel/ScGetReports.svc/GetReports", "sent_via"=>"viber"}}
195
207
  #p hub_report
196
208
  #p "hub_report"
209
+ report_to_recip = []
210
+
197
211
  data_for_status = {
198
212
  23011 => {:status_id => 5, :status_grid => 3, :status_grname => "DELIVERED", :status_name => "DELIVERED_TO_HANDSET", :status_descr => "Message delivered by SMS",
199
213
  :error_id => 0, :error_grid => 0, :error_grname => "Ok", :error_name => "NO_ERROR", :error_descr => "No Error", :error_permanent => false
@@ -218,66 +232,132 @@ class Dabrab
218
232
  } #Viber subscriber not exists
219
233
  }
220
234
 
221
- if data_for_status[hub_report[:msg_status]] != nil && data_for_status[hub_report[:msg_status]] != {} && data_for_status[hub_report[:msg_status]] != [] && data_for_status[hub_report[:msg_status]] != ""
222
- report_to_recip = {
223
- "results": [
224
- {
225
-
226
- "bulkId": "00000000-0000-0000-0000-000000000000",
227
- "messageId": hub_report[:report][:message_id],
228
- "to": hub_report[:report][:number],
229
- # "sentAt": "2020-05-05T20:00:00.000+0000",
230
- # "doneAt": "2020-05-05T20:00:00.000+0000",
231
- "status": {
232
- "groupId": data_for_status[hub_report[:msg_status]][:status_grid],
233
- "groupName": data_for_status[hub_report[:msg_status]][:status_grname],
234
- "id": data_for_status[hub_report[:msg_status]][:status_id],
235
- "name": data_for_status[hub_report[:msg_status]][:status_name],
236
- "description": data_for_status[hub_report[:msg_status]][:status_descr]
237
- },
238
- "error": {
239
- "groupId": data_for_status[hub_report[:msg_status]][:error_grid],
240
- "groupName": data_for_status[hub_report[:msg_status]][:error_grname],
241
- "id": data_for_status[hub_report[:msg_status]][:error_id],
242
- "name": data_for_status[hub_report[:msg_status]][:error_name],
243
- "description": data_for_status[hub_report[:msg_status]][:error_descr],
244
- "permanent": data_for_status[hub_report[:msg_status]][:error_permanent]
245
- }
246
- }
247
- ]
248
- }
235
+ if hub_report_in.key?("msg_status") && !hub_report_in.key?("_json") && !hub_report_in["report"].key?("_json")
236
+ internal_func.printer_texter({:input => "One message delivery_report_transform", :procedure => "Dabrab.delivery_report_transform"}, log_level)
237
+
238
+ hub_report = hub_report_in
239
+
240
+ if data_for_status[hub_report["msg_status"]] != nil && data_for_status[hub_report["msg_status"]] != {} && data_for_status[hub_report["msg_status"]] != [] && data_for_status[hub_report["msg_status"]] != ""
241
+
242
+ report_to_recip.push({
243
+
244
+ "bulkId": "00000000-0000-0000-0000-000000000000",
245
+ "messageId": hub_report["report"]["message_id"],
246
+ "to": hub_report["report"]["number"],
247
+ # "sentAt": "2020-05-05T20:00:00.000+0000",
248
+ # "doneAt": "2020-05-05T20:00:00.000+0000",
249
+ "status": {
250
+ "groupId": data_for_status[hub_report["msg_status"]][:status_grid],
251
+ "groupName": data_for_status[hub_report["msg_status"]][:status_grname],
252
+ "id": data_for_status[hub_report["msg_status"]][:status_id],
253
+ "name": data_for_status[hub_report["msg_status"]][:status_name],
254
+ "description": data_for_status[hub_report["msg_status"]][:status_descr]
255
+ },
256
+ "error": {
257
+ "groupId": data_for_status[hub_report["msg_status"]][:error_grid],
258
+ "groupName": data_for_status[hub_report["msg_status"]][:error_grname],
259
+ "id": data_for_status[hub_report["msg_status"]][:error_id],
260
+ "name": data_for_status[hub_report["msg_status"]][:error_name],
261
+ "description": data_for_status[hub_report["msg_status"]][:error_descr],
262
+ "permanent": data_for_status[hub_report["msg_status"]][:error_permanent]
263
+ }
264
+ })
265
+
266
+
267
+ else
268
+
269
+ report_to_recip.push({
270
+
271
+ "bulkId": "00000000-0000-0000-0000-000000000000",
272
+ "messageId": hub_report["report"]["message_id"],
273
+ "to": hub_report["report"]["number"],
274
+ # "sentAt": "2020-05-05T20:00:00.000+0000",
275
+ # "doneAt": "2020-05-05T20:00:00.000+0000",
276
+ "status": {
277
+ "groupId": 2,
278
+ "groupName": "UNDELIVERABLE_NOT_DELIVERED",
279
+ "id": 9,
280
+ "name": "UNDELIVERED",
281
+ "description": "Unknown error"
282
+ },
283
+ "error": {
284
+ "groupId": 1,
285
+ "groupName": "HANDSET_ERRORS",
286
+ "id": 32,
287
+ "name": "EC_SM_DELIVERY_FAILURE",
288
+ "description": "Unknown error",
289
+ "permanent": false
290
+ }
291
+ })
292
+
293
+ end
249
294
 
250
295
  else
251
296
 
252
- report_to_recip = {
253
- "results": [
254
- {
255
-
256
- "bulkId": "00000000-0000-0000-0000-000000000000",
257
- "messageId": hub_report[:report][:message_id],
258
- "to": hub_report[:report][:number],
259
- # "sentAt": "2020-05-05T20:00:00.000+0000",
260
- # "doneAt": "2020-05-05T20:00:00.000+0000",
261
- "status": {
262
- "groupId": 2,
263
- "groupName": "UNDELIVERABLE_NOT_DELIVERED",
264
- "id": 9,
265
- "name": "UNDELIVERED",
266
- "description": "Unknown error"
267
- },
268
- "error": {
269
- "groupId": 1,
270
- "groupName": "HANDSET_ERRORS",
271
- "id": 32,
272
- "name": "EC_SM_DELIVERY_FAILURE",
273
- "description": "Unknown error",
274
- "permanent": false
275
- }
276
- }
277
- ]
297
+ hub_report_in["_json"].each {|hub_report2|
298
+
299
+ internal_func.printer_texter({:input => "Start Mass message delivery_report_transform", :procedure => "Dabrab.delivery_report_transform"}, log_level)
300
+
301
+ internal_func.printer_texter({:input => {:hub_report2 => hub_report2}, :procedure => "Dabrab.delivery_report_transform"}, log_level)
302
+
303
+
304
+ if data_for_status[hub_report2["msg_status"]] != nil && data_for_status[hub_report2["msg_status"]] != {} && data_for_status[hub_report2["msg_status"]] != [] && data_for_status[hub_report2["msg_status"]] != ""
305
+ report_to_recip.push({
306
+
307
+ "bulkId": "00000000-0000-0000-0000-000000000000",
308
+ "messageId": hub_report2["message_id"],
309
+ "to": hub_report2["number"],
310
+ # "sentAt": "2020-05-05T20:00:00.000+0000",
311
+ # "doneAt": "2020-05-05T20:00:00.000+0000",
312
+ "status": {
313
+ "groupId": data_for_status[hub_report2["msg_status"]][:status_grid],
314
+ "groupName": data_for_status[hub_report2["msg_status"]][:status_grname],
315
+ "id": data_for_status[hub_report2["msg_status"]][:status_id],
316
+ "name": data_for_status[hub_report2["msg_status"]][:status_name],
317
+ "description": data_for_status[hub_report2["msg_status"]][:status_descr]
318
+ },
319
+ "error": {
320
+ "groupId": data_for_status[hub_report2["msg_status"]][:error_grid],
321
+ "groupName": data_for_status[hub_report2["msg_status"]][:error_grname],
322
+ "id": data_for_status[hub_report2["msg_status"]][:error_id],
323
+ "name": data_for_status[hub_report2["msg_status"]][:error_name],
324
+ "description": data_for_status[hub_report2["msg_status"]][:error_descr],
325
+ "permanent": data_for_status[hub_report2["msg_status"]][:error_permanent]
326
+ }
327
+ })
328
+
329
+
330
+ else
331
+
332
+ report_to_recip.push({
333
+
334
+ "bulkId": "00000000-0000-0000-0000-000000000000",
335
+ "messageId": hub_report2["message_id"],
336
+ "to": hub_report2["number"],
337
+ # "sentAt": "2020-05-05T20:00:00.000+0000",
338
+ # "doneAt": "2020-05-05T20:00:00.000+0000",
339
+ "status": {
340
+ "groupId": 2,
341
+ "groupName": "UNDELIVERABLE_NOT_DELIVERED",
342
+ "id": 9,
343
+ "name": "UNDELIVERED",
344
+ "description": "Unknown error"
345
+ },
346
+ "error": {
347
+ "groupId": 1,
348
+ "groupName": "HANDSET_ERRORS",
349
+ "id": 32,
350
+ "name": "EC_SM_DELIVERY_FAILURE",
351
+ "description": "Unknown error",
352
+ "permanent": false
353
+ }
354
+ })
355
+ end
356
+
278
357
  }
279
358
  end
280
- {:code => 200, :result => "Data processed", :body => {:report_to_recip => report_to_recip}}
359
+
360
+ {:code => 200, :result => "Data processed", :body => {:report_to_recip => {"results": report_to_recip}}}
281
361
  end
282
362
 
283
363
  end
@@ -45,25 +45,25 @@ class StateWTTX
45
45
  http = Net::HTTP.new(uri.host, uri.port)
46
46
  response = http.request(Net::HTTP::Get.new(uri.request_uri))
47
47
  p content = response.body
48
- p resultcode = response.to_s.include?("OK")
48
+ p result_code = response.to_s.include?("OK")
49
49
  #Rails.logger = Logger.new(STDOUT)
50
50
  #logger.info "WTTX service getrestCPS result code: #{response.to_s}"
51
51
  #logger.info "WTTX service getrestCPS soap body: #{content.to_s}"
52
52
 
53
53
 
54
54
 
55
- if resultcode == false
55
+ if !result_code
56
56
  "false"
57
57
  else
58
- regimsi = /<field code=\"imsi\" value=\"([0-9]{10,15})\"/
59
- regimei = /<field code=\"imei\" value=\"([0-9]{10,17})\"/
58
+ reg_imsi = /<field code=\"imsi\" value=\"([0-9]{10,15})\"/
59
+ reg_imei = /<field code=\"imei\" value=\"([0-9]{10,17})\"/
60
60
 
61
- m1 = regimsi.match(content)
62
- m2 = regimei.match(content)
61
+ m1 = reg_imsi.match(content)
62
+ m2 = reg_imei.match(content)
63
63
  imsi = m1[1]
64
64
  imei = m2[1]
65
65
 
66
- res = resultcode.to_s + " " + imsi + " " + imei
66
+ res = result_code.to_s + " " + imsi + " " + imei
67
67
  p res
68
68
  res
69
69
  end
@@ -1,4 +1,4 @@
1
1
  module Imperituroard
2
- VERSION = "1.1.10"
2
+ VERSION = "1.1.15"
3
3
  end
4
4
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imperituroard
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.10
4
+ version: 1.1.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dzmitry Buynovskiy
@@ -187,7 +187,9 @@ extra_rdoc_files: []
187
187
  files:
188
188
  - ".gitignore"
189
189
  - ".idea/runConfigurations/autovpn.xml"
190
+ - ".idea/runConfigurations/dabrab_proced.xml"
190
191
  - ".idea/runConfigurations/hua_oceanconnect_adapter.xml"
192
+ - ".idea/runConfigurations/test9_dab.xml"
191
193
  - ".idea/runConfigurations/version.xml"
192
194
  - ".ruby-gemset"
193
195
  - ".ruby-version"
@@ -209,6 +211,7 @@ files:
209
211
  - lib/imperituroard/platforms/cps/request_formatter.rb
210
212
  - lib/imperituroard/platforms/iwag/get_iwag_data.rb
211
213
  - lib/imperituroard/platforms/iwag/iwag_database_worker.rb
214
+ - lib/imperituroard/platforms/iwag/iwag_telnet_connector.rb
212
215
  - lib/imperituroard/platforms/public/telegram.rb
213
216
  - lib/imperituroard/platforms/staros/get_data_ssh.rb
214
217
  - lib/imperituroard/platforms/staros/staros_automation.rb