Sha256: f45ddc4861a5c6918a48bcb6f2bb6a0ff9de5fc78d0e8764454dac8eb0f337c9

Contents?: true

Size: 727 Bytes

Versions: 5

Compression:

Stored size: 727 Bytes

Contents

# frozen_string_literal: true

module Alma
  class ItemRequestOptions < RequestOptions
    class ResponseError < Alma::StandardError
    end

    def self.get(mms_id, holding_id = nil, item_pid = nil, options = {})
      url = "#{bibs_base_path}/#{mms_id}/holdings/#{holding_id}/items/#{item_pid}/request-options"
      options.select! { |k, _|  REQUEST_OPTIONS_PERMITTED_ARGS.include? k }
      response = Net.get(url, headers:, query: options, timeout:)
      new(response)
    end

    def validate(response)
      if response.code != 200
        message = "Could not get item request options."
        log = loggable.merge(response.parsed_response)
        raise ResponseError.new(message, log)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
alma-0.6.2 lib/alma/item_request_options.rb
alma-0.6.1 lib/alma/item_request_options.rb
alma-0.6.0 lib/alma/item_request_options.rb
alma-0.5.1 lib/alma/item_request_options.rb
alma-0.5.0 lib/alma/item_request_options.rb