<commit_before># coding: utf-8
require 'libis-tools'

require 'libis/services/rest_client'

module Libis
  module Services
    module Alma

      class WebService
        include ::Libis::Services::RestClient

        def initialize(url = 'https://api-eu.hosted.exlibrisgroup.com/almaws/v1/bibs')
          configure(url)
        end

        def get_marc(alma_id, apikey)
          get alma_id, apikey: apikey
        end

        protected

        def result_parser(response)
          Libis::Tools::XmlDocument.parse(response)
        end

      end
    end
  end
end
<commit_msg>Alma Web Services: add support for predefined API keys.<commit_after># coding: utf-8
require 'libis-tools'
require 'libis/services/service_error'
require 'libis/services/rest_client'

module Libis
  module Services
    module Alma

      class WebService
        include ::Libis::Services::RestClient

        def initialize(url = 'https://api-eu.hosted.exlibrisgroup.com/almaws/v1/bibs')
          configure(url)
        end

        def get_marc(alma_id, apikey = nil)
          apikey ||= case alma_id
                      when /1480$/
                        '<KEY>'
                      else
                        raise Libis::Services::ServiceError, "No Alma API key available for '#{alma_id}'"
                    end
          get alma_id, apikey: apikey
        end

        protected

        def result_parser(response)
          Libis::Tools::XmlDocument.parse(response)
        end

      end
    end
  end
end

{'fraction_non_alphanumeric': 0.08531746031746032, 'fraction_numerical': 0.005291005291005291, 'mean_word_length': 1.9264990328820115, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3209377', 'n_tokens_mistral': 467, 'n_tokens_neox': 444, 'n_words': 106}