Class: GunBroker::ItemsAsPage
- Inherits:
-
Object
- Object
- GunBroker::ItemsAsPage
- Defined in:
- lib/gun_broker/items_as_page.rb
Overview
Represents a page of GunBroker items (listings).
Instance Method Summary collapse
- #fetch_items ⇒ Array<Item>
-
#initialize(attributes = {}) ⇒ ItemsAsPage
constructor
A new instance of ItemsAsPage.
Constructor Details
#initialize(attributes = {}) ⇒ ItemsAsPage
Returns a new instance of ItemsAsPage.
6 7 8 |
# File 'lib/gun_broker/items_as_page.rb', line 6 def initialize(attributes = {}) @attributes = attributes end |
Instance Method Details
#fetch_items ⇒ Array<Item>
11 12 13 14 15 16 17 18 19 |
# File 'lib/gun_broker/items_as_page.rb', line 11 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 |