Module: APIHub::LeadScore

Extended by:
LeadScore
Includes:
APIHub
Included in:
LeadScore
Defined in:
lib/apihub/lead_score.rb,
lib/apihub/lead_score/async.rb,
lib/apihub/lead_score/score.rb,
lib/apihub/lead_score/version.rb,
lib/apihub/lead_score/email_providers.rb

Defined Under Namespace

Modules: EmailProviders, Score Classes: Async

Constant Summary collapse

VERSION =
"0.0.2"

Instance Method Summary collapse

Instance Method Details

#api_key=(value) ⇒ Object



12
13
14
# File 'lib/apihub/lead_score.rb', line 12

def api_key=(value)
  APIHub.api_key = value
end

#baller?(email, options = {}) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
19
20
# File 'lib/apihub/lead_score.rb', line 16

def baller?(email, options = {})
  threshold = options[:threshold] || 20

  lookup(options).score > threshold
end

#lookup(email) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/apihub/lead_score.rb', line 22

def lookup(email)
  if email =~ /.+@.+/
    person = Streaming::Person[email: email]
    suffix, domain = email.split('@', 2)

  else
    domain = email
  end

  unless EmailProviders::DOMAINS.include?(domain)
    company = Streaming::Company[domain: domain]
  end

  return unless person || company

  result = Mash.new(
    person:  person,
    company: company
  )

  result.merge!(
    score: Score.calculate(result)
  )

  result
end