imperituroard 1.1.8 → 1.1.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: 5f9c5a08701e31d0a87ce664a92db4cc736dd56a
4
- data.tar.gz: 1f5b19a4aaf12b01b0ef9f30026541f5f63e05d1
3
+ metadata.gz: 629626efbfcfa0108c2b1646a42d25856e6f3135
4
+ data.tar.gz: 8a3a7f5357873aa432d9058a2a54d933e6177c7d
5
5
  SHA512:
6
- metadata.gz: 821eec2e26448ded59f48f9a5a9564e6253fd95d302038a4f375218d0ff4215e79302adf8b5a4904aaa2b48051f37cae86657258b01f27baadf1734cf8e1d83c
7
- data.tar.gz: 6284ef90f6d634930e5a87d6dc6fc590c4a924ba2df7168023bf82ae9c7cdab42f44a8854db3731ed8462aa1b6ea935f39f824f4a4366782c6bf2086ff01fc5a
6
+ metadata.gz: 61e4e034d6b705161bc67e7c270406cbb62a0306ca18c17a619b04b6cf78af4bd802c0f59517e5856101ec75be031be38086872e68893de159412ef241aaaf53
7
+ data.tar.gz: 87151a1bbfa092b6d77fef7279cf114446dba7540ca949b897cad0a8f77270afe3833d7d49678f7e46476fb144be849a805d2bc493c2c625b3a185630f1e96ad
@@ -51,7 +51,7 @@ Gem::Specification.new do |spec|
51
51
  spec.add_dependency "ipaddr", "1.2.2"
52
52
  spec.add_dependency "simpleidn", "0.1.1"
53
53
  spec.add_dependency "net-scp", "3.0.0"
54
-
55
54
  spec.add_dependency "rails", "5.0.7.2"
56
55
 
56
+
57
57
  end
@@ -25,6 +25,7 @@ require 'imperituroard/projects/dns'
25
25
  require 'imperituroard/platforms/cps/qps_connector'
26
26
  require 'imperituroard/platforms/public/telegram'
27
27
  require 'imperituroard/projects/ukaz60'
28
+ require 'imperituroard/projects/mhub/gms'
28
29
 
29
30
  require 'json'
30
31
  require 'ipaddr'
@@ -345,6 +346,26 @@ class Mhub_2
345
346
  end
346
347
 
347
348
 
349
+ #2020.09.02 function for some procedure for get message status
350
+ class GmsFunctions_2
351
+
352
+ attr_accessor :gms_func
353
+
354
+ def initialize(gms_t_login, gms_t_password, gms_r_login, gms_r_password, telegram_api_url, telegram_chat_id)
355
+ @gms_func = Gmsgms_2.new(gms_t_login, gms_t_password, gms_r_login, gms_r_password, telegram_api_url, telegram_chat_id)
356
+ end
357
+
358
+ def get_t_status_external(external_id)
359
+ gms_func.get_t_status_external_2(external_id)
360
+ end
361
+
362
+ def get_r_status_external(external_id)
363
+ gms_func.get_r_status_external_2(external_id)
364
+ end
365
+
366
+ end
367
+
368
+
348
369
  class CpsFunctions_2
349
370
 
350
371
  attr_accessor :qps_connector
@@ -1427,6 +1427,6 @@ class IotFunctions_2
1427
1427
  p "yyyyy"
1428
1428
 
1429
1429
  #fff = HuaIot.new("134.17.93.4", "443", "/Users/imperituroard/Desktop/cert.crt", "/Users/imperituroard/Desktop/key.pem")
1430
- p hua_aceanconnect_connector.querying_device_id("Jy5KpoBUOScZEcrO2bRZhzfaIOUa", "VFFWTOb9k3_cQhzrGsRWT4HE8Z0a", "123456789876543")
1430
+ p hua_aceanconnect_connector.querying_device_id("Jy5KpoBUOScZEcrO2bRZhzfaIOUa", "VFFWTOb9k3_cQhzrGsRWT4HE8Z0a", "123412341284999")
1431
1431
  end
1432
1432
  end
@@ -82,6 +82,7 @@ class HuaIot
82
82
  request.content_type = 'application/x-www-form-urlencoded'
83
83
  request.body = URI.encode_www_form(data)
84
84
  res = https.request(request)
85
+ p "get_token"
85
86
  p res.code
86
87
  p res.message
87
88
  p res.body.to_s
@@ -293,30 +294,30 @@ class HuaIot
293
294
 
294
295
  #2.2.44 Querying the Device ID
295
296
  def querying_device_id(app_id, secret, node_id)
