alma 0.4.0 → 0.4.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
  SHA256:
3
- metadata.gz: 55ea295ada19c46e1c3c157ded8cdf0997d62e744913b513a288c45f2239cdce
4
- data.tar.gz: 213034074451c8d5388abdf9a6ee6385b56432adab463fa3e9a5d39b8e3dd953
3
+ metadata.gz: d8abf09ab18832b9e07c6ff3f19f55579799558aeeb94434757f4295d3e15be1
4
+ data.tar.gz: aa9956de6794d3a2d7e1690aab759e80cb62dd1c6a4c6525132ff57b5f82d5d9
5
5
  SHA512:
6
- metadata.gz: 3c9d95eb4c80778b3d132ed790a7a615c775a7c650e38936cc588782efabaa1a2e393b39ef94ea90acecee05e514c625b0bace832cbbf6aa9e885ecff77c32bf
7
- data.tar.gz: 55060edf008d1ee5c78a5d598daaa03666b3a423960e03fdea668aa7976e839b31385d1f4d2577f945cd4a66d1f40f6a20ca7fd19e0883fb5ced62a8c0fca420
6
+ metadata.gz: 27a32ba65c33fb1d78dfc9a0cf13b504661667ed4eacf3d80136cb0ad2eeedb1ef20bed4cc5a2109c75984b6f276443aee9de21561e845f5950f6ea0690a337a
7
+ data.tar.gz: 28b451a986c72c7e9564f0f1933f5ba356863c14871176a0da50a83ad4de9a38da7ec9c9466aeb172408f0331228dc756a66fec6fc7a509e03e5cc9b696d30b4
data/.circleci/config.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  version: 2.1
2
2
  orbs:
3
- ruby: circleci/ruby@1.2
3
+ ruby: circleci/ruby@2.0.0
4
4
 
5
5
  workflows:
6
6
  version: 2
@@ -17,7 +17,7 @@ workflows:
17
17
  jobs:
18
18
  build:
19
19
  docker:
20
- - image: cimg/ruby:2.7.2-browsers
20
+ - image: cimg/ruby:3.1-browsers
21
21
  auth:
22
22
  username: $DOCKERHUB_USER
23
23
  password: $DOCKERHUB_PASSWORD
@@ -37,7 +37,7 @@ jobs:
37
37
  command: bundle exec rake
38
38
  deploy:
39
39
  docker:
40
- - image: cimg/ruby:2.7.2-browsers
40
+ - image: cimg/ruby:3.1-browsers
41
41
 
42
42
  working_directory: ~/repo
43
43
 
data/.rubocop.yml CHANGED
@@ -2,7 +2,7 @@ require:
2
2
  - rubocop-rails
3
3
 
4
4
  AllCops:
5
- TargetRubyVersion: 2.7
5
+ TargetRubyVersion: 3.1
6
6
  # RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
7
7
  # to ignore them, so only the ones explicitly set in this file are enabled.
8
8
  DisabledByDefault: true
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-2.7.2
1
+ ruby-3.1.3
data/README.md CHANGED
@@ -138,6 +138,20 @@ Alma::User.get_requests({:user_id => 123456789})
138
138
 
