class Libis::Services::Rosetta::PdsHandler
Public Class Methods
new(base_url = 'https://pds.libis.be')
click to toggle source
@param [String] base_url
# File lib/libis/services/rosetta/pds_handler.rb, line 13 def initialize(base_url = 'https://pds.libis.be') configure base_url end
Public Instance Methods
login(user, password, institute)
click to toggle source
@param [String] user @param [String] password @param [String] institute @return [String] PDS handle, nil if could not login
# File lib/libis/services/rosetta/pds_handler.rb, line 21 def login(user, password, institute) params = { func: 'login-url', bor_id: user, bor_verification: password, institute: institute } response = get 'pds', params return nil unless response.code == 200 and response.body.match /pds_handle=(\d+)[^\d]/ $1 end
logout(pds_handle)
click to toggle source
@param [String] pds_handle @return [Boolean] true if success
# File lib/libis/services/rosetta/pds_handler.rb, line 35 def logout(pds_handle) params = { func: 'logout', pds_handle: pds_handle } response = get 'pds', params response.code == 200 end
user_info(pds_handle)
click to toggle source
@param [String] pds_handle @return [Hash] with user information. At least containing: 'id', 'name', 'institute' and 'group'
# File lib/libis/services/rosetta/pds_handler.rb, line 46 def user_info(pds_handle) params = { func: 'get-attribute', attribute: 'BOR_INFO', pds_handle: pds_handle } response = get 'pds', params return nil unless response.code == 200 Nori.new(convert_tags_to: lambda {|tag| tag.to_sym}).parse(response.body) end