lib/imperituroard/projects/iot/hua_oceanconnect_adapter.rb in imperituroard-0.2.4 vs lib/imperituroard/projects/iot/hua_oceanconnect_adapter.rb in imperituroard-0.2.5

- old
+ new

@@ -210,9 +210,32 @@ request['app_key'] = app_id res = https.request(request) {:code => res.code, :message => res.message, :body => JSON.parse(res.body.to_s)} end + + #2.9.6 Querying Directly Connected Devices and Their Mounted Devices in Batches + def quer_dev_direct_conn_batches(app_id, secret, dev_list) + token = get_token(app_id, secret)[:body]["accessToken"] + path = "/iocm/app/dm/v1.1.0/queryDevicesByIds" + url_string = "https://" + platformip + ":" + platformport + path + uri = URI.parse url_string + https = Net::HTTP.new(uri.host, uri.port) + https.use_ssl = true + https.cert = OpenSSL::X509::Certificate.new(File.read(cert_file)) + https.key = OpenSSL::PKey::RSA.new(File.read(key_file)) + https.verify_mode = OpenSSL::SSL::VERIFY_NONE + request = Net::HTTP::Post.new(uri.path) + request.content_type = 'application/json' + request['Authorization'] = 'Bearer ' + token + request['app_key'] = app_id + request.body = {deviceIds: dev_list}.to_json + res = https.request(request) + {:code => res.code, :message => res.message, :body => JSON.parse(res.body.to_s)} + end + + + def test() url_string = "https://134.17.93.4:8743/iocm/app/sec/v1.1.0/login" headers = { 'Authorization' => 'Bearer ppeMsOq6zdb2fSUH4GoRooS_FgEa', \ No newline at end of file