Class: WalmartOpen::Requests::Feed

Inherits:
WalmartOpen::Request show all
Defined in:
lib/walmart_open/requests/feed.rb

Constant Summary collapse

TYPES =
[
  :preorder,
  :bestsellers,
  :rollback,
  :clearance,
  :specialbuy
]
CATEGORY_REQUIRED_TYPES =
TYPES - [:preorder]

Instance Attribute Summary

Attributes inherited from WalmartOpen::Request

#params, #path

Instance Method Summary collapse

Methods inherited from WalmartOpen::Request

#submit

Constructor Details

#initialize(type, params = {}) ⇒ Feed

Returns a new instance of Feed.



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/walmart_open/requests/feed.rb', line 15

def initialize(type, params = {})
  unless TYPES.include?(type)
    raise ArgumentError, "Invalid feed type #{type}"
  end

  if !params[:category_id] && CATEGORY_REQUIRED_TYPES.include?(type)
    raise ArgumentError, "Category id param is required for the #{type} feed"
  end

  self.path = "feeds/#{type.to_s}"
  self.params = params
end