folio_client 1.0.0 → 1.2.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/.rubocop.yml +9 -6
- data/Gemfile.lock +32 -31
- data/README.md +7 -1
- data/lib/folio_client/records_editor.rb +3 -1
- data/lib/folio_client/version.rb +1 -1
- data/lib/folio_client.rb +29 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e374f053307ee51d65ddfb9ee59796f1544686be6921ee52dbc08a21d570c5f1
|
|
4
|
+
data.tar.gz: 36fe9cb668791aff197898b78ddf51da0cec7924b5933c33a35a752b8873951b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a45652bb503b98551e65a306512e24410a629056a2f41a9239e3e75c7ef88f4f565e3045e7007d96639e110e0d0a171dbf2a6ca0c311b2ecb0fafb511e3e3568
|
|
7
|
+
data.tar.gz: cf5cdfd3864e239674dee3654b714d2a7e1b3c2b56b7d7664ec08ae72b92b753f1813228634c80eb0d4330cd32b30dcb01de2a8428f7191f21d0943a4398b4d2
|
data/.rubocop.yml
CHANGED
|
@@ -22,6 +22,8 @@ RSpec/MultipleExpectations:
|
|
|
22
22
|
Max: 3
|
|
23
23
|
RSpec/ExampleLength:
|
|
24
24
|
Max: 15
|
|
25
|
+
RSpec/NestedGroups:
|
|
26
|
+
Enabled: false
|
|
25
27
|
|
|
26
28
|
RSpec/BeEq: # new in 2.9.0
|
|
27
29
|
Enabled: true
|
|
@@ -53,15 +55,15 @@ RSpecRails/HaveHttpStatus: # new in 2.12
|
|
|
53
55
|
Enabled: true
|
|
54
56
|
RSpecRails/InferredSpecType: # new in 2.14
|
|
55
57
|
Enabled: true
|
|
56
|
-
Capybara/MatchStyle: # new in 2.17
|
|
58
|
+
Capybara/RSpec/MatchStyle: # new in 2.17
|
|
57
59
|
Enabled: true
|
|
58
|
-
Capybara/NegationMatcher: # new in 2.14
|
|
60
|
+
Capybara/RSpec/NegationMatcher: # new in 2.14
|
|
59
61
|
Enabled: true
|
|
60
62
|
Capybara/SpecificActions: # new in 2.14
|
|
61
63
|
Enabled: true
|
|
62
64
|
Capybara/SpecificFinders: # new in 2.13
|
|
63
65
|
Enabled: true
|
|
64
|
-
Capybara/SpecificMatcher: # new in 2.12
|
|
66
|
+
Capybara/RSpec/SpecificMatcher: # new in 2.12
|
|
65
67
|
Enabled: true
|
|
66
68
|
RSpec/DuplicatedMetadata: # new in 2.16
|
|
67
69
|
Enabled: true
|
|
@@ -292,8 +294,6 @@ Style/SwapValues: # new in 1.1
|
|
|
292
294
|
Enabled: true
|
|
293
295
|
Style/YAMLFileRead: # new in 1.53
|
|
294
296
|
Enabled: true
|
|
295
|
-
Capybara/ClickLinkOrButtonStyle: # new in 2.19
|
|
296
|
-
Enabled: true
|
|
297
297
|
Capybara/RedundantWithinFind: # new in 2.20
|
|
298
298
|
Enabled: true
|
|
299
299
|
Capybara/RSpec/HaveSelector: # new in 2.19
|
|
@@ -441,7 +441,7 @@ RSpec/IncludeExamples: # new in 3.6
|
|
|
441
441
|
Enabled: true
|
|
442
442
|
Capybara/FindAllFirst: # new in 2.22
|
|
443
443
|
Enabled: true
|
|
444
|
-
Capybara/NegationMatcherAfterVisit: # new in 2.22
|
|
444
|
+
Capybara/RSpec/NegationMatcherAfterVisit: # new in 2.22
|
|
445
445
|
Enabled: true
|
|
446
446
|
Gemspec/AttributeAssignment: # new in 1.77
|
|
447
447
|
Enabled: true
|
|
@@ -491,3 +491,6 @@ Style/SelectByRange: # new in 1.85
|
|
|
491
491
|
Enabled: true
|
|
492
492
|
Style/TallyMethod: # new in 1.85
|
|
493
493
|
Enabled: true
|
|
494
|
+
Capybara/AmbiguousClick: # new in 2.21
|
|
495
|
+
Enabled: true
|
|
496
|
+
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
folio_client (1.
|
|
4
|
+
folio_client (1.2.0)
|
|
5
5
|
activesupport (>= 4.2)
|
|
6
6
|
deprecation
|
|
7
7
|
dry-monads
|
|
@@ -31,13 +31,12 @@ GEM
|
|
|
31
31
|
public_suffix (>= 2.0.2, < 8.0)
|
|
32
32
|
ast (2.4.3)
|
|
33
33
|
base64 (0.3.0)
|
|
34
|
-
bigdecimal (4.1.
|
|
35
|
-
concurrent-ruby (1.3.
|
|
34
|
+
bigdecimal (4.1.2)
|
|
35
|
+
concurrent-ruby (1.3.7)
|
|
36
36
|
connection_pool (3.0.2)
|
|
37
37
|
crack (1.0.1)
|
|
38
38
|
bigdecimal
|
|
39
39
|
rexml
|
|
40
|
-
date (3.5.1)
|
|
41
40
|
debug (1.11.1)
|
|
42
41
|
irb (~> 1.10)
|
|
43
42
|
reline (>= 0.3.8)
|
|
@@ -51,66 +50,68 @@ GEM
|
|
|
51
50
|
concurrent-ruby (~> 1.0)
|
|
52
51
|
logger
|
|
53
52
|
zeitwerk (~> 2.6)
|
|
54
|
-
dry-monads (1.
|
|
53
|
+
dry-monads (1.10.0)
|
|
55
54
|
concurrent-ruby (~> 1.0)
|
|
56
55
|
dry-core (~> 1.1)
|
|
57
56
|
zeitwerk (~> 2.6)
|
|
58
|
-
erb (6.0.
|
|
59
|
-
faraday (2.14.
|
|
57
|
+
erb (6.0.4)
|
|
58
|
+
faraday (2.14.3)
|
|
60
59
|
faraday-net_http (>= 2.0, < 3.5)
|
|
61
60
|
json
|
|
62
61
|
logger
|
|
63
62
|
faraday-cookie_jar (0.0.8)
|
|
64
63
|
faraday (>= 0.8.0)
|
|
65
64
|
http-cookie (>= 1.0.0)
|
|
66
|
-
faraday-net_http (3.4.
|
|
65
|
+
faraday-net_http (3.4.4)
|
|
67
66
|
net-http (~> 0.5)
|
|
68
67
|
hashdiff (1.2.1)
|
|
69
|
-
http-cookie (1.1.
|
|
68
|
+
http-cookie (1.1.6)
|
|
70
69
|
domain_name (~> 0.5)
|
|
71
|
-
i18n (1.
|
|
70
|
+
i18n (1.15.2)
|
|
72
71
|
concurrent-ruby (~> 1.0)
|
|
73
72
|
io-console (0.8.2)
|
|
74
|
-
irb (1.
|
|
73
|
+
irb (1.18.0)
|
|
75
74
|
pp (>= 0.6.0)
|
|
76
75
|
prism (>= 1.3.0)
|
|
77
76
|
rdoc (>= 4.0.0)
|
|
78
77
|
reline (>= 0.4.2)
|
|
79
|
-
json (2.
|
|
78
|
+
json (2.20.0)
|
|
80
79
|
language_server-protocol (3.17.0.5)
|
|
81
80
|
lint_roller (1.1.0)
|
|
82
81
|
logger (1.7.0)
|
|
83
82
|
marc (1.4.0)
|
|
84
83
|
nokogiri (~> 1.0)
|
|
85
84
|
rexml
|
|
86
|
-
minitest (6.0.
|
|
85
|
+
minitest (6.0.6)
|
|
87
86
|
drb (~> 2.0)
|
|
88
87
|
prism (~> 1.5)
|
|
89
88
|
net-http (0.9.1)
|
|
90
89
|
uri (>= 0.11.1)
|
|
91
|
-
nokogiri (1.19.
|
|
90
|
+
nokogiri (1.19.4-arm64-darwin)
|
|
92
91
|
racc (~> 1.4)
|
|
93
|
-
nokogiri (1.19.
|
|
92
|
+
nokogiri (1.19.4-x86_64-linux-gnu)
|
|
94
93
|
racc (~> 1.4)
|
|
95
94
|
ostruct (0.6.3)
|
|
96
|
-
parallel (2.0
|
|
95
|
+
parallel (2.1.0)
|
|
97
96
|
parser (3.3.11.1)
|
|
98
97
|
ast (~> 2.4.1)
|
|
99
98
|
racc
|
|
100
|
-
pp (0.6.
|
|
99
|
+
pp (0.6.4)
|
|
101
100
|
prettyprint
|
|
102
101
|
prettyprint (0.2.0)
|
|
103
102
|
prism (1.9.0)
|
|
104
|
-
psych (5.3.1)
|
|
105
|
-
date
|
|
106
|
-
stringio
|
|
107
103
|
public_suffix (7.0.5)
|
|
108
104
|
racc (1.8.1)
|
|
109
105
|
rainbow (3.1.1)
|
|
110
|
-
rake (13.
|
|
111
|
-
|
|
106
|
+
rake (13.4.2)
|
|
107
|
+
rbs (4.0.3)
|
|
108
|
+
logger
|
|
109
|
+
prism (>= 1.6.0)
|
|
110
|
+
tsort
|
|
111
|
+
rdoc (8.0.0)
|
|
112
112
|
erb
|
|
113
|
-
|
|
113
|
+
prism (>= 1.6.0)
|
|
114
|
+
rbs (>= 4.0.0)
|
|
114
115
|
tsort
|
|
115
116
|
regexp_parser (2.12.0)
|
|
116
117
|
reline (0.6.3)
|
|
@@ -129,7 +130,7 @@ GEM
|
|
|
129
130
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
130
131
|
rspec-support (~> 3.13.0)
|
|
131
132
|
rspec-support (3.13.7)
|
|
132
|
-
rubocop (1.
|
|
133
|
+
rubocop (1.88.0)
|
|
133
134
|
json (~> 2.3)
|
|
134
135
|
language_server-protocol (~> 3.17.0.2)
|
|
135
136
|
lint_roller (~> 1.1.0)
|
|
@@ -143,9 +144,9 @@ GEM
|
|
|
143
144
|
rubocop-ast (1.49.1)
|
|
144
145
|
parser (>= 3.3.7.2)
|
|
145
146
|
prism (~> 1.7)
|
|
146
|
-
rubocop-capybara (
|
|
147
|
+
rubocop-capybara (3.0.0)
|
|
147
148
|
lint_roller (~> 1.1)
|
|
148
|
-
rubocop (~> 1.
|
|
149
|
+
rubocop (~> 1.81)
|
|
149
150
|
rubocop-factory_bot (2.28.0)
|
|
150
151
|
lint_roller (~> 1.1)
|
|
151
152
|
rubocop (~> 1.72, >= 1.72.1)
|
|
@@ -153,9 +154,10 @@ GEM
|
|
|
153
154
|
lint_roller (~> 1.1)
|
|
154
155
|
rubocop (>= 1.75.0, < 2.0)
|
|
155
156
|
rubocop-ast (>= 1.47.1, < 2.0)
|
|
156
|
-
rubocop-rspec (3.
|
|
157
|
+
rubocop-rspec (3.10.2)
|
|
157
158
|
lint_roller (~> 1.1)
|
|
158
|
-
|
|
159
|
+
regexp_parser (>= 2.0)
|
|
160
|
+
rubocop (~> 1.86, >= 1.86.2)
|
|
159
161
|
rubocop-rspec_rails (2.32.0)
|
|
160
162
|
lint_roller (~> 1.1)
|
|
161
163
|
rubocop (~> 1.72, >= 1.72.1)
|
|
@@ -168,7 +170,6 @@ GEM
|
|
|
168
170
|
simplecov_json_formatter (~> 0.1)
|
|
169
171
|
simplecov-html (0.13.2)
|
|
170
172
|
simplecov_json_formatter (0.1.4)
|
|
171
|
-
stringio (3.2.0)
|
|
172
173
|
tsort (0.2.0)
|
|
173
174
|
tzinfo (2.0.6)
|
|
174
175
|
concurrent-ruby (~> 1.0)
|
|
@@ -180,7 +181,7 @@ GEM
|
|
|
180
181
|
addressable (>= 2.8.0)
|
|
181
182
|
crack (>= 0.3.2)
|
|
182
183
|
hashdiff (>= 0.4.0, < 2.0.0)
|
|
183
|
-
zeitwerk (2.
|
|
184
|
+
zeitwerk (2.8.2)
|
|
184
185
|
|
|
185
186
|
PLATFORMS
|
|
186
187
|
arm64-darwin-23
|
|
@@ -203,4 +204,4 @@ DEPENDENCIES
|
|
|
203
204
|
webmock
|
|
204
205
|
|
|
205
206
|
BUNDLED WITH
|
|
206
|
-
4.0.
|
|
207
|
+
4.0.15
|
data/README.md
CHANGED
|
@@ -18,7 +18,7 @@ If bundler is not being used to manage dependencies, install the gem by executin
|
|
|
18
18
|
|
|
19
19
|
## Usage
|
|
20
20
|
|
|
21
|
-
The gem should be configured first, and then you can either call API endpoints directly using GET
|
|
21
|
+
The gem should be configured first, and then you can either call API endpoints directly using GET, POST, PUT, and DELETE. It may be more convenient to use the helper methods provided, as described in the section below, if your use case is already covered by what's been implemented already.
|
|
22
22
|
|
|
23
23
|
```ruby
|
|
24
24
|
require 'folio_client'
|
|
@@ -34,6 +34,12 @@ client = FolioClient.configure(
|
|
|
34
34
|
response = client.get('/organizations/organizations', {query_string_param: 'abcdef'})
|
|
35
35
|
|
|
36
36
|
response = client.post('/some/post/endpoint', params_hash.to_json)
|
|
37
|
+
|
|
38
|
+
# If you want direct access to the response object for your own handling, you can also
|
|
39
|
+
# pass a block to the get, post, put, and delete methods:
|
|
40
|
+
response = client.post('/some/post/endpoint', params_hash.to_json) do |resp|
|
|
41
|
+
# Do something with resp.status, resp.headers, resp.body, etc.
|
|
42
|
+
end
|
|
37
43
|
```
|
|
38
44
|
|
|
39
45
|
Note that the settings will live in the consumer of this gem and would typically be used like this:
|
|
@@ -30,9 +30,11 @@ class FolioClient
|
|
|
30
30
|
record_json['relatedRecordVersion'] = version
|
|
31
31
|
record_json['_actionType'] = 'edit'
|
|
32
32
|
|
|
33
|
+
original_record_json = record_json.deep_dup
|
|
34
|
+
|
|
33
35
|
yield record_json
|
|
34
36
|
|
|
35
|
-
client.put("/records-editor/records/#{parsed_record_id}", record_json)
|
|
37
|
+
client.put("/records-editor/records/#{parsed_record_id}", record_json) unless record_json == original_record_json
|
|
36
38
|
end
|
|
37
39
|
|
|
38
40
|
private
|
data/lib/folio_client/version.rb
CHANGED
data/lib/folio_client.rb
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
require 'http/cookie' # Workaround for https://github.com/sparklemotion/http-cookie/issues/62
|
|
4
4
|
require 'active_support/core_ext/module/delegation'
|
|
5
5
|
require 'active_support/core_ext/object/blank'
|
|
6
|
+
require 'active_support/core_ext/object/deep_dup'
|
|
6
7
|
require 'deprecation'
|
|
7
8
|
require 'faraday'
|
|
8
9
|
require 'faraday-cookie_jar'
|
|
@@ -103,6 +104,7 @@ class FolioClient # rubocop:disable Metrics/ClassLength
|
|
|
103
104
|
# @param path [String] API path relative to configured +url+
|
|
104
105
|
# @param params [Hash] query parameters
|
|
105
106
|
# @return [Hash, Array, nil] parsed JSON body, or +nil+ for empty body
|
|
107
|
+
# @yield [Faraday::Response] optional block to receive the raw +Faraday::Response+ object
|
|
106
108
|
# @raise [FolioClient::Error] when Folio responds with an unexpected status
|
|
107
109
|
def get(path, params = {})
|
|
108
110
|
response = with_token_refresh_when_unauthorized do
|
|
@@ -111,6 +113,8 @@ class FolioClient # rubocop:disable Metrics/ClassLength
|
|
|
111
113
|
|
|
112
114
|
UnexpectedResponse.call(response) unless response.success?
|
|
113
115
|
|
|
116
|
+
yield response if block_given?
|
|
117
|
+
|
|
114
118
|
JSON.parse(response.body) if response.body.present?
|
|
115
119
|
end
|
|
116
120
|
|
|
@@ -121,6 +125,7 @@ class FolioClient # rubocop:disable Metrics/ClassLength
|
|
|
121
125
|
# @param body [Hash, String, nil] request payload
|
|
122
126
|
# @param content_type [String] MIME type of request body
|
|
123
127
|
# @return [Hash, Array, nil] parsed JSON body, or +nil+ for empty body
|
|
128
|
+
# @yield [Faraday::Response] optional block to receive the raw +Faraday::Response+ object
|
|
124
129
|
# @raise [FolioClient::Error] when Folio responds with an unexpected status
|
|
125
130
|
def post(path, body = nil, content_type: 'application/json')
|
|
126
131
|
req_body = content_type == 'application/json' ? body&.to_json : body
|
|
@@ -130,6 +135,8 @@ class FolioClient # rubocop:disable Metrics/ClassLength
|
|
|
130
135
|
|
|
131
136
|
UnexpectedResponse.call(response) unless response.success?
|
|
132
137
|
|
|
138
|
+
yield response if block_given?
|
|
139
|
+
|
|
133
140
|
JSON.parse(response.body) if response.body.present?
|
|
134
141
|
end
|
|
135
142
|
|
|
@@ -141,6 +148,7 @@ class FolioClient # rubocop:disable Metrics/ClassLength
|
|
|
141
148
|
# @param content_type [String] MIME type of request body
|
|
142
149
|
# @param exception_args [Hash] supplemental context forwarded to +UnexpectedResponse+
|
|
143
150
|
# @return [Hash, Array, nil] parsed JSON body, or +nil+ for empty body
|
|
151
|
+
# @yield [Faraday::Response] optional block to receive the raw +Faraday::Response+ object
|
|
144
152
|
# @raise [FolioClient::Error] when Folio responds with an unexpected status
|
|
145
153
|
def put(path, body = nil, content_type: 'application/json', **exception_args)
|
|
146
154
|
req_body = content_type == 'application/json' ? body&.to_json : body
|
|
@@ -150,6 +158,27 @@ class FolioClient # rubocop:disable Metrics/ClassLength
|
|
|
150
158
|
|
|
151
159
|
UnexpectedResponse.call(response, **exception_args) unless response.success?
|
|
152
160
|
|
|
161
|
+
yield response if block_given?
|
|
162
|
+
|
|
163
|
+
JSON.parse(response.body) if response.body.present?
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
# Send an authenticated DELETE request
|
|
167
|
+
# @note None of the current FolioClient services use this method, but it's provided
|
|
168
|
+
# primarily to accommodate work in folio-tasks
|
|
169
|
+
# @param path [String] API path relative to configured +url+
|
|
170
|
+
# @return [Hash, Array, nil] parsed JSON body, or +nil+ for empty body
|
|
171
|
+
# @yield [Faraday::Response] optional block to receive the raw +Faraday::Response+ object
|
|
172
|
+
# @raise [FolioClient::Error] when Folio responds with an unexpected status
|
|
173
|
+
def delete(path)
|
|
174
|
+
response = with_token_refresh_when_unauthorized do
|
|
175
|
+
connection.delete(path)
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
UnexpectedResponse.call(response) unless response.success?
|
|
179
|
+
|
|
180
|
+
yield response if block_given?
|
|
181
|
+
|
|
153
182
|
JSON.parse(response.body) if response.body.present?
|
|
154
183
|
end
|
|
155
184
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: folio_client
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Peter Mangiafico
|
|
@@ -309,7 +309,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
309
309
|
- !ruby/object:Gem::Version
|
|
310
310
|
version: '0'
|
|
311
311
|
requirements: []
|
|
312
|
-
rubygems_version: 4.0.
|
|
312
|
+
rubygems_version: 4.0.6
|
|
313
313
|
specification_version: 4
|
|
314
314
|
summary: Interface for interacting with the Folio ILS API.
|
|
315
315
|
test_files: []
|