Sha256: cede51e4efa1e1ee3d0085191f4d690bb7ff7e09f6025609544e9bd7946fa281

Contents?: true

Size: 962 Bytes

Versions: 9

Compression:

Stored size: 962 Bytes

Contents

require 'parliament'
require 'parliament/ntriple'

module Parliament
  module Utils
    module Helpers
      module ParliamentHelper
        def self.parliament_request(request_id = nil, request_number = 1)
          headers = {}.tap do |headers|
            headers['Ocp-Apim-Subscription-Key'] = ENV['PARLIAMENT_AUTH_TOKEN']
            headers['Api-Version'] = ENV['PARLIAMENT_API_VERSION'] if ENV['PARLIAMENT_API_VERSION']
            headers['Request-Id'] = "#{request_id}#{request_number}" if request_id
          end

          Parliament::Request::UrlRequest.new(
            builder:    Parliament::Builder::NTripleResponseBuilder,
            headers:    headers,
            decorators: Parliament::Grom::Decorator
          )
        end

        def parliament_request(request_id = nil, request_number = 1)
          Parliament::Utils::Helpers::ParliamentHelper.parliament_request(request_id, request_number)
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
parliament-utils-0.11.3 lib/parliament/utils/helpers/parliament_helper.rb
parliament-utils-0.11.2 lib/parliament/utils/helpers/parliament_helper.rb
parliament-utils-0.11.1 lib/parliament/utils/helpers/parliament_helper.rb
parliament-utils-0.11.0 lib/parliament/utils/helpers/parliament_helper.rb
parliament-utils-0.10.2 lib/parliament/utils/helpers/parliament_helper.rb
parliament-utils-0.10.1 lib/parliament/utils/helpers/parliament_helper.rb
parliament-utils-0.10.0 lib/parliament/utils/helpers/parliament_helper.rb
parliament-utils-0.9.1 lib/parliament/utils/helpers/parliament_helper.rb
parliament-utils-0.9.0 lib/parliament/utils/helpers/parliament_helper.rb