imperituroard 1.1.9 → 1.1.14

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: 629626efbfcfa0108c2b1646a42d25856e6f3135
4
- data.tar.gz: 8a3a7f5357873aa432d9058a2a54d933e6177c7d
3
+ metadata.gz: 43b90b49ef287bd5255675f8687a9fb6cc036f85
4
+ data.tar.gz: 3e97f122233aa15acaaf07a6bd25b1bc98af1d69
5
5
  SHA512:
6
- metadata.gz: 61e4e034d6b705161bc67e7c270406cbb62a0306ca18c17a619b04b6cf78af4bd802c0f59517e5856101ec75be031be38086872e68893de159412ef241aaaf53
7
- data.tar.gz: 87151a1bbfa092b6d77fef7279cf114446dba7540ca949b897cad0a8f77270afe3833d7d49678f7e46476fb144be849a805d2bc493c2c625b3a185630f1e96ad
6
+ metadata.gz: 17e89a0109c1f6d8821a39e7e1a8572cf0d8fe3c6795120d3000a2242f6a9e1987bfa6b920d2a8b7b72bd39d74e8d08ec85ca1a2098844231ccaf7f1d3b6e51c
7
+ data.tar.gz: bacdd4a4e1f59f9530daede8cc142672d044fc16a04f8ed5d3a329e4c25007911f39b8b90ee828710743b17da5785473a3cec9f9bd3868d65a0a65c9a1e57152
@@ -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>
Binary file
@@ -311,19 +311,21 @@ class Mhub_2
311
311
  :internal_func,
312
312
  :dabrab_connecter,
313
313
  :static_callback,
314
- :crm_connector
314
+ :crm_connector,
315
+ :log_level
315
316
 
316
- 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)
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")
317
318
  @sk_url = sk_url_simple
318
319
  @sk_login = sk_login
319
320
  @sk_password = sk_password
321
+ @log_level = log_level
320
322
  @internal_func = InternalFunc.new
321
- @mhub_connector = Sksk_2.new(sk_url_simple, sk_login, sk_password, sk_url_broadcast, telegram_api_url, telegram_chat_id)
323
+ @mhub_connector = Sksk_2.new(sk_url_simple, sk_login, sk_password, sk_url_broadcast, telegram_api_url, telegram_chat_id, log_level)
322
324
  @internal_func = InternalFunc.new
323
- @dabrab_connecter = Dabrab.new
325
+ @dabrab_connecter = Dabrab.new(log_level)
324
326
  @static_callback = static_callback
325
- @crm_connector = Crm_2.new(crm_callback_url, crm_login, crm_password, telegram_api_url, telegram_chat_id)
326
- @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)
327
+ @crm_connector = Crm_2.new(crm_callback_url, crm_login, crm_password, telegram_api_url, telegram_chat_id, log_level)
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)
327
329
  end
328
330
 
329
331
  #{"destinations"=>[{"to"=>{"phoneNumber"=>"375297116638", "emailAddress"=>nil}}],
@@ -339,8 +341,12 @@ class Mhub_2
339
341
  mhub_connector.get_send_message_2(params, ip_src, ip_real, ip_vip)
340
342
  end
341
343
 
342
- def recieve_delivery_report(params, ip_src, ip_real, ip_vip)
343
- mhub_connector.rec_deliv_report_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
+ end
347
+
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)
344
350
  end
345
351
 
346
352
  end
Binary file
@@ -14,8 +14,10 @@ class LogAddFunctions_2
14
14
  end
15
15
 
16
16
  def printer_texter(text, log_level)
17
- mess = {:datetime => datetimenow, :sdk => "imperituroard", :sdk_version => Imperituroard::VERSION, :message => text}
18
- p mess
17
+ if log_level == debug
18
+ mess = {:datetime => datetimenow, :sdk => "imperituroard", :sdk_version => Imperituroard::VERSION, :message => text}
19
+ p mess
20
+ end
19
21
  end
20
22
 
21
23
 
