Module: CoinbaseCommerceClient::APIResources::Base::List

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

Instance Method Summary collapse

Instance Method Details

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



10
11
12
13
14
15
16
17
18
19
# File 'lib/coinbase_commerce_client/api_resources/base/list.rb', line 10

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



5
6
7
8
# File 'lib/coinbase_commerce_client/api_resources/base/list.rb', line 5

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