imperituroard 0.3.8 → 0.3.9

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: 105b8bfcf0691a85c3e70bd793cceb9cfde52aa4
4
- data.tar.gz: 6bed91d82f8ae0174587ddc05837284411b218d1
3
+ metadata.gz: 541de7d03bfd56a1dcb6d5bcdc4b5be30984ab52
4
+ data.tar.gz: cea1b867c6a8c5692bbcaceaed72c00be1b5a448
5
5
  SHA512:
6
- metadata.gz: dccc03ba30a1ca692af12363c70ee3f405a73d87e3a767784b750661ca2b926efd9dba540876b76dae5f90e6091252b643e3bc6acd35d9f77fda88c6e22c27cd
7
- data.tar.gz: 9d4917de0ab216a8a6e76379879793833c526768bd11a13f70efcfd1c512d44617305dc864821fb447b430485a72124a6cfee58f5739ac038a47597e45568207
6
+ metadata.gz: 5da3dac0cd2ea28ac338b7d9d6931988f00f58d871a39cfba3c81544928da902984723241d4d4b1cb9ec881775f0120145386cf8ad7f4d83428494d2d3da9bdc
7
+ data.tar.gz: 3f50dd6c0252afd409be4081c225fbacf5d8ee37c8a5528bfb8f30f143ed40753fa349b9f78f0e17c8b82223d4ec59a1296de2091ad792ad04139dfb9233c1b4
@@ -1,152 +1,343 @@
1
-
2
-
3
-
1
+ require 'imperituroard/projects/iot/internal_functions'
4
2
 
5
3
  class Sksk_1
6
4
 
7
- attr_accessor :sk_url, :sk_login, :sk_password
5
+ attr_accessor :sk_url, :sk_url_broadcast, :sk_login, :sk_password, :internal_func
8
6
 
9
- def initialize(sk_url, sk_login, sk_password)
7
+ def initialize(sk_url, sk_login, sk_password, sk_url_broadcast)
10
8
  @sk_url = sk_url
11
9
  @sk_login = sk_login
12
10
  @sk_password = sk_password
13
11
  @internal_func = InternalFunc.new
12
+ @sk_url_broadcast = sk_url_broadcast
14
13
  end
15
14
 
16
15
 
16
+ def sk_send_sms_one(msisdn, callback_url, text, alphaname)
17
+
18
+ input_params = {:msisdn => msisdn, :callback_url => callback_url, :text => text, :alphaname => alphaname}
19
+ output_params = {}
20
+ request_message = {}
21
+
22
+ begin
23
+ uri = URI(sk_url)
24
+ #8 - client id
25
+
26
+ https = Net::HTTP.new(uri.host, uri.port)
27
+ https.use_ssl=true
28
+ https.verify_mode = OpenSSL::SSL::VERIFY_NONE
29
+ req = Net::HTTP::Post.new(uri.path, initheader = {:"Content-Type" => 'application/json'})
30
+
31
+ req.basic_auth sk_login, sk_password
32
+
33
+ request_message = {
34
+ "phone_number": msisdn,
35
+ "extra_id": "4232j4h89932kjhs",
36
+ "callback_url": callback_url,
37
+ #"start_time": "2019-08-16 09:59:10",
38
+ "tag": "Dabrab_custom_api_1",
39
+ "channels": [
40
+ "sms"
41
+ ],
42
+ "channel_options": {
43
+ "sms": {
44
+ "text": text,
45
+ "alpha_name": alphaname,
46
+ "ttl": 600
47
+ }
48
+ }
49
+ }
50
+
51
+ req.body = request_message.to_json
52
+ res = https.request(req)
53
+ output_params = {:code => 200,
54
+ :result => "Sksk_1.sk_send_sms_one: Request processed",
55
+ :body => {:request_message => request_message,
56
+ :res_code => res.code,
57
+ :res_body => JSON.parse(res.body.to_s)}}
58
+ p res.body
59
+
60
+ rescue
61
+ output_params = {:code => 500, :result => "Sksk_1.sk_send_sms_one: Something wrong", :body => {:request_message => request_message}}
62
+ end
63
+ internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Sksk_1.sk_send_sms_one"}, "debug")
64
+ output_params
65
+ end
17
66
 
