Class: Zerobounce::Configuration

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

Overview

Configuration object for Zerobounce.

Author:

  • Aaron Frase

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/zerobounce/configuration.rb', line 36

def initialize
  self.host = 'https://api.zerobounce.net'
  self.api_key = ENV['ZEROBOUNCE_API_KEY']
  self.valid_statuses = i[valid catch_all]
  self.headers = { user_agent: "ZerobounceRubyGem/#{Zerobounce::VERSION}" }

  self.middleware = proc do |builder|
    builder.response(:json, content_type: /\bjson$/, parser_options: { symbolize_names: true })
    builder.use(Zerobounce::Middleware::RaiseError)
    builder.adapter(Faraday.default_adapter)
  end
end

Instance Attribute Details

#api_keyString

A Zerobounce API key.

Returns:

  • (String)

    the current value of api_key



29
30
31
# File 'lib/zerobounce/configuration.rb', line 29

def api_key
  @api_key
end

#headersHash

Headers to use in all requests.

Returns:

  • (Hash)

    the current value of headers



29
30
31
# File 'lib/zerobounce/configuration.rb', line 29

def headers
  @headers
end

#hostString

The Zerobounce API host.

Returns:

  • (String)

    the current value of host



29
30
31
# File 'lib/zerobounce/configuration.rb', line 29

def host
  @host
end

#middlewareProc

Note:

If you modify the default make sure to add middleware to parse the response as json and symbolize the keys.

The middleware used by Faraday for each request.

Returns:

  • (Proc)

    the current value of middleware



29
30
31
# File 'lib/zerobounce/configuration.rb', line 29

def middleware
  @middleware
end

#valid_statuesArray<Symbol>

The statuses that are considered valid by Response#valid?.

Returns:

  • (Array<Symbol>)

    the current value of valid_statues



29
30
31
# File 'lib/zerobounce/configuration.rb', line 29

def valid_statues
  @valid_statues
end

#valid_statusesObject

Returns the value of attribute valid_statuses.



34
35
36
# File 'lib/zerobounce/configuration.rb', line 34

def valid_statuses
  @valid_statuses
end