alma 0.2.6 → 0.2.8

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
- SHA256:
3
- metadata.gz: 9f8f97556fd38ab3e4b03c42ee739d1a8a878f997e1d2ee54fb5dd5017b3cd51
4
- data.tar.gz: 1e5d6362f38d31fe538afe713b9b5ec87469f0364ddfde258e29a1c3b076cf88
2
+ SHA1:
3
+ metadata.gz: e3079955feac35f5665cae0f49298159c6739f8e
4
+ data.tar.gz: ada299082a4b7c0a15e8126b3417e4d8264d66f4
5
5
  SHA512:
6
- metadata.gz: 2e9e26c6789cf81b7d8390c56a42f6c422dffda52befa4b629873bfa7edc0a7974c20ed51c485f861809743e9fa9db988af4d4cbe4f63ee8b15b4371ee27f38c
7
- data.tar.gz: ad6e0abc8e573bb1c02b34047eab1847e21ca858c6baa385b969c1faf45033151679201543f13ddc74d696035e234387e75eba7bfe4e046ff60231fc1e795b3b
6
+ metadata.gz: 267aa00bed5ba01ab29862986d549fc637ebe3ea26fefd7236728fe49c4a90c2f607608c8c44f52cbfcb8e4098403ee4d18f1094d51421ae289e81e41af46fb8
7
+ data.tar.gz: 9babb4fda07c15927e659af938c3038f261082f70db8a7d102004dd323620f33565d3b5d5d19b9497987608d7acbd8651cefcac3ed6786da47952b02c7a531ce
@@ -5,7 +5,6 @@ module Alma
5
5
  #include Alma::Error
6
6
 
7
7
  attr_reader :response
8
- def_delegators :list, :each, :size
9
8
  def_delegators :response, :[], :fetch
10
9
 
11
10
  def initialize(response_body_hash)
@@ -16,8 +15,13 @@ module Alma
16
15
  'fee'
17
16
  end
18
17
 
19
- def list
20
- fetch(key, [])
18
+ def each
19
+ @response.fetch(key, []).map{|item| Alma::AlmaRecord.new(item)}
20
+ end
21
+ alias list each
22
+
23
+ def size
24
+ each.count
21
25
  end
22
26
 
23
27
  def sum
@@ -1,9 +1,18 @@
1
1
  module Alma
2
2
  class Loan < AlmaRecord
3
3
 
4
+
5
+ def renewable?
6
+ !!renewable
7
+ end
8
+
9
+ def overdue?
10
+ loan_status == "Overdue"
11
+ end
12
+
4
13
  def renew
5
14
  Alma::User.renew_loan({user_id: user_id, loan_id: loan_id})
6
15
  end
7
16
 
8
17
  end
9
- end
18
+ end
@@ -5,16 +5,21 @@ module Alma
5
5
  #include Alma::Error
6
6
 
7
7
  attr_reader :response
8
- def_delegators :list, :each, :size
9
8
  def_delegators :response, :[], :fetch
10
9
 
11
10
  def initialize(response_body_hash)
12
11
  @response = response_body_hash
13
12
  end
14
13
 
15
- def list
16
- fetch(key, [])
14
+ def each
15
+ @response.fetch(key, []).map{|item| Alma::Loan.new(item)}
17
16
  end
17
+ alias list each
18
+
19
+ def size
20
+ each.count
21
+ end
22
+
18
23
 
19
24
  def key
20
25
  'item_loan'
@@ -12,8 +12,12 @@ module Alma
12
12
  @success
13
13
  end
14
14
 
15
+ def has_error?
16
+ !renewed?
17
+ end
18
+
15
19
  def due_date
16
- @response.fetch('dueDate', '')
20
+ @response.fetch('due_date', '')
17
21
  end
18
22
 
19
23
 
@@ -23,6 +23,10 @@ module Alma
23
23
  !request_options.select {|option| option["type"]["value"] == "HOLD" }.empty?
24
24
  end
25
25
 