18
- def sk_send_sms(msisdn, callback_url, text, alphaname)
19
-
20
- uri = URI(sk_url)
21
- #8 - client id
22
-
23
- https = Net::HTTP.new(uri.host, uri.port)
24
- https.use_ssl=true
25
- https.verify_mode = OpenSSL::SSL::VERIFY_NONE
26
- req = Net::HTTP::Post.new(uri.path, initheader = {:"Content-Type" => 'application/json'})
27
-
28
- req.basic_auth sk_login, sk_password
29
-
30
-
31
- request_message = {
32
- "phone_number": msisdn,
33
- "extra_id": "4232j4h89932kjhs",
34
- "callback_url": callback_url,
35
- #"start_time": "2019-08-16 09:59:10",
36
- "tag": "Dabrab_custom_api_1",
37
- "channels": [
38
- "sms"
39
- ],
40
- "channel_options": {
41
- "sms": {
42
- "text": text,
43
- "alpha_name": alphaname,
44
- "ttl": 600
45
- }
46
- }
47
- }
48
67
 
49
- p request_message
68
+ def sk_send_viber_one(msisdn, callback_url, text)
69
+
70
+ input_params = {:msisdn => msisdn, :callback_url => callback_url, :text => text}
71
+ output_params = {}
72
+ request_message = {}
73
+
74
+ begin
75
+
76
+ uri = URI(sk_url)
77
+ #8 - client id
78
+
79
+ https = Net::HTTP.new(uri.host, uri.port)
80
+ https.use_ssl=true
81
+ https.verify_mode = OpenSSL::SSL::VERIFY_NONE
82
+ req = Net::HTTP::Post.new(uri.path, initheader = {:"Content-Type" => 'application/json'})
83
+
84
+ req.basic_auth sk_login, sk_password
85
+
86
+ request_message = {
87
+ "phone_number": msisdn,
88
+ "extra_id": "4232j4h89932kjhs",
89
+ "callback_url": callback_url,
90
+ #"start_time": "2019-08-16 09:59:10",
91
+ "tag": "Dabrab_custom_api_1",
92
+ "channels": [
93
+ "viber"
94
+ ],
95
+ "channel_options": {
96
+ "viber": {
97
+ "text": text,
98
+ "ttl": 60,
99
+ # "img": "http://olddogs.org/logo.png",
100
+ # "caption": "Old Dogs need you!",
101
+ # "action": "http://olddogs.org",
102
+ },
103
+ }
104
+ }
105
+ req.body = request_message.to_json
106
+ res = https.request(req)
107
+ output_params = {:code => 200,
108
+ :result => "Sksk_1.sk_send_viber_one: Request processed",
109
+ :body => {:request_message => request_message,
110
+ :res_code => res.code,
111
+ :res_body => JSON.parse(res.body.to_s)}}
112
+
113
+ rescue
114
+ output_params = {:code => 500, :result => "Sksk_1.sk_send_viber_one: Something wrong"}
115
+ end
116
+ internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Sksk_1.sk_send_viber_one"}, "debug")
117
+ output_params
118
+ end
50
119
 
51
- req.body = request_message.to_json
52
- p req.body
53
- p req
120
+ def sk_send_viber_sms_one(msisdn, callback_url, sms_text, viber_txt, alphaname)
121
+
122
+ input_params = {:msisdn => msisdn, :callback_url => callback_url, :sms_text => sms_text, :viber_txt => viber_txt, :alphaname => alphaname}
123
+ output_params = {}
124
+ request_message = {}
125
+
126
+ begin
127
+
128
+ uri = URI(sk_url)
129
+ #8 - client id
130
+
131
+ https = Net::HTTP.new(uri.host, uri.port)
132
+ https.use_ssl=true
133
+ https.verify_mode = OpenSSL::SSL::VERIFY_NONE
134
+ req = Net::HTTP::Post.new(uri.path, initheader = {:"Content-Type" => 'application/json'})
135
+
136
+ req.basic_auth sk_login, sk_password
137
+
138
+ request_message = {
139
+ "phone_number": msisdn,
140
+ "extra_id": "4232j4h89932kjhs",
141
+ "callback_url": callback_url,
142
+ #"start_time": "2019-08-16 09:59:10",
143
+ "tag": "Dabrab_custom_api_1",
144
+ "channels": [
145
+ "viber",
146
+ "sms"
147
+ ],
148
+ "channel_options": {
149
+ "sms": {
150
+ "text": sms_text,
151
+ "alpha_name": alphaname,
152
+ "ttl": 600
153
+ },
154
+ "viber": {
155
+ "text": viber_txt,
156
+ "ttl": 60,
157
+ # "img": "http://olddogs.org/logo.png",
158
+ # "caption": "Old Dogs need you!",
159
+ # "action": "http://olddogs.org",
160
+ },
161
+ }
162
+ }
163
+
164
+ req.body = request_message.to_json
165
+ res = https.request(req)
166
+
167
+ output_params = {:code => 200,
168
+ :result => "Sksk_1.sk_send_viber_sms_one: Request processed",
169
+ :body => {:request_message => request_message,
170
+ :res_code => res.code,
171
+ :res_body => JSON.parse(res.body.to_s)}}
172
+
173
+ rescue
174
+ output_params = {:code => 500, :result => "Sksk_1.sk_send_viber_sms_one: Something wrong"}
175
+ end
176
+ internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Sksk_1.sk_send_viber_sms_one"}, "debug")
177
+ output_params
54
178
 
