folio_client 0.10.1 → 0.11.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: 49b7e49d6350ec5da1e3d1b86df567520dbe89c9eed80fb42b8c158c79c3f426
4
- data.tar.gz: f957345b73f2071fee40ffbe6f6e4f8082468f383bc7848ff9953ac017917c4b
3
+ metadata.gz: e5e7b3edaad66a7bca966c6316eb979f722fe0eb2336def7f45eda9952a2a5ee
4
+ data.tar.gz: 7d4d555e56d607acbb4649ef59e94e5ab417ee1f4f78fce2a999864f9e8486ee
5
5
  SHA512:
6
- metadata.gz: c775d4984eab9d5a89d310da0983dbde38824af07498ed4504cb9b9d0614c4a12c3328dde4c59d96aede407672529d39ebabeb227fe01a6b0380de716704f109
7
- data.tar.gz: bc70a108d1a3d70131db2eed2e20343f5c0462c00a2dab65a1484456dfe7e2e19b4b6d616e628531cf664348c9bf85fc88eda94874cdbc859ae614e2a21bbde6
6
+ metadata.gz: ad63a3b363409b8561ca3ecf0f94b05f915ffe8ec621915e692f7d805d1f1c140b7626d2c95d613cc35974c08425a313e33ac72cc3249f68a1b3aece8d182688
7
+ data.tar.gz: 6e0bfb061e5fafda66cc4690726bb69a17e3ccdd474997bb433d3fa9f02d55f2e6c103edc263ab82e22d69c36960576a7acc5ab73f23b7e6364acee487efb99e
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- folio_client (0.10.1)
4
+ folio_client (0.11.0)
5
5
  activesupport (>= 4.2, < 8)
6
6
  dry-monads
7
7
  faraday
@@ -7,6 +7,8 @@ require "stringio"
7
7
  class FolioClient
8
8
  # Imports MARC records into FOLIO
9
9
  class DataImport
10
+ JOB_PROFILE_ATTRIBUTES = %w[id name description dataType].freeze
11
+
10
12
  # @param client [FolioClient] the configured client
11
13
  def initialize(client)
12
14
  @client = client
@@ -15,6 +17,7 @@ class FolioClient
15
17
  # @param record [MARC::Record] record to be imported
16
18
  # @param job_profile_id [String] job profile id to use for import
17
19
  # @param job_profile_name [String] job profile name to use for import
20
+ # @return [JobStatus] a job status instance to get information about the data import job
18
21
  def import(marc:, job_profile_id:, job_profile_name:)
19
22
  response_hash = client.post("/data-import/uploadDefinitions", {fileDefinitions: [{name: marc_filename}]})
20
23
  upload_definition_id = response_hash.dig("fileDefinitions", 0, "uploadDefinitionId")
@@ -38,6 +41,14 @@ class FolioClient
38
41
  JobStatus.new(client, job_execution_id: job_execution_id)
39
42
  end
40
43
 
44
+ # @return [Array<Hash<String,String>>] a list of job profile hashes
45
+ def job_profiles
46
+ client
47
+ .get("/data-import-profiles/jobProfiles")
48
+ .fetch("jobProfiles", [])
49
+ .map { |profile| profile.slice(*JOB_PROFILE_ATTRIBUTES) }
50
+ end
51
+
41
52
  private
42
53
 
43
54
  attr_reader :client, :marc, :job_profile_id, :job_profile_name
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class FolioClient
4
- VERSION = "0.10.1"
4
+ VERSION = "0.11.0"
5
5
  end
data/lib/folio_client.rb CHANGED
@@ -48,16 +48,24 @@ class FolioClient
48
48
  # @param login_params [Hash] the folio client login params (username:, password:)
49
49
  # @param okapi_headers [Hash] the okapi specific headers to add (X-Okapi-Tenant:, User-Agent:)
50
50
  def configure(url:, login_params:, okapi_headers:, timeout: default_timeout)
51
- instance.config = OpenStruct.new(url: url, login_params: login_params, okapi_headers: okapi_headers, token: nil, timeout: timeout)
52
-
51
+ instance.config = OpenStruct.new(
52
+ url: url,
53
+ login_params: login_params,
54
+ okapi_headers: okapi_headers,
55
+ timeout: timeout
56
+ )
57
+
58
+ # NOTE: The token cannot be set above, since `#connection` relies on
59
+ # `instance.config` parameters having already been set.
53
60
  instance.config.token = Authenticator.token(login_params, connection)
54
61
 
55
62
  self
56
63
  end
57
64
 
58
- delegate :config, :connection, :get, :post, :put, :default_timeout, to: :instance
59
- delegate :fetch_hrid, :fetch_external_id, :fetch_instance_info, :fetch_marc_hash, :has_instance_status?, :data_import, :edit_marc_json,
60
- :organizations, :organization_interfaces, :interface_details, to: :instance
65
+ delegate :config, :connection, :data_import, :default_timeout, :edit_marc_json,
66
+ :fetch_external_id, :fetch_hrid, :fetch_instance_info, :fetch_marc_hash, :get,
67
+ :has_instance_status?, :interface_details, :job_profiles, :organization_interfaces,
68
+ :organizations, :post, :put, to: :instance
61
69
  end
62
70
 
63
71
  attr_accessor :config
@@ -172,25 +180,35 @@ class FolioClient
172
180
  .import(...)
173
181
  end
174
182
 
175
- # @see RecordsEditor.edit_marc_json
183
+ # @ see DataImport#job_profiles
184
+ def job_profiles(...)
185
+ DataImport
186
+ .new(self)
187
+ .job_profiles(...)
188
+ end
189
+
190
+ # @see RecordsEditor#edit_marc_json
176
191
  def edit_marc_json(...)
177
192
  RecordsEditor
178
193
  .new(self)
179
194
  .edit_marc_json(...)
180
195
  end
181
196
 
197
+ # @see Organizations#fetch_list
182
198
  def organizations(...)
183
199
  Organizations
184
200
  .new(self)
185
201
  .fetch_list(...)
186
202
  end
187
203
 
204
+ # @see Organizations#fetch_interface_list
188
205
  def organization_interfaces(...)
189
206
  Organizations
190
207
  .new(self)
191
208
  .fetch_interface_list(...)
192
209
  end
193
210
 
211
+ # @see Organizations#fetch_interface_details
194
212
  def interface_details(...)
195
213
  Organizations
196
214
  .new(self)
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.10.1
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Mangiafico
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-03-31 00:00:00.000000000 Z
11
+ date: 2023-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -206,7 +206,7 @@ metadata:
206
206
  source_code_uri: https://github.com/sul-dlss/folio_client
207
207
  changelog_uri: https://github.com/sul-dlss/folio_client/releases
208
208
  rubygems_mfa_required: 'true'
209
- post_install_message:
209
+ post_install_message:
210
210
  rdoc_options: []
211
211
  require_paths:
212
212
  - lib
@@ -221,8 +221,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
221
221
  - !ruby/object:Gem::Version
222
222
  version: '0'
223
223
  requirements: []
224
- rubygems_version: 3.3.3
225
- signing_key:
224
+ rubygems_version: 3.3.7
225
+ signing_key:
226
226
  specification_version: 4
227
227
  summary: Interface for interacting with the Folio ILS API.
228
228
  test_files: []