Class: Dscf::Marketplace::AggregatorListingsController

Inherits:
ApplicationController show all
Includes:
Core::Common
Defined in:
app/controllers/dscf/marketplace/aggregator_listings_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#bypass_permissions_for_demo?, #pundit_user

Instance Method Details

#feedObject



6
7
8
9
10
11
12
13
14
15
16
# File 'app/controllers/dscf/marketplace/aggregator_listings_controller.rb', line 6

def feed
  authorize @clazz.new, :index?
  listings = @clazz.active.includes(supplier_product: :product)

  options = {
    include: default_serializer_includes[:index] || [],
    meta: { resource_type: "aggregator_feed" }
  }

  render_success(data: listings, serializer_options: options)
end

#my_listingsObject



18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/dscf/marketplace/aggregator_listings_controller.rb', line 18

def my_listings
  authorize @clazz.new, :my_listings?
  businesses = current_user.businesses.pluck(:id)
  listings = @clazz.where(aggregator_id: businesses).includes(supplier_product: :product)

  options = {
    include: default_serializer_includes[:index] || [],
    meta: { resource_type: "my_aggregator_listings" }
  }

  render_success(data: listings, serializer_options: options)
end