alma 0.3.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.circleci/config.yml +4 -4
- data/CODE_OF_CONDUCT.md +1 -1
- data/lib/alma/bib_item_set.rb +2 -1
- data/lib/alma/error.rb +1 -1
- data/lib/alma/fine_set.rb +1 -1
- data/lib/alma/library_set.rb +1 -1
- data/lib/alma/loan_set.rb +2 -2
- data/lib/alma/payment_response.rb +36 -0
- data/lib/alma/request_set.rb +2 -2
- data/lib/alma/result_set.rb +1 -1
- data/lib/alma/user.rb +11 -10
- data/lib/alma/version.rb +1 -1
- data/lib/alma.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55ea295ada19c46e1c3c157ded8cdf0997d62e744913b513a288c45f2239cdce
|
4
|
+
data.tar.gz: 213034074451c8d5388abdf9a6ee6385b56432adab463fa3e9a5d39b8e3dd953
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c9d95eb4c80778b3d132ed790a7a615c775a7c650e38936cc588782efabaa1a2e393b39ef94ea90acecee05e514c625b0bace832cbbf6aa9e885ecff77c32bf
|
7
|
+
data.tar.gz: 55060edf008d1ee5c78a5d598daaa03666b3a423960e03fdea668aa7976e839b31385d1f4d2577f945cd4a66d1f40f6a20ca7fd19e0883fb5ced62a8c0fca420
|
data/.circleci/config.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
version: 2.1
|
2
2
|
orbs:
|
3
|
-
ruby: circleci/ruby@
|
3
|
+
ruby: circleci/ruby@1.2
|
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-
|
20
|
+
- image: cimg/ruby:2.7.2-browsers
|
21
21
|
auth:
|
22
22
|
username: $DOCKERHUB_USER
|
23
23
|
password: $DOCKERHUB_PASSWORD
|
@@ -28,7 +28,7 @@ jobs:
|
|
28
28
|
- run:
|
29
29
|
name: Which bundler?
|
30
30
|
command: bundle -v
|
31
|
-
-
|
31
|
+
- run: bundle install
|
32
32
|
- run:
|
33
33
|
name: lint
|
34
34
|
command: bundle exec rubocop
|
@@ -37,7 +37,7 @@ jobs:
|
|
37
37
|
command: bundle exec rake
|
38
38
|
deploy:
|
39
39
|
docker:
|
40
|
-
- image:
|
40
|
+
- image: cimg/ruby:2.7.2-browsers
|
41
41
|
|
42
42
|
working_directory: ~/repo
|
43
43
|
|
data/CODE_OF_CONDUCT.md
CHANGED
@@ -55,7 +55,7 @@ further defined and clarified by project maintainers.
|
|
55
55
|
## Enforcement
|
56
56
|
|
57
57
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
-
reported by contacting the project team at
|
58
|
+
reported by contacting the project team at svc.libdev@temple.edu. All
|
59
59
|
complaints will be reviewed and investigated and will result in a response that
|
60
60
|
is deemed necessary and appropriate to the circumstances. The project team is
|
61
61
|
obligated to maintain confidentiality with regard to the reporter of an incident.
|
data/lib/alma/bib_item_set.rb
CHANGED
@@ -21,7 +21,8 @@ module Alma
|
|
21
21
|
@mms_id = @options.delete(:mms_id)
|
22
22
|
|
23
23
|
validate(response)
|
24
|
-
@items = parsed.fetch(key, [])
|
24
|
+
@items = (parsed.fetch(key, []) || [])
|
25
|
+
.map { |item| single_record_class.new(item) }
|
25
26
|
end
|
26
27
|
|
27
28
|
def loggable
|
data/lib/alma/error.rb
CHANGED
data/lib/alma/fine_set.rb
CHANGED
data/lib/alma/library_set.rb
CHANGED
data/lib/alma/loan_set.rb
CHANGED
@@ -16,8 +16,8 @@ module Alma
|
|
16
16
|
@response = raw_response.parsed_response
|
17
17
|
@search_args = search_args
|
18
18
|
validate(raw_response)
|
19
|
-
@results = @response.fetch(key, [])
|
20
|
-
|
19
|
+
@results = @response.fetch(key, []) || []
|
20
|
+
@results.map! { |item| single_record_class.new(item) }
|
21
21
|
# args passed to the search that returned this set
|
22
22
|
# such as limit, expand, order_by, etc
|
23
23
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Alma
|
4
|
+
class PaymentResponse
|
5
|
+
def initialize(response)
|
6
|
+
@raw_response = response
|
7
|
+
@response = response.parsed_response
|
8
|
+
@success = response["total_sum"] == 0.0
|
9
|
+
end
|
10
|
+
|
11
|
+
def loggable
|
12
|
+
{ uri: @raw_response&.request&.uri.to_s
|
13
|
+
}.select { |k, v| !(v.nil? || v.empty?) }
|
14
|
+
end
|
15
|
+
|
16
|
+
def paid?
|
17
|
+
@success
|
18
|
+
end
|
19
|
+
|
20
|
+
def has_payment_error?
|
21
|
+
!paid?
|
22
|
+
end
|
23
|
+
|
24
|
+
def payment_message
|
25
|
+
if paid?
|
26
|
+
"Your balance has been paid."
|
27
|
+
else
|
28
|
+
"There was a problem processing your payment. Please contact the library for assistance."
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def error_message
|
33
|
+
@response unless paid?
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/alma/request_set.rb
CHANGED
@@ -14,8 +14,8 @@ module Alma
|
|
14
14
|
@raw_response = raw_response
|
15
15
|
@response = raw_response.parsed_response
|
16
16
|
validate(raw_response)
|
17
|
-
@results = @response.fetch(key, [])
|
18
|
-
|
17
|
+
@results = @response.fetch(key, []) || []
|
18
|
+
@results.map! { |item| single_record_class.new(item) }
|
19
19
|
end
|
20
20
|
|
21
21
|
def loggable
|
data/lib/alma/result_set.rb
CHANGED
data/lib/alma/user.rb
CHANGED
@@ -26,7 +26,6 @@ module Alma
|
|
26
26
|
response.code == 204
|
27
27
|
end
|
28
28
|
|
29
|
-
|
30
29
|
# The User object can respond directly to Hash like access of attributes
|
31
30
|
def_delegators :response, :[], :[]=, :has_key?, :keys, :to_json
|
32
31
|
|
@@ -58,7 +57,7 @@ module Alma
|
|
58
57
|
end
|
59
58
|
|
60
59
|
def total_fines
|
61
|
-
response.dig("fees", "value") ||
|
60
|
+
response.dig("fees", "value") || 0.0
|
62
61
|
end
|
63
62
|
|
64
63
|
def total_requests
|
@@ -69,7 +68,6 @@ module Alma
|
|
69
68
|
response.dig("loans", "value") || "0"
|
70
69
|
end
|
71
70
|
|
72
|
-
|
73
71
|
# Access the top level JSON attributes as object methods
|
74
72
|
def method_missing(name)
|
75
73
|
return response[name.to_s] if has_key?(name.to_s)
|
@@ -80,14 +78,12 @@ module Alma
|
|
80
78
|
has_key?(name.to_s) || super
|
81
79
|
end
|
82
80
|
|
83
|
-
|
84
81
|
# Persist the user in it's current state back to Alma
|
85
82
|
def save!
|
86
83
|
response = HTTParty.put("#{users_base_path}/#{id}", timeout: timeout, headers: headers, body: to_json)
|
87
84
|
get_body_from(response)
|
88
85
|
end
|
89
86
|
|
90
|
-
|
91
87
|
def fines
|
92
88
|
Alma::Fine.where_user(id)
|
93
89
|
end
|
@@ -96,7 +92,6 @@ module Alma
|
|
96
92
|
Alma::UserRequest.where_user(id)
|
97
93
|
end
|
98
94
|
|
99
|
-
|
100
95
|
def loans(args = {})
|
101
96
|
@loans ||= Alma::Loan.where_user(id, args)
|
102
97
|
end
|
@@ -108,7 +103,6 @@ module Alma
|
|
108
103
|
end
|
109
104
|
end
|
110
105
|
|
111
|
-
|
112
106
|
def renew_multiple_loans(loan_ids)
|
113
107
|
loan_ids.map { |id| renew_loan(id) }
|
114
108
|
end
|
@@ -148,8 +142,6 @@ module Alma
|
|
148
142
|
"#{preferred_first_name} #{preferred_middle_name} #{preferred_last_name} #{preferred_suffix}"
|
149
143
|
end
|
150
144
|
|
151
|
-
|
152
|
-
|
153
145
|
private
|
154
146
|
|
155
147
|
# Attempts to renew a single item for a user
|
@@ -177,11 +169,20 @@ module Alma
|
|
177
169
|
loan_ids.map { |id| Alma::User.send_loan_renewal_request(args.merge(loan_id: id)) }
|
178
170
|
end
|
179
171
|
|
172
|
+
# Attempts to pay total fines for a user
|
173
|
+
# @param [Hash] args
|
174
|
+
# @option args [String] :user_id The unique id of the user
|
175
|
+
def self.send_payment(args)
|
176
|
+
user_id = args.delete(:user_id) { raise ArgumentError }
|
177
|
+
params = { op: "pay", amount: "ALL", method: "ONLINE" }
|
178
|
+
response = HTTParty.post("#{users_base_path}/#{user_id}/fees/all", query: params, headers: headers)
|
179
|
+
PaymentResponse.new(response)
|
180
|
+
end
|
181
|
+
|
180
182
|
def get_body_from(response)
|
181
183
|
JSON.parse(response.body)
|
182
184
|
end
|
183
185
|
|
184
|
-
|
185
186
|
def self.users_base_path
|
186
187
|
"https://api-na.hosted.exlibrisgroup.com/almaws/v1/users"
|
187
188
|
end
|
data/lib/alma/version.rb
CHANGED
data/lib/alma.rb
CHANGED
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
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jennifer Anton
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2022-11-08 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: ezwadl
|
@@ -260,6 +260,7 @@ files:
|
|
260
260
|
- lib/alma/loan_set.rb
|
261
261
|
- lib/alma/location.rb
|
262
262
|
- lib/alma/location_set.rb
|
263
|
+
- lib/alma/payment_response.rb
|
263
264
|
- lib/alma/renewal_response.rb
|
264
265
|
- lib/alma/request.rb
|
265
266
|
- lib/alma/request_options.rb
|