alma 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 205918f513cfea340ea21733aebf97f9028a87ac
4
- data.tar.gz: c8e0ada2ffcdd3cd1742bf076be8ee8416ec9c76
3
+ metadata.gz: f6514577bde1155ebeaac6f1c1b0b6e18c615b32
4
+ data.tar.gz: 8fbceca83bc75f49fc1aa5890c84ce1c9b8944ec
5
5
  SHA512:
6
- metadata.gz: b1e361f47c0f0b3feebf760111b3760ff7891aec3b040a697a79bbe827d5464a23d763350f04f14593c242bda1169713ff4a36d43140a6658969e8a5af7b8c97
7
- data.tar.gz: 12b24d9df96c5c796324e4f3fee471883f77fd78079402e740b04b25a466d4fc2fa609fb7ef31ecb2ad7273af0517faa8739ac1881ec5fd6ae0f2985f5881522
6
+ metadata.gz: 30f11ef82444e7cbf6a581cd7ad8adbad12d795f67396331663cac62c2da58e873b043e8e5078c6163103fbc3b2363a139ddaf8dad0513b45ddf34caa01c01f0
7
+ data.tar.gz: c450a1b9be6e4c603b836d4b879fba1c90eee5d815fb2d98b8a8230038efbd10bdb7f5fb016f0694763d5c55753365f32b3b510ad482aac6966a69aee3d0a7d6
data/README.md CHANGED
@@ -7,7 +7,7 @@ A client for Web Services provided by the Ex Libris's Alma Library System.
7
7
  Add this line to your application's Gemfile:
8
8
 
9
9
  ```ruby
10
- gem 'alma', :git => "https://github.com/tulibraries/alma_rb.git"
10
+ gem 'alma'
11
11
  ```
12
12
 
13
13
  And then execute:
@@ -16,7 +16,7 @@ And then execute:
16
16
 
17
17
  Or install it yourself as:
18
18
 
19
- $ gem install alma_rb
19
+ $ gem install alma
20
20
 
21
21
  ## Usage
22
22
 
@@ -2,7 +2,7 @@ module Alma
2
2
  class Loan < AlmaRecord
3
3
 
4
4
  def renew
5
- Alma::User.renew_loan({user_id: user_id, loan: self})
5
+ Alma::User.renew_loan({user_id: user_id, loan_id: loan_id})
6
6
  end
7
7
 
8
8
  end
@@ -1,30 +1,34 @@
1
1
  module Alma
2
2
  class RenewalResponse
3
3
 
4
- def initialize(response, loan=nil)
5
- @loan = loan
6
- @success = response.fetch('item_loan', nil)
7
- @error = response.fetch('web_service_result', nil)
8
- @renewed = @error.nil?
4
+ def initialize(response)
5
+ @success = response.fetch('item_loan', {})
6
+ @error = response.fetch('web_service_result', {})
7
+ @renewed = @error.empty?
9
8
  end
10
9
 
11
10
  def renewed?
12
11
  @renewed
13
12
  end
14
13
 
15
- def new_due_date
16
- Time.parse(@success['due_date']).strftime('%m-%e-%y %H:%M')
14
+ def due_date
15
+ @success.fetch('due_date', '')
16
+ end
17
+
18
+
19
+ def due_date_pretty
20
+ Time.parse(due_date).strftime('%m-%e-%y %H:%M')
17
21
  end
18
22
 
19
23
  def error_message
20
- @error['errorList']['error']['errorMessage']
24
+ (renewed?) ? '' : @error['errorList']['error']['errorMessage']
21
25
  end
22
26
 
23
27
  def item_title
24
- if @loan
25
- @loan.title
28
+ if @success
29
+ @success['title']
26
30
  else
27
- "This Item"
31
+ 'This Item'
28
32
  end
29
33
  end
30
34
 
@@ -23,8 +23,8 @@ module Alma
23
23
  @loans
24
24
  end
25
25
 
26
- def renew_loan(loan)
27
- response = self.class.renew_loan({user_id: self.id, loan: loan})
26
+ def renew_loan(loan_id)
27
+ response = self.class.renew_loan({user_id: self.id, loan_id: loan_id})
28
28
  @recheck_loans = true if response.renewed?
29
29
  response
30
30
  end
@@ -95,21 +95,14 @@ module Alma
95
95
  # Attempts to renew a single item for a user
96
96
  # @param [Hash] args
97
97
  # @option args [String] :user_id The unique id of the user
98
- # @option args [String] :loan_id The unique id of the loan - optional (either :loan_id or :loan must be present)
99
- # @option args [String] :loan_id A loan object - optional (either :loan_id or :loan must be present)
100
- # @option args [String] :user_id_type Type of identifier being used to search
98
+ # @option args [String] :loan_id The unique id of the loan
99
+ # @option args [String] :user_id_type Type of identifier being used to search. OPTIONAL
101
100
  # @return [RenewalResponse] Object indicating the renewal message
102
101
  def renew_loan(args)
103
102
  args.merge!({op: 'renew'})
104
-
105
- # If a loan object is passed in args, us its id as loan_id
106
- loan = args.delete(:loan)
107
- if loan
108
- args[:loan_id] = loan.loan_id
109
- end
110
103
  params = query_merge args
111
104
  response = resources.almaws_v1_users.user_id_loans_loan_id.post(params)
112
- RenewalResponse.new(response, loan)
105
+ RenewalResponse.new(response)
113
106
  end
114
107
 
115
108
 
@@ -1,3 +1,3 @@
1
1
  module Alma
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alma
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chad Nelson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-01-23 00:00:00.000000000 Z
11
+ date: 2017-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ezwadl