139
139
  ```
140
140
 
141
+ ##### Get a single user without fees, requests, or loans
142
+
143
+ By default, this gem fetches a user's fees, requests,
144
+ and loans. If you don't want these, you can pass the
145
+ `expand` param with only the expansions you need.
146
+
147
+ ```ruby
148
+ # don't request fees or loans
149
+ user = Alma::User.find(123456789, expand: 'requests')
150
+
151
+ # don't request any of the above
152
+ user = Alma::User.find(123456789, expand: '')
153
+ ```
154
+
141
155
  ### Bib Records
142
156
  Wrappings for some of the API endpoints described by the [Bibliographic Records and Inventory
143
157
  ](https://developers.exlibrisgroup.com/alma/apis/bibs) section of the Ex Libris Developers Network
data/alma.gemspec CHANGED
@@ -23,7 +23,6 @@ Gem::Specification.new do |spec|
23
23
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
24
  spec.require_paths = ["lib"]
25
25
 
26
- spec.add_dependency "ezwadl"
27
26
  spec.add_dependency "httparty"
28
27
  spec.add_dependency "xml-simple"
29
28
  spec.add_dependency "activesupport"
data/lib/alma/bib.rb CHANGED
@@ -13,8 +13,8 @@ module Alma
13
13
  response = HTTParty.get(
14
14
  self.bibs_base_path,
15
15
  query: { mms_id: ids_from_array(ids) }.merge(args),
16
- headers: headers,
17
- timeout: timeout
16
+ headers:,
17
+ timeout:
18
18
  )
19
19
 
20
20
  if response.code == 200
@@ -7,7 +7,7 @@ module Alma
7
7
 
8
8
  def self.find(mms_id:, holding_id:)
9
9
  url = "#{bibs_base_path}/#{mms_id}/holdings/#{holding_id}"
10
- response = HTTParty.get(url, headers: headers, timeout: timeout)
10
+ response = HTTParty.get(url, headers:, timeout:)
11
11
  new(response)
12
12
  end
13
13
 
data/lib/alma/bib_item.rb CHANGED
@@ -18,18 +18,18 @@ module Alma
18
18
  holding_id = options.delete(:holding_id) || "ALL"
19
19
  options.select! { |k, _| PERMITTED_ARGS.include? k }
20
20
  url = "#{bibs_base_path}/#{mms_id}/holdings/#{holding_id}/items"
21
- response = HTTParty.get(url, headers: headers, query: options, timeout: timeout)
22
- BibItemSet.new(response, options.merge({ mms_id: mms_id, holding_id: holding_id }))
21
+ response = HTTParty.get(url, headers:, query: options, timeout:)
22
+ BibItemSet.new(response, options.merge({ mms_id:, holding_id: }))
23
23
  end
24
24
 
25
25
  def self.find_by_barcode(barcode)
26
- response = HTTParty.get(items_base_path, headers: headers, query: { item_barcode: barcode }, timeout: timeout, follow_redirects: true)
26
+ response = HTTParty.get(items_base_path, headers:, query: { item_barcode: barcode }, timeout:, follow_redirects: true)
27
27
  new(response)
28
28
  end
29
29
 
30
30
  def self.scan(mms_id:, holding_id:, item_pid:, options: {})
31
31
  url = "#{bibs_base_path}/#{mms_id}/holdings/#{holding_id}/items/#{item_pid}"
32
- response = HTTParty.post(url, headers: headers, query: options)
32
+ response = HTTParty.post(url, headers:, query: options)
33
33
  new(response)
34
34
  end
35
35
 
@@ -54,7 +54,7 @@ module Alma
54
54
  Enumerator.new do |yielder|
55
55
  offset = 0
56
56
  while (!@last_page_index || @last_page_index >= offset / items_per_page) do
57
- r = (offset == 0) ? self : single_record_class.find(@mms_id, options = @options.merge({ limit: items_per_page, offset: offset }))
57
+ r = (offset == 0) ? self : single_record_class.find(@mms_id, options = @options.merge({ limit: items_per_page, offset: }))
58
58
  unless r.empty?
59
59
  r.map { |item| yielder << item }
60
60
  @last_page_index = (offset / items_per_page)
data/lib/alma/course.rb CHANGED
@@ -8,8 +8,8 @@ module Alma
8
8
  def self.all_courses(args: {})
9
9
  response = HTTParty.get("#{courses_base_path}/courses",
10
10
  query: args,
11
- headers: headers,
12
- timeout: timeout)
11
+ headers:,
12
+ timeout:)
13
13
  if response.code == 200
14
14
  Alma::CourseSet.new(get_body_from(response))
15
15
  else
@@ -72,7 +72,7 @@ module Alma
72
72
  end
73
73
 
74
74
  if data.present?
75
- log(params.merge(data).merge(type: type, start: start, tag: tag))
75
+ log(params.merge(data).merge(type:, start:, tag:))
76
76
 
77
77
  notes[id] = data unless data["error"].present?
78
78
  end
@@ -81,11 +81,11 @@ module Alma
81
81
  end
82
82
 
83
83
  self.class.new(options.merge(
84
- chain: chain,
85
- ids: ids,
86
- type: type,
87
- tag: tag,
88
- notes: notes,
84
+ chain:,
85
+ ids:,
86
+ type:,
87
+ tag:,
88
+ notes:,
89
89
  logger: @@logger,
90
90
  ))
91
91
  end
@@ -97,14 +97,14 @@ module Alma
97
97
  make_collection_ids(ids)
98
98
  .map { |id| id.merge(type: "services") }
99
99
  .inject([]) do |service_ids, params|
100
- params.merge!(tag: tag)
100
+ params.merge!(tag:)
101
101
 
102
102
  begin
103
103
  item = Alma::Electronic.get(params)
104
104
 
105
105
  if item["errorList"]
106
106
  log params.merge(item["errorList"])
107
- .merge(start: start)
107
+ .merge(start:)
108
108
  else
109
109
  item["electronic_service"].each { |service|
110
110
  service_id = { service_id: service["id"].to_s }
@@ -112,13 +112,13 @@ module Alma
112
112
  .merge(service_id)
113
113
 
114
114
  log params.merge(service_id)
115
- .merge(start: start)
115
+ .merge(start:)
116
116
  }
117
117
  end
118
118
 
119
119
  rescue StandardError => e
120
120
  log params.merge("error" => e.message)
121
- .merge(start: start)
121
+ .merge(start:)
122
122
  end
123
123
 
124
124
  service_ids
@@ -179,10 +179,10 @@ module Alma
179
179
  end
180
180
 
181
181
  self.class.new(options.merge(
182
- chain: chain,
183
- notes: notes,
184
- type: type,
185
- tag: tag,
182
+ chain:,
183
+ notes:,
184
+ type:,
185
+ tag:,
186
186
  logger: @@logger,
187
187
  ))
188
188
  end
@@ -48,7 +48,7 @@ module Alma
48
48
  @ids ||= groups.map { |limit|
49
49
  prev_offset = offset
50
50
  offset += limit
51
- { offset: prev_offset, limit: limit }
51
+ { offset: prev_offset, limit: }
52
52
  }
53
53
  .map { |params| Thread.new { self.get(params) } }
54
54
  .map(&:value).map(&:data)
@@ -76,8 +76,8 @@ module Alma
76
76
  def initialize(params = {})
77
77
  @params = params
78
78
  headers = self.class::headers
79
- log.info(url: url, query: params)
80
- response = self.class::get(url, headers: headers, query: params, timeout: timeout)
79
+ log.info(url:, query: params)
80
+ response = self.class::get(url, headers:, query: params, timeout:)
81
81
  @data = JSON.parse(response.body) rescue {}
82
82
  end
83
83
 
data/lib/alma/fine.rb CHANGED
@@ -5,7 +5,7 @@ module Alma
5
5
  extend Alma::ApiDefaults
6
6
 
7
7
  def self.where_user(user_id, args = {})
8
- response = HTTParty.get("#{users_base_path}/#{user_id}/fees", query: args, headers: headers, timeout: timeout)
8
+ response = HTTParty.get("#{users_base_path}/#{user_id}/fees", query: args, headers:, timeout:)
9
9
  if response.code == 200
10
10
  Alma::FineSet.new(response)
11
11
  else
@@ -8,7 +8,7 @@ module Alma
8
8
  def self.get(mms_id, holding_id = nil, item_pid = nil, options = {})
9
9
  url = "#{bibs_base_path}/#{mms_id}/holdings/#{holding_id}/items/#{item_pid}/request-options"
10
10
  options.select! { |k, _| REQUEST_OPTIONS_PERMITTED_ARGS.include? k }
11
- response = HTTParty.get(url, headers: headers, query: options, timeout: timeout)
11
+ response = HTTParty.get(url, headers:, query: options, timeout:)
12
12
  new(response)
13
13
  end
14
14
 
data/lib/alma/library.rb CHANGED
@@ -5,7 +5,7 @@ module Alma
5
5
  extend Alma::ApiDefaults
6
6
 
7
7
  def self.all(args: {})
8
- response = HTTParty.get("#{configuration_base_path}/libraries", query: args, headers: headers, timeout: timeout)
8
+ response = HTTParty.get("#{configuration_base_path}/libraries", query: args, headers:, timeout:)
9
9
  if response.code == 200
10
10
  LibrarySet.new(response)
11
11
  else
@@ -14,7 +14,7 @@ module Alma
14
14
  end
15
15
 
16
16
  def self.find(library_code:, args: {})
17
- response = HTTParty.get("#{configuration_base_path}/libraries/#{library_code}", query: args, headers: headers, timeout: timeout)
17
+ response = HTTParty.get("#{configuration_base_path}/libraries/#{library_code}", query: args, headers:, timeout:)
18
18
  if response.code == 200
19
19
  AlmaRecord.new(response)
20
20
  else
data/lib/alma/loan.rb CHANGED
@@ -18,7 +18,7 @@ module Alma
18
18
  end
19
19
 
20
20
  def renew
21
- Alma::User.renew_loan({ user_id: user_id, loan_id: loan_id })
21
+ Alma::User.renew_loan({ user_id:, loan_id: })
22
22
  end
23
23
 
24
24
  def self.where_user(user_id, args = {})
@@ -29,8 +29,8 @@ module Alma
29
29
  response = HTTParty.get(
30
30
  "#{users_base_path}/#{user_id}/loans",
31
31
  query: args,
32
- headers: headers,
33
- timeout: timeout
32
+ headers:,
33
+ timeout:
34
34
  )
35
35
  Alma::LoanSet.new(response, args)
36
36
  end
data/lib/alma/loan_set.rb CHANGED
@@ -40,12 +40,15 @@ module Alma
40
40
  Enumerator.new do |yielder|
41
41
  offset = 0
42
42
  loop do
43
- extra_args = @search_args.merge({ limit: 100, offset: offset })
43
+ extra_args = @search_args.merge({ limit: 100, offset: })
44
44
  r = (offset == 0) ? self : single_record_class.where_user(user_id, extra_args)
45
+
45
46
  unless r.empty?
46
47
  r.map { |item| yielder << item }
47
48
  offset += 100
48
- else
49
+ end
50
+
51
+ if r.empty? || r.count < extra_args[:limit]
49
52
  raise StopIteration
50
53
  end
51
54
  end
data/lib/alma/location.rb CHANGED
@@ -5,7 +5,7 @@ module Alma
5
5
  extend Alma::ApiDefaults
6
6
 
7
7
  def self.all(library_code:, args: {})
8
- response = HTTParty.get("#{configuration_base_path}/libraries/#{library_code}/locations", query: args, headers: headers, timeout: timeout)
8
+ response = HTTParty.get("#{configuration_base_path}/libraries/#{library_code}/locations", query: args, headers:, timeout:)
9
9
  if response.code == 200
10
10
  LocationSet.new(response)
11
11
  else
@@ -14,7 +14,7 @@ module Alma
14
14
  end
15
15
 
16
16
  def self.find(library_code:, location_code:, args: {})
17
- response = HTTParty.get("#{configuration_base_path}/libraries/#{library_code}/locations/#{location_code}", query: args, headers: headers, timeout: timeout)
17
+ response = HTTParty.get("#{configuration_base_path}/libraries/#{library_code}/locations/#{location_code}", query: args, headers:, timeout:)
18
18
  if response.code == 200
19
19
  AlmaRecord.new(response)
20
20
  else
data/lib/alma/request.rb CHANGED
@@ -14,7 +14,7 @@ module Alma
14
14
  response = HTTParty.post(
15
15
  "#{bibs_base_path}/#{request.mms_id}/requests",
16
16
  query: { user_id: request.user_id },
17
- headers: headers,
17
+ headers:,
18
18
  body: request.body.to_json
19
19
  )
20
20
  Alma::Response.new(response)
@@ -143,7 +143,7 @@ module Alma
143
143
  response = HTTParty.post(
144
144
  "#{bibs_base_path}/#{request.mms_id}/holdings/#{request.holding_id}/items/#{request.item_pid}/requests",
145
145
  query: { user_id: request.user_id },
146
- headers: headers,
146
+ headers:,
147
147
  body: request.body.to_json
148
148
  )
149
149
  Alma::Response.new(response)
@@ -23,7 +23,7 @@ module Alma
23
23
  def self.get(mms_id, options = {})
24
24
  url = "#{bibs_base_path}/#{mms_id}/request-options"
25
25
  options.select! { |k, _| REQUEST_OPTIONS_PERMITTED_ARGS.include? k }
26
- response = HTTParty.get(url, headers: headers, query: options, timeout: timeout)
26
+ response = HTTParty.get(url, headers:, query: options, timeout:)
27
27
  new(response)
28
28
  end
29
29
 
@@ -34,12 +34,16 @@ module Alma
34
34
  def all
35
35
  Enumerator.new do |yielder|
36
36
  offset = 0
37
+ limit = 100
38
+
37
39
  loop do
38
- r = (offset == 0) ? self : single_record_class.where_user(user_id, { limit: 100, offset: offset })
40
+ r = (offset == 0) ? self : single_record_class.where_user(user_id, { limit:, offset: })
39
41
  unless r.empty?
40
42
  r.map { |item| yielder << item }
41
43
  offset += 100
42
- else
44
+ end
45
+
46
+ if r.empty? || r.count < limit
43
47
  raise StopIteration
44
48
  end
45
49
  end
data/lib/alma/user.rb CHANGED
@@ -9,7 +9,7 @@ module Alma
9
9
 
10
10
  def self.find(user_id, args = {})
11
11
  args[:expand] ||= "fees,requests,loans"
12
- response = HTTParty.get("#{self.users_base_path}/#{user_id}", query: args, headers: headers, timeout: timeout)
12
+ response = HTTParty.get("#{self.users_base_path}/#{user_id}", query: args.compact_blank, headers:, timeout:)
13
13
 
14
14
  Alma::User.new response
15
15
  end
@@ -22,7 +22,7 @@ module Alma
22
22
  def self.authenticate(args)
23
23
  user_id = args.delete(:user_id) { raise ArgumentError }
24
24
  args.merge!({ op: "auth" })
25
- response = HTTParty.post("#{users_base_path}/#{user_id}", query: args, headers: headers, timeout: timeout)
25
+ response = HTTParty.post("#{users_base_path}/#{user_id}", query: args, headers:, timeout:)
26
26
  response.code == 204
27
27
  end
28
28
 
@@ -80,7 +80,7 @@ module Alma
80
80
 
81
81
  # Persist the user in it's current state back to Alma
82
82
  def save!
83
- response = HTTParty.put("#{users_base_path}/#{id}", timeout: timeout, headers: headers, body: to_json)
83
+ response = HTTParty.put("#{users_base_path}/#{id}", timeout:, headers:, body: to_json)
84
84
  get_body_from(response)
85
85
  end
86
86
 
@@ -97,7 +97,7 @@ module Alma
97
97
  end
98
98
 
99
99
  def renew_loan(loan_id)
100
- response = self.class.send_loan_renewal_request({ user_id: id, loan_id: loan_id })
100
+ response = self.class.send_loan_renewal_request({ user_id: id, loan_id: })
101
101
  if response.renewed?
102
102
  @recheck_loans ||= true
103
103
  end
@@ -154,7 +154,7 @@ module Alma
154
154
  loan_id = args.delete(:loan_id) { raise ArgumentError }
155
155
  user_id = args.delete(:user_id) { raise ArgumentError }
156
156
  params = { op: "renew" }
157
- response = HTTParty.post("#{users_base_path}/#{user_id}/loans/#{loan_id}", query: params, headers: headers)
157
+ response = HTTParty.post("#{users_base_path}/#{user_id}/loans/#{loan_id}", query: params, headers:)
158
158
  RenewalResponse.new(response)
159
159
  end
160
160
 
@@ -175,7 +175,7 @@ module Alma
175
175
  def self.send_payment(args)
176
176
  user_id = args.delete(:user_id) { raise ArgumentError }
177
177
  params = { op: "pay", amount: "ALL", method: "ONLINE" }
178
- response = HTTParty.post("#{users_base_path}/#{user_id}/fees/all", query: params, headers: headers)
178
+ response = HTTParty.post("#{users_base_path}/#{user_id}/fees/all", query: params, headers:)
179
179
  PaymentResponse.new(response)
180
180
  end
181
181
 
@@ -10,8 +10,8 @@ module Alma
10
10
  response = HTTParty.get(
11
11
  "#{users_base_path}/#{user_id}/requests",
12
12
  query: args,
13
- headers: headers,
14
- timeout: timeout
13
+ headers:,
14
+ timeout:
15
15
  )
16
16
  Alma::RequestSet.new(response)
17
17
  end
data/lib/alma/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Alma
4
- VERSION = "0.4.0"
4
+ VERSION = "0.4.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alma
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jennifer Anton
@@ -10,22 +10,8 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2022-11-08 00:00:00.000000000 Z
13
+ date: 2023-09-06 00:00:00.000000000 Z
14
14
  dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: ezwadl
17
- requirement: !ruby/object:Gem::Requirement
18
- requirements:
19
- - - ">="
20
- - !ruby/object:Gem::Version
21
- version: '0'
22
- type: :runtime
23
- prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- version: '0'
29
15
  - !ruby/object:Gem::Dependency
30
16
  name: httparty
31
17
  requirement: !ruby/object:Gem::Requirement
@@ -293,7 +279,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
293
279
  - !ruby/object:Gem::Version
294
280
  version: '0'
295
281
  requirements: []
296
- rubygems_version: 3.1.4
282
+ rubygems_version: 3.4.19
297
283
  signing_key:
298
284
  specification_version: 4
299
285
  summary: Client for Ex Libris Alma Web Services