Class: Snov::GetProfileByEmail

Inherits:
Object
  • Object
show all
Defined in:
lib/snov/get_profile_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) ⇒ GetProfileByEmail

Returns a new instance of GetProfileByEmail.



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

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

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *arguments, &block) ⇒ Object



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

def method_missing(method_name, *arguments, &block)
  if prospect.respond_to?(method_name)
    prospect.public_send(method_name, *arguments, &block)
  else
    super
  end
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



5
6
7
# File 'lib/snov/get_profile_by_email.rb', line 5

def client
  @client
end

#emailObject (readonly)

Returns the value of attribute email.



5
6
7
# File 'lib/snov/get_profile_by_email.rb', line 5

def email
  @email
end

Instance Method Details

#each(&block) ⇒ Object



12
13
14
# File 'lib/snov/get_profile_by_email.rb', line 12

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

#prospectObject



16
17
18
# File 'lib/snov/get_profile_by_email.rb', line 16

def prospect
  @prospect ||= ProspectResult.new(raw_result)
end

#raw_resultObject



32
33
34
35
36
# File 'lib/snov/get_profile_by_email.rb', line 32

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

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/snov/get_profile_by_email.rb', line 28

def respond_to_missing?(method_name, include_private = false)
  prospect.respond_to?(method_name) || super
end