Class: Dotloop::Loop
- Inherits:
-
Object
- Object
- Dotloop::Loop
- Includes:
- QueryParamHelpers
- Defined in:
- lib/dotloop/loop.rb
Constant Summary
Constants included from QueryParamHelpers
QueryParamHelpers::BATCH_SIZE, QueryParamHelpers::MAX_LOOPS
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
Instance Method Summary collapse
- #all(options = {}) ⇒ Object
- #batch(options = {}) ⇒ Object
- #detail(profile_id:, loop_view_id:) ⇒ Object
- #find(profile_id:, loop_view_id:) ⇒ Object
-
#initialize(client:) ⇒ Loop
constructor
A new instance of Loop.
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( = {}) loops = [] [:batch_size] = BATCH_SIZE (1..MAX_LOOPS).each do |i| [:batch_number] = i current_batch = batch() loops += current_batch break if current_batch.size < [:batch_size] end loops end |
#batch(options = {}) ⇒ Object
22 23 24 25 26 |
# File 'lib/dotloop/loop.rb', line 22 def batch( = {}) @client.get("/profile/#{profile_id()}/loop", query_params()).map do |attrs| Dotloop::Models::Loop.new(attrs) end end |
#detail(profile_id:, loop_view_id:) ⇒ Object
33 34 35 36 37 |
# File 'lib/dotloop/loop.rb', line 33 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 |