Class: Alma::RenewalResponse
- Inherits:
-
Object
- Object
- Alma::RenewalResponse
- Defined in:
- lib/alma/renewal_response.rb
Instance Method Summary collapse
- #error_message ⇒ Object
-
#initialize(response, loan = nil) ⇒ RenewalResponse
constructor
A new instance of RenewalResponse.
- #item_title ⇒ Object
- #message ⇒ Object
- #new_due_date ⇒ Object
- #renewed? ⇒ Boolean
Constructor Details
#initialize(response, loan = nil) ⇒ RenewalResponse
Returns a new instance of RenewalResponse.
4 5 6 7 8 9 |
# File 'lib/alma/renewal_response.rb', line 4 def initialize(response, loan=nil) @loan = loan @success = response.fetch('item_loan', nil) @error = response.fetch('web_service_result', nil) @renewed = @error.nil? end |
Instance Method Details
#error_message ⇒ Object
19 20 21 |
# File 'lib/alma/renewal_response.rb', line 19 def @error['errorList']['error']['errorMessage'] end |
#item_title ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/alma/renewal_response.rb', line 23 def item_title if @loan @loan.title else "This Item" end end |
#message ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/alma/renewal_response.rb', line 31 def if @success "#{item_title} is now due #{new_due_date}" else "#{item_title} could not be renewed." end end |
#new_due_date ⇒ Object
15 16 17 |
# File 'lib/alma/renewal_response.rb', line 15 def new_due_date Time.parse(@success['due_date']).strftime('%m-%e-%y %H:%M') end |
#renewed? ⇒ Boolean
11 12 13 |
# File 'lib/alma/renewal_response.rb', line 11 def renewed? @renewed end |