Class: Snov::GetEmailsFromName

Inherits:
Object
  • Object
show all
Defined in:
lib/snov/get_emails_from_name.rb

Defined Under Namespace

Classes: ProspectData, ProspectEmail, ProspectResult, ProspectStatus

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client: Snov.client, first_name:, last_name:, domain:) ⇒ GetEmailsFromName

Returns a new instance of GetEmailsFromName.



5
6
7
8
9
10
# File 'lib/snov/get_emails_from_name.rb', line 5

def initialize(client: Snov.client, first_name:, last_name:, domain:)
  @client = client
  @first_name = first_name
  @last_name = last_name
  @domain = domain
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



3
4
5
# File 'lib/snov/get_emails_from_name.rb', line 3

def client
  @client
end

Instance Method Details

#prospectObject



12
13
14
15
16
# File 'lib/snov/get_emails_from_name.rb', line 12

def prospect
  @prospect ||= ProspectResult.new(raw_result)
rescue ArgumentError => e
  raise ArgumentError.new("#{@raw_result} searching prospect with #{@first_name} #{@last_name} #{@domain}")
end

#raw_resultObject



18
19
20
21
22
23
24
# File 'lib/snov/get_emails_from_name.rb', line 18

def raw_result
  @raw_result ||= client.post("/v1/get-emails-from-names",
                              "firstName" => @first_name,
                              "lastName" => @last_name,
                              "domain" => @domain)
                        .deep_transform_keys! { |key| key.underscore }
end