imperituroard 0.5.5 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/imperituroard.gemspec +3 -0
- data/lib/.DS_Store +0 -0
- data/lib/imperituroard.rb +97 -71
- data/lib/imperituroard/.DS_Store +0 -0
- data/lib/imperituroard/platforms/cps/cps_multiple_thread_req.rb +0 -0
- data/lib/imperituroard/platforms/staros/get_data_ssh.rb +54 -0
- data/lib/imperituroard/platforms/staros/staros_automation.rb +95 -0
- data/lib/imperituroard/platforms/staros/staros_automation_fun.rb +37 -0
- data/lib/imperituroard/platforms/staros/staros_parser.rb +141 -0
- data/lib/imperituroard/projects/dns.rb +1 -1
- data/lib/imperituroard/projects/iot.rb +191 -30
- data/lib/imperituroard/projects/iot/hua_oceanconnect_adapter.rb +22 -8
- data/lib/imperituroard/projects/iot/mongoconnector.rb +177 -2
- data/lib/imperituroard/projects/mhub.rb +2 -0
- data/lib/imperituroard/projects/mhub/infobip.rb +1 -1
- data/lib/imperituroard/projects/mhub/sk.rb +171 -157
- data/lib/imperituroard/projects/mhub/subs/dabrab/dabrab_proced.rb +124 -12
- data/lib/imperituroard/projects/ukaz60.rb +140 -0
- data/lib/imperituroard/projects/{dns/ukaz60 → ukaz60}/belgim.rb +48 -9
- data/lib/imperituroard/projects/{dns/ukaz60 → ukaz60}/dns.rb +0 -0
- data/lib/imperituroard/projects/{dns/ukaz60 → ukaz60}/dns_update.rb +0 -0
- data/lib/imperituroard/projects/{dns/ukaz60 → ukaz60}/fortigate.rb +43 -4
- data/lib/imperituroard/projects/ukaz60/staros.rb +141 -0
- data/lib/imperituroard/projects/{dns/ukaz60 → ukaz60}/ukaz60_add_func.rb +159 -4
- data/lib/imperituroard/version.rb +1 -1
- metadata +28 -8
- data/lib/imperituroard/projects/dns/ukaz60.rb +0 -87
@@ -6,13 +6,14 @@ require 'rubygems'
|
|
6
6
|
require 'nokogiri'
|
7
7
|
require 'rails'
|
8
8
|
require "imperituroard/projects/iot/internal_functions"
|
9
|
+
require 'imperituroard/projects/iot/mongoconnector'
|
9
10
|
|
10
11
|
|
11
12
|
class HuaIot
|
12
13
|
|
13
|
-
attr_accessor :platformip, :platformport, :client, :database, :cert_file, :key_file, :internal_func
|
14
|
+
attr_accessor :platformip, :platformport, :client, :database, :cert_file, :key_file, :internal_func, :client_iot_mongo
|
14
15
|
|
15
|
-
def initialize(platformip, platformport, cert_file, key_file)
|
16
|
+
def initialize(platformip, platformport, cert_file, key_file, mongo_ip, mongo_port, mongo_database)
|
16
17
|
@database = database
|
17
18
|
@platformip = platformip
|
18
19
|
@platformport = platformport
|
@@ -21,6 +22,7 @@ class HuaIot
|
|
21
22
|
#client_host = [mongoip + ":" + mongoport]
|
22
23
|
#@client = Mongo::Client.new(client_host, :database => database)
|
23
24
|
@internal_func = InternalFunc.new
|
25
|
+
@client_iot_mongo = MongoIot.new(mongo_ip, mongo_port, mongo_database)
|
24
26
|
end
|
25
27
|
|
26
28
|
def parse_token(str)
|
@@ -157,13 +159,18 @@ class HuaIot
|
|
157
159
|
manufacturerName: manufacturer_name,
|
158
160
|
model: model,
|
159
161
|
isSecurity: "FALSE",
|
160
|
-
supportedSecurity: "FALSE"}}
|
162
|
+
supportedSecurity: "FALSE"}}
|
161
163
|
internal_func.printer_texter({:procedure => "dev_register_passw_code_mode2", :data => {:body => data_out, :url => url_string}}, "debug")
|
162
|
-
request.body = data_out
|
164
|
+
request.body = data_out.to_json
|
163
165
|
res = https.request(request)
|
164
|
-
p res.body.to_s
|
165
166
|
out_resp = {:code => res.code, :message => res.message, :body => JSON.parse(res.body.to_s)}
|
166
|
-
|
167
|
+
fff = {:func => "dev_register_passw_code_mode2",
|
168
|
+
:iot_fun => "2.2.4",
|
169
|
+
:req_header => {:authorization => 'Bearer ' + token,
|
170
|
+
:content_type => 'application/json',
|
171
|
+
:app_key => app_id
|
172
|
+
}}
|
173
|
+
client_iot_mongo.audit_iot_logger(fff, url_string, data_out, out_resp)
|
167
174
|
out_resp
|
168
175
|
end
|
169
176
|
|
@@ -221,6 +228,14 @@ class HuaIot
|
|
221
228
|
else
|
222
229
|
out_resp = {:code => res.code, :message => res.message, :body => {:answ => "no data"}}
|
223
230
|
end
|
231
|
+
|
232
|
+
fff = {:func => "dev_delete",
|
233
|
+
:iot_fun => "2.2.12",
|
234
|
+
:req_header => {:authorization => 'Bearer ' + token,
|
235
|
+
:content_type => 'application/json',
|
236
|
+
:app_key => app_id
|
237
|
+
}}
|
238
|
+
client_iot_mongo.audit_iot_logger(fff, url_string, "Delete", out_resp)
|
224
239
|
rescue
|
225
240
|
out_resp = {:code => 500, :message => "dev_delete: Unknown IOT error"}
|
226
241
|
end
|
@@ -364,7 +379,7 @@ class HuaIot
|
|
364
379
|
begin
|
365
380
|
path = "/iocm/app/dm/v1.4.0/devices/" + dev_id + "?app_Id=" + app_id
|
366
381
|
url_string = "https://" + platformip + ":" + platformport + path
|
367
|
-
internal_func.printer_texter({:url_string=>url_string, :procedure=>"dev_modify_location_v2"}, "debug")
|
382
|
+
internal_func.printer_texter({:url_string => url_string, :procedure => "dev_modify_location_v2"}, "debug")
|
368
383
|
uri = URI.parse url_string
|
369
384
|
https = Net::HTTP.new(uri.host, uri.port)
|
370
385
|
https.use_ssl = true
|
@@ -392,7 +407,6 @@ class HuaIot
|
|
392
407
|
end
|
393
408
|
|
394
409
|
|
395
|
-
|
396
410
|
##2.10.7 Adding Members to a Device Group
|
397
411
|
|
398
412
|
|
@@ -41,6 +41,30 @@ class MongoIot
|
|
41
41
|
out_resp
|
42
42
|
end
|
43
43
|
|
44
|
+
def audit_iot_logger(proc_name, url_str, input_json, output_json)
|
45
|
+
out_resp = {}
|
46
|
+
p "iiiiiiiot"
|
47
|
+
p input_json
|
48
|
+
begin
|
49
|
+
current = internal_func.datetimenow
|
50
|
+
collection = client[:audit_iot_platform]
|
51
|
+
doc = {
|
52
|
+
:proc_name => proc_name,
|
53
|
+
:date => current,
|
54
|
+
:url => url_str,
|
55
|
+
:iot_platform_request => input_json,
|
56
|
+
:iot_platform_responce => output_json
|
57
|
+
}
|
58
|
+
p doc
|
59
|
+
result = collection.insert_one(doc)
|
60
|
+
out_resp = {:code => 200, :result => "audit_logger: Request completed successfully", :body => result}
|
61
|
+
rescue
|
62
|
+
out_resp = {:code => 507, :result => "audit_logger: Unknown SDK error"}
|
63
|
+
end
|
64
|
+
internal_func.printer_texter(out_resp, "debug")
|
65
|
+
out_resp
|
66
|
+
end
|
67
|
+
|
44
68
|
#:code => 507, :result => "Unknown SDK error"
|
45
69
|
#{:code => 200, :result => "Request completed successfully", :body => result_ps}
|
46
70
|
def get_profiles_by_login(login)
|
@@ -364,6 +388,7 @@ class MongoIot
|
|
364
388
|
|
365
389
|
def get_profile_name_from_imei(imei)
|
366
390
|
out_resp = {}
|
391
|
+
info = {}
|
367
392
|
begin
|
368
393
|
id = ""
|
369
394
|
begin
|
@@ -387,7 +412,7 @@ class MongoIot
|
|
387
412
|
end
|
388
413
|
begin
|
389
414
|
if res["profile"]!=nil
|
390
|
-
out_resp = {:code => 200, :result => "get_profile_name_from_imei: Request completed successfully", :body => res}
|
415
|
+
out_resp = {:code => 200, :result => "get_profile_name_from_imei: Request completed successfully", :body => res, :imei_info => info}
|
391
416
|
end
|
392
417
|
rescue
|
393
418
|
out_resp = {:code => 506, :result => "get_profile_name_from_imei: Function get_profile_name_by_id not processed correctly and returned: #{res.to_s}"}
|
@@ -523,5 +548,155 @@ class MongoIot
|
|
523
548
|
out_resp
|
524
549
|
end
|
525
550
|
|
551
|
+
def get_device_type_info_universal(device_model)
|
552
|
+
out_resp = {}
|
553
|
+
begin
|
554
|
+
as = internal_func.if_digit_or_string(device_model)
|
555
|
+
|
556
|
+
if as[:body][:string]
|
557
|
+
result_ps = []
|
558
|
+
collection = client[:device_types]
|
559
|
+
collection.find({"model" => device_model}).each {|row|
|
560
|
+
result_ps.append(row)
|
561
|
+
}
|
562
|
+
dattaa = result_ps[0]
|
563
|
+
if dattaa!=nil
|
564
|
+
out_resp = {:code => 200, :result => "get_device_type_info_by_model: Request completed successfully", :body => dattaa}
|
565
|
+
else
|
566
|
+
out_resp = {:code => 404, :result => "get_device_type_info_by_model: Device info not found", :body => {"model" => device_model, "ManufacturerID" => "unknown", "ManufacturerNAME" => "unknown", "device_type" => "unknown"}}
|
567
|
+
end
|
568
|
+
else
|
569
|
+
result_ps2 = []
|
570
|
+
collection = client[:device_types]
|
571
|
+
collection.find({"type_id" => device_model.to_i}).each {|row|
|
572
|
+
result_ps2.append(row)
|
573
|
+
}
|
574
|
+
dattaa = result_ps2[0]
|
575
|
+
if dattaa!=nil
|
576
|
+
out_resp = {:code => 200, :result => "get_device_type_info_by_model: Request completed successfully", :body => dattaa}
|
577
|
+
else
|
578
|
+
out_resp = {:code => 404, :result => "get_device_type_info_by_model: Device info not found", :body => {"model" => device_model, "ManufacturerID" => "unknown", "ManufacturerNAME" => "unknown", "device_type" => "unknown"}}
|
579
|
+
end
|
580
|
+
end
|
581
|
+
|
582
|
+
rescue
|
583
|
+
out_resp = {:code => 500, :result => "get_device_type_info_universal: procedure error", :body => {"model" => device_model, "ManufacturerID" => "unknown", "ManufacturerNAME" => "unknown", "device_type" => "unknown"}}
|
584
|
+
end
|
585
|
+
internal_func.printer_texter(out_resp, "debug")
|
586
|
+
out_resp
|
587
|
+
end
|
588
|
+
|
589
|
+
|
590
|
+
|
591
|
+
def compare_profiles(profile1, profile2)
|
592
|
+
out_answ = {}
|
593
|
+
ch1 = internal_func.if_digit_or_string(profile1)
|
594
|
+
ch2 = internal_func.if_digit_or_string(profile2)
|
595
|
+
if ch1[:body][:string] == ch2[:body][:string] && ch1[:body][:string] == false
|
596
|
+
if profile1.to_i == profile2.to_i
|
597
|
+
out_answ = {:code => 200, :result => "compare_profiles: profiles are the same", :is_the_same => true, :data_type => "integer"}
|
598
|
+
else
|
599
|
+
out_answ = {:code => 200, :result => "compare_profiles: profiles are different", :is_the_same => false, :data_type => "integer"}
|
600
|
+
end
|
601
|
+
elsif ch1[:body][:string] == ch2[:body][:string] && ch1[:body][:string] == true
|
602
|
+
if profile1 == profile2
|
603
|
+
out_answ = {:code => 200, :result => "compare_profiles: profiles are the same", :is_the_same => true, :data_type => "string"}
|
604
|
+
else
|
605
|
+
out_answ = {:code => 200, :result => "compare_profiles: profiles are different", :is_the_same => false, :data_type => "string"}
|
606
|
+
end
|
607
|
+
else
|
608
|
+
ch1_data = {}
|
609
|
+
ch2_data = {}
|
610
|
+
if ch1[:body][:string]
|
611
|
+
ch1_data = self.get_profile_id_by_name(profile1)
|
612
|
+
else
|
613
|
+
ch1_data = self.get_profile_name_by_id(profile1.to_i)
|
614
|
+
end
|
615
|
+
|
616
|
+
if ch2[:body][:string]
|
617
|
+
ch2_data = self.get_profile_id_by_name(profile2)
|
618
|
+
else
|
619
|
+
ch2_data = self.get_profile_name_by_id(profile2.to_i)
|
620
|
+
end
|
621
|
+
|
622
|
+
if ch1_data["profile_id"] == ch2_data["profile_id"]
|
623
|
+
out_answ = {:code => 200, :result => "compare_profiles: profiles are the same", :is_the_same => true, :data_type => "different"}
|
624
|
+
else
|
625
|
+
out_answ = {:code => 200, :result => "compare_profiles: profiles are different", :is_the_same => false, :data_type => "different"}
|
626
|
+
end
|
627
|
+
end
|
628
|
+
out_answ
|
629
|
+
end
|
630
|
+
|
631
|
+
def compare_device_types(type1, type2)
|
632
|
+
out_answ = {}
|
633
|
+
tp1 = internal_func.if_digit_or_string(type1)
|
634
|
+
tp2 = internal_func.if_digit_or_string(type2)
|
635
|
+
|
636
|
+
if tp1[:body][:string] == tp2[:body][:string] && tp1[:body][:string] == false
|
637
|
+
if type1.to_i == type2.to_i
|
638
|
+
out_answ = {:code => 200, :result => "compare_device_types: types are the same", :is_the_same => true, :data_type => "integer"}
|
639
|
+
else
|
640
|
+
out_answ = {:code => 200, :result => "compare_device_types: types are different", :is_the_same => false, :data_type => "integer"}
|
641
|
+
end
|
642
|
+
elsif tp1[:body][:string] == tp2[:body][:string] && tp1[:body][:string] == true
|
643
|
+
if type1 == type2
|
644
|
+
out_answ = {:code => 200, :result => "compare_device_types: types are the same", :is_the_same => true, :data_type => "string"}
|
645
|
+
else
|
646
|
+
out_answ = {:code => 200, :result => "compare_device_types: types are different", :is_the_same => false, :data_type => "string"}
|
647
|
+
end
|
648
|
+
else
|
649
|
+
tp1_data = {}
|
650
|
+
tp2_data = {}
|
651
|
+
if tp1[:body][:string]
|
652
|
+
tp1_data = self.get_type_by_name(type1)
|
653
|
+
else
|
654
|
+
tp1_data = self.get_type_by_id(type1.to_i)
|
655
|
+
end
|
656
|
+
|
657
|
+
if tp2[:body][:string]
|
658
|
+
tp2_data = self.get_type_by_name(type2)
|
659
|
+
else
|
660
|
+
tp2_data = self.get_type_by_id(type2.to_i)
|
661
|
+
end
|
662
|
+
|
663
|
+
if tp1_data["type_id"] == tp2_data["type_id"]
|
664
|
+
out_answ = {:code => 200, :result => "compare_device_types: profiles are the same", :is_the_same => true, :data_type => "different"}
|
665
|
+
else
|
666
|
+
out_answ = {:code => 200, :result => "compare_device_types: profiles are different", :is_the_same => false, :data_type => "different"}
|
667
|
+
end
|
668
|
+
end
|
669
|
+
out_answ
|
670
|
+
end
|
671
|
+
|
672
|
+
|
673
|
+
def get_profile_universal(profile)
|
674
|
+
inn = internal_func.if_digit_or_string(profile)
|
675
|
+
out = {}
|
676
|
+
if inn[:body][:string]
|
677
|
+
out = self.get_profile_id_by_name(profile)
|
678
|
+
else
|
679
|
+
out = self.get_profile_name_by_id(profile.to_i)
|
680
|
+
end
|
681
|
+
out
|
682
|
+
end
|
683
|
+
|
684
|
+
def modify_attr_mongo_universal(imei, attribute)
|
685
|
+
out_resp = {}
|
686
|
+
begin
|
687
|
+
collection = client[:device_imei]
|
688
|
+
doc = {
|
689
|
+
"imei" => imei
|
690
|
+
}
|
691
|
+
sett = {'$set' => attribute}
|
692
|
+
result = collection.update_one(doc, sett)
|
693
|
+
out_resp = {:code => 200, :result => "modify_attr_mongo_universal: Request completed successfully"}
|
694
|
+
rescue
|
695
|
+
out_resp = {:code => 507, :result => "modify_attr_mongo_universal: Unknown SDK error"}
|
696
|
+
end
|
697
|
+
internal_func.printer_texter(out_resp, "debug")
|
698
|
+
out_resp
|
699
|
+
end
|
700
|
+
|
701
|
+
end
|
526
702
|
|
527
|
-
end
|
@@ -51,6 +51,7 @@ class MhubFunctions_2
|
|
51
51
|
# "notifyContentType"=>"application/json"}}
|
52
52
|
|
53
53
|
|
54
|
+
#for bank dabrabyt
|
54
55
|
def get_send_message_2(params, ip_src, ip_real, ip_vip)
|
55
56
|
|
56
57
|
input_params = {:params => params}
|
@@ -123,6 +124,7 @@ class MhubFunctions_2
|
|
123
124
|
end
|
124
125
|
|
125
126
|
|
127
|
+
#for bank dabrabyt
|
126
128
|
def rec_deliv_report_2(params, ip_src, ip_real, ip_vip)
|
127
129
|
input_params = {:params => params, :ip_src => ip_src, :ip_real => ip_real, :ip_vip => ip_vip}
|
128
130
|
output_params = {}
|
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
|
7
7
|
|
8
|
-
class
|
8
|
+
class Infobip_2
|
9
9
|
|
10
10
|
def test
|
11
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\"}}"
|
@@ -1,8 +1,9 @@
|
|
1
1
|
require 'imperituroard/projects/iot/internal_functions'
|
2
|
+
require 'imperituroard/projects/mhub/subs/dabrab/dabrab_proced'
|
2
3
|
|
3
4
|
class Sksk_2
|
4
5
|
|
5
|
-
attr_accessor :sk_url, :sk_url_broadcast, :sk_login, :sk_password, :internal_func, :telegram_connector
|
6
|
+
attr_accessor :sk_url, :sk_url_broadcast, :sk_login, :sk_password, :internal_func, :telegram_connector, :dabrab_add_func
|
6
7
|
|
7
8
|
def initialize(sk_url, sk_login, sk_password, sk_url_broadcast, telegram_api_url, telegram_chat_id)
|
8
9
|
@sk_url = sk_url
|
@@ -11,6 +12,7 @@ class Sksk_2
|
|
11
12
|
@internal_func = InternalFunc.new
|
12
13
|
@sk_url_broadcast = sk_url_broadcast
|
13
14
|
@telegram_connector = Telegram_2.new(telegram_api_url, telegram_chat_id)
|
15
|
+
@dabrab_add_func = Dabrab.new
|
14
16
|
end
|
15
17
|
|
16
18
|
|
@@ -82,50 +84,49 @@ class Sksk_2
|
|
82
84
|
request_message = {}
|
83
85
|
|
84
86
|
begin
|
85
|
-
|
86
87
|
thr_sk_send_viber_one = Thread.new do
|
88
|
+
viber_mess_ans = dabrab_add_func.dabrabyt_text_field_parse(text)
|
89
|
+
|
90
|
+
if viber_mess_ans[:code] == 200
|
91
|
+
uri = URI(sk_url)
|
92
|
+
#8 - client id
|
93
|
+
|
94
|
+
https = Net::HTTP.new(uri.host, uri.port)
|
95
|
+
https.use_ssl=true
|
96
|
+
https.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
97
|
+
req = Net::HTTP::Post.new(uri.path, initheader = {:"Content-Type" => 'application/json'})
|
98
|
+
|
99
|
+
req.basic_auth sk_login, sk_password
|
100
|
+
|
101
|
+
req["Content-Type"] = "application/json"
|
102
|
+
req["Accept"] = "application/json"
|
103
|
+
|
104
|
+
request_message = {
|
105
|
+
"phone_number": msisdn,
|
106
|
+
#"extra_id": "4232j4h89932kjhs",
|
107
|
+
"callback_url": callback_url,
|
108
|
+
#"start_time": "2019-08-16 09:59:10",
|
109
|
+
"tag": "Dabrab_custom_api_1",
|
110
|
+
"channels": [
|
111
|
+
"viber"
|
112
|
+
],
|
113
|
+
"channel_options": {
|
114
|
+
"viber": viber_mess_ans[:body][:to_sk_format]
|
115
|
+
}
|
116
|
+
}
|
117
|
+
req.body = request_message.to_json
|
118
|
+
res = https.request(req)
|
119
|
+
output_params = {:code => 200,
|
120
|
+
:result => "Sksk_2.sk_send_viber_one: Request processed",
|
121
|
+
:body => {:request_message => request_message,
|
122
|
+
:res_code => res.code,
|
123
|
+
:res_body => JSON.parse(res.body.to_s)}}
|
124
|
+
|
125
|
+
else
|
126
|
+
output_params = {:code => 508, :result => "Sksk_2.sk_send_viber_one: Something wrong with dabrabyt_text_field_parse"}
|
127
|
+
end
|
87
128
|
|
88
129
|
|
89
|
-
uri = URI(sk_url)
|
90
|
-
#8 - client id
|
91
|
-
|
92
|
-
https = Net::HTTP.new(uri.host, uri.port)
|
93
|
-
https.use_ssl=true
|
94
|
-
https.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
95
|
-
req = Net::HTTP::Post.new(uri.path, initheader = {:"Content-Type" => 'application/json'})
|
96
|
-
|
97
|
-
req.basic_auth sk_login, sk_password
|
98
|
-
|
99
|
-
req["Content-Type"] = "application/json"
|
100
|
-
req["Accept"] = "application/json"
|
101
|
-
|
102
|
-
request_message = {
|
103
|
-
"phone_number": msisdn,
|
104
|
-
#"extra_id": "4232j4h89932kjhs",
|
105
|
-
"callback_url": callback_url,
|
106
|
-
#"start_time": "2019-08-16 09:59:10",
|
107
|
-
"tag": "Dabrab_custom_api_1",
|
108
|
-
"channels": [
|
109
|
-
"viber"
|
110
|
-
],
|
111
|
-
"channel_options": {
|
112
|
-
"viber": {
|
113
|
-
"text": text,
|
114
|
-
"ttl": 60,
|
115
|
-
# "img": "http://olddogs.org/logo.png",
|
116
|
-
# "caption": "Old Dogs need you!",
|
117
|
-
# "action": "http://olddogs.org",
|
118
|
-
},
|
119
|
-
}
|
120
|
-
}
|
121
|
-
req.body = request_message.to_json
|
122
|
-
res = https.request(req)
|
123
|
-
output_params = {:code => 200,
|
124
|
-
:result => "Sksk_2.sk_send_viber_one: Request processed",
|
125
|
-
:body => {:request_message => request_message,
|
126
|
-
:res_code => res.code,
|
127
|
-
:res_body => JSON.parse(res.body.to_s)}}
|
128
|
-
|
129
130
|
end
|
130
131
|
|
131
132
|
thr_sk_send_viber_one.join
|
@@ -149,53 +150,54 @@ class Sksk_2
|
|
149
150
|
|
150
151
|
thr_sk_send_viber_sms_one = Thread.new do
|
151
152
|
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
153
|
+
viber_mess_ans = dabrab_add_func.dabrabyt_text_field_parse(viber_txt)
|
154
|
+
|
155
|
+
if viber_mess_ans[:code] == 200
|
156
|
+
uri = URI(sk_url)
|
157
|
+
#8 - client id
|
158
|
+
|
159
|
+
https = Net::HTTP.new(uri.host, uri.port)
|
160
|
+
https.use_ssl=true
|
161
|
+
https.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
162
|
+
req = Net::HTTP::Post.new(uri.path, initheader = {:"Content-Type" => 'application/json'})
|
163
|
+
|
164
|
+
req.basic_auth sk_login, sk_password
|
165
|
+
|
166
|
+
req["Content-Type"] = "application/json"
|
167
|
+
req["Accept"] = "application/json"
|
168
|
+
|
169
|
+
request_message = {
|
170
|
+
"phone_number": msisdn,
|
171
|
+
#"extra_id": "4232j4h89932kjhs",
|
172
|
+
"callback_url": callback_url,
|
173
|
+
#"start_time": "2019-08-16 09:59:10",
|
174
|
+
"tag": "Dabrab_custom_api_1",
|
175
|
+
"channels": [
|
176
|
+
"viber",
|
177
|
+
"sms"
|
178
|
+
],
|
179
|
+
"channel_options": {
|
180
|
+
"sms": {
|
181
|
+
"text": sms_text,
|
182
|
+
"alpha_name": alphaname,
|
183
|
+
"ttl": 600
|
184
|
+
},
|
185
|
+
"viber": viber_mess_ans[:body][:to_sk_format]
|
186
|
+
}
|
187
|
+
}
|
188
|
+
|
189
|
+
req.body = request_message.to_json
|
190
|
+
res = https.request(req)
|
191
|
+
|
192
|
+
output_params = {:code => 200,
|
193
|
+
:result => "Sksk_2.sk_send_viber_sms_one: Request processed",
|
194
|
+
:body => {:request_message => request_message,
|
195
|
+
:res_code => res.code,
|
196
|
+
:res_body => JSON.parse(res.body.to_s)}}
|
197
|
+
|
198
|
+
else
|
199
|
+
output_params = {:code => 508, :result => "Sksk_2.sk_send_viber_sms_one: Something wrong with dabrabyt_text_field_parse"}
|
200
|
+
end
|
199
201
|
|
200
202
|
end
|
201
203
|
|
@@ -281,44 +283,49 @@ class Sksk_2
|
|
281
283
|
begin
|
282
284
|
|
283
285
|
thr_sk_send_viber_list = Thread.new do
|
284
|
-
uri = URI(sk_url_broadcast)
|
285
|
-
#8 - client id
|
286
286
|
|
287
|
-
|
288
|
-
https.use_ssl = true
|
289
|
-
https.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
290
|
-
req = Net::HTTP::Post.new(uri.path, initheader = {:"Content-Type" => 'application/json'})
|
287
|
+
viber_mess_ans = dabrab_add_func.dabrabyt_text_field_parse(text)
|
291
288
|
|
292
|
-
|
293
|
-
|
289
|
+
if viber_mess_ans[:code] == 200
|
290
|
+
uri = URI(sk_url_broadcast)
|
291
|
+
#8 - client id
|
294
292
|
|
295
|
-
|
293
|
+
https = Net::HTTP.new(uri.host, uri.port)
|
294
|
+
https.use_ssl = true
|
295
|
+
https.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
296
|
+
req = Net::HTTP::Post.new(uri.path, initheader = {:"Content-Type" => 'application/json'})
|
296
297
|
|
298
|
+
req["Content-Type"] = "application/json"
|
299
|
+
req["Accept"] = "application/json"
|
297
300
|
|
298
|
-
|
299
|
-
request_message = {
|
300
|
-
"recipients": msisdn_list,
|
301
|
-
"callback_url": callback_url,
|
302
|
-
"tag": "Dabrab_custom_api_1",
|
303
|
-
"channels": [
|
304
|
-
"viber"
|
305
|
-
],
|
306
|
-
"channel_options": {
|
307
|
-
"viber": {
|
308
|
-
"text": text,
|
309
|
-
"ttl": 60
|
310
|
-
}
|
311
|
-
}
|
312
|
-
}
|
301
|
+
req.basic_auth sk_login, sk_password
|
313
302
|
|
314
|
-
req.body = request_message.to_json
|
315
|
-
res = https.request(req)
|
316
303
|
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
304
|
+
# [{"phone_number": 375298766719}, {"phone_number": 375295730878}]
|
305
|
+
request_message = {
|
306
|
+
"recipients": msisdn_list,
|
307
|
+
"callback_url": callback_url,
|
308
|
+
"tag": "Dabrab_custom_api_1",
|
309
|
+
"channels": [
|
310
|
+
"viber"
|
311
|
+
],
|
312
|
+
"channel_options": {
|
313
|
+
"viber": viber_mess_ans[:body][:to_sk_format]
|
314
|
+
}
|
315
|
+
}
|
316
|
+
|
317
|
+
req.body = request_message.to_json
|
318
|
+
res = https.request(req)
|
319
|
+
|
320
|
+
output_params = {:code => 200,
|
321
|
+
:result => "Sksk_2.sk_send_viber_list: Request processed",
|
322
|
+
:body => {:request_message => request_message,
|
323
|
+
:res_code => res.code,
|
324
|
+
:res_body => JSON.parse(res.body.to_s)}}
|
325
|
+
else
|
326
|
+
output_params = {:code => 508, :result => "Sksk_2.sk_send_viber_list: Something wrong with dabrabyt_text_field_parse"}
|
327
|
+
end
|
328
|
+
|
322
329
|
end
|
323
330
|
thr_sk_send_viber_list.join
|
324
331
|
rescue
|
@@ -337,50 +344,57 @@ class Sksk_2
|
|
337
344
|
|
338
345
|
begin
|
339
346
|
thr_sk_send_viber_sms_list = Thread.new do
|
340
|
-
uri = URI(sk_url_broadcast)
|
341
|
-
#8 - client id
|
342
347
|
|
343
|
-
|
344
|
-
https.use_ssl = true
|
345
|
-
https.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
346
|
-
req = Net::HTTP::Post.new(uri.path, initheader = {:"Content-Type" => 'application/json'})
|
348
|
+
viber_mess_ans = dabrab_add_func.dabrabyt_text_field_parse(viber_text)
|
347
349
|
|
348
|
-
|
350
|
+
if viber_mess_ans[:code] == 200
|
349
351
|
|
352
|
+
uri = URI(sk_url_broadcast)
|
353
|
+
#8 - client id
|
350
354
|
|
351
|
-
|
352
|
-
|
355
|
+
https = Net::HTTP.new(uri.host, uri.port)
|
356
|
+
https.use_ssl = true
|
357
|
+
https.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
358
|
+
req = Net::HTTP::Post.new(uri.path, initheader = {:"Content-Type" => 'application/json'})
|
353
359
|
|
354
|
-
|
355
|
-
request_message = {
|
356
|
-
"recipients": msisdn_list,
|
357
|
-
"callback_url": callback_url,
|
358
|
-
"tag": "Dabrab_custom_api_1",
|
359
|
-
"channels": [
|
360
|
-
"viber",
|
361
|
-
"sms"
|
362
|
-
],
|
363
|
-
"channel_options": {
|
364
|
-
"sms": {
|
365
|
-
"alpha_name": alphaname,
|
366
|
-
"text": sms_text,
|
367
|
-
"ttl": 60
|
368
|
-
},
|
369
|
-
"viber": {
|
370
|
-
"text": viber_text,
|
371
|
-
"ttl": 60
|
372
|
-
}
|
373
|
-
}
|
374
|
-
}
|
360
|
+
req.basic_auth sk_login, sk_password
|
375
361
|
|
376
|
-
req.body = request_message.to_json
|
377
|
-
res = https.request(req)
|
378
362
|
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
363
|
+
req["Content-Type"] = "application/json"
|
364
|
+
req["Accept"] = "application/json"
|
365
|
+
|
366
|
+
# [{"phone_number": 375298766719}, {"phone_number": 375295730878}]
|
367
|
+
request_message = {
|
368
|
+
"recipients": msisdn_list,
|
369
|
+
"callback_url": callback_url,
|
370
|
+
"tag": "Dabrab_custom_api_1",
|
371
|
+
"channels": [
|
372
|
+
"viber",
|
373
|
+
"sms"
|
374
|
+
],
|
375
|
+
"channel_options": {
|
376
|
+
"sms": {
|
377
|
+
"alpha_name": alphaname,
|
378
|
+
"text": sms_text,
|
379
|
+
"ttl": 60
|
380
|
+
},
|
381
|
+
"viber": viber_mess_ans[:body][:to_sk_format]
|
382
|
+
}
|
383
|
+
}
|
384
|
+
|
385
|
+
req.body = request_message.to_json
|
386
|
+
res = https.request(req)
|
387
|
+
|
388
|
+
output_params = {:code => 200,
|
389
|
+
:result => "Sksk_2.sk_send_viber_sms_list: Request processed",
|
390
|
+
:body => {:request_message => request_message,
|
391
|
+
:res_code => res.code,
|
392
|
+
:res_body => JSON.parse(res.body.to_s)}}
|
393
|
+
|
394
|
+
else
|
395
|
+
output_params = {:code => 508, :result => "Sksk_2.sk_send_viber_sms_list: Something wrong with dabrabyt_text_field_parse"}
|
396
|
+
end
|
397
|
+
|
384
398
|
end
|
385
399
|
|
386
400
|
thr_sk_send_viber_sms_list.join
|