55
- res = https.request(req)
179
+ end
56
180
 
57
- p res.body
58
- p res.code
59
181
 
182
+ def sk_send_sms_list(msisdn_list, callback_url, text, alphaname)
183
+
184
+ input_params = {:msisdn_list => msisdn_list, :callback_url => callback_url, :text => text, :alphaname => alphaname}
185
+ output_params = {}
186
+ request_message = {}
187
+
188
+ begin
189
+ uri = URI(sk_url_broadcast)
190
+ #8 - client id
191
+
192
+ https = Net::HTTP.new(uri.host, uri.port)
193
+ https.use_ssl = true
194
+ https.verify_mode = OpenSSL::SSL::VERIFY_NONE
195
+ req = Net::HTTP::Post.new(uri.path, initheader = {:"Content-Type" => 'application/json'})
196
+
197
+ req.basic_auth sk_login, sk_password
198
+
199
+ # [{"phone_number": 375298766719}, {"phone_number": 375295730878}]
200
+ request_message = {
201
+ "recipients": msisdn_list,
202
+ "callback_url": callback_url,
203
+ "tag": "Dabrab_custom_api_1",
204
+ "channels": [
205
+ "sms"
206
+ ],
207
+ "channel_options": {
208
+ "sms": {
209
+ "alpha_name": alphaname,
210
+ "text": text,
211
+ "ttl": 60
212
+ }
213
+ }
214
+ }
215
+
216
+ p request_message
217
+
218
+ req.body = request_message.to_json
219
+ res = https.request(req)
220
+
221
+ output_params = {:code => 200,
222
+ :result => "Sksk_1.sk_send_sms_list: Request processed",
223
+ :body => {:request_message => request_message,
224
+ :res_code => res.code,
225
+ :res_body => JSON.parse(res.body.to_s)}}
226
+ rescue
227
+ output_params = {:code => 500, :result => "Sksk_1.sk_send_sms_list: Something wrong"}
228
+ end
229
+ internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Sksk_1.sk_send_sms_list"}, "debug")
230
+ output_params
60
231
  end
61
232
 
62
233
 
