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

#initialize(mock = false) ⇒ Configuration

Returns a new instance of Configuration.



32
33
34
35
36
37
38
39
40
# File 'lib/zerobounce/configuration.rb', line 32

def initialize(mock = false)
  File.file?('.env') ? Dotenv.load('.env') : Dotenv.load
  self.apikey = ENV['ZEROBOUNCE_API_KEY']
  self.api_root_url = ENV['ZEROBOUNCE_API_URL'] || ApiUrls::DEFAULT_URL
  self.bulk_api_root_url = ENV['ZEROBOUNCE_BULK_API_URL'] || ApiUrls::BULK_DEFAULT_URL
  self.valid_statuses = %i[valid catch_all accept_all]
  self.headers = { user_agent: "ZerobounceRubyGem/#{Zerobounce::VERSION}" }
  self.mock = mock
end

Instance Attribute Details

#api_root_urlString

The Zerobounce API root URL. Defaults to ApiUrls::DEFAULT_URL.

Returns:

  • (String)

    the current value of api_root_url



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

def api_root_url
  @api_root_url
end

#apikeyString

A Zerobounce API key.

Returns:

  • (String)

    the current value of apikey



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

def apikey
  @apikey
end

#bulk_api_root_urlString

The Zerobounce bulk API root URL.

Returns:

  • (String)

    the current value of bulk_api_root_url



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

def bulk_api_root_url
  @bulk_api_root_url
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

#mockObject

Returns the value of attribute mock.



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

def mock
  @mock
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.



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

def valid_statuses
  @valid_statuses
end