folio_api_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: 954b7e6b1e48039f364a809e5106625b64d86befca6cfb581b044395b793cc4b
4
- data.tar.gz: afa3897ee6b420e72e38cced7c3206d9bdefed076214a3bea7216b6abf5bb2e1
3
+ metadata.gz: b1529c6d23ad243ce9503b24965a0afc4db6abd28a6cea7aae1000b42b5a19b0
4
+ data.tar.gz: 8da619e1c7614fe9bf46951af5ee6c086467ec90869d0f32ba9803584b65487a
5
5
  SHA512:
6
- metadata.gz: a3ed8ef0912573e43adc2263ab65e5096f06bdd6118946fa5e2b9276bdd17e2ea9e88fe98027c1d0d2040a30036afff7ff009d70ee8bf87c11e2be87912e7ce4
7
- data.tar.gz: 8ff84094f0a2be25a608e313bd29369d3f72a295be31903aa97b261c041fcd4361c4690c2fb609766670b9ed3dd74473aa19dc3c27142eccaa188c2f9bcddcbb
6
+ metadata.gz: c6196344ec464f39dfdd0b44dbd269f3b949a630c7a41d449961a73091f494ad1d49edff1eb39d2f79b4d36ee0b9f6456257cb2ca645a4d8d1a4c8f0b3c50cd0
7
+ data.tar.gz: 064356b0fe0d418128ae36d101005229d3eb766f89a62456a6b024bedb5a9d748e42335177918985c34a2bef7ed4a0168c54f38b6bea58a5fd2ed3b0508e86f4
data/README.md CHANGED
@@ -4,9 +4,15 @@ A Ruby interface for making requests to the FOLIO ILS API (https://folio.org), i
4
4
 
5
5
  ## Installation
6
6
 
7
- At this time, this gem is only available on GitHub and has not been published to RubyGems yet. You can include it in your Gemfile using this syntax:
7
+ ```bash
8
+ bundle add folio_api_client
9
+ ```
10
+
11
+ If bundler is not being used to manage dependencies, you can install the gem by running:
8
12
 
9
- `gem 'folio_api_client', github: 'cul/folio_api_client', branch: 'main'`
13
+ ```bash
14
+ gem install folio_api_client
15
+ ```
10
16
 
11
17
  ## Usage
12
18
 
@@ -3,5 +3,6 @@
3
3
  class FolioApiClient
4
4
  module Exceptions
5
5
  class Error < StandardError; end
6
+ class UnexpectedMultipleRecordsFoundError < Error; end
6
7
  end
7
8
  end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ class FolioApiClient
4
+ module Finders
5
+ def find_item_record(barcode:)
6
+ item_search_results = self.get('/item-storage/items', { query: "barcode==#{barcode}", limit: 2 })['items']
7
+ return nil if item_search_results.empty?
8
+
9
+ if item_search_results.length > 1
10
+ raise FolioApiClient::Exceptions::UnexpectedMultipleRecordsFoundError,
11
+ 'Only expected one item with this barcode, but found more than one.'
12
+ end
13
+
14
+ item_record_id = item_search_results.first['id']
15
+ self.get("/item-storage/items/#{item_record_id}")
16
+ end
17
+
18
+ def find_location_record(location_id:)
19
+ self.get("/locations/#{location_id}")
20
+ end
21
+
22
+ def find_holdings_record(holdings_record_id:)
23
+ self.get("/holdings-storage/holdings/#{holdings_record_id}")
24
+ end
25
+
26
+ def find_instance_record(instance_record_id:)
27
+ self.get("/instance-storage/instances/#{instance_record_id}")
28
+ end
29
+
30
+ def find_marc_record(instance_record_id:)
31
+ source_record_search_results = self.get('/source-storage/source-records', { instanceId: instance_record_id })
32
+ return nil if source_record_search_results['totalRecords'].zero?
33
+
34
+ bib_record_marc_hash = source_record_search_results['sourceRecords'].first['parsedRecord']['content']
35
+ MARC::Record.new_from_hash(bib_record_marc_hash)
36
+ end
37
+ end
38
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class FolioApiClient
4
- VERSION = '0.1.0'
4
+ VERSION = '0.2.0'
5
5
  end
@@ -5,9 +5,12 @@ loader = Zeitwerk::Loader.for_gem
5
5
  loader.setup # ready!
6
6
 
7
7
  require 'faraday'
8
+ require 'marc'
8
9
 
9
10
  # A client used for making http requests (get/post/etc.) to the FOLIO ILS REST API.
10
11
  class FolioApiClient
12
+ include Finders
13
+
11
14
  attr_reader :config
12
15
 
13
16
  def initialize(config)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: folio_api_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
  - Eric O'Hanlon
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-04-29 00:00:00.000000000 Z
11
+ date: 2025-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -68,6 +68,7 @@ files:
68
68
  - lib/folio_api_client.rb
69
69
  - lib/folio_api_client/configuration.rb
70
70
  - lib/folio_api_client/exceptions.rb
71
+ - lib/folio_api_client/finders.rb
71
72
  - lib/folio_api_client/version.rb
72
73
  homepage: https://www.github.com/cul/folio_api_client
73
74
  licenses: []