Class: Snov::GetAllProspectsFromList

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(list_id:, max: 9999, per_page: 100, client: Snov.client) ⇒ GetAllProspectsFromList

Returns a new instance of GetAllProspectsFromList.



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

def initialize(list_id:, max: 9999, per_page: 100, client: Snov.client)
  @client = client
  @list_id = list_id
  @max = max.to_int
  @per_page = per_page
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



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

def client
  @client
end

#list_idObject (readonly)

Returns the value of attribute list_id.



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

def list_id
  @list_id
end

#maxObject (readonly)

Returns the value of attribute max.



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

def max
  @max
end

#per_pageObject (readonly)

Returns the value of attribute per_page.



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

def per_page
  @per_page
end

Instance Method Details

#each(&block) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/snov/get_all_prospects_from_list.rb', line 14

def each(&block)
  (1..max).each do |page|
    list = GetProspectList.new(list_id: list_id, page: page, per_page: per_page,
                               client: client)
    prospects = list.prospects

    prospects.each(&block)

    break if prospects.size < per_page
  end
end