Sha256: 3bc7555785bbccc6990ef731a1178cebfd150c91c1eef5ed10b5ee2a86550a08

Contents?: true

Size: 982 Bytes

Versions: 2

Compression:

Stored size: 982 Bytes

Contents

require "celsius/transformation/step"
require "ox"

class Celsius::Primo::SoapApi::Searcher::SearchBrief::SearchRequestTransformation::
  ProcessRangeQueries < Celsius::Transformation::Step

  def call
    if range_queries = Celsius::Hash.deep_find_key(source, :range)
      query_terms_node = transformation.inner_search_request.locate("PrimoSearchRequest/QueryTerms").first

      range_queries.each do |range_query|
        lower_bound = Celsius::Hash.smart_fetch(range_query.values.first, :gte)
        upper_bound = Celsius::Hash.smart_fetch(range_query.values.first, :lte)
        index_field = index_field_mapping(range_query.keys.first)

        query_terms_node << Ox.parse(
          <<-xml
            <QueryTerm>
              <IndexField>#{index_field}</IndexField>
              <PrecisionOperator>contains</PrecisionOperator>
              <Value>[#{lower_bound} TO #{upper_bound}]</Value>
            </QueryTerm>
          xml
        )
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
celsius-primo-0.1.4 lib/celsius/primo/soap_api/searcher/search_brief/search_request_transformation/process_range_queries.rb
celsius-primo-0.1.3 lib/celsius/primo/soap_api/searcher/search_brief/search_request_transformation/process_range_queries.rb