Sha256: 6db5742416dc3b22762ecff2928e35e24684390f29e6ae8eba09d585ba12fbc8

Contents?: true

Size: 636 Bytes

Versions: 1

Compression:

Stored size: 636 Bytes

Contents

module GunBroker
  # Represents a page of GunBroker items (listings).
  class ItemsAsPage

    # @param attrs [Hash] The attributes required to fetch items from the API.
    def initialize(attributes = {})
      @attributes = attributes
    end

    # @return [Array<Item>]
    def fetch_items
      @attributes[:params].merge!({
        'PageIndex' => @attributes[:page_index],
        'PageSize'  => @attributes[:page_size]
      })
      response = GunBroker::API.get(@attributes[:endpoint], @attributes[:params], @attributes[:token_header])

      response['results'].map { |result| GunBroker::Item.new(result) }
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gun_broker-1.3.0 lib/gun_broker/items_as_page.rb