imperituroard 0.4.2 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,45 @@
1
+ require 'savon'
2
+ require 'json'
3
+ require 'imperituroard/platforms/cps/request_formatter'
4
+
5
+ class Qps_2
6
+
7
+ attr_accessor :formatter_connector, :cps_connector_client
8
+
9
+ def initialize(cps_wsdl, cps_endpoint, cps_namespace)
10
+ @formatter_connector = CpsFormatter_2.new
11
+ @cps_connector_client = Savon.client do
12
+ ssl_verify_mode :none
13
+ wsdl cps_wsdl
14
+ endpoint cps_endpoint
15
+ namespace cps_namespace
16
+ end
17
+ end
18
+
19
+ #final procedure
20
+ def get_subscriber_msisdn(msisdn)
21
+ response = cps_connector_client.call(:get_subscriber) do
22
+ message(networkId: msisdn)
23
+ end
24
+ answer = JSON.parse(response.to_json)
25
+ end
26
+
27
+ def recreate_subscriber(info_from_get_subs)
28
+ mess = formatter_connector.create_subs_for_recreate(info_from_get_subs)
29
+ #tmp = {:subscriber=>{:credential=>[{:networkId=>"375001029830"}, {:networkId=>"Ethernet1/0/9:1933.0 Min_Ljubimova_37_2/0/0/1/0/9", :type=>"User-Name"}], :notification=>[{"destination"=>"etrofimenko@bntu.by", "enabled"=>true, "transport"=>"EMAIL"}, {"destination"=>nil, "enabled"=>false, "transport"=>"SMS"}], :service=>[{"code"=>"FR0000", "enabled"=>true}, {"code"=>"FR10312", "enabled"=>true}, {"code"=>"FR11885", "enabled"=>true}, {"code"=>"FR11873", "enabled"=>true}]}}
30
+ response = cps_connector_client.call(:create_subscriber) do
31
+ message(mess)
32
+ end
33
+ response.to_hash
34
+ end
35
+
36
+ #final procedure
37
+ def delete_subscriber(user)
38
+ mess = {:networkId => user, :hardDelete => "true"}
39
+ response = cps_connector_client.call(:delete_subscriber) do
40
+ message(mess)
41
+ end
42
+ access_interface1 = response.to_hash #[:mts_wifi_portal_get_access_int_response][:accessinterface]
43
+ end
44
+
45
+ end
@@ -0,0 +1,43 @@
1
+
2
+
3
+ class CpsFormatter_2
4
+
5
+ def create_subs_for_recreate(answer_from_get_subs)
6
+
7
+ output_result = {}
8
+
9
+ credent = answer_from_get_subs["get_subscriber_response"]["subscriber"]["credential"]
10
+
11
+ credd = []
12
+
13
+ for dd in credent
14
+
15
+ if dd.key?("type")
16
+ credd.append({:networkId => dd["network_id"], :type => dd["type"]})
17
+ else
18
+ credd.append({:networkId => dd["network_id"]})
19
+ end
20
+ end
21
+
22
+ service = answer_from_get_subs["get_subscriber_response"]["subscriber"]["service"]
23
+ notify = answer_from_get_subs["get_subscriber_response"]["subscriber"]["notification"]
24
+ avp = answer_from_get_subs["get_subscriber_response"]["subscriber"]["avp"]
25
+
26
+ if notify == nil || notify == {}
27
+ if avp != nil && avp != {}
28
+ output_result = {:subscriber => {:credential => credd, :service => service, :avp => avp}}
29
+ else
30
+ output_result = {:subscriber => {:credential => credd, :service => service}}
31
+ end
32
+ else
33
+ if avp != nil && avp != {}
34
+ output_result = {:subscriber => {:credential => credd, :notification => notify, :service => service, :avp => avp}}
35
+ else
36
+ output_result = {:subscriber => {:credential => credd, :notification => notify, :service => service}}
37
+ end
38
+ end
39
+ output_result
40
+ end
41
+
42
+ end
43
+
@@ -25,6 +25,25 @@ class InternalFunc
25
25
  p mess
26
26
  end
27
27
 
28
+ def prof_id_list_transform_mongo(id_list)
29
+ res = []
30
+ for gh in id_list
31
+ res.append({"profile_id" => gh})
32
+ end
33
+ res
34
+ end
35
+
36
+
37
+
38
+ def type_id_list_transform_mongo(id_list)
39
+ res = []
40
+ for gh in id_list
41
+ res.append({"type_id" => gh})
42
+ end
43
+ res
44
+ end
45
+
46
+
28
47
 
29
48
  def test()
30
49
  p "eeeeeeeeeeeeeeeeeeeeeeee"
@@ -106,6 +106,31 @@ class MongoIot
106
106
  out_resp
107
107
  end
108
108
 
109
+ def get_login_inf2_select(login)
110
+ out_resp = {}
111
+ begin
112
+ login_profiles = []
113
+ req2 = []
114
+ result_ps = []
115
+ collection = client[:users]
116
+ collection2 = client[:device_profiles]
117
+ collection.find({:login => login}).each {|row|
118
+ login_profiles = row
119
+ }
120
+ if login_profiles != [] && login_profiles["login"] != nil && login_profiles["login"] != ""
121
+ out_resp = {:code => 200, :result => "get_login_info: Request completed successfully", :body => login_profiles}
122
+ else
123
+ out_resp = {:code => 404, :result => "get_login_info: login not found in database"}
124
+ end
125
+ rescue
126
+ out_resp = {:code => 507, :result => "get_login_info: Unknown SDK error"}
127
+ end
128
+ p out_resp
129
+ internal_func.printer_texter(out_resp, "debug")
130
+ out_resp
131
+ end
132
+
133
+
109
134
  def get_imei_info_from_db(imeilist)
110
135
  out_resp = {}
111
136
  p imeilist
@@ -154,6 +179,63 @@ class MongoIot
154
179
  end
155
180
  end
156
181
 
182
+
183
+
184
+ def get_profile_list_by_id(profile_id_list)
185
+ begin
186
+ result_ps = []
187
+ collection = client[:device_profiles]
188
+ list_id = internal_func.prof_id_list_transform_mongo(profile_id_list)
189
+ collection.find({:$or => list_id}).each {|row|
190
+ result_ps.append(row)
191
+ }
192
+ result_ps
193
+ rescue
194
+ []
195
+ end
196
+ end
197
+
198
+
199
+ def get_type_list_by_id(type_id_list)
200
+ begin
201
+ result_ps = []
202
+ collection = client[:device_types]
203
+ list_id = internal_func.type_id_list_transform_mongo(type_id_list)
204
+ collection.find({:$or => list_id}).each {|row|
205
+ result_ps.append(row)
206
+ }
207
+ result_ps
208
+ rescue
209
+ []
210
+ end
211
+ end
212
+
213
+ def get_type_by_id(type_id)
214
+ begin
215
+ result_ps = []
216
+ collection = client[:device_types]
217
+ collection.find({"type_id" => type_id}).each {|row|
218
+ result_ps.append(row)
219
+ }
220
+ result_ps[0]
221
+ rescue
222
+ []
223
+ end
224
+ end
225
+
226
+ def get_type_by_name(type_name)
227
+ begin
228
+ result_ps = []
229
+ collection = client[:device_types]
230
+ collection.find({"model" => type_name}).each {|row|
231
+ result_ps.append(row)
232
+ }
233
+ result_ps[0]
234
+ rescue
235
+ []
236
+ end
237
+ end
238
+
157
239
  def check_login_profile_permiss(login, profile)
158
240
  out_resp = {}
159
241
  get_login_info = get_profiles_by_login(login)
@@ -1,3 +1,3 @@
1
1
  module Imperituroard
2
- VERSION = "0.4.2"
2
+ VERSION = "0.4.3"
3
3
  end