Class: EvergreenHoldings::Connection
- Inherits:
-
Object
- Object
- EvergreenHoldings::Connection
- Defined in:
- lib/evergreen_holdings.rb
Instance Attribute Summary collapse
-
#org_units ⇒ Object
readonly
Returns the value of attribute org_units.
Instance Method Summary collapse
-
#get_holdings(tcn, options = {}) ⇒ Object
Fetch holdings data from the Evergreen server Returns a Status object.
-
#initialize(evergreen_domain) ⇒ Connection
constructor
Create a new object with the evergreen_domain specified, e.g.
-
#location_name(id) ⇒ Object
Given an ID, returns a human-readable name.
- #ou_name(id) ⇒ Object
- #status_name(id) ⇒ Object
Constructor Details
#initialize(evergreen_domain) ⇒ Connection
Create a new object with the evergreen_domain specified, e.g. libcat.linnbenton.edu
Usage: ‘conn = EvergreenHoldings::Connection.new ’gapines.org’‘
20 21 22 23 24 25 26 27 28 |
# File 'lib/evergreen_holdings.rb', line 20 def initialize(evergreen_domain) @evergreen_domain = evergreen_domain @gateway = URI evergreen_domain + OSRF_PATH @acpl_cache = {} fetch_idl_order raise CouldNotConnectToEvergreenError unless fetch_statuses fetch_ou_tree end |
Instance Attribute Details
#org_units ⇒ Object (readonly)
Returns the value of attribute org_units.
14 15 16 |
# File 'lib/evergreen_holdings.rb', line 14 def org_units @org_units end |
Instance Method Details
#get_holdings(tcn, options = {}) ⇒ Object
Fetch holdings data from the Evergreen server Returns a Status object
Usage: ‘stat = conn.get_holdings 23405` If you just want holdings at a specific org_unit: `my_connection.get_holdings 23405, org_unit: 5`
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/evergreen_holdings.rb', line 35 def get_holdings(tcn, = {}) if .key?(:org_unit) if [:descendants] params = "format=json&input_format=json&service=open-ils.cat&method=open-ils.cat.asset.copy_tree.retrieve¶m=auth_token_not_needed_for_this_call¶m=#{tcn}" @org_units[[:org_unit]][:descendants]&.each do |ou| params << + "¶m=#{ou}" end else params = "format=json&input_format=json&service=open-ils.cat&method=open-ils.cat.asset.copy_tree.retrieve¶m=auth_token_not_needed_for_this_call¶m=#{tcn}¶m=#{[:org_unit]}" end else params = "format=json&input_format=json&service=open-ils.cat&method=open-ils.cat.asset.copy_tree.global.retrieve¶m=auth_token_not_needed_for_this_call¶m=#{tcn}" end @gateway.query = params res = send_query return Status.new res.body, @idl_order, self if res end |
#location_name(id) ⇒ Object
Given an ID, returns a human-readable name
55 56 57 |
# File 'lib/evergreen_holdings.rb', line 55 def location_name(id) @acpl_cache.fetch(id) { |id| fetch_new_acpl(id) || id } end |
#ou_name(id) ⇒ Object
63 64 65 |
# File 'lib/evergreen_holdings.rb', line 63 def ou_name(id) @org_units[id][:name] end |
#status_name(id) ⇒ Object
59 60 61 |
# File 'lib/evergreen_holdings.rb', line 59 def status_name(id) @possible_item_statuses[id] end |