class EmailListVerify

Constants

BASE
BULK_ERRORS
FILE_INFO_PATH
ONE_BY_ONE_PATH
UPLOAD_FILE_PATH
VERSION

Public Class Methods

new(api_key) click to toggle source
# File lib/email_list_verify.rb, line 11
def initialize(api_key)
  @api_key = api_key
end

Public Instance Methods

bulk_status(file_id=nil) click to toggle source
# File lib/email_list_verify.rb, line 28
def bulk_status(file_id=nil)
  unless file_id or @id
    return "Please provide the file_id or call the upload_file with a success"
  end
  id = file_id
  id ||= @id
  options = {params: {id: id, secret: @api_key}}
  RestClient.get(FILE_INFO_PATH, options)
end
one_by_one(email) click to toggle source
# File lib/email_list_verify.rb, line 14
def one_by_one(email)
  options = {params: {email: email, secret: @api_key}}
  RestClient.get(ONE_BY_ONE_PATH, options)
end
upload_file(file_name, file_path=nil) click to toggle source
# File lib/email_list_verify.rb, line 18
def upload_file(file_name, file_path=nil)
  file_path ||= file_name
  options = {file_contents: File.new(file_path)}
  url = UPLOAD_FILE_PATH+"?secret=#{@api_key}&filename=#{file_name}"
  res = RestClient.post(url, options)
  unless BULK_ERRORS.include? (res.to_s)
    @id = res
  end
  res
end