imperituroard 0.3.5 → 0.3.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -11
- data/imperituroard.gemspec +1 -1
- data/lib/imperituroard/projects/iot/hua_oceanconnect_adapter.rb +1 -1
- data/lib/imperituroard/projects/iot/internal_functions.rb +1 -1
- data/lib/imperituroard/projects/mhub/infobip.rb +15 -0
- data/lib/imperituroard/projects/mhub/sk.rb +152 -0
- data/lib/imperituroard/projects/mhub/subs/dabrab/dabrab_proced.rb +8 -0
- data/lib/imperituroard/projects/wttx/updatepostcps.rb +2 -2
- data/lib/imperituroard/version.rb +1 -1
- data/lib/imperituroard.rb +80 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e3e7410b715b2528c3d416e5a81123344be298b
|
4
|
+
data.tar.gz: 2029812a6b530bb3b99d78b6e7c7ebbb3090719f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0374e67308f658d3e6ec990ccfb3d42b99ac6607773fd024eb1ad90b5e193cb19187526c39c096a4163e964afdb7411a9b0c821bfc917b7737da00fb26f96fac
|
7
|
+
data.tar.gz: 7c3031eb6254f1ec1cef713dab84093ae747459b787808460ef282e5a4d3c475e75bad75b3d29875861011c75247e4f848a7a10d82837cbc9009e0b32a61376d
|
data/Gemfile
CHANGED
@@ -2,14 +2,3 @@ source "https://rubygems.org"
|
|
2
2
|
|
3
3
|
# Specify your gem's dependencies in imperituroard.gemspec
|
4
4
|
gemspec
|
5
|
-
|
6
|
-
gem "rake", ">= 12.3.3"
|
7
|
-
gem "minitest", "5.14.0"
|
8
|
-
gem 'mysql2', '>= 0.3.13', '< 0.5'
|
9
|
-
gem 'savon', '2.12.0'
|
10
|
-
gem 'json', '2.3.0'
|
11
|
-
#gem 'uri'
|
12
|
-
gem 'mongo', '2.11.4'
|
13
|
-
gem 'nokogiri'
|
14
|
-
gem 'rails'
|
15
|
-
gem 'ipaddr'
|
data/imperituroard.gemspec
CHANGED
@@ -33,8 +33,8 @@ Gem::Specification.new do |spec|
|
|
33
33
|
spec.add_development_dependency "mysql2", "0.4.10"
|
34
34
|
spec.add_development_dependency "savon", "2.12.0"
|
35
35
|
spec.add_development_dependency "json", "2.3.0"
|
36
|
-
#spec.add_development_dependency "uri"
|
37
36
|
spec.add_development_dependency "mongo", "2.11.4"
|
38
37
|
spec.add_development_dependency "nokogiri", "1.10.9"
|
39
38
|
spec.add_development_dependency "ipaddr", "1.2.2"
|
39
|
+
|
40
40
|
end
|
@@ -232,7 +232,7 @@ class HuaIot
|
|
232
232
|
def querying_device_id(app_id, secret, node_id)
|
233
233
|
token = get_token(app_id, secret)[:body]["accessToken"]
|
234
234
|
p token
|
235
|
-
path = "/iocm/app/dm/v1.1.0/queryDeviceIdByNodeId?nodeId=" + node_id
|
235
|
+
path = "/iocm/app/dm/v1.1.0/queryDeviceIdByNodeId?nodeId=" + node_id + "&appId=Cd1v0k2gTBCbpQlMVlW1FVqOSqga"
|
236
236
|
p path
|
237
237
|
p path
|
238
238
|
url_string = "https://" + platformip + ":" + platformport + path
|
@@ -21,7 +21,7 @@ class InternalFunc
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def printer_texter(text, log_level)
|
24
|
-
mess = {:datetime => datetimenow, :sdk=> "imperituroard", :sdk_version=>
|
24
|
+
mess = {:datetime => datetimenow, :sdk=> "imperituroard", :sdk_version=> Imperituroard::VERSION, :message => text}
|
25
25
|
p mess
|
26
26
|
end
|
27
27
|
|
@@ -0,0 +1,15 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
#https://dev.infobip.com/#programmable-communications/sms/sms-preview
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
|
8
|
+
class Infobip_1
|
9
|
+
|
10
|
+
def test
|
11
|
+
gg = "{\"destinations\"=>[{\"to\"=>{\"phoneNumber\"=>\"375297116638\", \"emailAddress\"=>nil}}], \"scenarioKey\"=>\"1\", \"viber\"=>nil, \"sms\"=>{\"text\"=>\"карточка готова\"}, \"sendAt\"=>\"2019-08-15T08:40:00.000\", \"notifyUrl\"=>\"https://bpmonline.bankdabrabyt.by:444/0/ServiceModel/ScGetReports.svc/GetReports\", \"notifyContentType\"=>\"application/json\", \"controller\"=>\"bank\", \"action\"=>\"api\", \"bank\"=>{\"destinations\"=>[{\"to\"=>{\"phoneNumber\"=>\"375297116638\", \"emailAddress\"=>nil}}], \"scenarioKey\"=>\"1\", \"viber\"=>nil, \"sms\"=>{\"text\"=>\"карточка готова\"}, \"sendAt\"=>\"2019-08-15T08:40:00.000\", \"notifyUrl\"=>\"https://bpmonline.bankdabrabyt.by:444/0/ServiceModel/ScGetReports.svc/GetReports\", \"notifyContentType\"=>\"application/json\"}}"
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
@@ -0,0 +1,152 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
class Sksk_1
|
6
|
+
|
7
|
+
attr_accessor :sk_url, :sk_login, :sk_password
|
8
|
+
|
9
|
+
def initialize(sk_url, sk_login, sk_password)
|
10
|
+
@sk_url = sk_url
|
11
|
+
@sk_login = sk_login
|
12
|
+
@sk_password = sk_password
|
13
|
+
@internal_func = InternalFunc.new
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
|
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
|
+
|
49
|
+
p request_message
|
50
|
+
|
51
|
+
req.body = request_message.to_json
|
52
|
+
p req.body
|
53
|
+
p req
|
54
|
+
|
55
|
+
res = https.request(req)
|
56
|
+
|
57
|
+
p res.body
|
58
|
+
p res.code
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
|
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
|
102
|
+
end
|
103
|
+
|
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
|
+
|
150
|
+
|
151
|
+
|
152
|
+
end
|
@@ -52,7 +52,7 @@ class StateWTTX
|
|
52
52
|
|
53
53
|
|
54
54
|
|
55
|
-
if resultcode
|
55
|
+
if resultcode == false
|
56
56
|
"false"
|
57
57
|
else
|
58
58
|
regimsi = /<field code=\"imsi\" value=\"([0-9]{10,15})\"/
|
@@ -65,7 +65,7 @@ class StateWTTX
|
|
65
65
|
|
66
66
|
res = resultcode.to_s + " " + imsi + " " + imei
|
67
67
|
p res
|
68
|
-
|
68
|
+
res
|
69
69
|
end
|
70
70
|
|
71
71
|
end
|
data/lib/imperituroard.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
$LOAD_PATH.unshift File.expand_path("../projects/iot", __dir__)
|
2
2
|
$LOAD_PATH.unshift File.expand_path("../projects/wttx", __dir__)
|
3
|
+
$LOAD_PATH.unshift File.expand_path("../projects/mhub", __dir__)
|
3
4
|
|
4
5
|
require "imperituroard/version"
|
5
6
|
require "imperituroard/phpipamdb"
|
@@ -8,9 +9,13 @@ require "imperituroard/projects/iot/mongoconnector"
|
|
8
9
|
require "imperituroard/projects/iot/hua_oceanconnect_adapter"
|
9
10
|
require "imperituroard/projects/iot/add_functions"
|
10
11
|
require "imperituroard/projects/iot/internal_functions"
|
12
|
+
require 'imperituroard/projects/mhub/infobip'
|
13
|
+
require 'imperituroard/projects/mhub/sk'
|
11
14
|
require 'json'
|
12
15
|
require 'ipaddr'
|
13
16
|
require 'date'
|
17
|
+
require 'net/http'
|
18
|
+
require 'uri'
|
14
19
|
|
15
20
|
module Imperituroard
|
16
21
|
class Error < StandardError;
|
@@ -784,7 +789,81 @@ class Iot
|
|
784
789
|
#p ddd.get_device_type_info_by_model("BGT_PPMC11")
|
785
790
|
|
786
791
|
#fff = HuaIot.new("134.17.93.4", "443", "/Users/imperituroard/Desktop/cert.crt", "/Users/imperituroard/Desktop/key.pem")
|
787
|
-
|
792
|
+
p hua_aceanconnect_connector.querying_device_id("Cd1v0k2gTBCbpQlMVlW1FVqOSqga", "eWllZpHgXgvgDAQlJjWs4QXaR94a", "91234")
|
788
793
|
end
|
789
794
|
|
790
795
|
end
|
796
|
+
|
797
|
+
|
798
|
+
class Mhub_2
|
799
|
+
|
800
|
+
attr_accessor :sk_url, :sk_login, :sk_password, :mhub_connector
|
801
|
+
|
802
|
+
def initialize(sk_url, sk_login, sk_password, telegram_api_url, telegram_chat_id)
|
803
|
+
@sk_url = sk_url
|
804
|
+
@sk_login = sk_login
|
805
|
+
@sk_password = sk_password
|
806
|
+
@internal_func = InternalFunc.new
|
807
|
+
@mhub_connector = Sksk_1.new(sk_url, sk_login, sk_password)
|
808
|
+
@internal_func = InternalFunc.new
|
809
|
+
@add_functions_connector = AdditionalFunc.new(telegram_api_url, telegram_chat_id)
|
810
|
+
end
|
811
|
+
|
812
|
+
|
813
|
+
#{"destinations"=>[{"to"=>{"phoneNumber"=>"375297116638", "emailAddress"=>nil}}],
|
814
|
+
# "scenarioKey"=>"1", "viber"=>nil, "sms"=>{"text"=>"карточка готова"},
|
815
|
+
# "sendAt"=>"2019-08-15T08:40:00.000", "notifyUrl"=>"https://bpmonline.bankdabrabyt.by:444/0/ServiceModel/ScGetReports.svc/GetReports",
|
816
|
+
# "notifyContentType"=>"application/json", "controller"=>"bank", "action"=>"api",
|
817
|
+
# "bank"=>{"destinations"=>[{"to"=>{"phoneNumber"=>"375297116638", "emailAddress"=>nil}}], "scenarioKey"=>"1",
|
818
|
+
# "viber"=>nil, "sms"=>{"text"=>"карточка готова"}, "sendAt"=>"2019-08-15T08:40:00.000",
|
819
|
+
# "notifyUrl"=>"https://bpmonline.bankdabrabyt.by:444/0/ServiceModel/ScGetReports.svc/GetReports",
|
820
|
+
# "notifyContentType"=>"application/json"}}
|
821
|
+
|
822
|
+
|
823
|
+
def get_send_message(params)
|
824
|
+
|
825
|
+
input_params = {:params => params}
|
826
|
+
|
827
|
+
p input_params
|
828
|
+
|
829
|
+
output_params = {}
|
830
|
+
|
831
|
+
begin
|
832
|
+
|
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
|
+
|
848
|
+
else
|
849
|
+
|
850
|
+
output_params = {:code => 501, :result => "Invalid input data"}
|
851
|
+
|
852
|
+
end
|
853
|
+
|
854
|
+
rescue
|
855
|
+
output_params = {:code => 500, :result => "Invalid input data"}
|
856
|
+
end
|
857
|
+
|
858
|
+
internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Mhub_2.get_send_message"}, "debug")
|
859
|
+
|
860
|
+
|
861
|
+
end
|
862
|
+
|
863
|
+
|
864
|
+
def test2
|
865
|
+
hh = Infobip_1.new
|
866
|
+
hh.test
|
867
|
+
end
|
868
|
+
|
869
|
+
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.
|
4
|
+
version: 0.3.7
|
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-04
|
11
|
+
date: 2020-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -165,6 +165,9 @@ files:
|
|
165
165
|
- lib/imperituroard/projects/iot/hua_oceanconnect_adapter.rb
|
166
166
|
- lib/imperituroard/projects/iot/internal_functions.rb
|
167
167
|
- lib/imperituroard/projects/iot/mongoconnector.rb
|
168
|
+
- lib/imperituroard/projects/mhub/infobip.rb
|
169
|
+
- lib/imperituroard/projects/mhub/sk.rb
|
170
|
+
- lib/imperituroard/projects/mhub/subs/dabrab/dabrab_proced.rb
|
168
171
|
- lib/imperituroard/projects/wttx/updatepostcps.rb
|
169
172
|
- lib/imperituroard/version.rb
|
170
173
|
homepage: https://rubygems.org/
|