folio_client 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/lib/folio_client/inventory.rb +17 -0
- data/lib/folio_client/version.rb +1 -1
- data/lib/folio_client.rb +10 -3
- 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: f2421b3de04e4754677703bb1012074d586cbce87bd90fe8b3341212ebeffae7
|
4
|
+
data.tar.gz: 54b49208c11498964a494c5c57c0c97ca3a47d71fddef9766ccf1ef4e0c404a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6fa88a92dcf548e03d69978c3600cadb33324106871ec1fcd86652e83af86aa14ed2bb3d60725cc74e6fd7291a8e4056b090d71061c04c24425d25a86310e158
|
7
|
+
data.tar.gz: 2094388e4e9c87abf1f09bdee68a05341358365940db25cde91e411e1f929ff1059a481089bde26c5b44398be824eb2300f1480d55ca431a07004fcbef26e0b6
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
folio_client (0.
|
4
|
+
folio_client (0.4.0)
|
5
5
|
activesupport (>= 4.2, < 8)
|
6
6
|
faraday
|
7
7
|
zeitwerk
|
@@ -18,7 +18,7 @@ GEM
|
|
18
18
|
public_suffix (>= 2.0.2, < 6.0)
|
19
19
|
ast (2.4.2)
|
20
20
|
byebug (11.1.3)
|
21
|
-
concurrent-ruby (1.2.
|
21
|
+
concurrent-ruby (1.2.2)
|
22
22
|
crack (0.4.5)
|
23
23
|
rexml
|
24
24
|
diff-lcs (1.5.0)
|
@@ -23,5 +23,22 @@ class FolioClient
|
|
23
23
|
result = client.get("/inventory/instances/#{instance_uuid}")
|
24
24
|
result.dig("hrid")
|
25
25
|
end
|
26
|
+
|
27
|
+
# @param hrid [String] folio instance HRID
|
28
|
+
# @param status_id [String] uuid for an instance status code
|
29
|
+
# @raise [FolioClient::UnexpectedResponse::ResourceNotFound] if search by hrid returns 0 results
|
30
|
+
def has_instance_status?(hrid:, status_id:)
|
31
|
+
# get the instance record and its statusId
|
32
|
+
instance = client.get("/inventory/instances", {query: "hrid==#{hrid}"})
|
33
|
+
raise FolioClient::UnexpectedResponse::ResourceNotFound, "No matching instance found for #{hrid}" if instance["totalRecords"] == 0
|
34
|
+
|
35
|
+
instance_status_id = instance.dig("instances", 0, "statusId")
|
36
|
+
|
37
|
+
return false unless instance_status_id
|
38
|
+
|
39
|
+
return true if instance_status_id == status_id
|
40
|
+
|
41
|
+
false
|
42
|
+
end
|
26
43
|
end
|
27
44
|
end
|
data/lib/folio_client/version.rb
CHANGED
data/lib/folio_client.rb
CHANGED
@@ -31,7 +31,7 @@ class FolioClient
|
|
31
31
|
end
|
32
32
|
|
33
33
|
delegate :config, :connection, :get, :post, to: :instance
|
34
|
-
delegate :fetch_hrid, :fetch_marc_hash, to: :instance
|
34
|
+
delegate :fetch_hrid, :fetch_marc_hash, :has_instance_status?, to: :instance
|
35
35
|
end
|
36
36
|
|
37
37
|
attr_accessor :config
|
@@ -40,7 +40,7 @@ class FolioClient
|
|
40
40
|
# @param path [String] the path to the Folio API request
|
41
41
|
# @param request [Hash] params to get to the API
|
42
42
|
def get(path, params = {})
|
43
|
-
response = connection.get(path, params, {
|
43
|
+
response = connection.get(path, params, {"x-okapi-token": config.token})
|
44
44
|
|
45
45
|
UnexpectedResponse.call(response) unless response.success?
|
46
46
|
|
@@ -51,7 +51,7 @@ class FolioClient
|
|
51
51
|
# @param path [String] the path to the Folio API request
|
52
52
|
# @param request [json] request body to post to the API
|
53
53
|
def post(path, request = nil)
|
54
|
-
response = connection.post(path, request, {
|
54
|
+
response = connection.post(path, request, {"x-okapi-token": config.token})
|
55
55
|
|
56
56
|
UnexpectedResponse.call(response) unless response.success?
|
57
57
|
|
@@ -81,4 +81,11 @@ class FolioClient
|
|
81
81
|
source_storage.fetch_marc_hash(...)
|
82
82
|
end
|
83
83
|
end
|
84
|
+
|
85
|
+
def has_instance_status?(...)
|
86
|
+
TokenWrapper.refresh(config, connection) do
|
87
|
+
inventory = Inventory.new(self)
|
88
|
+
inventory.has_instance_status?(...)
|
89
|
+
end
|
90
|
+
end
|
84
91
|
end
|
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: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Mangiafico
|
@@ -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.3.
|
192
|
+
rubygems_version: 3.3.3
|
193
193
|
signing_key:
|
194
194
|
specification_version: 4
|
195
195
|
summary: Interface for interacting with the Folio ILS API.
|