Class: Zerobounce::Configuration
- Inherits:
-
Object
- Object
- Zerobounce::Configuration
- Defined in:
- lib/zerobounce/configuration.rb
Overview
Configuration object for Zerobounce.
Instance Attribute Summary collapse
-
#api_key ⇒ 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.
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_key ⇒ String
A Zerobounce API key.
29 30 31 |
# File 'lib/zerobounce/configuration.rb', line 29 def api_key @api_key end |
#headers ⇒ Hash
Headers to use in all requests.
29 30 31 |
# File 'lib/zerobounce/configuration.rb', line 29 def headers @headers end |
#host ⇒ String
The Zerobounce API host.
29 30 31 |
# File 'lib/zerobounce/configuration.rb', line 29 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.
29 30 31 |
# File 'lib/zerobounce/configuration.rb', line 29 def middleware @middleware end |
#valid_statues ⇒ Array<Symbol>
The statuses that are considered valid by Response#valid?.
29 30 31 |
# File 'lib/zerobounce/configuration.rb', line 29 def valid_statues @valid_statues end |
#valid_statuses ⇒ Object
Returns the value of attribute valid_statuses.
34 35 36 |
# File 'lib/zerobounce/configuration.rb', line 34 def valid_statuses @valid_statuses end |