imperituroard 1.1.8 → 1.1.13

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
- 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
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
- p "failed: #{g.to_s}"
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,17 +183,20 @@ 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}}
188
190
  end
189
191
 
190
192
 
191
- def delivery_report_transform(hub_report)
193
+ def delivery_report_transform(hub_report_in)
194
+
192
195
  #{"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"
196
+ #p hub_report
197
+ #p "hub_report"
198
+ report_to_recip = []
199
+
195
200
  data_for_status = {
196
201
  23011 => {:status_id => 5, :status_grid => 3, :status_grname => "DELIVERED", :status_name => "DELIVERED_TO_HANDSET", :status_descr => "Message delivered by SMS",
197
202
  :error_id => 0, :error_grid => 0, :error_grname => "Ok", :error_name => "NO_ERROR", :error_descr => "No Error", :error_permanent => false
@@ -216,66 +221,125 @@ class Dabrab
216
221
  } #Viber subscriber not exists
217
222
  }
218
223
 
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
- }
224
+ if hub_report_in.key?("msg_status")
225
+ hub_report = hub_report_in
226
+
227
+ 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"]] != ""
228
+
229
+ report_to_recip.push({
230
+
231
+ "bulkId": "00000000-0000-0000-0000-000000000000",
232
+ "messageId": hub_report["report"]["message_id"],
233
+ "to": hub_report["report"]["number"],
234
+ # "sentAt": "2020-05-05T20:00:00.000+0000",
235
+ # "doneAt": "2020-05-05T20:00:00.000+0000",
236
+ "status": {
237
+ "groupId": data_for_status[hub_report["msg_status"]][:status_grid],
238
+ "groupName": data_for_status[hub_report["msg_status"]][:status_grname],
239
+ "id": data_for_status[hub_report["msg_status"]][:status_id],
240
+ "name": data_for_status[hub_report["msg_status"]][:status_name],
241
+ "description": data_for_status[hub_report["msg_status"]][:status_descr]
242
+ },
243
+ "error": {
244
+ "groupId": data_for_status[hub_report["msg_status"]][:error_grid],
245
+ "groupName": data_for_status[hub_report["msg_status"]][:error_grname],
246
+ "id": data_for_status[hub_report["msg_status"]][:error_id],
247
+ "name": data_for_status[hub_report["msg_status"]][:error_name],
248
+ "description": data_for_status[hub_report["msg_status"]][:error_descr],
249
+ "permanent": data_for_status[hub_report["msg_status"]][:error_permanent]
250
+ }
251
+ })
252
+
253
+
254
+ else
255
+
256
+ report_to_recip.push({
257
+
258
+ "bulkId": "00000000-0000-0000-0000-000000000000",
259
+ "messageId": hub_report["report"]["message_id"],
260
+ "to": hub_report["report"]["number"],
261
+ # "sentAt": "2020-05-05T20:00:00.000+0000",
262
+ # "doneAt": "2020-05-05T20:00:00.000+0000",
263
+ "status": {
264
+ "groupId": 2,
265
+ "groupName": "UNDELIVERABLE_NOT_DELIVERED",
266
+ "id": 9,
267
+ "name": "UNDELIVERED",
268
+ "description": "Unknown error"
269
+ },
270
+ "error": {
271
+ "groupId": 1,
272
+ "groupName": "HANDSET_ERRORS",
273
+ "id": 32,
274
+ "name": "EC_SM_DELIVERY_FAILURE",
275
+ "description": "Unknown error",
276
+ "permanent": false
277
+ }
278
+ })
279
+
280
+ end
247
281
 
248
282
  else
249
283
 
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
- ]
284
+ hub_report_in["_json"].each {|hub_report2|
285
+
286
+ 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"]] != ""
287
+ report_to_recip.push({
288
+
289
+ "bulkId": "00000000-0000-0000-0000-000000000000",
290
+ "messageId": hub_report2["message_id"],
291
+ "to": hub_report2["number"],
292
+ # "sentAt": "2020-05-05T20:00:00.000+0000",
293
+ # "doneAt": "2020-05-05T20:00:00.000+0000",
294
+ "status": {
295
+ "groupId": data_for_status[hub_report2["msg_status"]][:status_grid],
296
+ "groupName": data_for_status[hub_report2["msg_status"]][:status_grname],
297
+ "id": data_for_status[hub_report2["msg_status"]][:status_id],
298
+ "name": data_for_status[hub_report2["msg_status"]][:status_name],
299
+ "description": data_for_status[hub_report2["msg_status"]][:status_descr]
300
+ },
301
+ "error": {
302
+ "groupId": data_for_status[hub_report2["msg_status"]][:error_grid],
303
+ "groupName": data_for_status[hub_report2["msg_status"]][:error_grname],
304
+ "id": data_for_status[hub_report2["msg_status"]][:error_id],
305
+ "name": data_for_status[hub_report2["msg_status"]][:error_name],
306
+ "description": data_for_status[hub_report2["msg_status"]][:error_descr],
307
+ "permanent": data_for_status[hub_report2["msg_status"]][:error_permanent]
308
+ }
309
+ })
310
+
311
+
312
+ else
313
+
314
+ report_to_recip.push({
315
+
316
+ "bulkId": "00000000-0000-0000-0000-000000000000",
317
+ "messageId": hub_report2["message_id"],
318
+ "to": hub_report2["number"],
319
+ # "sentAt": "2020-05-05T20:00:00.000+0000",
320
+ # "doneAt": "2020-05-05T20:00:00.000+0000",
321
+ "status": {
322
+ "groupId": 2,
323
+ "groupName": "UNDELIVERABLE_NOT_DELIVERED",
324
+ "id": 9,
325
+ "name": "UNDELIVERED",
326
+ "description": "Unknown error"
327
+ },
328
+ "error": {
329
+ "groupId": 1,
330
+ "groupName": "HANDSET_ERRORS",
331
+ "id": 32,
332
+ "name": "EC_SM_DELIVERY_FAILURE",
333
+ "description": "Unknown error",
334
+ "permanent": false
335
+ }
336
+ })
337
+ end
338
+
276
339
  }
277
340
  end
278
- {:code => 200, :result => "Data processed", :body => {:report_to_recip => report_to_recip}}
341
+
342
+ {:code => 200, :result => "Data processed", :body => {:report_to_recip => {"results": report_to_recip}}}
279
343
  end
280
344
 
281
345
  end
@@ -0,0 +1,69 @@
1
+ require 'net/https'
2
+
3
+ require 'json'
4
+
5
+ require 'uri'
6
+ require 'net/http'
7
+ require 'rubygems'
8
+ require 'nokogiri'
9
+ require 'rails'
10
+
11
+ require 'imperituroard/projects/iot/internal_functions'
12
+
13
+
14
+ class Gms_2
15
+
16
+ attr_accessor :gms_login, :gms_password, :telegram_connector, :internal_func
17
+
18
+ def initialize(gms_login, gms_password, telegram_api_url, telegram_chat_id)
19
+ @gms_login = gms_login
20
+ @gms_password = gms_password
21
+ @internal_func = InternalFunc.new
22
+ @telegram_connector = Telegram_2.new(telegram_api_url, telegram_chat_id)
23
+ end
24
+
25
+ def get_advanced_by_external(external_id)
26
+
27
+ input_params = {:external_id => external_id}
28
+ output_params = {}
29
+ thr1_get_advanced_by_external = Thread.new do
30
+ begin
31
+ uri = URI("https://dr-v2.hyber.im/2160/api/dr/external/" + external_id + "/advanced")
32
+ https = Net::HTTP.new(uri.host, uri.port)
33
+ https.use_ssl = true
34
+ https.verify_mode = OpenSSL::SSL::VERIFY_NONE
35
+ req = Net::HTTP::Get.new(uri.path, initheader = {:"Content-Type" => 'application/json'})
36
+ req.basic_auth gms_login, gms_password
37
+ req["Content-Type"] = "application/json"
38
+ res = https.request(req)
39
+
40
+ p res.code
41
+ p res.body
42
+ if res.code == "200"
43
+ output_params = {:code => 200,
44
+ :result => "Gms_2.get_advanced_by_external: Request processed",
45
+ :body => {:request_message => input_params,
46
+ :res_code => res.code,
47
+ :res_body => JSON.parse(res.body.to_s)}}
48
+ else
49
+ output_params = {:code => res.code.to_i,
50
+ :result => "Gms_2.get_advanced_by_external: Request processed",
51
+ :body => {:request_message => input_params,
52
+ :res_code => res.code,
53
+ :res_body => res.body.to_s}}
54
+ end
55
+ rescue
56
+ output_params = {:code => 500, :result => "Gms_2.get_advanced_by_external: Something wrong", :body => {:request_message => input_params}}
57
+ end
58
+ end
59
+ thr1_get_advanced_by_external.join
60
+
61
+ internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Gms_2.get_advanced_by_external"}, "debug")
62
+ output_params
63
+
64
+ end
65
+
66
+
67
+
68
+
69
+ 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.8"
2
+ VERSION = "1.1.13"
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.8
4
+ version: 1.1.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dzmitry Buynovskiy
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-29 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
@@ -222,10 +227,12 @@ files:
222
227
  - lib/imperituroard/projects/iot/internal_functions.rb
223
228
  - lib/imperituroard/projects/iot/mongoconnector.rb
224
229
  - lib/imperituroard/projects/mhub.rb
230
+ - lib/imperituroard/projects/mhub/gms.rb
225
231
  - lib/imperituroard/projects/mhub/infobip.rb
226
232
  - lib/imperituroard/projects/mhub/sk.rb
227
233
  - lib/imperituroard/projects/mhub/subs/dabrab/dabrab_platform.rb
228
234
  - lib/imperituroard/projects/mhub/subs/dabrab/dabrab_proced.rb
235
+ - lib/imperituroard/projects/mhub/subs/evrotorg/gms_connector.rb
229
236
  - lib/imperituroard/projects/ukaz60.rb
230
237
  - lib/imperituroard/projects/ukaz60/belgim.rb
231
238
  - lib/imperituroard/projects/ukaz60/dns.rb
@@ -245,7 +252,7 @@ metadata:
245
252
  homepage_uri: https://rubygems.org/
246
253
  source_code_uri: https://github.com/imperituroard/imperituroard
247
254
  changelog_uri: https://rubygems.org/
248
- post_install_message:
255
+ post_install_message:
249
256
  rdoc_options: []
250
257
  require_paths:
251
258
  - lib
@@ -260,9 +267,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
260
267
  - !ruby/object:Gem::Version
261
268
  version: '0'
262
269
  requirements: []
263
- rubyforge_project:
270
+ rubyforge_project:
264
271
  rubygems_version: 2.6.14
265
- signing_key:
272
+ signing_key:
266
273
  specification_version: 4
267
274
  summary: imperituroard gem
268
275
  test_files: []