@@ -0,0 +1,90 @@
1
+ require 'net/ssh'
2
+
3
+ class IwagRequester
4
+
5
+ attr_accessor :iwag_host, :iwag_login, :iwag_password
6
+
7
+ def initialize(iwag_host, iwag_login, iwag_password)
8
+ @iwag_host = iwag_host
9
+ @iwag_login = iwag_login
10
+ @iwag_password = iwag_password
11
+ end
12
+
13
+ def mac_parse(mac)
14
+ a = mac.upcase
15
+ pos = a[0] + a[1]
16
+ if pos == "01"
17
+ subscribers_mac = a[2] + a[3] + ":" + a[5] + a[6] + ":" + a[7] + a[8] + ":" + a[10] + a[11] + ":" + a[12] + a[13] + ":" + a[15] + a[16]
18
+ else
19
+ subscribers_mac = a[0] + a[1] + ":" + a[2] + a[3] + ":" + a[5] + a[6] + ":" + a[7] + a[8] + ":" + a[10] + a[11] + ":" + a[12] + a[13]
20
+ end
21
+ subscribers_mac
22
+ end
23
+
24
+
25
+ def iwag_get_dhcp_binding_ssh(bind_ip)
26
+ mac = "Unknown"
27
+ accessinterface = "Unknown"
28
+ hostname = "Unknown"
29
+ ssid = "Unknown"
30
+ iwag_thr = Thread.new do
31
+ Net::SSH.start(iwag_host, iwag_login, :password => iwag_password) do |session|
32
+ answ_bind = session.exec!("show ip dhcp binding #{bind_ip}")
33
+ regexp_main = /\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}\s{1,20}(\w{2,4}.\w{2,4}.\w{2,4}.\w{2,4})|\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}\s{1,20}(\w{4}.\w{4}.\w{4})/
34
+ #regexp_main = /\r\n(\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3})\s+(\S{13,18})\s+Sep 18 2020 07:44 PM\s+Automatic\s+Active\s+Tunnel201\r\n/
35
+ ggg7 = answ_bind.match(regexp_main)
36
+ begin
37
+ if ggg7[1] != nil
38
+ mac = mac_parse(ggg7[1])
39
+ else
40
+ mac = mac_parse(ggg7[2])
41
+ end
42
+ rescue
43
+ mac = "Unknown"
44
+ end
45
+ regexp_remote_id = /Remote id :\s(\S{2,100})/
46
+ regexp_tunnel = /Active\s{2,40}(\S{2,40})|Selecting\s{2,40}(\S{2,40})/
47
+ regexp_curcuit_id = /Circuit id :\s(\S{2,100})/
48
+ ggg9 = answ_bind.match(regexp_tunnel)
49
+
50
+ begin
51
+ if ggg9[1] != nil
52
+ accessinterface = ggg9[1]
53
+ else
54
+ accessinterface = ggg9[2]
55
+ end
56
+ rescue
57
+ accessinterface = "Unknown"
58
+ end
59
+ ggg8 = answ_bind.match(regexp_remote_id)
60
+ ggg10 = answ_bind.match(regexp_curcuit_id)
61
+ begin
62
+ a1 = ggg8[1].split(":")
63
+ hostname = a1[0]
64
+ ssid = a1[1]
65
+ rescue
66
+ begin
67
+ if ggg8[1] != nil
68
+ if ggg8[1].include?("wireless_public_interface")
69
+ hostname = ggg10[1]
70
+ ssid = "Unknown"
71
+ else
72
+ hostname = ggg8[1]
73
+ ssid = "Unknown"
74
+ end
75
+ else
76
+ ssid = "Unknown"
77
+ hostname = "Unknown"
78
+ end
79
+ rescue
80
+ ssid = "Unknown"
81
+ hostname = "Unknown"
82
+ end
83
+ end
84
+ end
85
+ end
86
+ iwag_thr.join
87
+ {"mac": mac, "iwaginterface": accessinterface, "aphostname": hostname, "SSID": ssid}
88
+ end
89
+
90
+ end
@@ -0,0 +1,24 @@
1
+
2
+
3
+ class IwagDbCache
4
+
5
+ attr_accessor :db_host, :db_login, :db_password
6
+
7
+ def initialize(db_host, db_login, db_password)
8
+ @db_host = db_host
9
+ @db_login = db_login
10
+ @db_password = db_password
11
+ end
12
+
13
+ def check_db_exists(ip)
14
+
15
+ end
16
+
17
+
18
+ def insert_new_cache()
19
+
20
+ end
21
+
22
+
23
+ end
24
+
@@ -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
@@ -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
- @dabrab_connecter = Dabrab.new
38
+ @dabrab_connecter = Dabrab.new(log_level)
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,21 +122,75 @@ 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
125
183
 
