imperituroard 0.5.2 → 0.5.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (28) hide show
  1. checksums.yaml +4 -4
  2. data/imperituroard.gemspec +3 -2
  3. data/lib/.DS_Store +0 -0
  4. data/lib/imperituroard.rb +49 -19
  5. data/lib/imperituroard/.DS_Store +0 -0
  6. data/lib/imperituroard/add_functions/logger/any_functions.rb +22 -0
  7. data/lib/imperituroard/platforms/cps/cps_multiple_thread_req.rb +0 -0
  8. data/lib/imperituroard/platforms/staros/get_data_ssh.rb +54 -0
  9. data/lib/imperituroard/platforms/staros/staros_automation.rb +95 -0
  10. data/lib/imperituroard/platforms/staros/staros_automation_fun.rb +37 -0
  11. data/lib/imperituroard/platforms/staros/staros_parser.rb +141 -0
  12. data/lib/imperituroard/projects/dns.rb +1 -1
  13. data/lib/imperituroard/projects/iot.rb +66 -4
  14. data/lib/imperituroard/projects/iot/add_functions.rb +27 -27
  15. data/lib/imperituroard/projects/mhub.rb +8 -4
  16. data/lib/imperituroard/projects/mhub/infobip.rb +1 -1
  17. data/lib/imperituroard/projects/mhub/sk.rb +171 -157
  18. data/lib/imperituroard/projects/mhub/subs/dabrab/dabrab_proced.rb +124 -12
  19. data/lib/imperituroard/projects/ukaz60.rb +140 -0
  20. data/lib/imperituroard/projects/ukaz60/belgim.rb +221 -0
  21. data/lib/imperituroard/projects/ukaz60/dns.rb +18 -0
  22. data/lib/imperituroard/projects/{dns/ukaz60 → ukaz60}/dns_update.rb +2 -134
  23. data/lib/imperituroard/projects/ukaz60/fortigate.rb +210 -0
  24. data/lib/imperituroard/projects/ukaz60/staros.rb +141 -0
  25. data/lib/imperituroard/projects/ukaz60/ukaz60_add_func.rb +306 -0
  26. data/lib/imperituroard/projects/vpn/ezuev_fun/functions_ezuev.rb +29 -0
  27. data/lib/imperituroard/version.rb +1 -1
  28. metadata +31 -4
@@ -1,4 +1,4 @@
1
- require 'imperituroard/projects/dns/ukaz60/dns_update'
1
+ require 'imperituroard/projects/ukaz60/dns_update'
2
2
 
3
3
 
4
4
  class Dns_2
@@ -86,6 +86,9 @@ class IotFunctions_2
86
86
 
87
87
  for ss in list_checked[:body][:exists]
88
88
  not_processed_list.append({:imei => ss, :error => "Device exists in database"})
89
+ p ss
90
+ p "ss"
91
+ p list_checked
89
92
  end
90
93
 
91
94
  for jj in list_checked[:body][:not_exists]
@@ -686,6 +689,7 @@ class IotFunctions_2
686
689
 
687
690
 
688
691
  #7 procedure for subscriber autorization
692
+ # save data to mongodb
689
693
  def autorize_subscriber_2(login, password)
690
694
  input_json = {:login => login, :password => password}
691
695
  resp_out = {}
@@ -717,6 +721,7 @@ class IotFunctions_2
717
721
  end
718
722
 
719
723
 
724
+ #8 get available profiles by login
720
725
  def get_available_prof_2(login)
721
726
 
722
727
  input_params = {:login => login}
@@ -767,7 +772,7 @@ class IotFunctions_2
767
772
  resp_out
768
773
  end
769
774
 
770
-
775
+ #9 get available device types by login
771
776
  def get_available_types_2(login)
772
777
 
773
778
  input_params = {:login => login}
@@ -824,7 +829,64 @@ class IotFunctions_2
824
829
  end
825
830
 
826
831
 
