Class: Vodka::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/vodka/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



11
12
13
14
15
# File 'lib/vodka/configuration.rb', line 11

def initialize
  @digest = Digest::SHA512
  @perform_request_signing = true
  @her_auto_configure = true
end

Instance Attribute Details

#api_urlObject

Secret token to use in signing requests, stronger is better



3
4
5
# File 'lib/vodka/configuration.rb', line 3

def api_url
  @api_url
end

#digestObject

Secret token to use in signing requests, stronger is better



3
4
5
# File 'lib/vodka/configuration.rb', line 3

def digest
  @digest
end

#her_auto_configureObject

Secret token to use in signing requests, stronger is better



3
4
5
# File 'lib/vodka/configuration.rb', line 3

def her_auto_configure
  @her_auto_configure
end

#perform_request_signingObject

Secret token to use in signing requests, stronger is better



3
4
5
# File 'lib/vodka/configuration.rb', line 3

def perform_request_signing
  @perform_request_signing
end

#prefixObject

Secret token to use in signing requests, stronger is better



3
4
5
# File 'lib/vodka/configuration.rb', line 3

def prefix
  @prefix
end

#request_secretObject

Secret token to use in signing requests, stronger is better



3
4
5
# File 'lib/vodka/configuration.rb', line 3

def request_secret
  @request_secret
end

#response_secretObject

Secret token to use in signing requests, stronger is better



3
4
5
# File 'lib/vodka/configuration.rb', line 3

def response_secret
  @response_secret
end

Instance Method Details

#configure_her!Object

Raises:

  • (Exception)


17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/vodka/configuration.rb', line 17

def configure_her!
  raise Exception.new('api_url must be set') if api_url.nil?

  ::Her::API.setup(url: api_url) do |c|
    c.use(Vodka::Client::Middleware::ErrorAware)
    c.use(Vodka::Client::Middleware::SignedRequest) if perform_request_signing
    c.use(Faraday::Request::UrlEncoded)
    c.use(Vodka::Client::Middleware::SignedResponse) if perform_request_signing
    c.use(::Her::Middleware::SecondLevelParseJSON)
    c.use(Faraday::Adapter::NetHttp)
  end
end