126
184
 
127
185
  #for bank dabrabyt
128
- 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)
129
187
  input_params = {:params => params, :ip_src => ip_src, :ip_real => ip_real, :ip_vip => ip_vip}
130
188
  output_params = {}
131
189
  hub_resp = {}
132
190
 
133
191
  begin
134
192
  mes_report = dabrab_connecter.delivery_report_transform(params)[:body][:report_to_recip]
135
- result = crm_connector.crm_status_2(mes_report)
193
+ result = crm_connector.crm_status_2(mes_report, crm_slice_num)
136
194
  if result[:body][:res_body]["GetReportsResult"]==""
137
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}}}
138
196
  else
@@ -142,15 +200,10 @@ 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
- def test2
150
- hh = Infobip_1.new
151
- hh.test
152
- end
153
-
154
207
 
155
208
  end
156
209
 
@@ -1,21 +1,30 @@
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)
15
- @dabrab_add_func = Dabrab.new
17
+ @dabrab_add_func = Dabrab.new(log_level)
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
 
@@ -3,17 +3,18 @@ require 'imperituroard/projects/iot/internal_functions'
3
3
 
4
4
  class Crm_2
5
5
 
6
- attr_accessor :crm_callback_url, :crm_login, :crm_password, :internal_func, :telegram_connector
6
+ attr_accessor :crm_callback_url, :crm_login, :crm_password, :internal_func, :telegram_connector, :log_level
7
7
 
8
- def initialize(crm_callback_url, crm_login, crm_password, telegram_api_url, telegram_chat_id)
8
+ def initialize(crm_callback_url, crm_login, crm_password, telegram_api_url, telegram_chat_id, log_level)
9
9
  @crm_callback_url = crm_callback_url
10
10
  @crm_login = crm_login
11
+ @log_level = log_level
11
12
  @crm_password = crm_password
12
13
  @internal_func = InternalFunc.new
13
14
  @telegram_connector = Telegram_2.new(telegram_api_url, telegram_chat_id)
14
15
  end
15
16
 
16
- def crm_status_2(crm_payload)
17
+ def crm_status_2(crm_payload, slice_num)
17
18
 
18
19
  input_params = {:crm_payload => crm_payload}
19
20
  output_params = {}
@@ -21,30 +22,51 @@ class Crm_2
21
22
 
22
23
  begin
23
24
 
25
+ internal_func.printer_texter({:input => "Start process", :procedure => "Crm_2.crm_status_2"}, log_level)
26
+
27
+
24
28
  thr_crm_status_2 = Thread.new do
25
- uri = URI(crm_callback_url)
26
- #8 - client id
27
29
 
28
- https = Net::HTTP.new(uri.host, uri.port)
29
- https.use_ssl = true
30
- https.verify_mode = OpenSSL::SSL::VERIFY_NONE
31
- 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
32
54
 
33
- 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)
34
56
 
35
- req["Content-Type"] = "application/json"
36
- req["Accept"] = "application/json"
57
+ res = https.request(req)
37
58
 
38
- req.body = crm_payload.to_json
39
- 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 => JSON.parse(res.body.to_s)}, :procedure => "Crm_2.crm_status_2"}, log_level)
40
61
 
62
+ }
41
63
 
42
64
  output_params = {:code => 200,
43
65
  :result => "Crm_2.crm_status_2: Request processed",
44
66
  :body => {:request_message => crm_payload,
45
- :res_code => res.code,
46
- :res_body => JSON.parse(res.body.to_s)}}
47
- p res.body
67
+ :res_code => "200",
68
+ :res_body => ""}}
69
+ #p res.body
48
70
  end
