Class: Exlibris::Primo::Reviews

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

Overview

Manipulate a Primo reviews using Exlibris::Primo::Reviews

reviews = Reviews.new.base_url!("http://primo.library.edu").institution!("PRIMO").
  user_id!("USER_ID").record_id!("aleph0123456789")
reviews.reviews #=> Array of Primo reviews

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from WriteAttributes

#write_attributes

Methods included from ChainGang::Record

#record_id!

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) ⇒ Reviews

Returns a new instance of Reviews.


20
21
22
# File 'lib/exlibris/primo/reviews.rb', line 20

def initialize *args
  super
end

Instance Attribute Details

#record_idObject (readonly)

Returns the value of attribute record_id


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

def record_id
  @record_id
end

#user_idObject (readonly)

Returns the value of attribute user_id


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

def user_id
  @user_id
end

Instance Method Details

#add_review(value, rating, user_display_name, status = 2, allow_user_name = true) ⇒ Object

Call web service to add a review to Primo for the specified record


59
60
61
62
63
# File 'lib/exlibris/primo/reviews.rb', line 59

def add_review(value, rating, user_display_name, status=2, allow_user_name = true)
  Exlibris::Primo::WebService::Request::AddReview.new(user_record_request_attributes.merge :value => value, 
    :rating => rating, :user_display_name => user_display_name, :status =>status, :allow_user_name => allow_user_name).call
  reset_reviews
end

#rating_reviews(rating) ⇒ Object

Get the reviews of a certain rating for the specified user


51
52
53
54
# File 'lib/exlibris/primo/reviews.rb', line 51

def rating_reviews(rating)
  Exlibris::Primo::WebService::Request::GetReviewsByRating.new(
    user_request_attributes.merge :rating => rating).call.reviews
end

#record_reviewsObject

Call web service to get all reviews for the specified record


43
44
45
46
# File 'lib/exlibris/primo/reviews.rb', line 43

def record_reviews
  @record_reviews ||= Exlibris::Primo::WebService::Request::GetReviewsForRecord.new(
    record_request_attributes).call.reviews
end

#remove_reviewObject

Call web service to remove review from Primo for the specified record


68
69
70
71
# File 'lib/exlibris/primo/reviews.rb', line 68

def remove_review
  Exlibris::Primo::WebService::Request::RemoveReview.new(user_record_request_attributes).call
  reset_reviews
end

#reviewsObject

Call web service to get reviews for the specified user and record


27
28
29
30
# File 'lib/exlibris/primo/reviews.rb', line 27

def reviews
  @reviews ||= Exlibris::Primo::WebService::Request::GetReviews.new(
    user_record_request_attributes).call.reviews
end

#user_reviewsObject

Call web service to get all reviews for the specified user


35
36
37
38
# File 'lib/exlibris/primo/reviews.rb', line 35

def user_reviews
  @user_reviews ||= Exlibris::Primo::WebService::Request::GetAllMyReviews.new(
    user_request_attributes).call.reviews
end