63
-
64
- def sk_send_viber(msisdn, callback_url, text)
65
-
66
- uri = URI(sk_url)
67
- #8 - client id
68
-
69
- https = Net::HTTP.new(uri.host, uri.port)
70
- https.use_ssl=true
71
- https.verify_mode = OpenSSL::SSL::VERIFY_NONE
72
- req = Net::HTTP::Post.new(uri.path, initheader = {:"Content-Type" => 'application/json'})
73
-
74
- req.basic_auth sk_login, sk_password
75
-
76
- request_message = {
77
- "phone_number": msisdn,
78
- "extra_id": "4232j4h89932kjhs",
79
- "callback_url": callback_url,
80
- #"start_time": "2019-08-16 09:59:10",
81
- "tag": "Dabrab_custom_api_1",
82
- "channels": [
83
- "viber"
84
- ],
85
- "channel_options": {
86
- "viber": {
87
- "text": text,
88
- "ttl": 60,
89
- # "img": "http://olddogs.org/logo.png",
90
- # "caption": "Old Dogs need you!",
91
- # "action": "http://olddogs.org",
92
- },
93
- }
94
- }
95
- p request_message
96
- req.body = request_message.to_json
97
- p req.body
98
- p req
99
- res = https.request(req)
100
- p res.body
101
- p res.code
234
+ def sk_send_viber_list(msisdn_list, callback_url, text)
235
+
236
+ input_params = {:msisdn_list => msisdn_list, :callback_url => callback_url, :text => text}
237
+ output_params = {}
238
+ request_message = {}
239
+
240
+ begin
241
+ uri = URI(sk_url_broadcast)
242
+ #8 - client id
243
+
244
+ https = Net::HTTP.new(uri.host, uri.port)
245
+ https.use_ssl = true
246
+ https.verify_mode = OpenSSL::SSL::VERIFY_NONE
247
+ req = Net::HTTP::Post.new(uri.path, initheader = {:"Content-Type" => 'application/json'})
248
+
249
+ req.basic_auth sk_login, sk_password
250
+
251
+ # [{"phone_number": 375298766719}, {"phone_number": 375295730878}]
252
+ request_message = {
253
+ "recipients": msisdn_list,
254
+ "callback_url": callback_url,
255
+ "tag": "Dabrab_custom_api_1",
256
+ "channels": [
257
+ "viber"
258
+ ],
259
+ "channel_options": {
260
+ "viber": {
261
+ "text": text,
262
+ "ttl": 60
263
+ }
264
+ }
265
+ }
266
+
267
+ p request_message
268
+
269
+ req.body = request_message.to_json
270
+ res = https.request(req)
271
+
272
+ output_params = {:code => 200,
273
+ :result => "Sksk_1.sk_send_viber_list: Request processed",
274
+ :body => {:request_message => request_message,
275
+ :res_code => res.code,
276
+ :res_body => JSON.parse(res.body.to_s)}}
277
+ rescue
278
+ output_params = {:code => 500, :result => "Sksk_1.sk_send_viber_list: Something wrong"}
279
+ end
280
+ internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Sksk_1.sk_send_viber_list"}, "debug")
281
+ output_params
102
282
  end
103
283
 
104
- def sk_send_viber_sms(msisdn, callback_url, sms_text, viber_txt, alphaname)
105
-
106
- uri = URI(sk_url)
107
- #8 - client id
108
-
109
- https = Net::HTTP.new(uri.host, uri.port)
110
- https.use_ssl=true
111
- https.verify_mode = OpenSSL::SSL::VERIFY_NONE
112
- req = Net::HTTP::Post.new(uri.path, initheader = {:"Content-Type" => 'application/json'})
113
-
114
- req.basic_auth sk_login, sk_password
115
-
116
- request_message = {
117
- "phone_number": msisdn,
118
- "extra_id": "4232j4h89932kjhs",
119
- "callback_url": callback_url,
120
- #"start_time": "2019-08-16 09:59:10",
121
- "tag": "Dabrab_custom_api_1",
122
- "channels": [
123
- "viber",
124
- "sms"
125
- ],
126
- "channel_options": {
127
- "sms": {
128
- "text": sms_text,
129
- "alpha_name": alphaname,
130
- "ttl": 600
131
- },
132
- "viber": {
133
- "text": viber_txt,
134
- "ttl": 60,
135
- # "img": "http://olddogs.org/logo.png",
136
- # "caption": "Old Dogs need you!",
137
- # "action": "http://olddogs.org",
138
- },
139
- }
140
- }
141
- p request_message
142
- req.body = request_message.to_json
143
- p req.body
144
- p req
145
- res = https.request(req)
146
- p res.body
147
- p res.code
148
- end
149
284
 
