Class: Dotloop::Loop
Constant Summary
QueryParamHelpers::BATCH_SIZE, QueryParamHelpers::MAX_LOOPS
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(client:) ⇒ Loop
Returns a new instance of Loop.
6
7
8
|
# File 'lib/dotloop/loop.rb', line 6
def initialize(client:)
@client = client
end
|
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
4
5
6
|
# File 'lib/dotloop/loop.rb', line 4
def client
@client
end
|
Instance Method Details
#all(options = {}) ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/dotloop/loop.rb', line 10
def all(options = {})
loops = []
options[:batch_size] = BATCH_SIZE
(1..MAX_LOOPS).each do |i|
options[:batch_number] = i
current_batch = batch(options)
loops += current_batch
break if current_batch.size < options[:batch_size]
end
loops
end
|
#batch(options = {}) ⇒ Object
22
23
24
25
26
27
28
29
|
# File 'lib/dotloop/loop.rb', line 22
def batch(options = {})
@client.get("/profile/#{profile_id(options)}/loop", query_params(options)).map do |attrs|
lp = Dotloop::Models::Loop.new(attrs)
lp.client = client
lp.profile_id = profile_id(options)
lp
end
end
|
#detail(profile_id:, loop_view_id:) ⇒ Object
39
40
41
42
43
|
# File 'lib/dotloop/loop.rb', line 39
def detail(profile_id:, loop_view_id:)
loop_detail = @client.get("/profile/#{profile_id.to_i}/loop/#{loop_view_id.to_i}/detail")
loop_detail[:sections] = Dotloop::Section.new(loop_detail[:sections]).sections if loop_detail[:sections]
Dotloop::Models::LoopDetail.new(loop_detail)
end
|
#find(profile_id:, loop_view_id:) ⇒ Object
31
32
33
34
35
36
37
|
# File 'lib/dotloop/loop.rb', line 31
def find(profile_id:, loop_view_id:)
loop_data = @client.get("/profile/#{profile_id.to_i}/loop/#{loop_view_id.to_i}")
lp = Dotloop::Models::Loop.new(loop_data)
lp.client = client
lp.profile_id = profile_id.to_i
lp
end
|