Class: Dscf::Marketplace::MyResourceService
- Inherits:
-
Object
- Object
- Dscf::Marketplace::MyResourceService
- Defined in:
- app/services/dscf/marketplace/my_resource_service.rb
Instance Method Summary collapse
-
#initialize(current_user) ⇒ MyResourceService
constructor
A new instance of MyResourceService.
- #listings_by_supplier(supplier_id, params = {}) ⇒ Object
- #my_listings(params = {}) ⇒ Object
- #my_orders(params = {}) ⇒ Object
- #my_products(params = {}) ⇒ Object
- #my_quotes(params = {}) ⇒ Object
- #my_rfqs(params = {}) ⇒ Object
Constructor Details
#initialize(current_user) ⇒ MyResourceService
Returns a new instance of MyResourceService.
4 5 6 |
# File 'app/services/dscf/marketplace/my_resource_service.rb', line 4 def initialize(current_user) @current_user = current_user end |
Instance Method Details
#listings_by_supplier(supplier_id, params = {}) ⇒ Object
46 47 48 49 50 51 52 |
# File 'app/services/dscf/marketplace/my_resource_service.rb', line 46 def listings_by_supplier(supplier_id, params = {}) listings = Dscf::Marketplace::Listing.joins(:supplier_product) .where(dscf_marketplace_supplier_products: {business_id: supplier_id}) .includes(:business, :supplier_product, :order_items, supplier_product: [ :product ]) apply_filters(listings, params) end |
#my_listings(params = {}) ⇒ Object
30 31 32 33 34 35 36 |
# File 'app/services/dscf/marketplace/my_resource_service.rb', line 30 def my_listings(params = {}) listings = Dscf::Marketplace::Listing.joins(:business) .where(dscf_core_businesses: {user_id: @current_user.id}) .includes(:business, :supplier_product, :order_items, supplier_product: [ :product ]) apply_filters(listings, params) end |
#my_orders(params = {}) ⇒ Object
8 9 10 11 12 13 |
# File 'app/services/dscf/marketplace/my_resource_service.rb', line 8 def my_orders(params = {}) orders = Dscf::Marketplace::Order.where(ordered_by: @current_user) .includes(:quotation, :listing, :user, :ordered_by, :ordered_to, :delivery_order, :order_items) apply_filters(orders, params) end |
#my_products(params = {}) ⇒ Object
38 39 40 41 42 43 44 |
# File 'app/services/dscf/marketplace/my_resource_service.rb', line 38 def my_products(params = {}) products = Dscf::Marketplace::SupplierProduct.joins(:business) .where(dscf_core_businesses: {user_id: @current_user.id}) .includes(:business, :product, :listings) apply_filters(products, params) end |
#my_quotes(params = {}) ⇒ Object
22 23 24 25 26 27 28 |
# File 'app/services/dscf/marketplace/my_resource_service.rb', line 22 def my_quotes(params = {}) quotes = Dscf::Marketplace::Quotation.joins(:request_for_quotation) .where(dscf_marketplace_request_for_quotations: {user_id: @current_user.id}) .includes(:request_for_quotation, :business, :quotation_items, :order) apply_filters(quotes, params) end |
#my_rfqs(params = {}) ⇒ Object
15 16 17 18 19 20 |
# File 'app/services/dscf/marketplace/my_resource_service.rb', line 15 def my_rfqs(params = {}) rfqs = Dscf::Marketplace::RequestForQuotation.where(user: @current_user) .includes(:user, :selected_quotation, :rfq_items, :quotations) apply_filters(rfqs, params) end |