Class: Immobilienscout::Authenticator

Inherits:
Object
  • Object
show all
Defined in:
lib/immobilienscout/authenticator.rb

Constant Summary collapse

ALLOWED_METHODS =
%w[POST GET DELETE PUT].freeze
OAUTH_SIGNATURE_METHOD =
'HMAC-SHA1'
OAUTH_VERSION =
'1.0'
HASH_DIGEST =
'sha1'

Instance Method Summary collapse

Constructor Details

#initialize(url, method, query_params = nil) ⇒ Authenticator

Returns a new instance of Authenticator.

Raises:

  • (ArgumentError)


12
13
14
15
16
17
18
# File 'lib/immobilienscout/authenticator.rb', line 12

def initialize(url, method, query_params = nil)
  @url = url
  @method = method
  @query_params = query_params

  raise ArgumentError unless valid?
end

Instance Method Details

#callObject



20
21
22
23
24
25
# File 'lib/immobilienscout/authenticator.rb', line 20

def call
  header_params.merge!(@query_params) if @query_params
  auth_headers = auth_headers(header_params)

  auth_header_string(auth_headers)
end