Class: Dscf::Marketplace::ListingsController
- Inherits:
-
ApplicationController
- Object
- ActionController::API
- ApplicationController
- Dscf::Marketplace::ListingsController
- Includes:
- Core::Common
- Defined in:
- app/controllers/dscf/marketplace/listings_controller.rb
Instance Method Summary collapse
- #activate ⇒ Object
- #listings_by_supplier ⇒ Object
- #my_listings ⇒ Object
- #pause ⇒ Object
- #sold_out ⇒ Object
Instance Method Details
#activate ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'app/controllers/dscf/marketplace/listings_controller.rb', line 6 def activate @obj = find_record if @obj.update(status: :active) render_success("listings.success.activated", data: @obj) else render_error("listings.errors.activate_failed") end end |
#listings_by_supplier ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'app/controllers/dscf/marketplace/listings_controller.rb', line 45 def listings_by_supplier supplier_id = params[:supplier_id] # Validate supplier exists supplier = Dscf::Core::Business.find_by(id: supplier_id) return render_error("listings.errors.supplier_not_found") unless supplier service = MyResourceService.new(current_user) listings = service.listings_by_supplier(supplier_id, params) = { include: default_serializer_includes[:index] || [], meta: { resource_type: "listings_by_supplier", supplier_id: supplier_id, supplier_name: supplier.name } } render_success("listings.success.index", data: listings, serializer_options: ) end |
#my_listings ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/controllers/dscf/marketplace/listings_controller.rb', line 33 def my_listings service = MyResourceService.new(current_user) listings = service.my_listings(params) = { include: default_serializer_includes[:index] || [], meta: {resource_type: "my_listings"} } render_success("listings.success.index", data: listings, serializer_options: ) end |
#pause ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'app/controllers/dscf/marketplace/listings_controller.rb', line 15 def pause @obj = find_record if @obj.update(status: :paused) render_success("listings.success.paused", data: @obj) else render_error("listings.errors.pause_failed") end end |
#sold_out ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'app/controllers/dscf/marketplace/listings_controller.rb', line 24 def sold_out @obj = find_record if @obj.update(status: :sold_out) render_success("listings.success.sold_out", data: @obj) else render_error("listings.errors.sold_out_failed") end end |