285
+ def sk_send_viber_sms_list(msisdn_list, callback_url, text, alphaname)
286
+
287
+ input_params = {:msisdn_list => msisdn_list, :callback_url => callback_url, :text => text, :alphaname => alphaname}
288
+ output_params = {}
289
+ request_message = {}
290
+
291
+ begin
292
+ uri = URI(sk_url_broadcast)
293
+ #8 - client id
294
+
295
+ https = Net::HTTP.new(uri.host, uri.port)
296
+ https.use_ssl = true
297
+ https.verify_mode = OpenSSL::SSL::VERIFY_NONE
298
+ req = Net::HTTP::Post.new(uri.path, initheader = {:"Content-Type" => 'application/json'})
299
+
300
+ req.basic_auth sk_login, sk_password
301
+
302
+ # [{"phone_number": 375298766719}, {"phone_number": 375295730878}]
303
+ request_message = {
304
+ "recipients": msisdn_list,
305
+ "callback_url": callback_url,
306
+ "tag": "Dabrab_custom_api_1",
307
+ "channels": [
308
+ "viber",
309
+ "sms"
310
+ ],
311
+ "channel_options": {
312
+ "sms": {
313
+ "alpha_name": alphaname,
314
+ "text": text,
315
+ "ttl": 60
316
+ },
317
+ "viber": {
318
+ "text": text,
319
+ "ttl": 60
320
+ }
321
+ }
322
+ }
323
+
324
+
325
+ p request_message
326
+
327
+ req.body = request_message.to_json
328
+ res = https.request(req)
329
+
330
+ output_params = {:code => 200,
331
+ :result => "Sksk_1.sk_send_viber_sms_list: Request processed",
332
+ :body => {:request_message => request_message,
333
+ :res_code => res.code,
334
+ :res_body => JSON.parse(res.body.to_s)}}
335
+ rescue
336
+ output_params = {:code => 500, :result => "Sksk_1.sk_send_viber_sms_list: Something wrong"}
337
+ end
338
+ internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Sksk_1.sk_send_viber_sms_list"}, "debug")
339
+ output_params
340
+ end
150
341
 
151
342
 
152
343
  end
@@ -3,6 +3,67 @@
3
3
 
4
4
  class Dabrab
5
5
 
6
+ def num_formatter(infobip_msisdn, extra_id)
7
+ #[{"to"=>{"phoneNumber"=>"375297116638", "emailAddress"=>nil}}]
8
+ # [{"phone_number": 375298766719}, {"phone_number": 375295730878}]
6
9
 
10
+ converted_msisdn_list = []
11
+
12
+ for g in infobip_msisdn
13
+ begin
14
+ converted_msisdn_list.append({"phone_number": g["to"]["phoneNumber"].to_i, "extra_id": extra_id})
15
+ rescue
16
+ p "failed: #{g.to_s}"
17
+ end
18
+
19
+ end
20
+ p converted_msisdn_list
21
+
22
+ converted_msisdn_list
23
+
24
+ end
25
+
26
+
27
+ def send_responce_formatter(hub_answer)
28
+ input = {:hub_answer => hub_answer}
29
+ mess_to_recip = {}
30
+ messages_sect = []
31
+ example = {
32
+ "bulkId": "2034072219640523072",
33
+ "messages": [{
34
+ "to": "41793026727",
35
+ "status": {
36
+ "groupId": 1,
37
+ "groupName": "PENDING",
38
+ "id": 26,
39
+ "name": "MESSAGE_ACCEPTED",
40
+ "description": "Message sent to next instance"
41
+ },
42
+ "messageId": "2250be2d4219-3af1-78856-aabe-1362af1edfd2"
43
+ }
44
+ ]
45
+ }
46
+
47
+ p "send_responce_formatter(hub_answer)"
48
+
49
+ p hub_answer
50
+
51
+ for a in hub_answer[:body][:res_body]["messages"]
52
+ s1 = {"to": a["phone_number"], "status": {"groupId": 1,
53
+ "groupName": "PENDING",
54
+ "id": 26,
55
+ "name": "MESSAGE_ACCEPTED",
56
+ "description": "Message sent to next instance"},
57
+ "messageId": a["message_id"]}
58
+ messages_sect.append(s1)
59
+ end
60
+
61
+ p messages_sect
62
+
63
+ mess_to_recip = {"messages": messages_sect}
64
+
65
+ {:code => 200, :result => "Data processed", :body => {:mess_to_recip => mess_to_recip}}
66
+
67
+ end
7
68
 
8
69
  end
@@ -1,3 +1,3 @@
1
1
  module Imperituroard
2
- VERSION = "0.3.8"
2
+ VERSION = "0.3.9"
3
3
  end
