folio_client 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop/custom.yml +1 -1
- data/Gemfile.lock +1 -1
- data/README.md +30 -2
- data/lib/folio_client/version.rb +1 -1
- data/lib/folio_client.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e45342fc554ea5de7c33e31a2bc41fd1b550cf1d60a52edd47b18f2c861846e
|
4
|
+
data.tar.gz: 13b0ddc4db0c2f73c31b2db26c48c9295ffa836e1e5e491b3308382d61021e72
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5087d3b4a53111f8d442756e4ef4d7d5213c4232650fb46216c48aa877ea12c4bf5a2686ac90cbc575be3c1b7b271079357a00dd25a96f6cd7fc32a2738741f8
|
7
|
+
data.tar.gz: 1094cccbea7e0d3cfc5f0b602c78b1b1b85aa2374cd1f264dcdf569c3b7bd907153f5f9342ddc5ccc7a3a45e68e5462060f5c4452cbc1c2c5a87fd6f4bd903d8
|
data/.rubocop/custom.yml
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
# FolioClient
|
7
7
|
|
8
|
-
FolioClient is a Ruby gem that acts as a client to the RESTful HTTP APIs provided by the Folio ILS API.
|
8
|
+
FolioClient is a Ruby gem that acts as a client to the RESTful HTTP APIs provided by the Folio ILS API. It requires ruby 3.0 or better.
|
9
9
|
|
10
10
|
## Installation
|
11
11
|
|
@@ -19,6 +19,8 @@ If bundler is not being used to manage dependencies, install the gem by executin
|
|
19
19
|
|
20
20
|
## Usage
|
21
21
|
|
22
|
+
The gem should be configured first, and then you can either call API endpoints directly using GET or POST, or more commonly, use the helper methods provided, as described in the section below.
|
23
|
+
|
22
24
|
```ruby
|
23
25
|
require 'folio_client'
|
24
26
|
|
@@ -29,7 +31,9 @@ client = FolioClient.configure(
|
|
29
31
|
okapi_headers: { 'X-Okapi-Tenant': 'sul', 'User-Agent': 'FolioApiClient' }
|
30
32
|
)
|
31
33
|
|
32
|
-
response = client.get('/organizations/organizations')
|
34
|
+
response = client.get('/organizations/organizations', {query_string_param: 'abcdef'})
|
35
|
+
|
36
|
+
response = client.post('/some/post/endpoint', params_hash.to_json)
|
33
37
|
```
|
34
38
|
|
35
39
|
Note that the settings will live in the consumer of this gem and would typically be used like this:
|
@@ -44,6 +48,30 @@ client = FolioClient.configure(
|
|
44
48
|
)
|
45
49
|
```
|
46
50
|
|
51
|
+
The client is smart enough to automatically request a new token if it detects the one it is using has expired. If for some reason, you want to immediately request a new token, you can do this:
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
client.config.token = FolioClient::Authenticator.token(client.config.login_params, client.connection)
|
55
|
+
```
|
56
|
+
|
57
|
+
## API Coverage
|
58
|
+
|
59
|
+
FolioClient provides a number of methods to simplify connecting to the RESTful HTTP API of the Folio API. In this section we list all of the available methods, reflecting how much of the API the client covers. Note that this assumes the client has already been configured, as described above. See dor-services-app for an example of configuration and usage.
|
60
|
+
|
61
|
+
```ruby
|
62
|
+
# Lookup an instance hrid given a barcode
|
63
|
+
# returns a string if found, nil if nothing found
|
64
|
+
client.fetch_hrid(barcode: "12345")
|
65
|
+
=> "a7927874"
|
66
|
+
|
67
|
+
# Request a MARC record given an instance hrid
|
68
|
+
# returns a hash if found; raises FolioClient::UnexpectedResponse::ResourceNotFound if instance_hrid not found
|
69
|
+
client.fetch_marc_hash(instance_hrid: "a7927874")
|
70
|
+
=> {"fields"=>
|
71
|
+
[{"003"=>"FOLIO"}....]
|
72
|
+
}
|
73
|
+
```
|
74
|
+
|
47
75
|
## Development
|
48
76
|
|
49
77
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/folio_client/version.rb
CHANGED
data/lib/folio_client.rb
CHANGED
@@ -41,7 +41,7 @@ class FolioClient
|
|
41
41
|
# @param login_params [Hash] the folio client login params (username:, password:)
|
42
42
|
# @param okapi_headers [Hash] the okapi specific headers to add (X-Okapi-Tenant:, User-Agent:)
|
43
43
|
def configure(url:, login_params:, okapi_headers:)
|
44
|
-
instance.config = OpenStruct.new(url
|
44
|
+
instance.config = OpenStruct.new(url: url, login_params: login_params, okapi_headers: okapi_headers, token: nil)
|
45
45
|
|
46
46
|
instance.config.token = Authenticator.token(login_params, connection)
|
47
47
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: folio_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Mangiafico
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-02-
|
11
|
+
date: 2023-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -189,7 +189,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
189
189
|
- !ruby/object:Gem::Version
|
190
190
|
version: '0'
|
191
191
|
requirements: []
|
192
|
-
rubygems_version: 3.
|
192
|
+
rubygems_version: 3.4.5
|
193
193
|
signing_key:
|
194
194
|
specification_version: 4
|
195
195
|
summary: Interface for interacting with the Folio ILS API.
|