Class: SoapyCake::AdminBatched::BatchedRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/soapy_cake/admin_batched.rb

Constant Summary collapse

INITIAL_OFFSET =

Both 0 and 1 return the first element. We need to set it to 1, otherwise we get an overlap in the next call. This is not documented in the API spec.

1
LIMIT =

This value depends on the entity size. When all offers have a lot of info (e.g. geotargeting) we probably need to decrease this.

500

Instance Method Summary collapse

Constructor Details

#initialize(admin, method, opts, limit) ⇒ BatchedRequest

Returns a new instance of BatchedRequest.



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/soapy_cake/admin_batched.rb', line 23

def initialize(admin, method, opts, limit)
  if opts.key?(:row_limit) || opts.key?(:start_at_row)
    raise Error, 'Cannot set row_limit/start_at_row in batched mode!'
  end

  @admin = admin
  @method = method
  @opts = opts
  @offset = INITIAL_OFFSET
  @limit = limit || LIMIT
end

Instance Method Details

#to_enumObject



35
36
37
38
39
40
41
42
# File 'lib/soapy_cake/admin_batched.rb', line 35

def to_enum
  Enumerator.new do |y|
    loop do
      fetch_elements(y)
      @offset += limit
    end
  end
end