827
- #10 get info for device type
832
+ #10 get available device types by login and profile. procedure update
833
+ def get_available_types2_2(login, profile)
834
+
835
+ input_params = {:login => login}
836
+ resp_out = {}
837
+
838
+ begin
839
+ data_processed = []
840
+ data_soapgw = []
841
+ login_info = mongo_client.get_login_inf2_select(login)
842
+ if login_info[:code]==200
843
+
844
+ permit_profiles = login_info[:body]["permit_profiles"]
845
+ permit_types = login_info[:body]["permit_types"]
846
+
847
+ data_from_mongo = mongo_client.get_type_list_by_id(permit_types)
848
+
849
+ for ff in data_from_mongo
850
+ data_processed.append({:type_id => ff["type_id"],
851
+ :description => ff["description"],
852
+ :note => ff["note"],
853
+ :form => ff["form"],
854
+ :ManufacturerID => ff["ManufacturerID"],
855
+ :ManufacturerNAME => ff["ManufacturerNAME"],
856
+ :device_type => ff["device_type"],
857
+ :model => ff["model"],
858
+ :info => ff["info"]
859
+ })
860
+ data_soapgw.append({:name => ff["model"], :form => ff["form"], :description => ff["description"], :type_id => ff["type_id"]})
861
+ end
862
+
863
+ tosoapgw = {:code => 200,
864
+ :result => "Request completed successfully",
865
+ :types => data_soapgw
866
+ }
867
+
868
+ resp_out = {:code => 200, :result => "Request completed successfully", :body => {:data => data_processed, :tosoapgw => tosoapgw}}
869
+ else
870
+ tosoapgw = {:code => login_info[:code],
871
+ :result => login_info[:result],
872
+ :types => data_soapgw
873
+ }
874
+ resp_out = {:code => login_info[:code], :result => login_info[:result], :body => {:tosoapgw => tosoapgw}}
875
+ end
876
+
877
+ rescue
878
+ tosoapgw = {:code => 507,
879
+ :result => "Unknown SDK error",
880
+ :types => data_soapgw
881
+ }
882
+ resp_out = {:code => 507, :result => "Unknown SDK error", :body => {:tosoapgw => tosoapgw}}
883
+ end
884
+ mongo_client.audit_logger("get_available_types_2", remote_ip, input_params, resp_out, real_ip)
885
+ resp_out
886
+ end
887
+
888
+
889
+ #11 get info for device type
828
890
  def get_info_data_type_2(type)
829
891
 
830
892
  input_params = {:type => type}
@@ -854,7 +916,7 @@ class IotFunctions_2
854
916
  end
855
917
 
856
918
 
857
- #11 get info for profile
919
+ #12 get info for profile
858
920
  def get_info_data_profile_2(profile)
859
921
 
860
922
  input_params = {:profile => profile}
@@ -975,7 +1037,7 @@ class IotFunctions_2
975
1037
  end
976
1038
 
977
1039
 
978
- def test
1040
+ def test1278493
979
1041
  #ddd = MongoIot.new(mongoip, mongoport, mongo_database)
980
1042
  #ddd.get_profiles_by_login("test")
981
1043
 
@@ -96,27 +96,27 @@ class AdditionalFunc
96
96
  end
97
97
 
98
98
  def check_input_1(login, imei_list)
99
- {:code=>200, :result=>"Request completed successfully", :body=>"Data checked"}
99
+ {:code => 200, :result => "Request completed successfully", :body => "Data checked"}
100
100
  end
101
101
 
102
102
  def check_input_2(login, imei_list)
103
- {:code=>200, :result=>"Request completed successfully", :body=>"Data checked"}
103
+ {:code => 200, :result => "Request completed successfully", :body => "Data checked"}
104
104
  end
105
105
 
106
106
  def check_input_3(login, imei_list)
107
- {:code=>200, :result=>"Request completed successfully", :body=>"Data checked"}
107
+ {:code => 200, :result => "Request completed successfully", :body => "Data checked"}
108
108
  end
109
109
 
110
110
  def check_input_4(login, imei_list)
111
- {:code=>200, :result=>"Request completed successfully", :body=>"Data checked"}
111
+ {:code => 200, :result => "Request completed successfully", :body => "Data checked"}
112
112
  end
113
113
 
114
114
  def check_input_5(login, imei_list)
115
- {:code=>200, :result=>"Request completed successfully", :body=>"Data checked"}
115
+ {:code => 200, :result => "Request completed successfully", :body => "Data checked"}
116
116
  end
117
117
 
118
118
  def check_input_6(login, imei_list)
