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.



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

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.



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

def client
  @client
end

#domainObject (readonly)

Returns the value of attribute domain.



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

def domain
  @domain
end

#limitObject (readonly)

Returns the value of attribute limit.



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

def limit
  @limit
end

#typeObject (readonly)

Returns the value of attribute type.



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

def type
  @type
end

Instance Method Details

#company_nameObject



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

def company_name
  raw_result.company_name
end

#each(&block) ⇒ Object



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

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

#emailsObject



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

def emails
  raw_result.emails
end

#last_idObject



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

def last_id
  raw_result.last_id
end

#raw_resultObject



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

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



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

def result
  raw_result.result
end

#successObject



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

def success
  raw_result.success
end

#to_hObject



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

def to_h
  raw_result.to_h
end

#webmailObject



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

def webmail
  raw_result.webmail
end