folio_client 0.1.0 → 0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 10e1bbd3e3daa19c4149d5a44e143a76b4a9f6eee076bf9930b93f8ccb0e6dba
4
- data.tar.gz: 65cc43463f69c41fbebfb4b3cdfab5155b6acb1c86fa77c05834fbd3f4ff681c
3
+ metadata.gz: eb2abde077e892ded8a30319b08e773915d646d5c0193b8080789a49c73014e6
4
+ data.tar.gz: 9a8de9e86652903db4068919af862d08abfa9a0cd86fea4d78500d206620fa25
5
5
  SHA512:
6
- metadata.gz: 61e6b573661efa4008d7b9171242c0f50a465cccf875dd3c1cb2fd61b9cbf663fe0de8a464d0fe785d4955c09ce0080bb07ad0ce2ca75f74b9252c96367e80cc
7
- data.tar.gz: 25ed05f11889b0cd4bb2ad72eb7ce03b6e68948ab45733f370b6af026eae5021be6259503ff359749836a776aeed8ef4a77d9eddc299df642a9d5a66bab96f4e
6
+ metadata.gz: b187b89f764fce8d797f3caa2b654f08895868cfa2732b049b3e40c30439ddc4f38aae1ae77f7f8ab0e433844c600ab615daa72d12a7768f261d2f44e232d897
7
+ data.tar.gz: f7244e622f86eb96c8562baa62781c30cebc9909060945eac932b9ed8bcb3e3e08e6ba8578b1bd7712ac7964c3c7df630b2dffed8ed59708ee59cad1859b247a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- folio_client (0.1.0)
4
+ folio_client (0.2.0)
5
5
  activesupport (>= 4.2, < 8)
6
6
  faraday
7
7
  zeitwerk
@@ -34,7 +34,7 @@ GEM
34
34
  language_server-protocol (3.17.0.3)
35
35
  minitest (5.17.0)
36
36
  parallel (1.22.1)
37
- parser (3.2.0.0)
37
+ parser (3.2.1.0)
38
38
  ast (~> 2.4.1)
39
39
  public_suffix (5.0.1)
40
40
  rainbow (3.1.1)
@@ -64,8 +64,8 @@ GEM
64
64
  rubocop-ast (>= 1.24.1, < 2.0)
65
65
  ruby-progressbar (~> 1.7)
66
66
  unicode-display_width (>= 2.4.0, < 3.0)
67
- rubocop-ast (1.24.1)
68
- parser (>= 3.1.1.0)
67
+ rubocop-ast (1.26.0)
68
+ parser (>= 3.2.1.0)
69
69
  rubocop-capybara (2.17.0)
70
70
  rubocop (~> 1.41)
71
71
  rubocop-performance (1.15.2)
@@ -82,7 +82,7 @@ GEM
82
82
  simplecov_json_formatter (~> 0.1)
83
83
  simplecov-html (0.12.3)
84
84
  simplecov_json_formatter (0.1.4)
85
- standard (1.23.0)
85
+ standard (1.24.3)
86
86
  language_server-protocol (~> 3.17.0.2)
87
87
  rubocop (= 1.44.1)
88
88
  rubocop-performance (= 1.15.2)
@@ -93,7 +93,7 @@ GEM
93
93
  addressable (>= 2.8.0)
94
94
  crack (>= 0.3.2)
95
95
  hashdiff (>= 0.4.0, < 2.0.0)
96
- zeitwerk (2.6.6)
96
+ zeitwerk (2.6.7)
97
97
 
98
98
  PLATFORMS
99
99
  x86_64-darwin-19
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ class FolioClient
4
+ # Lookup items in the Folio inventory
5
+ class Inventory
6
+ attr_accessor :client
7
+
8
+ # @param client [FolioClient] the configured client
9
+ def initialize(client)
10
+ @client = client
11
+ end
12
+
13
+ # @param barcode [String] barcode to search by to fetch the HRID
14
+ def fetch_hrid(barcode:)
15
+ # find the instance UUID for this barcode
16
+ instance = client.get("/search/instances", {query: "items.barcode==#{barcode}"})
17
+ instance_uuid = instance.dig("instances", 0, "id")
18
+
19
+ return nil unless instance_uuid
20
+
21
+ # next lookup the instance given the instance_uuid so we can fetch the hrid
22
+ result = client.get("/inventory/instances/#{instance_uuid}")
23
+ result.dig("hrid")
24
+ end
25
+ end
26
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class FolioClient
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
data/lib/folio_client.rb CHANGED
@@ -31,6 +31,7 @@ class FolioClient
31
31
  end
32
32
 
33
33
  delegate :config, :connection, :get, :post, to: :instance
34
+ delegate :fetch_hrid, to: :instance
34
35
  end
35
36
 
36
37
  attr_accessor :config
@@ -64,4 +65,9 @@ class FolioClient
64
65
  headers: DEFAULT_HEADERS.merge(config.okapi_headers || {})
65
66
  )
66
67
  end
68
+
69
+ def fetch_hrid(...)
70
+ inventory = Inventory.new(self)
71
+ inventory.fetch_hrid(...)
72
+ end
67
73
  end
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.1.0
4
+ version: 0.2.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-10 00:00:00.000000000 Z
11
+ date: 2023-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -162,6 +162,7 @@ files:
162
162
  - folio_client.gemspec
163
163
  - lib/folio_client.rb
164
164
  - lib/folio_client/authenticator.rb
165
+ - lib/folio_client/inventory.rb
165
166
  - lib/folio_client/unexpected_response.rb
166
167
  - lib/folio_client/version.rb
167
168
  homepage: https://github.com/sul-dlss/folio_client