119
- {:code=>200, :result=>"Request completed successfully", :body=>"Data checked"}
119
+ {:code => 200, :result => "Request completed successfully", :body => "Data checked"}
120
120
  end
121
121
 
122
122
  def iot_query_dev_soapgw_answer(input_params, output_answer)
@@ -127,28 +127,28 @@ class AdditionalFunc
127
127
 
128
128
  begin
129
129
 
130
- if output_answer[:code]==200
131
- dataaa = []
132
- dataaa_failed = []
133
-
134
- ddd = answ_dev_query_format_process(output_answer[:data])[:body]
135
- p ddd
136
-
137
- answ = { :code => output_answer[:code],
138
- :result => output_answer[:result],
139
- :data => ddd[:ok],
140
- :error_list => ddd[:failed]
141
- }
142
- else
143
- answ = { :code => output_answer[:code],
144
- :result => output_answer[:result],
145
- :data => [],
146
- :error_list => input_params[:imei]
147
- }
148
- end
130
+ if output_answer[:code]==200
131
+ dataaa = []
132
+ dataaa_failed = []
133
+
134
+ ddd = answ_dev_query_format_process(output_answer[:data])[:body]
135
+ p ddd
136
+
137
+ answ = {:code => output_answer[:code],
138
+ :result => output_answer[:result],
139
+ :data => ddd[:ok],
140
+ :error_list => ddd[:failed]
141
+ }
142
+ else
143
+ answ = {:code => output_answer[:code],
144
+ :result => output_answer[:result],
145
+ :data => [],
146
+ :error_list => input_params[:imei]
147
+ }
148
+ end
149
149
  rescue
