Class: Snov::DomainSearch

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

Constant Summary collapse

Response =
Class.new(CamelSnakeStruct)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(domain:, type: 'all', limit: 10, last_id: 0, client: Snov.client) ⇒ DomainSearch

Returns a new instance of DomainSearch.



13
14
15
16
17
18
19
# File 'lib/snov/domain_search.rb', line 13

def initialize(domain:, type: 'all', limit: 10, last_id: 0, client: Snov.client)
  @client = client
  @domain = domain
  @type = type
  @limit = limit
  @last_id = last_id
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



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

def client
  @client
end

#domainObject (readonly)

Returns the value of attribute domain.



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

def domain
  @domain
end

#limitObject (readonly)

Returns the value of attribute limit.



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

def limit
  @limit
end

#typeObject (readonly)

Returns the value of attribute type.



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

def type
  @type
end

Instance Method Details

#company_nameObject



41
42
43
# File 'lib/snov/domain_search.rb', line 41

def company_name
  raw_result.company_name
end

#each(&block) ⇒ Object



21
22
23
# File 'lib/snov/domain_search.rb', line 21

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

#emailsObject



45
46
47
# File 'lib/snov/domain_search.rb', line 45

def emails
  raw_result.emails
end

#last_idObject



37
38
39
# File 'lib/snov/domain_search.rb', line 37

def last_id
  raw_result.last_id
end

#raw_resultObject



49
50
51
52
53
54
55
# File 'lib/snov/domain_search.rb', line 49

def raw_result
  @raw_result ||= Response.new(client.get("/v2/domain-emails-with-info",
                                          'lastId' => @last_id,
                                          'limit' => @limit,
                                          'type' => type.to_s,
                                          'domain' => domain.to_s))
end

#resultObject



33
34
35
# File 'lib/snov/domain_search.rb', line 33

def result
  raw_result.result
end

#successObject



25
26
27
# File 'lib/snov/domain_search.rb', line 25

def success
  raw_result.success
end

#to_hObject



57
58
59
# File 'lib/snov/domain_search.rb', line 57

def to_h
  raw_result.to_h
end

#webmailObject



29
30
31
# File 'lib/snov/domain_search.rb', line 29

def webmail
  raw_result.webmail
end