Module: CoinbaseCommerce::APIResources::Base::List

Included in:
Charge, Checkout, Event
Defined in:
lib/coinbase_commerce/api_resources/base/list.rb

Overview

list operations mixin

Instance Method Summary collapse

Instance Method Details

#auto_paging(params = {}, &blk) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/coinbase_commerce/api_resources/base/list.rb', line 13

def auto_paging(params = {}, &blk)
  loop do
    page = list(params)
    last_id = page.data.empty? ? nil : page.data.last.id
    break if last_id.nil?
    params[:starting_after] = last_id
    page.data.each(&blk)
  end
end

#list(params = {}) ⇒ Object



8
9
10
11
# File 'lib/coinbase_commerce/api_resources/base/list.rb', line 8

def list(params = {})
  resp = @client.request(:get, "#{self::RESOURCE_PATH}", params)
  Util.convert_to_api_object(resp.data, @client, self)
end