150
- answ = { :code => 500,
151
- :result => "Unknown error"
150
+ answ = {:code => 500,
151
+ :result => "Unknown error"
152
152
  }
153
153
  end
154
154
 
@@ -23,9 +23,10 @@ class MhubFunctions_2
23
23
  :dabrab_connecter,
24
24
  :static_callback,
25
25
  :crm_connector,
26
- :telegram_connector
26
+ :telegram_connector,
27
+ :sms_alphaname
27
28
 
28
- def initialize(sk_url_simple, sk_login, sk_password, telegram_api_url, telegram_chat_id, sk_url_broadcast, static_callback, crm_callback_url, crm_login, crm_password)
29
+ def initialize(sk_url_simple, sk_login, sk_password, telegram_api_url, telegram_chat_id, sk_url_broadcast, static_callback, crm_callback_url, crm_login, crm_password, sms_alphaname)
29
30
  @sk_url = sk_url_simple
30
31
  @sk_login = sk_login
31
32
  @sk_password = sk_password
@@ -36,6 +37,7 @@ class MhubFunctions_2
36
37
  @telegram_connector = Telegram_2.new(telegram_api_url, telegram_chat_id)
37
38
  @static_callback = static_callback
38
39
  @crm_connector = Crm_2.new(crm_callback_url, crm_login, crm_password, telegram_api_url, telegram_chat_id)
40
+ @sms_alphaname = sms_alphaname
39
41
  end
40
42
 
41
43
 
@@ -49,6 +51,7 @@ class MhubFunctions_2
49
51
  # "notifyContentType"=>"application/json"}}
50
52
 
51
53
 
54
+ #for bank dabrabyt
52
55
  def get_send_message_2(params, ip_src, ip_real, ip_vip)
53
56
 
54
57
  input_params = {:params => params}
@@ -91,13 +94,13 @@ class MhubFunctions_2
91
94
  msisdn2 = dabrab_connecter.num_formatter(params["destinations"], params["notifyUrl"].split(":")[2])
92
95
 
93
96
  if null_statement.include?(params["viber"]) && !null_statement.include?(params["sms"])
94
- hub_resp = mhub_connector.sk_send_sms_list(msisdn2, static_callback, params["sms"]["text"], "TEST")
97
+ hub_resp = mhub_connector.sk_send_sms_list(msisdn2, static_callback, params["sms"]["text"], sms_alphaname)
95
98
  elsif !null_statement.include?(params["viber"]) && null_statement.include?(params["sms"])
96
99
  hub_resp = mhub_connector.sk_send_viber_list(msisdn2, static_callback, params["viber"]["text"])
97
100
  elsif !null_statement.include?(params["viber"]) && !null_statement.include?(params["sms"])
98
101
  p "vibersms"
99
102
  p msisdn2
100
- hub_resp = mhub_connector.sk_send_viber_sms_list(msisdn2, static_callback, params["sms"]["text"], params["viber"]["text"], "TEST")
103
+ hub_resp = mhub_connector.sk_send_viber_sms_list(msisdn2, static_callback, params["sms"]["text"], params["viber"]["text"], sms_alphaname)
101
104
  else
102
105
  output_params = {"code": 502, "result": "Invalid input data st2", "body": {"answer": {}, "sender": {"ip_src": ip_src, "ip_real": ip_real, "ip_vip": ip_vip}}}
103
106
  end
@@ -121,6 +124,7 @@ class MhubFunctions_2
121
124
  end
122
125
 
123
126
 
127
+ #for bank dabrabyt
124
128
  def rec_deliv_report_2(params, ip_src, ip_real, ip_vip)
125
129
  input_params = {:params => params, :ip_src => ip_src, :ip_real => ip_real, :ip_vip => ip_vip}
126
130
  output_params = {}
@@ -5,7 +5,7 @@
5
5
 
6
6
 
7
7
 
8
- class Infobip_1
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
- uri = URI(sk_url)
153
- #8 - client id
154
-
155
- https = Net::HTTP.new(uri.host, uri.port)
156
- https.use_ssl=true
157
- https.verify_mode = OpenSSL::SSL::VERIFY_NONE
158
- req = Net::HTTP::Post.new(uri.path, initheader = {:"Content-Type" => 'application/json'})
159
-
160
- req.basic_auth sk_login, sk_password
161
-
162
- req["Content-Type"] = "application/json"
163
- req["Accept"] = "application/json"
164
-
165
- request_message = {
166
- "phone_number": msisdn,
167
- #"extra_id": "4232j4h89932kjhs",
168
- "callback_url": callback_url,
169
- #"start_time": "2019-08-16 09:59:10",
170
- "tag": "Dabrab_custom_api_1",
171
- "channels": [
172
- "viber",
173
- "sms"
174
- ],
175
- "channel_options": {
176
- "sms": {
177
- "text": sms_text,
178
- "alpha_name": alphaname,
179
- "ttl": 600
180
- },
181
- "viber": {
182
- "text": viber_txt,
183
- "ttl": 60,
184
- # "img": "http://olddogs.org/logo.png",
185
- # "caption": "Old Dogs need you!",
186
- # "action": "http://olddogs.org",
187
- },
188
- }
189
- }
190
-
191
- req.body = request_message.to_json
192
- res = https.request(req)
193
-
194
- output_params = {:code => 200,
195
- :result => "Sksk_2.sk_send_viber_sms_one: Request processed",
196
- :body => {:request_message => request_message,
197
- :res_code => res.code,
198
- :res_body => JSON.parse(res.body.to_s)}}
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
- https = Net::HTTP.new(uri.host, uri.port)
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
- req["Content-Type"] = "application/json"
293
- req["Accept"] = "application/json"
289
+ if viber_mess_ans[:code] == 200
290
+ uri = URI(sk_url_broadcast)
291
+ #8 - client id
294
292
 
295
- req.basic_auth sk_login, sk_password
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
- # [{"phone_number": 375298766719}, {"phone_number": 375295730878}]
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
- output_params = {:code => 200,
318
- :result => "Sksk_2.sk_send_viber_list: Request processed",
319
- :body => {:request_message => request_message,
320
- :res_code => res.code,
321
- :res_body => JSON.parse(res.body.to_s)}}
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
- https = Net::HTTP.new(uri.host, uri.port)
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
- req.basic_auth sk_login, sk_password
350
+ if viber_mess_ans[:code] == 200
349
351
 
352
+ uri = URI(sk_url_broadcast)
353
+ #8 - client id
350
354
 
351
- req["Content-Type"] = "application/json"
352
- req["Accept"] = "application/json"
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
- # [{"phone_number": 375298766719}, {"phone_number": 375295730878}]
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
- output_params = {:code => 200,
380
- :result => "Sksk_2.sk_send_viber_sms_list: Request processed",
381
- :body => {:request_message => request_message,
382
- :res_code => res.code,
383
- :res_body => JSON.parse(res.body.to_s)}}
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