Class: Zerobounce::Configuration
- Inherits:
-
Object
- Object
- Zerobounce::Configuration
- Defined in:
- lib/zerobounce/configuration.rb
Overview
Configuration object for Zerobounce.
Instance Attribute Summary collapse
-
#api_version ⇒ String
The version of the API to use.
-
#apikey ⇒ String
A Zerobounce API key.
-
#headers ⇒ Hash
Headers to use in all requests.
-
#host ⇒ String
The Zerobounce API host.
-
#middleware ⇒ Proc
The middleware used by Faraday for each request.
-
#valid_statues ⇒ Array<Symbol>
The statuses that are considered valid by Response#valid?.
-
#valid_statuses ⇒ Object
Returns the value of attribute valid_statuses.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/zerobounce/configuration.rb', line 39 def initialize self.host = 'https://api.zerobounce.net' self.apikey = ENV.fetch('ZEROBOUNCE_API_KEY', nil) self.api_version = 'v2' 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.response(:logger) { |l| l.filter(/(api_?key=)(\w+)/, '\1[REMOVED]') } if ENV['ZEROBOUNCE_API_DEBUG'] builder.use(Zerobounce::Middleware::RaiseHttpException) builder.adapter(Faraday.default_adapter) end end |
Instance Attribute Details
#api_version ⇒ String
The version of the API to use.
31 32 33 |
# File 'lib/zerobounce/configuration.rb', line 31 def api_version @api_version end |
#apikey ⇒ String
A Zerobounce API key.
31 32 33 |
# File 'lib/zerobounce/configuration.rb', line 31 def apikey @apikey end |
#headers ⇒ Hash
Headers to use in all requests.
31 32 33 |
# File 'lib/zerobounce/configuration.rb', line 31 def headers @headers end |
#host ⇒ String
The Zerobounce API host.
31 32 33 |
# File 'lib/zerobounce/configuration.rb', line 31 def host @host end |
#middleware ⇒ Proc
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.
31 32 33 |
# File 'lib/zerobounce/configuration.rb', line 31 def middleware @middleware end |
#valid_statues ⇒ Array<Symbol>
The statuses that are considered valid by Response#valid?.
31 32 33 |
# File 'lib/zerobounce/configuration.rb', line 31 def valid_statues @valid_statues end |
#valid_statuses ⇒ Object
Returns the value of attribute valid_statuses.
37 38 39 |
# File 'lib/zerobounce/configuration.rb', line 37 def valid_statuses @valid_statuses end |