Skip to content
This repository has been archived by the owner on Oct 24, 2018. It is now read-only.

Commit

Permalink
Make name canonical.
Browse files Browse the repository at this point in the history
  • Loading branch information
redlibrarian committed Jul 30, 2013
1 parent a37811b commit d5ef1cb
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ gem "rest-open-uri", "~> 1.0.0"
gem "nokogiri"
gem "rest-client"
gem "json"
gem "fakeweb"


2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
GEM
remote: https://rubygems.org/
specs:
fakeweb (1.3.0)
json (1.7.7)
mime-types (1.23)
mini_portile (0.5.1)
Expand All @@ -14,6 +15,7 @@ PLATFORMS
ruby

DEPENDENCIES
fakeweb
json
nokogiri
rest-client
Expand Down
41 changes: 41 additions & 0 deletions lib/ruby_eds.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
require 'rest-open-uri'
require 'nokogiri'
require 'rest-client'
require 'json'

module RubyEDS

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

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

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

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

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

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

end

0 comments on commit d5ef1cb

Please sign in to comment.