class Varanus::DCV

An connection to the DCV API. This should not be initialized directly. Instead, use Varanus#dcv

Public Instance Methods

start(domain, type) click to toggle source

Start domain validation process. This must be called before submit is called @option domain [String] domain to validate @option type [String] Type of validation. Must be one of 'http', 'https', 'cname',

or 'email'
# File lib/varanus/dcv.rb, line 26
def start domain, type
  post("dcv/v1/validation/start/domain/#{type}", domain: domain)
end
status(domain) click to toggle source

Retrieve DCV status for a single domain Result will included an extra 'expiration_date_obj' if 'expirationDate' is in the response

# File lib/varanus/dcv.rb, line 33
def status domain
  _format_status(post('dcv/v2/validation/status', domain: domain))
end
submit(domain, type, email_address = nil) click to toggle source

Submit domain validation for verficiation. This must be called after start @option domain [String] domain to validate @option type [String] Type of validation. Must be one of 'http', 'https', 'cname',

or 'email'

@option email_address [String] This is required of type is 'email'. Otherwise, it is

ignored.
# File lib/varanus/dcv.rb, line 43
def submit domain, type, email_address = nil
  if type.to_s == 'email'
    raise ArgumentError, 'email_address must be specified' if email_address.nil?

    post('dcv/v1/validation/submit/domain/email', domain: domain,
                                                  email: email_address)
  else
    post("dcv/v1/validation/submit/domain/#{type}", domain: domain)
  end
end

Private Instance Methods

_format_status(status) click to toggle source
# File lib/varanus/dcv.rb, line 56
def _format_status status
  return status unless status['expirationDate']

  status.merge('expiration_date_obj' =>
                 Date.strptime(status['expirationDate'], '%Y-%m-%d'))
end