Class: Exlibris::Aleph::Patron
- Defined in:
- lib/exlibris/aleph/patron.rb
Overview
Overview
Provides access to the Aleph Patron REST API.
Instance Attribute Summary collapse
-
#patron_id ⇒ Object
readonly
Returns the value of attribute patron_id.
Instance Method Summary collapse
-
#address ⇒ Object
Call the patronInformation/address Aleph Patron REST API Returns a HTTParty::Response.
-
#error ⇒ Object
Returns the error associated with the request.
-
#initialize(patron_id, uri) ⇒ Patron
constructor
Creates an instance of Exlibris::Aleph::Patron for the given :patron_id.
-
#loans ⇒ Object
Call the circulationActions/loans Aleph Patron REST API Returns a HTTParty::Response.
-
#note ⇒ Object
Returns the note associated with the request.
-
#place_hold(adm_library, bib_library, bib_id, item_id, params) ⇒ Object
Place a hold on the specificed item.
-
#renew_loans(item_id = "") ⇒ Object
Renew the specified item.
Methods inherited from Rest
Constructor Details
#initialize(patron_id, uri) ⇒ Patron
Creates an instance of Exlibris::Aleph::Patron for the given :patron_id
9 10 11 12 13 14 |
# File 'lib/exlibris/aleph/patron.rb', line 9 def initialize(patron_id, uri) @patron_id = patron_id raise "Initialization error in #{self.class}. Missing patron id." if @patron_id.nil? super(uri) @uri = @uri+ "/patron/#{patron_id}" end |
Instance Attribute Details
#patron_id ⇒ Object (readonly)
Returns the value of attribute patron_id.
6 7 8 |
# File 'lib/exlibris/aleph/patron.rb', line 6 def patron_id @patron_id end |
Instance Method Details
#address ⇒ Object
Call the patronInformation/address Aleph Patron REST API Returns a HTTParty::Response.
49 50 51 52 53 |
# File 'lib/exlibris/aleph/patron.rb', line 49 def address() @response = self.class.get(self.uri+ "/patronInformation/address") return nil unless error.nil? return @response end |
#error ⇒ Object
Returns the error associated with the request. Returns nil if no error.
79 80 81 82 |
# File 'lib/exlibris/aleph/patron.rb', line 79 def error return nil if reply_code == "0000" return "#{reply_text}#{note}" end |
#loans ⇒ Object
Call the circulationActions/loans Aleph Patron REST API Returns a HTTParty::Response.
57 58 59 60 61 |
# File 'lib/exlibris/aleph/patron.rb', line 57 def loans() @response = self.class.get(@uri+ "/circulationActions/loans?view=full") raise "Error getting loans through Aleph REST APIs. #{error}" unless error.nil? return @response end |
#note ⇒ Object
Returns the note associated with the request.
73 74 75 |
# File 'lib/exlibris/aleph/patron.rb', line 73 def note return (not @response.first.last.kind_of?(Hash) or @response.first.last["create_hold"].nil?) ? "" : ": #{@response.first.last["create_hold"]["note"]}" if @response.instance_of?(Hash) end |
#place_hold(adm_library, bib_library, bib_id, item_id, params) ⇒ Object
Place a hold on the specificed item. Raises an error if there was a problem placing the hold. Returns a HTTParty::Response.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/exlibris/aleph/patron.rb', line 19 def place_hold(adm_library, bib_library, bib_id, item_id, params) pickup_location = params[:pickup_location] raise "Error in place hold. Missing pickup location." if pickup_location.nil? last_interest_date = params.fetch(:last_interest_date, "") start_interest_date = params.fetch(:start_interest_date, "") = params.fetch(:sub_author, "") sub_title = params.fetch(:sub_title, "") pages = params.fetch(:pages, "") note_1 = params.fetch(:note_1, "") note_2 = params.fetch(:note_2, "") rush = params.fetch(:rush, "N") body_str = "<hold-request-parameters>" body_str << "<pickup-location>#{pickup_location}</pickup-location>" body_str << "<last-interest-date>#{last_interest_date}</last-interest-date>" body_str << "<start-interest-date>#{start_interest_date}</start-interest-date>" body_str << "<sub-author>#{}</sub-author>" body_str << "<sub-title>#{sub_title}</sub-title>" body_str << "<pages>#{pages}</pages>" body_str << "<note-1>#{note_1}</note-1>" body_str << "<note-2>#{note_2}</note-2>" body_str << "<rush>#{rush}</rush>" body_str << "</hold-request-parameters>" = { :body => "post_xml=#{body_str}"} @response = self.class.put(@uri+ "/record/#{bib_library}#{bib_id}/items/#{item_id}/hold", ) raise "Error placing hold through Aleph REST APIs. #{error}" unless error.nil? return @response end |
#renew_loans(item_id = "") ⇒ Object
Renew the specified item. Will renew all if item not specified. Returns a HTTParty::Response.
66 67 68 69 70 |
# File 'lib/exlibris/aleph/patron.rb', line 66 def renew_loans(item_id="") @response = self.class.post(@uri+ "/circulationActions/loans/#{item_id}") raise "Error renewing loan(s) through Aleph REST APIs. #{error}" unless error.nil? return @response end |