Sha256: 5ca75fa3d4898da7afd5232cf232049cf38c972e04d774d85f665a0499fd69d0

Contents?: true

Size: 814 Bytes

Versions: 10

Compression:

Stored size: 814 Bytes

Contents

require 'httparty'


module Moocher
  module Email
    def email_blacklisted?(email, details: false)
      return "Email doesn't seem to be valid." if (email =~ /\A[\w+\-.]+@[a-z\d\-]+(\.[a-z\d\-]+)*\.[a-z]+\z/i).nil?
      base_url = 'https://api.moocher.io/bademail/'
      unless details
        response = HTTParty.get(base_url + email)
        (response["response"]["email"]["blacklist"].empty? && response["response"]["source_ip"]["blacklist"].empty?) ? false : true
      else
        if details == true
          response = HTTParty.get("https://api.moocher.io/bademail/#{email}", headers: {"Content-Type": "application/json"})
          return response.parsed_response
        else
          "'details:' is by default set to false. You can only be set it to true."
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
moocher-0.3.2 lib/moocher/emails.rb
moocher-0.2.2 lib/moocher/emails.rb
moocher-0.2.1.3 lib/moocher/emails.rb
moocher-0.2.1.2 lib/moocher/emails.rb
moocher-0.2.1.1 lib/moocher/emails.rb
moocher-0.2.1 lib/moocher/emails.rb
moocher-0.2 lib/moocher/emails.rb
moocher-0.1.1.7pre lib/moocher/emails.rb
moocher-0.1.1.6pre lib/moocher/emails.rb
moocher-0.1.1.5pre lib/moocher/emails.rb