49
71
  thr_crm_status_2.join
50
72
 
@@ -52,7 +74,7 @@ class Crm_2
52
74
  output_params = {:code => 500, :result => "Crm_2.crm_status_2: Something wrong", :body => {:request_message => request_message}}
53
75
  telegram_connector.telegram_message(output_params)
54
76
  end
55
- internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Crm_2.crm_status_2"}, "debug")
77
+ internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Crm_2.crm_status_2"}, log_level)
56
78
  output_params
57
79
 
58
80
  end
@@ -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 = ""
@@ -30,9 +39,9 @@ class Dabrab
30
39
  image_dat = stri.scan(regexp_image1)
31
40
 
32
41
 
33
- p button_url_dat
34
- p button_text_dat
35
- p image_dat
42
+ #p button_url_dat
43
+ #p button_text_dat
44
+ #p image_dat
36
45
 
37
46
  begin
38
47
  if button_url_dat != [] && button_url_dat != nil && button_url_dat != ""
@@ -90,19 +99,20 @@ class Dabrab
90
99
  scheme = 0
91
100
  end
92
101
 
93
- if scheme==0
94
- sk_format = {"text": text, "ttl": 60}
95
- elsif scheme==1
96
- sk_format = {"text": text, "ttl": 60, "caption": button_text, "action": button_url}
97
- elsif scheme==2
98
- sk_format = {"text": text, "ttl": 60, "caption": button_text, "action": button_url, "img": image}
99
- elsif scheme==3
100
- sk_format = {"img": image, "ttl": 60}
101
- else
102
- nil
102
+ case scheme
103
+ when 0
104
+ sk_format = {"text": text, "ttl": 60}
105
+ when 1
106
+ sk_format = {"text": text, "ttl": 60, "caption": button_text, "action": button_url}
107
+ when 2
108
+ sk_format = {"text": text, "ttl": 60, "caption": button_text, "action": button_url, "img": image}
109
+ when 3
110
+ sk_format = {"img": image, "ttl": 60}
111
+ else
112
+ nil
103
113
  end
104
114
 
105
- p sk_format
115
+ #p sk_format
106
116
 
107
117
  output_answer ={:code => 200, :result => "Success", :body => {:to_sk_format => sk_format, :button_url => button_url, :image => image, :button_text => button_text, :text => text, :scheme => scheme, :scheme_dic => scheme_dic[scheme]}}
108
118
  rescue
@@ -125,11 +135,12 @@ class Dabrab
125
135
  #"extra_id": extra_id
126
136
  })
127
137
  rescue
128
- p "failed: #{g.to_s}"
138
+ nil
139
+ #p "failed: #{g.to_s}"
129
140
  end
130
141
 
131
142
  end
132
- p converted_msisdn_list
143
+ #p converted_msisdn_list
133
144
  converted_msisdn_list
134
145
 
135
146
  end
@@ -155,8 +166,8 @@ class Dabrab
155
166
  ]
156
167
  }
157
168
 
158
- p "send_responce_formatter(hub_answer)"
159
- p hub_answer
169
+ #p "send_responce_formatter(hub_answer)"
170
+ #p hub_answer
160
171
 
161
172
  for a in hub_answer[:body][:res_body]["messages"]
162
173
  status1 = {}
@@ -181,17 +192,22 @@ class Dabrab
181
192
  messages_sect.append(status1)
182
193
  end
183
194
 
184
- p messages_sect
195
+ #p messages_sect
185
196
 
186
197
  mess_to_recip = {"bulkId": "00000000-0000-0000-0000-000000000000", "messages": messages_sect}
187
198
  {:code => 200, :result => "Data processed", :body => {:mess_to_recip => mess_to_recip}}
188
199
  end
189
200
 
190
201
 
