lib/imperituroard/projects/iot/mongoconnector.rb in imperituroard-0.2.9 vs lib/imperituroard/projects/iot/mongoconnector.rb in imperituroard-0.3.0
- old
+ new
@@ -269,38 +269,48 @@
out_resp = {}
begin
id = ""
begin
info = get_imei_info_from_db([imei])
+ p info
+ p "info"
if info[:body]==[]
out_resp = {:code => 505, :result => "get_profile_name_from_imei: get_imei_info_from_db returned empty list from database. IMEIS not found"}
else
p "fshhsdf"
p info
id = info[:body][0]["profile"]
- end
- rescue
- out_resp = {:code => 506, :result => "get_profile_name_from_imei: Function get_imei_info_from_db not processed correctly and returned: #{info.to_s}"}
- end
- begin
- res = get_profile_name_by_id(id)
- if res.key?("profile")
- res=res
- else
- out_resp = {:code => 505, :result => "get_profile_name_from_imei: Function get_profile_name_by_id not returned profile. Invalid data in database and returned: #{res.to_s}"}
- end
+ p id
+ p "id"
- rescue
- out_resp = {:code => 506, :result => "get_profile_name_from_imei: Function get_profile_name_by_id not processed correctly and returned: #{res.to_s}"}
+ begin
+ p id
+ res = get_profile_name_by_id(id)
+ p res
+ if res.key?("profile")
+ res=res
+ else
+ out_resp = {:code => 505, :result => "get_profile_name_from_imei: Function get_profile_name_by_id not returned profile. Invalid data in database and returned: #{res.to_s}"}
+ end
- end
- begin
- if res["profile"]!=nil
- out_resp = {:code => 200, :result => "get_profile_name_from_imei: Request completed successfully", :body => res}
+ rescue
+ out_resp = {:code => 506, :result => "get_profile_name_from_imei: Function get_profile_name_by_id not processed correctly and returned: #{res.to_s}"}
+
+ end
+ begin
+ if res["profile"]!=nil
+ out_resp = {:code => 200, :result => "get_profile_name_from_imei: Request completed successfully", :body => res}
+ end
+ rescue
+ out_resp = {:code => 506, :result => "get_profile_name_from_imei: Function get_profile_name_by_id not processed correctly and returned: #{res.to_s}"}
+ end
+
+
end
rescue
- out_resp = {:code => 506, :result => "get_profile_name_from_imei: Function get_profile_name_by_id not processed correctly and returned: #{res.to_s}"}
+ out_resp = {:code => 506, :result => "get_profile_name_from_imei: Function get_imei_info_from_db not processed correctly and returned: #{info.to_s}"}
end
+
rescue
out_resp = {:code => 507, :result => "get_profile_name_from_imei: Unknown SDK error"}
end
p out_resp
\ No newline at end of file