Class: Locomotive::Steam::ExternalAPIService

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/locomotive/steam/services/external_api_service.rb

Instance Method Summary collapse

Instance Method Details

#consume(url, options = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/locomotive/steam/services/external_api_service.rb', line 10

def consume(url, options = {})
  options[:base_uri], path = extract_base_uri_and_path(url)

  options.delete(:format) if options[:format] == 'default'

  # auth ?
  username, password = options.delete(:username), options.delete(:password)
  options[:basic_auth] = { username: username, password: password } if username

  # authorization header ?
  header_auth = options.delete(:header_auth)
  options[:headers] = { 'Authorization' => header_auth } if header_auth

  perform_request_to(path, options)
end