Class: Exlibris::Primo::EShelf

Inherits:
Object
  • Object
show all
Includes:
ChainGang::Base, ChainGang::User, Config::Attributes, RequestAttributes, WriteAttributes
Defined in:
lib/exlibris/primo/eshelf.rb

Overview

Manipulate a user's Primo eshelf using Exlibris::Primo::Eshelf

eshelf = Eshelf.new.base_url!("http://primo.library.edu").institution!("PRIMO").user_id!("USER_ID")
eshelf.records #=> Array for Primo records

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from WriteAttributes

#write_attributes

Methods included from ChainGang::User

#user_id!

Methods included from ChainGang::Base

#base_url!, #group!, #institution!, #ip!, #logged_in, #logged_out, #off_campus, #on_campus, #pds_handle!

Methods included from Config::Attributes

#availability_statuses, #base_url, #config, #facet_collections, #facet_labels, #facet_resource_types, #facet_top_level, #institution, #institutions, #libraries, #sources

Constructor Details

#initialize(*args) ⇒ EShelf

Returns a new instance of EShelf.


18
19
20
# File 'lib/exlibris/primo/eshelf.rb', line 18

def initialize *args
  super
end

Instance Attribute Details

#user_idObject (readonly)

Returns the value of attribute user_id


16
17
18
# File 'lib/exlibris/primo/eshelf.rb', line 16

def user_id
  @user_id
end

Instance Method Details

#add_folder(folder_name, parent_id) ⇒ Object

Call web service to add folder to eshelf


108
109
110
111
112
# File 'lib/exlibris/primo/eshelf.rb', line 108

def add_folder(folder_name, parent_id)
  Exlibris::Primo::WebService::Request::AddFolderToEshelf.new(
    user_request_attributes.merge :folder_name => folder_name, :parent_folder => parent_id).call
  reset_eshelf
end

#add_record(record_id, folder_id) ⇒ Object

Call web service to add record to eshelf


80
81
82
83
84
# File 'lib/exlibris/primo/eshelf.rb', line 80

def add_record(record_id, folder_id)
  Exlibris::Primo::WebService::Request::AddToEshelf.new(
    user_request_attributes.merge :folder_id => folder_id, :doc_id => record_id).call
  reset_eshelf
end

#add_records(record_ids, folder_id) ⇒ Object

Call web service to add records to eshelf


70
71
72
73
74
75
# File 'lib/exlibris/primo/eshelf.rb', line 70

def add_records(record_ids, folder_id)
  record_ids.each do |record_id|
    add_record record_id, folder_id
  end
  reset_eshelf
end

#basket_idObject

Get the default basket id from eshelf structure web service call


55
56
57
# File 'lib/exlibris/primo/eshelf.rb', line 55

def basket_id
  @basket_id ||= eshelf_structure.basket_id
end

#eshelfObject

Call web service to get Eshelf contents and return


25
26
27
28
# File 'lib/exlibris/primo/eshelf.rb', line 25

def eshelf
  @eshelf ||= 
    Exlibris::Primo::WebService::Request::GetEshelf.new(user_request_attributes).call
end

#eshelf_structureObject

Call web service to get Eshelf structure and return


33
34
35
36
# File 'lib/exlibris/primo/eshelf.rb', line 33

def eshelf_structure
  @eshelf_structure ||= 
    Exlibris::Primo::WebService::Request::GetEshelfStructure.new(user_request_attributes).call
end

#folder_id(folder_name) ⇒ Object

Get the folder id from eshelf structure web service call for the given folder name.


63
64
65
# File 'lib/exlibris/primo/eshelf.rb', line 63

def folder_id(folder_name)
  eshelf_structure.folder_id(folder_name)
end

#recordsObject

Get all the records from user's eshelf as an array of Primo Record objects


48
49
50
# File 'lib/exlibris/primo/eshelf.rb', line 48

def records
  @records ||= eshelf.records
end

#remove_folder(folder_id) ⇒ Object

Call web service to remove folder from eshelf


117
118
119
120
121
# File 'lib/exlibris/primo/eshelf.rb', line 117

def remove_folder(folder_id)
  Exlibris::Primo::WebService::Request::RemoveFolderFromEshelf.new(
    user_request_attributes.merge :folder_id => folder_id).call
  reset_eshelf
end

#remove_record(record_id, folder_id) ⇒ Object

Call web service to remove a record from eshelf


99
100
101
102
103
# File 'lib/exlibris/primo/eshelf.rb', line 99

def remove_record(record_id, folder_id)
  Exlibris::Primo::WebService::Request::RemoveFromEshelf.new(
    user_request_attributes.merge :folder_id => folder_id, :doc_id => record_id).call
  reset_eshelf
end

#remove_records(record_ids, folder_id) ⇒ Object

Call web service to remove records from the eshelf


89
90
91
92
93
94
# File 'lib/exlibris/primo/eshelf.rb', line 89

def remove_records(record_ids, folder_id)
  record_ids.each do |record_id|
    remove_record record_id, folder_id
  end
  reset_eshelf
end

#sizeObject

Get the number of records in user's eshelf


41
42
43
# File 'lib/exlibris/primo/eshelf.rb', line 41

def size
  @size ||= eshelf.size
end