296
- token = get_token(app_id, secret)[:body]["accessToken"]
297
- p token
298
- path = "/iocm/app/dm/v1.1.0/queryDeviceIdByNodeId?nodeId=" + node_id + "&appId=Jy5KpoBUOScZEcrO2bRZhzfaIOUa"
299
- p path
300
- p path
301
- url_string = "https://" + platformip + ":" + platformport + path
302
- p url_string
303
- uri = URI.parse url_string
304
- https = Net::HTTP.new(uri.host, uri.port)
305
- https.use_ssl = true
306
- https.cert = OpenSSL::X509::Certificate.new(File.read(cert_file))
307
- https.key = OpenSSL::PKey::RSA.new(File.read(key_file))
308
- https.verify_mode = OpenSSL::SSL::VERIFY_NONE
309
- request = Net::HTTP::Get.new(uri.path)
310
- request.content_type = 'application/json'
311
- request['Authorization'] = 'Bearer ' + token
312
- request['app_key'] = app_id
313
- #request['node-id'] = node_id
314
- bbb = {"nodeId": node_id, "appId": "Jy5KpoBUOScZEcrO2bRZhzfaIOUa"}.to_json
315
- request.body = bbb
316
- res = https.request(request)
317
- p res.body.to_s
318
- p res.code
319
- {:code => res.code, :message => res.message, :body => valid_json?(res.body.to_s)}
297
+ get_token_data = get_token(app_id, secret)
298
+ if get_token_data[:code]=="200"
299
+ token = get_token_data[:body]["accessToken"]
300
+ uri1 = URI("https://134.17.93.4:8743/iocm/app/dm/v1.1.0/queryDeviceIdByNodeId?nodeId=" + node_id + "&" + app_id)
301
+ https = Net::HTTP.new(uri1.host, uri1.port)
302
+ https.use_ssl = true
303
+ https.cert = OpenSSL::X509::Certificate.new(File.read(cert_file))
304
+ https.key = OpenSSL::PKey::RSA.new(File.read(key_file))
305
+ https.verify_mode = OpenSSL::SSL::VERIFY_NONE
306
+ request = Net::HTTP::Get.new(uri1)
307
+ request.content_type = 'application/json'
308
+ request['app_key'] = app_id
309
+ request['Authorization'] = 'Bearer ' + token
310
+ #request.set_form_data( params )
311
+ #request['node-id'] = node_id
312
+ bbb = {"nodeId": node_id, "appId": "Jy5KpoBUOScZEcrO2bRZhzfaIOUa"}.to_json
313
+ #request.body = bbb
314
+ res = https.request(request)
315
+ #p res.body.to_s
316
+ #p res.code
317
+ {:code => res.code, :message => res.message, :body => valid_json?(res.body.to_s)}
318
+ else
319
+ {:code => "500", :message => "Something wrong", :body => {}}
320
+ end
320
321
  end
321
322
 
322
323
  #2.2.14 Querying Device Activation Status
@@ -146,11 +146,12 @@ class MhubFunctions_2
146
146
  output_params
147
147
  end
148
148
 
149
-
150
149
  def test2
151
150
  hh = Infobip_1.new
152
151
  hh.test
153
152
  end
154
153
 
155
154
 
156
- end
155
+ end
156
+
157
+
@@ -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
+
@@ -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
@@ -1,4 +1,4 @@
1
1
  module Imperituroard
2
- VERSION = "1.1.8"
2
+ VERSION = "1.1.9"
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.9
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-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -222,10 +222,12 @@ files:
222
222
  - lib/imperituroard/projects/iot/internal_functions.rb
223
223
  - lib/imperituroard/projects/iot/mongoconnector.rb
224
224
  - lib/imperituroard/projects/mhub.rb
225
+ - lib/imperituroard/projects/mhub/gms.rb
225
226
  - lib/imperituroard/projects/mhub/infobip.rb
226
227
  - lib/imperituroard/projects/mhub/sk.rb
227
228
  - lib/imperituroard/projects/mhub/subs/dabrab/dabrab_platform.rb
228
229
  - lib/imperituroard/projects/mhub/subs/dabrab/dabrab_proced.rb
230
+ - lib/imperituroard/projects/mhub/subs/evrotorg/gms_connector.rb
229
231
  - lib/imperituroard/projects/ukaz60.rb
230
232
  - lib/imperituroard/projects/ukaz60/belgim.rb
231
233
  - lib/imperituroard/projects/ukaz60/dns.rb
@@ -245,7 +247,7 @@ metadata:
245
247
  homepage_uri: https://rubygems.org/
246
248
  source_code_uri: https://github.com/imperituroard/imperituroard
247
249
  changelog_uri: https://rubygems.org/
248
- post_install_message:
250
+ post_install_message:
249
251
  rdoc_options: []
250
252
  require_paths:
251
253
  - lib
@@ -260,9 +262,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
260
262
  - !ruby/object:Gem::Version
261
263
  version: '0'
262
264
  requirements: []
263
- rubyforge_project:
265
+ rubyforge_project:
264
266
  rubygems_version: 2.6.14
265
- signing_key:
267
+ signing_key:
266
268
  specification_version: 4
267
269
  summary: imperituroard gem
268
270
  test_files: []