folio_api_client 0.2.0 → 0.3.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 +4 -4
- data/README.md +8 -0
- data/lib/folio_api_client/exceptions.rb +1 -0
- data/lib/folio_api_client/finders.rb +14 -2
- data/lib/folio_api_client/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd0f25ee382d9468806b7ae7c39a0d7801f43d5e45c7f7bd248565673fe9da23
|
4
|
+
data.tar.gz: e05cb433eb2134c574d2de93a3e9de4cdad6a4c9bd9c6ae3f67483179f64e855
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f68f5dab0e5080f62b307c8f72bf2fb75e5d4033f7fb70fdfdd99f749edf821ae2c9d1c697e31f70f8af4e1be60aa55c930c9c9bd494348fbff9fe1e7337e563
|
7
|
+
data.tar.gz: 6cdc0f1d8a571a11599ae906f985f0e2901dedcbc07b8f26f71f316337507693dd22ea0f8a841bbd6083ce6436c5b7dbebe252f4f54d685bb1366c66ec29ebdf
|
data/README.md
CHANGED
@@ -42,6 +42,14 @@ client.get(path, params)
|
|
42
42
|
client.post(path, body, content_type: 'application/json'))
|
43
43
|
client.put(path, body, content_type: 'application/json'))
|
44
44
|
client.delete(path, body, content_type: 'application/json'))
|
45
|
+
|
46
|
+
# Other convenience methods:
|
47
|
+
|
48
|
+
client.find_item_record(barcode: 'some-barcode')
|
49
|
+
client.find_location_record(location_id: 'some-location-id')
|
50
|
+
client.find_holdings_record(holdings_record_id: 'some-holdings-record-id')
|
51
|
+
client.find_instance_record(instance_record_id: 'some-instance-record-id')
|
52
|
+
client.find_marc_record(instance_record_id: 'some-instance-record-id') # returns a MARC::Record
|
45
53
|
```
|
46
54
|
|
47
55
|
See [https://dev.folio.org/reference/api/](https://dev.folio.org/reference/api/) for the full list of available FOLIO API endpoints.
|
@@ -27,12 +27,24 @@ class FolioApiClient
|
|
27
27
|
self.get("/instance-storage/instances/#{instance_record_id}")
|
28
28
|
end
|
29
29
|
|
30
|
-
|
31
|
-
|
30
|
+
# Find a MARC::Record by its instance record id or instance record hrid
|
31
|
+
def find_marc_record(instance_record_id: nil, instance_record_hrid: nil)
|
32
|
+
source_record_search_results = self.get(
|
33
|
+
'/source-storage/source-records',
|
34
|
+
marc_record_query(instance_record_id: instance_record_id, instance_record_hrid: instance_record_hrid)
|
35
|
+
)
|
32
36
|
return nil if source_record_search_results['totalRecords'].zero?
|
33
37
|
|
34
38
|
bib_record_marc_hash = source_record_search_results['sourceRecords'].first['parsedRecord']['content']
|
35
39
|
MARC::Record.new_from_hash(bib_record_marc_hash)
|
36
40
|
end
|
41
|
+
|
42
|
+
def marc_record_query(instance_record_id: nil, instance_record_hrid: nil)
|
43
|
+
return { instanceId: instance_record_id } if instance_record_id
|
44
|
+
return { instanceHrid: instance_record_hrid } if instance_record_hrid
|
45
|
+
|
46
|
+
raise FolioApiClient::Exceptions::MissingQueryFieldError,
|
47
|
+
'Missing query field. Must supply either an instance_record_id or instance_record_hrid.'
|
48
|
+
end
|
37
49
|
end
|
38
50
|
end
|