Module: Parliament::Utils::Helpers::ParliamentHelper

Defined in:
lib/parliament/utils/helpers/parliament_helper.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.parliament_request(request_id = nil, request_number = 1) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/parliament/utils/helpers/parliament_helper.rb', line 8

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

Instance Method Details

#parliament_request(request_id = nil, request_number = 1) ⇒ Object



22
23
24
# File 'lib/parliament/utils/helpers/parliament_helper.rb', line 22

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