imperituroard 1.1.4 → 1.1.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.idea/runConfigurations/autovpn.xml +21 -0
- data/imperituroard.gemspec +1 -1
- data/lib/.DS_Store +0 -0
- data/lib/imperituroard.rb +57 -5
- data/lib/imperituroard/.DS_Store +0 -0
- data/lib/imperituroard/add_functions/logger/any_functions.rb +4 -2
- data/lib/imperituroard/platforms/iwag/get_iwag_data.rb +90 -0
- data/lib/imperituroard/platforms/iwag/iwag_database_worker.rb +24 -0
- data/lib/imperituroard/platforms/staros/staros_automation.rb +1 -1
- data/lib/imperituroard/projects/autovpn.rb +27 -0
- data/lib/imperituroard/projects/{vpn/ezuev_fun → autovpn}/functions_ezuev.rb +0 -0
- data/lib/imperituroard/projects/autovpn/mongo_vpn.rb +56 -0
- data/lib/imperituroard/projects/iot.rb +3 -2
- data/lib/imperituroard/projects/iot/add_functions.rb +2 -2
- data/lib/imperituroard/projects/iot/hua_oceanconnect_adapter.rb +25 -21
- data/lib/imperituroard/projects/iot/internal_functions.rb +5 -4
- data/lib/imperituroard/projects/mhub.rb +77 -9
- data/lib/imperituroard/projects/mhub/gms.rb +96 -0
- data/lib/imperituroard/projects/mhub/sk.rb +10 -15
- data/lib/imperituroard/projects/mhub/subs/dabrab/dabrab_platform.rb +5 -4
- data/lib/imperituroard/projects/mhub/subs/dabrab/dabrab_proced.rb +23 -21
- data/lib/imperituroard/projects/mhub/subs/evrotorg/gms_connector.rb +69 -0
- data/lib/imperituroard/projects/ukaz60.rb +4 -2
- data/lib/imperituroard/projects/ukaz60/belgim.rb +1 -1
- data/lib/imperituroard/projects/ukaz60/fortigate.rb +1 -1
- data/lib/imperituroard/projects/ukaz60/staros.rb +5 -5
- data/lib/imperituroard/projects/ukaz60/ukaz60_add_func.rb +50 -4
- data/lib/imperituroard/version.rb +1 -1
- metadata +14 -7
@@ -21,8 +21,10 @@ class InternalFunc
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def printer_texter(text, log_level)
|
24
|
-
|
25
|
-
|
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"
|
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
|
|
@@ -89,10 +92,16 @@ class MhubFunctions_2
|
|
89
92
|
# output_params = {"code": 503, "result": "Invalid recipients", "answer": {}, "sender": {"ip_src": ip_src, "ip_real": ip_real, "ip_vip": ip_vip}}
|
90
93
|
# end
|
91
94
|
|
95
|
+
p params
|
92
96
|
if params["destinations"].length >= 1
|
97
|
+
p params["destinations"]
|
93
98
|
|
99
|
+
p "eeee"
|
94
100
|
msisdn2 = dabrab_connecter.num_formatter(params["destinations"], params["notifyUrl"].split(":")[2])
|
95
101
|
|
102
|
+
splitted_parts = msisdn2.each_slice(1).to_a
|
103
|
+
|
104
|
+
|
96
105
|
if null_statement.include?(params["viber"]) && !null_statement.include?(params["sms"])
|
97
106
|
hub_resp = mhub_connector.sk_send_sms_list(msisdn2, static_callback, params["sms"]["text"], sms_alphaname)
|
98
107
|
elsif !null_statement.include?(params["viber"]) && null_statement.include?(params["sms"])
|
@@ -104,12 +113,16 @@ class MhubFunctions_2
|
|
104
113
|
else
|
105
114
|
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
115
|
end
|
116
|
+
mes_data = dabrab_connecter.send_responce_formatter(hub_resp)
|
117
|
+
|
118
|
+
|
107
119
|
else
|
108
120
|
output_params = {"code": 503, "result": "Invalid recipients", "body": {"answer": {}, "sender": {"ip_src": ip_src, "ip_real": ip_real, "ip_vip": ip_vip}}}
|
109
121
|
end
|
110
122
|
|
111
|
-
|
123
|
+
|
112
124
|
p hub_resp
|
125
|
+
p mes_data
|
113
126
|
|
114
127
|
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
128
|
|
@@ -118,7 +131,61 @@ class MhubFunctions_2
|
|
118
131
|
telegram_connector.telegram_message(output_params)
|
119
132
|
end
|
120
133
|
|
121
|
-
internal_func.printer_texter({:input => input_params, :output => output_params, :hub_resp => hub_resp, :procedure => "Mhub_2.get_send_message"},
|
134
|
+
internal_func.printer_texter({:input => input_params, :output => output_params, :hub_resp => hub_resp, :procedure => "Mhub_2.get_send_message"}, log_level)
|
135
|
+
output_params
|
136
|
+
|
137
|
+
end
|
138
|
+
|
139
|
+
|
140
|
+
#for bank dabrabyt for massive nums
|
141
|
+
def get_send_message_mass_2(params, ip_src, ip_real, ip_vip)
|
142
|
+
|
143
|
+
input_params = {:params => params}
|
144
|
+
output_params = {}
|
145
|
+
|
146
|
+
null_statement = [nil, "nil", "", "null"]
|
147
|
+
mes_data_answ = []
|
148
|
+
|
149
|
+
begin
|
150
|
+
internal_func.printer_texter({:input => params, :procedure => "Mhub_2.get_send_message_mass_2"}, log_level)
|
151
|
+
if params["destinations"].length >= 1
|
152
|
+
msisdn2 = dabrab_connecter.num_formatter(params["destinations"], params["notifyUrl"].split(":")[2])
|
153
|
+
splitted_parts = msisdn2.each_slice(100).to_a
|
154
|
+
for part_list in splitted_parts
|
155
|
+
|
156
|
+
internal_func.printer_texter({:input => part_list, :procedure => "Mhub_2.get_send_message_mass_2"}, log_level)
|
157
|
+
|
158
|
+
hub_resp = {}
|
159
|
+
|
160
|
+
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)
|
162
|
+
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"])
|
164
|
+
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)
|
166
|
+
else
|
167
|
+
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
|
+
end
|
169
|
+
mes_data = dabrab_connecter.send_responce_formatter(hub_resp)
|
170
|
+
|
171
|
+
internal_func.printer_texter({:input => mes_data, :procedure => "Mhub_2.get_send_message_mass_2"}, log_level)
|
172
|
+
|
173
|
+
mes_data_answ = mes_data_answ + mes_data[:body][:mess_to_recip][:messages]
|
174
|
+
|
175
|
+
end
|
176
|
+
|
177
|
+
else
|
178
|
+
output_params = {"code": 503, "result": "Invalid recipients", "body": {"answer": {}, "sender": {"ip_src": ip_src, "ip_real": ip_real, "ip_vip": ip_vip}}}
|
179
|
+
end
|
180
|
+
|
181
|
+
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}}}
|
182
|
+
|
183
|
+
rescue
|
184
|
+
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}}}
|
185
|
+
telegram_connector.telegram_message(output_params)
|
186
|
+
end
|
187
|
+
|
188
|
+
internal_func.printer_texter({:input => input_params, :output => output_params, :hub_resp => {}, :procedure => "Mhub_2.get_send_message"}, log_level)
|
122
189
|
output_params
|
123
190
|
|
124
191
|
end
|
@@ -142,15 +209,16 @@ class MhubFunctions_2
|
|
142
209
|
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
210
|
telegram_connector.telegram_message(output_params)
|
144
211
|
end
|
145
|
-
internal_func.printer_texter({:input => input_params, :output => output_params, :hub_resp => hub_resp, :procedure => "Mhub_2.recieve_delivery_report"},
|
212
|
+
internal_func.printer_texter({:input => input_params, :output => output_params, :hub_resp => hub_resp, :procedure => "Mhub_2.recieve_delivery_report"}, log_level)
|
146
213
|
output_params
|
147
214
|
end
|
148
215
|
|
149
|
-
|
150
216
|
def test2
|
151
217
|
hh = Infobip_1.new
|
152
218
|
hh.test
|
153
219
|
end
|
154
220
|
|
155
221
|
|
156
|
-
end
|
222
|
+
end
|
223
|
+
|
224
|
+
|
@@ -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
|
+
|
@@ -3,12 +3,13 @@ require 'imperituroard/projects/mhub/subs/dabrab/dabrab_proced'
|
|
3
3
|
|
4
4
|
class Sksk_2
|
5
5
|
|
6
|
-
attr_accessor :sk_url, :sk_url_broadcast, :sk_login, :sk_password, :internal_func, :telegram_connector, :dabrab_add_func
|
6
|
+
attr_accessor :sk_url, :sk_url_broadcast, :sk_login, :sk_password, :internal_func, :telegram_connector, :dabrab_add_func, :log_level
|
7
7
|
|
8
|
-
def initialize(sk_url, sk_login, sk_password, sk_url_broadcast, telegram_api_url, telegram_chat_id)
|
8
|
+
def initialize(sk_url, sk_login, sk_password, sk_url_broadcast, telegram_api_url, telegram_chat_id, log_level)
|
9
9
|
@sk_url = sk_url
|
10
10
|
@sk_login = sk_login
|
11
11
|
@sk_password = sk_password
|
12
|
+
@log_level = log_level
|
12
13
|
@internal_func = InternalFunc.new
|
13
14
|
@sk_url_broadcast = sk_url_broadcast
|
14
15
|
@telegram_connector = Telegram_2.new(telegram_api_url, telegram_chat_id)
|
@@ -72,7 +73,7 @@ class Sksk_2
|
|
72
73
|
output_params = {:code => 500, :result => "Sksk_2.sk_send_sms_one: Something wrong", :body => {:request_message => request_message}}
|
73
74
|
telegram_connector.telegram_message(output_params)
|
74
75
|
end
|
75
|
-
internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Sksk_1.sk_send_sms_one"},
|
76
|
+
internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Sksk_1.sk_send_sms_one"}, log_level)
|
76
77
|
output_params
|
77
78
|
end
|
78
79
|
|
@@ -131,12 +132,11 @@ class Sksk_2
|
|
131
132
|
|
132
133
|
thr_sk_send_viber_one.join
|
133
134
|
|
134
|
-
|
135
135
|
rescue
|
136
136
|
output_params = {:code => 500, :result => "Sksk_2.sk_send_viber_one: Something wrong"}
|
137
137
|
telegram_connector.telegram_message(output_params)
|
138
138
|
end
|
139
|
-
internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Sksk_2.sk_send_viber_one"},
|
139
|
+
internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Sksk_2.sk_send_viber_one"}, log_level)
|
140
140
|
output_params
|
141
141
|
end
|
142
142
|
|
@@ -198,7 +198,6 @@ class Sksk_2
|
|
198
198
|
else
|
199
199
|
output_params = {:code => 508, :result => "Sksk_2.sk_send_viber_sms_one: Something wrong with dabrabyt_text_field_parse"}
|
200
200
|
end
|
201
|
-
|
202
201
|
end
|
203
202
|
|
204
203
|
thr_sk_send_viber_sms_one.join
|
@@ -207,7 +206,7 @@ class Sksk_2
|
|
207
206
|
output_params = {:code => 500, :result => "Sksk_2.sk_send_viber_sms_one: Something wrong"}
|
208
207
|
telegram_connector.telegram_message(output_params)
|
209
208
|
end
|
210
|
-
internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Sksk_2.sk_send_viber_sms_one"},
|
209
|
+
internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Sksk_2.sk_send_viber_sms_one"}, log_level)
|
211
210
|
output_params
|
212
211
|
|
213
212
|
end
|
@@ -269,7 +268,7 @@ class Sksk_2
|
|
269
268
|
output_params = {:code => 500, :result => "Sksk_2.sk_send_sms_list: Something wrong"}
|
270
269
|
telegram_connector.telegram_message(output_params)
|
271
270
|
end
|
272
|
-
internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Sksk_2.sk_send_sms_list"},
|
271
|
+
internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Sksk_2.sk_send_sms_list"}, log_level)
|
273
272
|
output_params
|
274
273
|
end
|
275
274
|
|
@@ -332,7 +331,7 @@ class Sksk_2
|
|
332
331
|
output_params = {:code => 500, :result => "Sksk_2.sk_send_viber_list: Something wrong"}
|
333
332
|
telegram_connector.telegram_message(output_params)
|
334
333
|
end
|
335
|
-
internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Sksk_2.sk_send_viber_list"},
|
334
|
+
internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Sksk_2.sk_send_viber_list"}, log_level)
|
336
335
|
output_params
|
337
336
|
end
|
338
337
|
|
@@ -345,6 +344,7 @@ class Sksk_2
|
|
345
344
|
begin
|
346
345
|
thr_sk_send_viber_sms_list = Thread.new do
|
347
346
|
|
347
|
+
|
348
348
|
viber_mess_ans = dabrab_add_func.dabrabyt_text_field_parse(viber_text)
|
349
349
|
|
350
350
|
if viber_mess_ans[:code] == 200
|
@@ -359,7 +359,6 @@ class Sksk_2
|
|
359
359
|
|
360
360
|
req.basic_auth sk_login, sk_password
|
361
361
|
|
362
|
-
|
363
362
|
req["Content-Type"] = "application/json"
|
364
363
|
req["Accept"] = "application/json"
|
365
364
|
|
@@ -390,20 +389,16 @@ class Sksk_2
|
|
390
389
|
:body => {:request_message => request_message,
|
391
390
|
:res_code => res.code,
|
392
391
|
:res_body => JSON.parse(res.body.to_s)}}
|
393
|
-
|
394
392
|
else
|
395
393
|
output_params = {:code => 508, :result => "Sksk_2.sk_send_viber_sms_list: Something wrong with dabrabyt_text_field_parse"}
|
396
394
|
end
|
397
|
-
|
398
395
|
end
|
399
|
-
|
400
396
|
thr_sk_send_viber_sms_list.join
|
401
|
-
|
402
397
|
rescue
|
403
398
|
output_params = {:code => 500, :result => "Sksk_2.sk_send_viber_sms_list: Something wrong"}
|
404
399
|
telegram_connector.telegram_message(output_params)
|
405
400
|
end
|
406
|
-
internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Sksk_2.sk_send_viber_sms_list"},
|
401
|
+
internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Sksk_2.sk_send_viber_sms_list"}, log_level)
|
407
402
|
output_params
|
408
403
|
end
|
409
404
|
|
@@ -3,11 +3,12 @@ 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)
|
@@ -44,7 +45,7 @@ class Crm_2
|
|
44
45
|
:body => {:request_message => crm_payload,
|
45
46
|
:res_code => res.code,
|
46
47
|
:res_body => JSON.parse(res.body.to_s)}}
|
47
|
-
p res.body
|
48
|
+
#p res.body
|
48
49
|
end
|
49
50
|
thr_crm_status_2.join
|
50
51
|
|
@@ -52,7 +53,7 @@ class Crm_2
|
|
52
53
|
output_params = {:code => 500, :result => "Crm_2.crm_status_2: Something wrong", :body => {:request_message => request_message}}
|
53
54
|
telegram_connector.telegram_message(output_params)
|
54
55
|
end
|
55
|
-
internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Crm_2.crm_status_2"},
|
56
|
+
internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Crm_2.crm_status_2"}, log_level)
|
56
57
|
output_params
|
57
58
|
|
58
59
|
end
|
@@ -30,9 +30,9 @@ class Dabrab
|
|
30
30
|
image_dat = stri.scan(regexp_image1)
|
31
31
|
|
32
32
|
|
33
|
-
p button_url_dat
|
34
|
-
p button_text_dat
|
35
|
-
p image_dat
|
33
|
+
#p button_url_dat
|
34
|
+
#p button_text_dat
|
35
|
+
#p image_dat
|
36
36
|
|
37
37
|
begin
|
38
38
|
if button_url_dat != [] && button_url_dat != nil && button_url_dat != ""
|
@@ -90,19 +90,20 @@ class Dabrab
|
|
90
90
|
scheme = 0
|
91
91
|
end
|
92
92
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
93
|
+
case scheme
|
94
|
+
when 0
|
95
|
+
sk_format = {"text": text, "ttl": 60}
|
96
|
+
when 1
|
97
|
+
sk_format = {"text": text, "ttl": 60, "caption": button_text, "action": button_url}
|
98
|
+
when 2
|
99
|
+
sk_format = {"text": text, "ttl": 60, "caption": button_text, "action": button_url, "img": image}
|
100
|
+
when 3
|
101
|
+
sk_format = {"img": image, "ttl": 60}
|
102
|
+
else
|
103
|
+
nil
|
103
104
|
end
|
104
105
|
|
105
|
-
p sk_format
|
106
|
+
#p sk_format
|
106
107
|
|
107
108
|
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
109
|
rescue
|
@@ -125,11 +126,12 @@ class Dabrab
|
|
125
126
|
#"extra_id": extra_id
|
126
127
|
})
|
127
128
|
rescue
|
128
|
-
|
129
|
+
nil
|
130
|
+
#p "failed: #{g.to_s}"
|
129
131
|
end
|
130
132
|
|
131
133
|
end
|
132
|
-
p converted_msisdn_list
|
134
|
+
#p converted_msisdn_list
|
133
135
|
converted_msisdn_list
|
134
136
|
|
135
137
|
end
|
@@ -155,8 +157,8 @@ class Dabrab
|
|
155
157
|
]
|
156
158
|
}
|
157
159
|
|
158
|
-
p "send_responce_formatter(hub_answer)"
|
159
|
-
p hub_answer
|
160
|
+
#p "send_responce_formatter(hub_answer)"
|
161
|
+
#p hub_answer
|
160
162
|
|
161
163
|
for a in hub_answer[:body][:res_body]["messages"]
|
162
164
|
status1 = {}
|
@@ -181,7 +183,7 @@ class Dabrab
|
|
181
183
|
messages_sect.append(status1)
|
182
184
|
end
|
183
185
|
|
184
|
-
p messages_sect
|
186
|
+
#p messages_sect
|
185
187
|
|
186
188
|
mess_to_recip = {"bulkId": "00000000-0000-0000-0000-000000000000", "messages": messages_sect}
|
187
189
|
{:code => 200, :result => "Data processed", :body => {:mess_to_recip => mess_to_recip}}
|
@@ -190,8 +192,8 @@ class Dabrab
|
|
190
192
|
|
191
193
|
def delivery_report_transform(hub_report)
|
192
194
|
#{"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
|
-
|
194
|
-
|
195
|
+
#p hub_report
|
196
|
+
#p "hub_report"
|
195
197
|
data_for_status = {
|
196
198
|
23011 => {:status_id => 5, :status_grid => 3, :status_grname => "DELIVERED", :status_name => "DELIVERED_TO_HANDSET", :status_descr => "Message delivered by SMS",
|
197
199
|
:error_id => 0, :error_grid => 0, :error_grname => "Ok", :error_name => "NO_ERROR", :error_descr => "No Error", :error_permanent => false
|