data/lib/imperituroard.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  $LOAD_PATH.unshift File.expand_path("../projects/iot", __dir__)
2
2
  $LOAD_PATH.unshift File.expand_path("../projects/wttx", __dir__)
3
3
  $LOAD_PATH.unshift File.expand_path("../projects/mhub", __dir__)
4
+ $LOAD_PATH.unshift File.expand_path("../projects/mhub/subs/dabrab", __dir__)
5
+
4
6
 
5
7
  require "imperituroard/version"
6
8
  require "imperituroard/phpipamdb"
@@ -11,6 +13,7 @@ require "imperituroard/projects/iot/add_functions"
11
13
  require "imperituroard/projects/iot/internal_functions"
12
14
  require 'imperituroard/projects/mhub/infobip'
13
15
  require 'imperituroard/projects/mhub/sk'
16
+ require 'imperituroard/projects/mhub/subs/dabrab/dabrab_proced'
14
17
  require 'json'
15
18
  require 'ipaddr'
16
19
  require 'date'
@@ -797,15 +800,16 @@ end
797
800
 
798
801
  class Mhub_2
799
802
 
800
- attr_accessor :sk_url, :sk_login, :sk_password, :mhub_connector, :internal_func
803
+ attr_accessor :sk_url, :sk_login, :sk_password, :mhub_connector, :internal_func, :dabrab_connecter
801
804
 
802
- def initialize(sk_url, sk_login, sk_password, telegram_api_url, telegram_chat_id)
803
- @sk_url = sk_url
805
+ def initialize(sk_url_simple, sk_login, sk_password, telegram_api_url, telegram_chat_id, sk_url_broadcast)
806
+ @sk_url = sk_url_simple
804
807
  @sk_login = sk_login
805
808
  @sk_password = sk_password
806
809
  @internal_func = InternalFunc.new
807
- @mhub_connector = Sksk_1.new(sk_url, sk_login, sk_password)
810
+ @mhub_connector = Sksk_1.new(sk_url_simple, sk_login, sk_password, sk_url_broadcast)
808
811
  @internal_func = InternalFunc.new
812
+ @dabrab_connecter = Dabrab.new
809
813
  @add_functions_connector = AdditionalFunc.new(telegram_api_url, telegram_chat_id)
810
814
  end
811
815
 
@@ -820,43 +824,70 @@ class Mhub_2
820
824
  # "notifyContentType"=>"application/json"}}
821
825
 
822
826
 
823
- def get_send_message(params)
827
+ def get_send_message(params, ip_src, ip_real, ip_vip)
824
828
 
825
829
  input_params = {:params => params}
826
-
827
- p input_params
828
-
829
830
  output_params = {}
831
+ hub_resp = {}
832
+ null_statement = [nil, "nil", "", "null"]
830
833
 
831
834
  begin
832
835
 
