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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4e53de53a53383306d8d102202f46a3d7812fea93d63ba876e4be9f3d31c122a
4
- data.tar.gz: 6a923cb74ab603ecba4fc9e909da87fdcd0a2540cbc58dafc381147012ae1a4f
3
+ metadata.gz: f2421b3de04e4754677703bb1012074d586cbce87bd90fe8b3341212ebeffae7
4
+ data.tar.gz: 54b49208c11498964a494c5c57c0c97ca3a47d71fddef9766ccf1ef4e0c404a2
5
5
  SHA512:
6
- metadata.gz: 1bf690f79b82a5ec7c7a53b88867671a389bcae846832971ecb8a07f55f227b3c77761270e1d584207a6c4b1775e00f49d5ddadaea1d10bb6c9ce4a64bbb69b4
7
- data.tar.gz: 98520694ded40e076ee49a456f46ad1b2c460c34d247fff9d519f9e5f5f4ae825e1ea2f3a56f7d8118301b14b8ffb02aa12c44cbe7e6106e9b1451f6fe8344fd
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.3.1)
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.0)
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class FolioClient
4
- VERSION = "0.3.1"
4
+ VERSION = "0.4.0"
5
5
  end
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, { "x-okapi-token": config.token })
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, { "x-okapi-token": config.token })
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.3.1
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.7
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.