Module: Zerobounce

Defined in:
lib/zerobounce.rb,
lib/zerobounce/error.rb,
lib/zerobounce/request.rb,
lib/zerobounce/version.rb,
lib/zerobounce/response.rb,
lib/zerobounce/configuration.rb,
lib/zerobounce/request/v1_request.rb,
lib/zerobounce/request/v2_request.rb,
lib/zerobounce/response/v1_response.rb,
lib/zerobounce/response/v2_response.rb,
lib/zerobounce/middleware/raise_http_exception.rb

Overview

Validate an email address with Zerobounce.net

Defined Under Namespace

Modules: Middleware Classes: ApiError, Configuration, Error, InternalServerError, MissingParameter, Request, Response, UnknownError

Constant Summary collapse

VERSION =

The version of the gem.

'0.3.1'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configurationZerobounce::Configuration Also known as: config

Zerobounce configuration



18
19
20
# File 'lib/zerobounce.rb', line 18

def configuration
  @configuration ||= Configuration.new
end

Class Method Details

.configure {|config| ... } ⇒ Object

Configure Zerobounce inside a block.

Examples:

Zerobounce.configure do |config|
  config.apikey = 'api-key'
end

Yield Parameters:



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

def configure
  yield configuration
end

.credits(params = {}) ⇒ Integer

Get the number of remaining credits on the account.

Parameters:

  • params (Hash) (defaults to: {})

Options Hash (params):

  • :apikey (String)

    Use a different API key for this request.

  • :host (String)

    Use a different host for this request.

  • :headers (String)

    Use different headers for this request.

  • :middleware (Proc)

    Use different middleware for this request.

Returns:

  • (Integer)


57
58
59
# File 'lib/zerobounce.rb', line 57

def credits(params={})
  Request.new(params).credits(params)
end

.invalid?(email, params = {}) ⇒ Boolean

Convenience method for checking if an email address is invalid.

Parameters:

  • email (String)
  • params (Hash) (defaults to: {})

Returns:

  • (Boolean)


75
76
77
# File 'lib/zerobounce.rb', line 75

def invalid?(email, params={})
  validate(params.merge(email: email)).invalid?
end

.valid?(email, params = {}) ⇒ Boolean

Convenience method for checking if an email address is valid.

Parameters:

  • email (String)
  • params (Hash) (defaults to: {})

Returns:

  • (Boolean)


66
67
68
# File 'lib/zerobounce.rb', line 66

def valid?(email, params={})
  validate(params.merge(email: email)).valid?
end

.validate(params) ⇒ Zerobounce::Response

Validates the email address and gets geoip information for an IP if provided.

Parameters:

  • params (Hash)

Options Hash (params):

  • :email (String)

    The email address to validate.

  • :ip_address (String)

    An IP address, :ipaddress also works.

  • :apikey (String)

    Use a different API key for this request.

  • :host (String)

    Use a different host for this request.

  • :headers (String)

    Use different headers for this request.

  • :middleware (Proc)

    Use different middleware for this request.

Returns:



45
46
47
# File 'lib/zerobounce.rb', line 45

def validate(params)
  Request.new(params).validate(params)
end