Created
July 31, 2015 02:55
-
-
Save wangbus/8e5bd6e78d52385d7e0c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net/https' | |
require 'uri' | |
require 'rest-client' | |
url = 'https://qms-md-demo.test.onemednet.com/omn/api/directory/remote-auth' | |
# query_params = {"rest-auth" => ENV['BEAM_SERVER_REST_AUTH']} | |
query_params = {"rest-auth" => 'rest:9facb917c463b609801c9aaef535b6f1', "mail" => 'julie@slickage.com', "facility_details" => 1} | |
response = RestClient.post url, query_params, {:content_type => :json, :accept => :json} | |
json = JSON.parse(response) | |
# render json: json['rows'] | |
# "rows": | |
# { | |
# "DEMO1.MD": | |
# { | |
# "users": | |
# { | |
# "julie@slickage.com": | |
data = json['rows']["DEMO1.MD"]["users"]["julie@slickage.com"] | |
puts "data" | |
puts data | |
key = data['key'] | |
# sleep(30) | |
uri = URI.parse('https://demo1--md-demo.test.onemednet.com/omn/api/directory/remote-auth?mail=julie@slickage.com&key=' + key +'&password=BEraCopaRGUiUSA') | |
# uri = URI('https://demo1--md-demo.test.onemednet.com/omn/api/directory/remote-auth') | |
# uri.query = URI.encode_www_form({"mail" => 'julie@slickage.com', "key" => key, "password" => 'BEraCopaRGUiUSA'}) | |
puts uri | |
puts uri.path | |
puts uri.host | |
puts uri.query | |
# request = Net::HTTP::Put.new(uri.path, initheader = {'Content-Type' =>'application/json', 'Accept' => 'application/json'}) | |
request = Net::HTTP::Put.new(uri.request_uri, initheader = {'Content-Type' =>'application/json', 'Accept' => 'application/json'}) | |
puts request['Content-Type'] | |
puts request['Accept'] | |
# request.set_form_data({"mail" => 'julie@slickage.com', "key" => key, "password" => 'BEraCopaRGUiUSA'}) | |
http = Net::HTTP.new(uri.host, uri.port) | |
begin | |
http.use_ssl = true | |
http.verify_mode = OpenSSL::SSL::VERIFY_NONE | |
response = http.start {|http| http.request(request) } | |
# response = Net::HTTP.new(uri.host).start {|http| http.request(request) } | |
puts response.code | |
puts response.header | |
puts response.body | |
rescue => e | |
puts e | |
end | |
# REST CLIENT | |
# url = "https://demo1--md-demo.test.onemednet.com/omn/api/directory/remote-auth" | |
# query_params = {"mail"=>"julie@slickage.com", "key"=> key, "password"=>"BEraCopaRGUiUSA"} | |
# | |
# begin | |
# puts url | |
# puts query_params | |
# response = RestClient.put url, query_params, {:content_type => :json, :accept => :json} | |
# | |
# | |
# puts response.code | |
# puts response.headers | |
# rescue RestClient::ExceptionWithResponse => e | |
# e.response | |
# puts e.response | |
# puts e | |
# end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment