class GunBroker::OrdersAsPage

Represents a page of GunBroker orders.

Public Class Methods

new(attributes = {}) click to toggle source

@param attrs [Hash] The attributes required to fetch orders from the API.

# File lib/gun_broker/orders_as_page.rb, line 6
def initialize(attributes = {})
  @attributes = attributes
end

Public Instance Methods

fetch_orders() click to toggle source

@return [Array<Order>]

# File lib/gun_broker/orders_as_page.rb, line 11
def fetch_orders
  @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::Order.new(result) }
end