Class: Snov::GetEmailsFromName

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

Defined Under Namespace

Classes: ProspectResult, ProspectStatus

Constant Summary collapse

InvalidProspectResultError =
Class.new(InvalidResponseError)
ProspectData =
Class.new(CamelSnakeStruct)

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.



7
8
9
10
11
12
# File 'lib/snov/get_emails_from_name.rb', line 7

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



14
15
16
17
18
# File 'lib/snov/get_emails_from_name.rb', line 14

def prospect
  @prospect ||= ProspectResult.new(raw_result)
rescue ArgumentError, NoMethodError => e
  raise InvalidProspectResultError.new(e.message, response: raw_result)
end

#raw_resultObject



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

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