Class: Skala::PrimoAdapter::GetRecords

Inherits:
Adapter::GetRecords show all
Defined in:
lib/skala/primo_adapter/get_records.rb

Instance Attribute Summary

Attributes inherited from Adapter::Operation

#adapter

Instance Method Summary collapse

Methods inherited from Adapter::Operation

#initialize

Constructor Details

This class inherits a constructor from Skala::Adapter::Operation

Instance Method Details

#call(record_ids, options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/skala/primo_adapter/get_records.rb', line 5

def call(record_ids, options = {})
  search_request = Skala::Adapter::Search::Request.new(
    queries: [
      {
        type: "ids",
        query: [record_ids].flatten(1)
      }
    ]
  )

  search_result = adapter.search(search_request, on_campus: true) # because you know the id -> you searched before
  self.class::Result.new({records: search_result.hits}).tap do |_get_records_result|
    _get_records_result.source = search_result.source
    _get_records_result.each do |_element|
      _element.found = true
      _element.version = 1
    end
  end
end