191
- 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
+
192
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"}}
193
- p hub_report
194
- p "hub_report"
207
+ #p hub_report
208
+ #p "hub_report"
209
+ report_to_recip = []
210
+
195
211
  data_for_status = {
196
212
  23011 => {:status_id => 5, :status_grid => 3, :status_grname => "DELIVERED", :status_name => "DELIVERED_TO_HANDSET", :status_descr => "Message delivered by SMS",
197
213
  :error_id => 0, :error_grid => 0, :error_grname => "Ok", :error_name => "NO_ERROR", :error_descr => "No Error", :error_permanent => false
@@ -216,66 +232,132 @@ class Dabrab
216
232
  } #Viber subscriber not exists
217
233
  }
218
234
 
219
- 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]] != ""
220
- report_to_recip = {
221
- "results": [
222
- {
223
-
224
- "bulkId": "00000000-0000-0000-0000-000000000000",
225
- "messageId": hub_report[:report][:message_id],
226
- "to": hub_report[:report][:number],
227
- # "sentAt": "2020-05-05T20:00:00.000+0000",
228
- # "doneAt": "2020-05-05T20:00:00.000+0000",
229
- "status": {
230
- "groupId": data_for_status[hub_report[:msg_status]][:status_grid],
231
- "groupName": data_for_status[hub_report[:msg_status]][:status_grname],
232
- "id": data_for_status[hub_report[:msg_status]][:status_id],
233
- "name": data_for_status[hub_report[:msg_status]][:status_name],
234
- "description": data_for_status[hub_report[:msg_status]][:status_descr]
235
- },
236
- "error": {
237
- "groupId": data_for_status[hub_report[:msg_status]][:error_grid],
238
- "groupName": data_for_status[hub_report[:msg_status]][:error_grname],
239
- "id": data_for_status[hub_report[:msg_status]][:error_id],
240
- "name": data_for_status[hub_report[:msg_status]][:error_name],
241
- "description": data_for_status[hub_report[:msg_status]][:error_descr],
242
- "permanent": data_for_status[hub_report[:msg_status]][:error_permanent]
243
- }
244
- }
245
- ]
246
- }
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
247
294
 
248
295
  else
249
296
 
250
- report_to_recip = {
251
- "results": [
252
- {
253
-
254
- "bulkId": "00000000-0000-0000-0000-000000000000",
255
- "messageId": hub_report[:report][:message_id],
256
- "to": hub_report[:report][:number],
257
- # "sentAt": "2020-05-05T20:00:00.000+0000",
258
- # "doneAt": "2020-05-05T20:00:00.000+0000",
259
- "status": {
260
- "groupId": 2,
261
- "groupName": "UNDELIVERABLE_NOT_DELIVERED",
262
- "id": 9,
263
- "name": "UNDELIVERED",
264
- "description": "Unknown error"
265
- },
266
- "error": {
267
- "groupId": 1,
268
- "groupName": "HANDSET_ERRORS",
269
- "id": 32,
270
- "name": "EC_SM_DELIVERY_FAILURE",
271
- "description": "Unknown error",
272
- "permanent": false
273
- }
274
- }
275
- ]
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
+
276
357
  }
277
358
  end
278
- {: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}}}
279
361
  end
280
362
 
281
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.9"
2
+ VERSION = "1.1.14"
3
3
  end
4
4
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imperituroard
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.9
4
+ version: 1.1.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dzmitry Buynovskiy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-09-01 00:00:00.000000000 Z
11
+ date: 2020-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -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"
@@ -207,6 +209,9 @@ files:
207
209
  - lib/imperituroard/platforms/cps/cps_multiple_thread_req.rb
208
210
  - lib/imperituroard/platforms/cps/qps_connector.rb
209
211
  - lib/imperituroard/platforms/cps/request_formatter.rb
212
+ - lib/imperituroard/platforms/iwag/get_iwag_data.rb
213
+ - lib/imperituroard/platforms/iwag/iwag_database_worker.rb
214
+ - lib/imperituroard/platforms/iwag/iwag_telnet_connector.rb
210
215
  - lib/imperituroard/platforms/public/telegram.rb
211
216
  - lib/imperituroard/platforms/staros/get_data_ssh.rb
212
217
  - lib/imperituroard/platforms/staros/staros_automation.rb