Class: Snov::GetProspectsByEmail

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/snov/get_prospects_by_email.rb

Defined Under Namespace

Classes: Job, List, ProspectResult, Social

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(email:, client: Snov.client) ⇒ GetProspectsByEmail

Returns a new instance of GetProspectsByEmail.



10
11
12
13
# File 'lib/snov/get_prospects_by_email.rb', line 10

def initialize(email:, client: Snov.client)
  @client = client
  @email = email.to_str
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



8
9
10
# File 'lib/snov/get_prospects_by_email.rb', line 8

def client
  @client
end

#emailObject (readonly)

Returns the value of attribute email.



8
9
10
# File 'lib/snov/get_prospects_by_email.rb', line 8

def email
  @email
end

Instance Method Details

#each(&block) ⇒ Object



15
16
17
# File 'lib/snov/get_prospects_by_email.rb', line 15

def each(&block)
  prospects.each(&block)
end

#prospectsObject



19
20
21
22
23
# File 'lib/snov/get_prospects_by_email.rb', line 19

def prospects
  @prospects ||= raw_result.fetch('data', []).map do |result|
    ProspectResult.new(result)
  end
end

#raw_resultObject



25
26
27
28
29
# File 'lib/snov/get_prospects_by_email.rb', line 25

def raw_result
  @raw_result ||= client.post("/v1/get-prospects-by-email",
                              'email' => email)
                        .deep_transform_keys! { |key| key.underscore }
end