833
- msisdn = params["destinations"][0]["to"]["phoneNumber"]
834
-
835
-
836
- if params["viber"] == nil && params["sms"] != nil
837
-
838
- mhub_connector.sk_send_sms(msisdn, params["notifyUrl"], params["sms"]["text"], "TEST")
839
-
840
- elsif params["viber"] != nil && params["sms"] == nil
841
-
842
- mhub_connector.sk_send_viber(msisdn, params["notifyUrl"], params["viber"]["text"])
843
-
844
- elsif params["viber"] != nil && params["sms"] != nil
845
-
846
- mhub_connector.sk_send_viber_sms(msisdn, params["notifyUrl"], params["sms"]["text"], params["viber"]["text"], "TEST")
847
-
836
+ # if params["destinations"].length == 1
837
+ # msisdn = params["destinations"][0]["to"]["phoneNumber"]
838
+ # if null_statement.include?(params["viber"]) && !null_statement.include?(params["sms"])
839
+ # hub_resp = mhub_connector.sk_send_sms_one(msisdn, params["notifyUrl"], params["sms"]["text"], "TEST")
840
+ # elsif !null_statement.include?(params["viber"]) && null_statement.include?(params["sms"])
841
+ # hub_resp = mhub_connector.sk_send_viber_one(msisdn, params["notifyUrl"], params["viber"]["text"])
842
+ # elsif !null_statement.include?(params["viber"]) && !null_statement.include?(params["sms"])
843
+ # hub_resp = mhub_connector.sk_send_viber_sms_one(msisdn, params["notifyUrl"], params["sms"]["text"], params["viber"]["text"], "TEST")
844
+ # else
845
+ # output_params = {"code": 501, "result": "Invalid input data st1", "answer": {}, "sender": {"ip_src": ip_src, "ip_real": ip_real, "ip_vip": ip_vip}}
846
+ # end
847
+ # elsif params["destinations"].length > 1
848
+ #
849
+ # msisdn2 = dabrab_connecter.num_formatter(params["destinations"], params["notifyUrl"].split(":")[2])
850
+ #
851
+ # if null_statement.include?(params["viber"]) && !null_statement.include?(params["sms"])
852
+ # hub_resp = mhub_connector.sk_send_sms_list(msisdn2, params["notifyUrl"], params["sms"]["text"], "TEST")
853
+ # elsif !null_statement.include?(params["viber"]) && null_statement.include?(params["sms"])
854
+ # hub_resp = mhub_connector.sk_send_viber_list(msisdn2, params["notifyUrl"], params["viber"]["text"])
855
+ # elsif !null_statement.include?(params["viber"]) && !null_statement.include?(params["sms"])
856
+ # hub_resp = mhub_connector.sk_send_viber_sms_list(msisdn2, params["notifyUrl"], params["sms"]["text"], params["viber"]["text"], "TEST")
857
+ # else
858
+ # output_params = {"code": 502, "result": "Invalid input data st2", "answer": {}, "sender": {"ip_src": ip_src, "ip_real": ip_real, "ip_vip": ip_vip}}
859
+ # end
860
+ # else
861
+ # output_params = {"code": 503, "result": "Invalid recipients", "answer": {}, "sender": {"ip_src": ip_src, "ip_real": ip_real, "ip_vip": ip_vip}}
862
+ # end
863
+
864
+ if params["destinations"].length >= 1
865
+
866
+ msisdn2 = dabrab_connecter.num_formatter(params["destinations"], params["notifyUrl"].split(":")[2])
867
+
868
+ if null_statement.include?(params["viber"]) && !null_statement.include?(params["sms"])
869
+ hub_resp = mhub_connector.sk_send_sms_list(msisdn2, params["notifyUrl"], params["sms"]["text"], "TEST")
870
+ elsif !null_statement.include?(params["viber"]) && null_statement.include?(params["sms"])
871
+ hub_resp = mhub_connector.sk_send_viber_list(msisdn2, params["notifyUrl"], params["viber"]["text"])
872
+ elsif !null_statement.include?(params["viber"]) && !null_statement.include?(params["sms"])
873
+ hub_resp = mhub_connector.sk_send_viber_sms_list(msisdn2, params["notifyUrl"], params["sms"]["text"], params["viber"]["text"], "TEST")
874
+ else
875
+ output_params = {"code": 502, "result": "Invalid input data st2", "body": {"answer": {}, "sender": {"ip_src": ip_src, "ip_real": ip_real, "ip_vip": ip_vip}}}
876
+ end
848
877
  else
878
+ output_params = {"code": 503, "result": "Invalid recipients", "body": {"answer": {}, "sender": {"ip_src": ip_src, "ip_real": ip_real, "ip_vip": ip_vip}}}
879
+ end
849
880
 
850
- output_params = {"code": 500, "result": "Invalid input data"}
881
+ mes_data = dabrab_connecter.send_responce_formatter(hub_resp)
882
+ p hub_resp
851
883
 
852
- end
884
+ 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}}}
853
885
 
854
886
  rescue
855
- output_params = {"code": 500, "result": "Invalid input data"}
887
+ output_params = {"code": 500, "result": "Unknown SDK error", "body": {"answer": {}, "sender": {"ip_src": ip_src, "ip_real": ip_real, "ip_vip": ip_vip}}}
856
888
  end
857
889
 
858
- internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Mhub_2.get_send_message"}, "debug")
859
-
890
+ internal_func.printer_texter({:input => input_params, :output => output_params, :hub_resp => hub_resp, :procedure => "Mhub_2.get_send_message"}, "debug")
860
891
  output_params
861
892
 
862
893
  end
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: 0.3.8
4
+ version: 0.3.9
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-05-04 00:00:00.000000000 Z
11
+ date: 2020-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler