Class: GunBroker::User::ItemsAsPagesDelegate
- Inherits:
-
Object
- Object
- GunBroker::User::ItemsAsPagesDelegate
- Includes:
- TokenHeader
- Defined in:
- lib/gun_broker/user/items_as_pages_delegate.rb
Overview
Used to scope ItemsAsPage actions by GunBroker::User.
Instance Method Summary collapse
-
#all ⇒ Array<ItemsAsPage>
Returns pages for all the the User's items (both selling and not selling).
-
#bid_on ⇒ Array<ItemsAsPage>
Returns pages for all items the User has bid on.
-
#initialize(user, options = {}) ⇒ ItemsAsPagesDelegate
constructor
A new instance of ItemsAsPagesDelegate.
-
#not_won(options = {}) ⇒ Array<ItemsAsPage>
Returns pages for items the User has bid on, but not won.
-
#selling ⇒ Array<ItemsAsPage>
Returns pages for items that are currently selling.
-
#sold(options = {}) ⇒ Array<ItemsAsPage>
Returns pages for items the User has sold.
-
#unsold(options = {}) ⇒ Array<ItemsAsPage>
Returns pages for items that were listed, but not sold.
-
#won(options = {}) ⇒ Array<ItemsAsPage>
Returns pages for items the User has won.
Constructor Details
#initialize(user, options = {}) ⇒ ItemsAsPagesDelegate
Returns a new instance of ItemsAsPagesDelegate.
12 13 14 15 16 17 18 19 20 |
# File 'lib/gun_broker/user/items_as_pages_delegate.rb', line 12 def initialize(user, = {}) max_page_size = GunBroker::API::PAGE_SIZE @user = user @items_per_page = .fetch(:items_per_page, max_page_size) if @items_per_page > max_page_size raise ArgumentError.new("`items_per_page` may not exceed #{max_page_size}") end end |
Instance Method Details
#all ⇒ Array<ItemsAsPage>
GET /Items
Returns pages for all the the User's items (both selling and not selling).
25 26 27 28 |
# File 'lib/gun_broker/user/items_as_pages_delegate.rb', line 25 def all # NOTE: this endpoint will not return items that were sold @all ||= build_pages_for(:Items, params_for(:sellername)) end |
#bid_on ⇒ Array<ItemsAsPage>
GET /ItemsBidOn
Returns pages for all items the User has bid on.
33 34 35 |
# File 'lib/gun_broker/user/items_as_pages_delegate.rb', line 33 def bid_on @bid_on ||= build_pages_for(:ItemsBidOn) end |
#not_won(options = {}) ⇒ Array<ItemsAsPage>
GET /ItemsNotWon
Returns pages for items the User has bid on, but not won.
40 41 42 |
# File 'lib/gun_broker/user/items_as_pages_delegate.rb', line 40 def not_won( = {}) @not_won ||= build_pages_for(:ItemsNotWon, params_for(:timeframe, )) end |
#selling ⇒ Array<ItemsAsPage>
GET /Items
Returns pages for items that are currently selling.
47 48 49 |
# File 'lib/gun_broker/user/items_as_pages_delegate.rb', line 47 def selling @selling ||= build_pages_for(:ItemsSelling) end |
#sold(options = {}) ⇒ Array<ItemsAsPage>
GET /ItemsSold
Returns pages for items the User has sold.
54 55 56 |
# File 'lib/gun_broker/user/items_as_pages_delegate.rb', line 54 def sold( = {}) @sold ||= build_pages_for(:ItemsSold, params_for(:timeframe, )) end |
#unsold(options = {}) ⇒ Array<ItemsAsPage>
GET /ItemsUnsold
Returns pages for items that were listed, but not sold.
61 62 63 |
# File 'lib/gun_broker/user/items_as_pages_delegate.rb', line 61 def unsold( = {}) @unsold ||= build_pages_for(:ItemsUnsold, params_for(:timeframe, )) end |
#won(options = {}) ⇒ Array<ItemsAsPage>
GET /ItemsWon
Returns pages for items the User has won.
68 69 70 |
# File 'lib/gun_broker/user/items_as_pages_delegate.rb', line 68 def won( = {}) @won ||= build_pages_for(:ItemsWon, params_for(:timeframe, )) end |