26
+ def digitization_allowed?
27
+ !request_options.select {|option| option["type"]["value"] == "DIGITIZATION" }.empty?
28
+ end
29
+
26
30
  private
27
31
 
28
32
  def self.region
@@ -5,15 +5,19 @@ module Alma
5
5
  #include Alma::Error
6
6
 
7
7
  attr_reader :response
8
- def_delegators :list, :each, :size
9
8
  def_delegators :response, :[], :fetch
10
9
 
11
10
  def initialize(response_body_hash)
12
11
  @response = response_body_hash
13
12
  end
14
13
 
15
- def list
16
- fetch(key, [])
14
+ def each
15
+ @response.fetch(key, []).map{|item| Alma::AlmaRecord.new(item)}
16
+ end
17
+ alias list each
18
+
19
+ def size
20
+ each.count
17
21
  end
18
22
 
19
23
  def total_record_count
@@ -86,11 +86,10 @@ module Alma
86
86
  end
87
87
 
88
88
  def renew_loan(loan_id)
89
- response = send_loan_renewal_request({user_id: id, loan_id: loan_id})
89
+ response = self.class.send_loan_renewal_request({user_id: id, loan_id: loan_id})
90
90
  if response.renewed?
91
91
  @recheck_loans ||= true
92
92
  end
93
- get_body_from response
94
93
  end
95
94
 
96
95
 
@@ -136,14 +135,24 @@ module Alma
136
135
  # @option args [String] :loan_id The unique id of the loan
137
136
  # @option args [String] :user_id_type Type of identifier being used to search. OPTIONAL
138
137
  # @return [RenewalResponse] Object indicating the renewal message
139
- def send_loan_renewal_request(args)
140
- user_id = args.delete(:user_id) { raise ArgumentError }
138
+ def self.send_loan_renewal_request(args)
141
139
  loan_id = args.delete(:loan_id) { raise ArgumentError }
140
+ user_id = args.delete(:user_id) { raise ArgumentError }
142
141
  params = {op: 'renew'}
143
- response = HTTParty.post("#{users_base_path}/#{id}/loans/#{loan_id}", query: params, headers: headers)
144
- RenewalResponse.new(get_body_from(response))
142
+ response = HTTParty.post("#{users_base_path}/#{user_id}/loans/#{loan_id}", query: params, headers: headers)
143
+ RenewalResponse.new(JSON.parse(response.body))
145
144
  end
146
145
 
146
+ # Attempts to renew multiple items for a user
147
+ # @param [Hash] args
148
+ # @option args [String] :user_id The unique id of the user
149
+ # @option args [Array<String>] :loan_ids The unique ids of the loans
150
+ # @option args [String] :user_id_type Type of identifier being used to search. OPTIONAL
151
+ # @return [Array<RenewalResponse>] Array of Objects indicating the renewal messages
152
+ def self.send_multiple_loan_renewal_requests(args)
153
+ loan_ids = args.delete(:loan_ids) { raise ArgumentError }
154
+ loan_ids.map { |id| Alma::User.send_loan_renewal_request(args.merge(loan_id: id))}
155
+ end
147
156
 
148
157
  def get_body_from(response)
149
158
  JSON.parse(response.body)
@@ -174,5 +183,5 @@ module Alma
174
183
  Alma.configuration.apikey
175
184
  end
176
185
 
177
- end
178
186
  end
187
+ end
@@ -1,3 +1,3 @@
1
1
  module Alma
2
- VERSION = "0.2.6"
2
+ VERSION = "0.2.8"
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.6
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chad Nelson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-06-14 00:00:00.000000000 Z
11
+ date: 2018-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ezwadl
@@ -184,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
184
184
  version: '0'
185
185
  requirements: []
186
186
  rubyforge_project:
187
- rubygems_version: 2.7.6
187
+ rubygems_version: 2.6.11
188
188
  signing_key:
189
189
  specification_version: 4
190
190
  summary: Client for Ex Libris Alma Web Services