Module: RubyEDS

Defined in:
lib/ruby_eds.rb

Instance Method Summary collapse

Instance Method Details

#advanced_search(search_json, return_type = "xml") ⇒ Object



38
39
# File 'lib/ruby_eds.rb', line 38

def advanced_search(search_json, return_type="xml")
end

#authenticate_user(username, password) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/ruby_eds.rb', line 8

def authenticate_user(username, password)
  auth_json = {"UserId"=>"#{username}","Password"=>"#{password}","InterfaceId"=>"WSapi"}.to_json
  response = open('https://eds-api.ebscohost.com/authservice/rest/UIDAuth', :method=>:post, :body => auth_json, 'Content-Type' => 'application/json')
  doc = Nokogiri::XML(response.read)
  doc.remove_namespaces!
  auth_token = doc.xpath("//AuthToken").inner_text
end

#basic_search(query, session_token, auth_token, view = 'brief', offset = 1, limit = 10, order = 'relevance', return_type = "xml") ⇒ Object



34
35
36
# File 'lib/ruby_eds.rb', line 34

def basic_search(query, session_token, auth_token, view='brief', offset=1, limit=10, order='relevance', return_type="xml")
  response = RestClient.get "http://eds-api.ebscohost.com/edsapi/rest/Search", {:params=>{"query-1"=>query}, "x-authenticationToken"=>auth_token, "x-sessionToken"=>session_token, :accept=>return_type}
end

#close_session(session_token, auth_token) ⇒ Object



23
24
25
26
27
28
# File 'lib/ruby_eds.rb', line 23

def close_session(session_token, auth_token)
  response = RestClient.get "http://eds-api.ebscohost.com/edsapi/rest/endsession", {:params=>{"sessiontoken"=>session_token}, :content_type=>:json, "x-authenticationToken"=>auth_token, "x-sessionToken"=>session_token}
  doc = Nokogiri::XML(response)
  doc.remove_namespaces!
  success = doc.xpath("//IsSuccessful").inner_text
end

#get_info(session_token, auth_token, return_type = "xml") ⇒ Object



30
31
32
# File 'lib/ruby_eds.rb', line 30

def get_info(session_token, auth_token, return_type="xml")
  response = RestClient.get "http://eds-api.ebscohost.com/edsapi/rest/info", "x-authenticationToken"=>auth_token, "x-sessionToken"=>session_token, :accept=>return_type
end

#open_session(profile, guest, auth_token) ⇒ Object



16
17
18
19
20
21
# File 'lib/ruby_eds.rb', line 16

def open_session(profile, guest, auth_token)
  response = RestClient.get "http://eds-api.ebscohost.com/edsapi/rest/CreateSession", {:params=>{"profile"=>profile, "guest"=>guest}, :content_type=>:json, "x-authenticationToken"=>auth_token}
  doc = Nokogiri::XML(response)
  doc.remove_namespaces!
  session_token = doc.xpath("//SessionToken").inner_text
end