lib/imperituroard/projects/iot.rb in imperituroard-0.5.2 vs lib/imperituroard/projects/iot.rb in imperituroard-0.5.3
- old
+ new
@@ -84,10 +84,13 @@
if imei != []
list_checked = mongo_client.check_imei_exists(imei)
for ss in list_checked[:body][:exists]
not_processed_list.append({:imei => ss, :error => "Device exists in database"})
+ p ss
+ p "ss"
+ p list_checked
end
for jj in list_checked[:body][:not_exists]
begin
get_login_info = mongo_client.check_login_prof_perm_id_one(login, list1[jj]["profile"])[:code]
@@ -684,10 +687,11 @@
resp_out
end
#7 procedure for subscriber autorization
+ # save data to mongodb
def autorize_subscriber_2(login, password)
input_json = {:login => login, :password => password}
resp_out = {}
thr7 = Thread.new do
begin
@@ -715,10 +719,11 @@
def answ_dev_query_format_process(dev_list)
add_functions_connector.answ_dev_query_format_process(dev_list)
end
+ #8 get available profiles by login
def get_available_prof_2(login)
input_params = {:login => login}
resp_out = {}
@@ -765,11 +770,11 @@
end
mongo_client.audit_logger("get_available_prof_2", remote_ip, input_params, resp_out, real_ip)
resp_out
end
-
+ #9 get available device types by login
def get_available_types_2(login)
input_params = {:login => login}
resp_out = {}
@@ -822,11 +827,68 @@
mongo_client.audit_logger("get_available_types_2", remote_ip, input_params, resp_out, real_ip)
resp_out
end
- #10 get info for device type
+ #10 get available device types by login and profile. procedure update
+ def get_available_types2_2(login, profile)
+
+ input_params = {:login => login}
+ resp_out = {}
+
+ begin
+ data_processed = []
+ data_soapgw = []
+ login_info = mongo_client.get_login_inf2_select(login)
+ if login_info[:code]==200
+
+ permit_profiles = login_info[:body]["permit_profiles"]
+ permit_types = login_info[:body]["permit_types"]
+
+ data_from_mongo = mongo_client.get_type_list_by_id(permit_types)
+
+ for ff in data_from_mongo
+ data_processed.append({:type_id => ff["type_id"],
+ :description => ff["description"],
+ :note => ff["note"],
+ :form => ff["form"],
+ :ManufacturerID => ff["ManufacturerID"],
+ :ManufacturerNAME => ff["ManufacturerNAME"],
+ :device_type => ff["device_type"],
+ :model => ff["model"],
+ :info => ff["info"]
+ })
+ data_soapgw.append({:name => ff["model"], :form => ff["form"], :description => ff["description"], :type_id => ff["type_id"]})
+ end
+
+ tosoapgw = {:code => 200,
+ :result => "Request completed successfully",
+ :types => data_soapgw
+ }
+
+ resp_out = {:code => 200, :result => "Request completed successfully", :body => {:data => data_processed, :tosoapgw => tosoapgw}}
+ else
+ tosoapgw = {:code => login_info[:code],
+ :result => login_info[:result],
+ :types => data_soapgw
+ }
+ resp_out = {:code => login_info[:code], :result => login_info[:result], :body => {:tosoapgw => tosoapgw}}
+ end
+
+ rescue
+ tosoapgw = {:code => 507,
+ :result => "Unknown SDK error",
+ :types => data_soapgw
+ }
+ resp_out = {:code => 507, :result => "Unknown SDK error", :body => {:tosoapgw => tosoapgw}}
+ end
+ mongo_client.audit_logger("get_available_types_2", remote_ip, input_params, resp_out, real_ip)
+ resp_out
+ end
+
+
+ #11 get info for device type
def get_info_data_type_2(type)
input_params = {:type => type}
output_answ = {}
mon_answer = {}
@@ -852,10 +914,10 @@
mongo_client.audit_logger("get_info_data_type_2", remote_ip, input_params, output_answ, real_ip)
output_answ
end
- #11 get info for profile
+ #12 get info for profile
def get_info_data_profile_2(profile)
input_params = {:profile => profile}
output_answ = {}
mon_answer = {}