atkhayar-spree-dev-api 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +5 -0
- data/LICENSE +26 -0
- data/Rakefile +29 -0
- data/app/controllers/concerns/spree/api/v2/caching.rb +37 -0
- data/app/controllers/concerns/spree/api/v2/coupon_codes_helper.rb +29 -0
- data/app/controllers/concerns/spree/api/v2/number_resource.rb +11 -0
- data/app/controllers/concerns/spree/api/v2/platform/nested_set_reposition_concern.rb +37 -0
- data/app/controllers/concerns/spree/api/v2/platform/promotion_calculator_params.rb +17 -0
- data/app/controllers/concerns/spree/api/v2/platform/promotion_rule_params.rb +16 -0
- data/app/controllers/concerns/spree/api/v2/product_list_includes.rb +25 -0
- data/app/controllers/concerns/spree/api/v2/storefront/metadata_controller_concern.rb +18 -0
- data/app/controllers/concerns/spree/api/v2/storefront/order_concern.rb +52 -0
- data/app/controllers/spree/api/v2/base_controller.rb +171 -0
- data/app/controllers/spree/api/v2/platform/addresses_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/adjustments_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/classifications_controller.rb +22 -0
- data/app/controllers/spree/api/v2/platform/cms_pages_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/cms_sections_controller.rb +29 -0
- data/app/controllers/spree/api/v2/platform/countries_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/digital_links_controller.rb +25 -0
- data/app/controllers/spree/api/v2/platform/digitals_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/firebase_controller.rb +76 -0
- data/app/controllers/spree/api/v2/platform/images_controller.rb +20 -0
- data/app/controllers/spree/api/v2/platform/line_items_controller.rb +59 -0
- data/app/controllers/spree/api/v2/platform/menu_items_controller.rb +21 -0
- data/app/controllers/spree/api/v2/platform/menus_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/option_types_controller.rb +15 -0
- data/app/controllers/spree/api/v2/platform/option_values_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/orders_controller.rb +163 -0
- data/app/controllers/spree/api/v2/platform/payment_methods_controller.rb +27 -0
- data/app/controllers/spree/api/v2/platform/payments_controller.rb +17 -0
- data/app/controllers/spree/api/v2/platform/products_controller.rb +37 -0
- data/app/controllers/spree/api/v2/platform/promotion_actions_controller.rb +30 -0
- data/app/controllers/spree/api/v2/platform/promotion_categories_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/promotion_rules_controller.rb +25 -0
- data/app/controllers/spree/api/v2/platform/promotions_controller.rb +31 -0
- data/app/controllers/spree/api/v2/platform/resource_controller.rb +146 -0
- data/app/controllers/spree/api/v2/platform/roles_controller.rb +15 -0
- data/app/controllers/spree/api/v2/platform/shipments_controller.rb +143 -0
- data/app/controllers/spree/api/v2/platform/shipping_categories_controller.rb +15 -0
- data/app/controllers/spree/api/v2/platform/shipping_methods_controller.rb +24 -0
- data/app/controllers/spree/api/v2/platform/states_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/stock_items_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/stock_locations_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/store_credit_categories_controller.rb +15 -0
- data/app/controllers/spree/api/v2/platform/store_credit_types_controller.rb +15 -0
- data/app/controllers/spree/api/v2/platform/store_credits_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/stores_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/tax_categories_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/tax_rates_controller.rb +23 -0
- data/app/controllers/spree/api/v2/platform/taxonomies_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/taxons_controller.rb +55 -0
- data/app/controllers/spree/api/v2/platform/users_controller.rb +32 -0
- data/app/controllers/spree/api/v2/platform/users_resource_controller.rb +144 -0
- data/app/controllers/spree/api/v2/platform/variants_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/webhooks/events_controller.rb +21 -0
- data/app/controllers/spree/api/v2/platform/webhooks/subscribers_controller.rb +21 -0
- data/app/controllers/spree/api/v2/platform/wished_items_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/wishlists_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/zones_controller.rb +19 -0
- data/app/controllers/spree/api/v2/resource_controller.rb +76 -0
- data/app/controllers/spree/api/v2/storefront/account/addresses_controller.rb +77 -0
- data/app/controllers/spree/api/v2/storefront/account/credit_cards_controller.rb +52 -0
- data/app/controllers/spree/api/v2/storefront/account/orders_controller.rb +50 -0
- data/app/controllers/spree/api/v2/storefront/account_controller.rb +52 -0
- data/app/controllers/spree/api/v2/storefront/cart_controller.rb +245 -0
- data/app/controllers/spree/api/v2/storefront/checkout_controller.rb +160 -0
- data/app/controllers/spree/api/v2/storefront/cms_pages_controller.rb +41 -0
- data/app/controllers/spree/api/v2/storefront/countries_controller.rb +57 -0
- data/app/controllers/spree/api/v2/storefront/digitals_controller.rb +58 -0
- data/app/controllers/spree/api/v2/storefront/menus_controller.rb +35 -0
- data/app/controllers/spree/api/v2/storefront/order_status_controller.rb +34 -0
- data/app/controllers/spree/api/v2/storefront/products_controller.rb +61 -0
- data/app/controllers/spree/api/v2/storefront/stores_controller.rb +27 -0
- data/app/controllers/spree/api/v2/storefront/taxons_controller.rb +50 -0
- data/app/controllers/spree/api/v2/storefront/wishlists_controller.rb +171 -0
- data/app/helpers/spree/api/v2/collection_options_helpers.rb +46 -0
- data/app/helpers/spree/api/v2/display_money_helper.rb +43 -0
- data/app/helpers/spree/api/v2/store_media_serializer_images_concern.rb +35 -0
- data/app/jobs/spree/webhooks/subscribers/make_request_job.rb +17 -0
- data/app/models/concerns/spree/user_api_authentication.rb +19 -0
- data/app/models/concerns/spree/user_api_methods.rb +7 -0
- data/app/models/concerns/spree/webhooks/has_webhooks.rb +84 -0
- data/app/models/spree/api/webhooks/order_decorator.rb +43 -0
- data/app/models/spree/api/webhooks/payment_decorator.rb +26 -0
- data/app/models/spree/api/webhooks/product_decorator.rb +46 -0
- data/app/models/spree/api/webhooks/shipment_decorator.rb +21 -0
- data/app/models/spree/api/webhooks/stock_item_decorator.rb +43 -0
- data/app/models/spree/api/webhooks/stock_movement_decorator.rb +52 -0
- data/app/models/spree/api/webhooks/variant_decorator.rb +26 -0
- data/app/models/spree/oauth_access_grant.rb +7 -0
- data/app/models/spree/oauth_access_token.rb +7 -0
- data/app/models/spree/oauth_application.rb +15 -0
- data/app/models/spree/webhooks/base.rb +11 -0
- data/app/models/spree/webhooks/event.rb +12 -0
- data/app/models/spree/webhooks/subscriber.rb +61 -0
- data/app/presenters/spree/api/products/filters_presenter.rb +39 -0
- data/app/serializers/concerns/spree/api/v2/image_transformation_concern.rb +15 -0
- data/app/serializers/concerns/spree/api/v2/resource_serializer_concern.rb +34 -0
- data/app/serializers/concerns/spree/api/v2/taxon_image_transformation_concern.rb +15 -0
- data/app/serializers/spree/api/v2/base_serializer.rb +39 -0
- data/app/serializers/spree/api/v2/platform/address_serializer.rb +15 -0
- data/app/serializers/spree/api/v2/platform/adjustment_serializer.rb +20 -0
- data/app/serializers/spree/api/v2/platform/asset_serializer.rb +13 -0
- data/app/serializers/spree/api/v2/platform/base_serializer.rb +10 -0
- data/app/serializers/spree/api/v2/platform/calculator_serializer.rb +17 -0
- data/app/serializers/spree/api/v2/platform/classification_serializer.rb +14 -0
- data/app/serializers/spree/api/v2/platform/cms_page_serializer.rb +13 -0
- data/app/serializers/spree/api/v2/platform/cms_section_image_one_serializer.rb +9 -0
- data/app/serializers/spree/api/v2/platform/cms_section_image_three_serializer.rb +9 -0
- data/app/serializers/spree/api/v2/platform/cms_section_image_two_serializer.rb +9 -0
- data/app/serializers/spree/api/v2/platform/cms_section_serializer.rb +18 -0
- data/app/serializers/spree/api/v2/platform/country_serializer.rb +13 -0
- data/app/serializers/spree/api/v2/platform/credit_card_serializer.rb +14 -0
- data/app/serializers/spree/api/v2/platform/customer_return_serializer.rb +17 -0
- data/app/serializers/spree/api/v2/platform/digital_link_serializer.rb +16 -0
- data/app/serializers/spree/api/v2/platform/digital_serializer.rb +30 -0
- data/app/serializers/spree/api/v2/platform/feature_page_serializer.rb +11 -0
- data/app/serializers/spree/api/v2/platform/hero_image_serializer.rb +10 -0
- data/app/serializers/spree/api/v2/platform/homepage_serializer.rb +11 -0
- data/app/serializers/spree/api/v2/platform/icon_serializer.rb +16 -0
- data/app/serializers/spree/api/v2/platform/image_gallery_serializer.rb +10 -0
- data/app/serializers/spree/api/v2/platform/image_serializer.rb +17 -0
- data/app/serializers/spree/api/v2/platform/inventory_unit_serializer.rb +19 -0
- data/app/serializers/spree/api/v2/platform/line_item_serializer.rb +19 -0
- data/app/serializers/spree/api/v2/platform/log_entry_serializer.rb +13 -0
- data/app/serializers/spree/api/v2/platform/menu_item_serializer.rb +45 -0
- data/app/serializers/spree/api/v2/platform/menu_serializer.rb +13 -0
- data/app/serializers/spree/api/v2/platform/option_type_serializer.rb +13 -0
- data/app/serializers/spree/api/v2/platform/option_value_serializer.rb +13 -0
- data/app/serializers/spree/api/v2/platform/order_promotion_serializer.rb +14 -0
- data/app/serializers/spree/api/v2/platform/order_serializer.rb +31 -0
- data/app/serializers/spree/api/v2/platform/payment_capture_event_serializer.rb +13 -0
- data/app/serializers/spree/api/v2/platform/payment_method_serializer.rb +18 -0
- data/app/serializers/spree/api/v2/platform/payment_serializer.rb +21 -0
- data/app/serializers/spree/api/v2/platform/price_serializer.rb +19 -0
- data/app/serializers/spree/api/v2/platform/product_property_serializer.rb +11 -0
- data/app/serializers/spree/api/v2/platform/product_serializer.rb +82 -0
- data/app/serializers/spree/api/v2/platform/promotion_action_line_item_serializer.rb +14 -0
- data/app/serializers/spree/api/v2/platform/promotion_action_serializer.rb +19 -0
- data/app/serializers/spree/api/v2/platform/promotion_category_serializer.rb +13 -0
- data/app/serializers/spree/api/v2/platform/promotion_rule_serializer.rb +21 -0
- data/app/serializers/spree/api/v2/platform/promotion_serializer.rb +17 -0
- data/app/serializers/spree/api/v2/platform/property_serializer.rb +11 -0
- data/app/serializers/spree/api/v2/platform/prototype_serializer.rb +15 -0
- data/app/serializers/spree/api/v2/platform/refund_reason_serializer.rb +11 -0
- data/app/serializers/spree/api/v2/platform/refund_serializer.rb +16 -0
- data/app/serializers/spree/api/v2/platform/reimbursement_credit_serializer.rb +10 -0
- data/app/serializers/spree/api/v2/platform/reimbursement_serializer.rb +18 -0
- data/app/serializers/spree/api/v2/platform/reimbursement_type_serializer.rb +11 -0
- data/app/serializers/spree/api/v2/platform/return_authorization_reason_serializer.rb +11 -0
- data/app/serializers/spree/api/v2/platform/return_authorization_serializer.rb +17 -0
- data/app/serializers/spree/api/v2/platform/return_item_serializer.rb +16 -0
- data/app/serializers/spree/api/v2/platform/role_serializer.rb +11 -0
- data/app/serializers/spree/api/v2/platform/shipment_serializer.rb +22 -0
- data/app/serializers/spree/api/v2/platform/shipping_category_serializer.rb +11 -0
- data/app/serializers/spree/api/v2/platform/shipping_method_serializer.rb +16 -0
- data/app/serializers/spree/api/v2/platform/shipping_rate_serializer.rb +15 -0
- data/app/serializers/spree/api/v2/platform/side_by_side_image_serializer.rb +10 -0
- data/app/serializers/spree/api/v2/platform/standard_page_serializer.rb +11 -0
- data/app/serializers/spree/api/v2/platform/state_change_serializer.rb +13 -0
- data/app/serializers/spree/api/v2/platform/state_serializer.rb +13 -0
- data/app/serializers/spree/api/v2/platform/stock_item_serializer.rb +18 -0
- data/app/serializers/spree/api/v2/platform/stock_location_serializer.rb +14 -0
- data/app/serializers/spree/api/v2/platform/stock_movement_serializer.rb +11 -0
- data/app/serializers/spree/api/v2/platform/stock_transfer_serializer.rb +15 -0
- data/app/serializers/spree/api/v2/platform/store_credit_category_serializer.rb +12 -0
- data/app/serializers/spree/api/v2/platform/store_credit_event_serializer.rb +14 -0
- data/app/serializers/spree/api/v2/platform/store_credit_serializer.rb +18 -0
- data/app/serializers/spree/api/v2/platform/store_credit_type_serializer.rb +12 -0
- data/app/serializers/spree/api/v2/platform/store_serializer.rb +15 -0
- data/app/serializers/spree/api/v2/platform/tax_category_serializer.rb +13 -0
- data/app/serializers/spree/api/v2/platform/tax_rate_serializer.rb +14 -0
- data/app/serializers/spree/api/v2/platform/taxon_image_serializer.rb +15 -0
- data/app/serializers/spree/api/v2/platform/taxon_serializer.rb +38 -0
- data/app/serializers/spree/api/v2/platform/taxonomy_serializer.rb +14 -0
- data/app/serializers/spree/api/v2/platform/user_serializer.rb +39 -0
- data/app/serializers/spree/api/v2/platform/variant_serializer.rb +58 -0
- data/app/serializers/spree/api/v2/platform/webhooks/event_serializer.rb +15 -0
- data/app/serializers/spree/api/v2/platform/webhooks/subscriber_serializer.rb +13 -0
- data/app/serializers/spree/api/v2/platform/wished_item_serializer.rb +29 -0
- data/app/serializers/spree/api/v2/platform/wishlist_serializer.rb +19 -0
- data/app/serializers/spree/api/v2/platform/zone_member_serializer.rb +13 -0
- data/app/serializers/spree/api/v2/platform/zone_serializer.rb +13 -0
- data/app/serializers/spree/v2/storefront/address_serializer.rb +20 -0
- data/app/serializers/spree/v2/storefront/base_serializer.rb +10 -0
- data/app/serializers/spree/v2/storefront/cart_serializer.rb +36 -0
- data/app/serializers/spree/v2/storefront/cms_page_serializer.rb +14 -0
- data/app/serializers/spree/v2/storefront/cms_section_serializer.rb +32 -0
- data/app/serializers/spree/v2/storefront/country_serializer.rb +24 -0
- data/app/serializers/spree/v2/storefront/credit_card_serializer.rb +13 -0
- data/app/serializers/spree/v2/storefront/digital_link_serializer.rb +11 -0
- data/app/serializers/spree/v2/storefront/estimated_shipping_rate_serializer.rb +29 -0
- data/app/serializers/spree/v2/storefront/icon_serializer.rb +14 -0
- data/app/serializers/spree/v2/storefront/image_serializer.rb +13 -0
- data/app/serializers/spree/v2/storefront/line_item_serializer.rb +20 -0
- data/app/serializers/spree/v2/storefront/menu_item_serializer.rb +43 -0
- data/app/serializers/spree/v2/storefront/menu_serializer.rb +13 -0
- data/app/serializers/spree/v2/storefront/option_type_serializer.rb +13 -0
- data/app/serializers/spree/v2/storefront/option_value_serializer.rb +13 -0
- data/app/serializers/spree/v2/storefront/order_serializer.rb +9 -0
- data/app/serializers/spree/v2/storefront/payment_method_serializer.rb +15 -0
- data/app/serializers/spree/v2/storefront/payment_serializer.rb +15 -0
- data/app/serializers/spree/v2/storefront/product_property_serializer.rb +19 -0
- data/app/serializers/spree/v2/storefront/product_serializer.rb +76 -0
- data/app/serializers/spree/v2/storefront/promotion_serializer.rb +12 -0
- data/app/serializers/spree/v2/storefront/shipment_serializer.rb +24 -0
- data/app/serializers/spree/v2/storefront/shipping_rate_serializer.rb +16 -0
- data/app/serializers/spree/v2/storefront/state_serializer.rb +11 -0
- data/app/serializers/spree/v2/storefront/stock_location_serializer.rb +11 -0
- data/app/serializers/spree/v2/storefront/store_credit_category_serializer.rb +11 -0
- data/app/serializers/spree/v2/storefront/store_credit_event_serializer.rb +15 -0
- data/app/serializers/spree/v2/storefront/store_credit_serializer.rb +17 -0
- data/app/serializers/spree/v2/storefront/store_credit_type_serializer.rb +11 -0
- data/app/serializers/spree/v2/storefront/store_serializer.rb +20 -0
- data/app/serializers/spree/v2/storefront/taxon_image_serializer.rb +13 -0
- data/app/serializers/spree/v2/storefront/taxon_serializer.rb +37 -0
- data/app/serializers/spree/v2/storefront/taxonomy_serializer.rb +11 -0
- data/app/serializers/spree/v2/storefront/user_serializer.rb +31 -0
- data/app/serializers/spree/v2/storefront/variant_serializer.rb +49 -0
- data/app/serializers/spree/v2/storefront/wished_item_serializer.rb +29 -0
- data/app/serializers/spree/v2/storefront/wishlist_serializer.rb +17 -0
- data/app/services/spree/api/error_handler.rb +40 -0
- data/app/services/spree/webhooks/subscribers/handle_request.rb +73 -0
- data/app/services/spree/webhooks/subscribers/make_request.rb +82 -0
- data/app/services/spree/webhooks/subscribers/queue_requests.rb +23 -0
- data/app/services/spree/webhooks.rb +13 -0
- data/config/i18n-tasks.yml +40 -0
- data/config/initializers/doorkeeper.rb +48 -0
- data/config/initializers/json_api_mime_types.rb +8 -0
- data/config/initializers/user_class_extensions.rb +7 -0
- data/config/locales/en.yml +38 -0
- data/config/routes.rb +214 -0
- data/db/migrate/20100107141738_add_api_key_to_spree_users.rb +7 -0
- data/db/migrate/20120411123334_resize_api_key_field.rb +7 -0
- data/db/migrate/20120530054546_rename_api_key_to_spree_api_key.rb +7 -0
- data/db/migrate/20131017162334_add_index_to_user_spree_api_key.rb +7 -0
- data/db/migrate/20180320110726_create_doorkeeper_tables.rb +69 -0
- data/db/migrate/20210727102516_change_integer_id_columns_type.rb +9 -0
- data/db/migrate/20210902162826_create_spree_webhooks_tables.rb +16 -0
- data/db/migrate/20210919183228_enable_polymorphic_resource_owner.rb +21 -0
- data/db/migrate/20211025162826_create_spree_webhooks_events.rb +14 -0
- data/docs/oauth/index.yml +233 -0
- data/docs/v2/platform/index.yaml +21111 -0
- data/docs/v2/storefront/index.yaml +16504 -0
- data/lib/spree/api/configuration.rb +11 -0
- data/lib/spree/api/dependencies.rb +165 -0
- data/lib/spree/api/engine.rb +34 -0
- data/lib/spree/api/testing_support/caching.rb +10 -0
- data/lib/spree/api/testing_support/factories/oauth_application_factory.rb +6 -0
- data/lib/spree/api/testing_support/factories/webhook_event_factory.rb +27 -0
- data/lib/spree/api/testing_support/factories/webhook_subscriber_factory.rb +13 -0
- data/lib/spree/api/testing_support/factories.rb +3 -0
- data/lib/spree/api/testing_support/jobs.rb +18 -0
- data/lib/spree/api/testing_support/matchers/webhooks.rb +67 -0
- data/lib/spree/api/testing_support/serializers.rb +25 -0
- data/lib/spree/api/testing_support/spree_webhooks.rb +9 -0
- data/lib/spree/api/testing_support/v2/base.rb +13 -0
- data/lib/spree/api/testing_support/v2/current_order.rb +112 -0
- data/lib/spree/api/testing_support/v2/platform_contexts.rb +273 -0
- data/lib/spree/api/testing_support/v2/serializers_params.rb +16 -0
- data/lib/spree/api.rb +8 -0
- data/lib/spree_api.rb +3 -0
- data/script/rails +9 -0
- data/spec/fixtures/files/icon_256x256.jpg +0 -0
- data/spec/fixtures/thinking-cat.jpg +0 -0
- data/spree_api.gemspec +35 -0
- metadata +427 -0
@@ -0,0 +1,245 @@
|
|
1
|
+
module Spree
|
2
|
+
module Api
|
3
|
+
module V2
|
4
|
+
module Storefront
|
5
|
+
class CartController < ::Spree::Api::V2::BaseController
|
6
|
+
include OrderConcern
|
7
|
+
include CouponCodesHelper
|
8
|
+
include Spree::Api::V2::Storefront::MetadataControllerConcern
|
9
|
+
|
10
|
+
before_action :ensure_valid_metadata, only: %i[create add_item]
|
11
|
+
before_action :ensure_order, except: %i[create associate]
|
12
|
+
before_action :load_variant, only: :add_item
|
13
|
+
before_action :require_spree_current_user, only: :associate
|
14
|
+
|
15
|
+
|
16
|
+
def create
|
17
|
+
spree_authorize! :create, Spree::Order
|
18
|
+
|
19
|
+
create_cart_params = {
|
20
|
+
user: spree_current_user,
|
21
|
+
store: current_store,
|
22
|
+
currency: current_currency,
|
23
|
+
public_metadata: add_item_params[:public_metadata],
|
24
|
+
private_metadata: add_item_params[:private_metadata],
|
25
|
+
}
|
26
|
+
|
27
|
+
order = spree_current_order if spree_current_order.present?
|
28
|
+
order ||= create_service.call(create_cart_params).value
|
29
|
+
|
30
|
+
render_serialized_payload(201) { serialize_resource(order) }
|
31
|
+
end
|
32
|
+
|
33
|
+
def add_item
|
34
|
+
spree_authorize! :update, spree_current_order, order_token
|
35
|
+
spree_authorize! :show, @variant
|
36
|
+
|
37
|
+
result = add_item_service.call(
|
38
|
+
order: spree_current_order,
|
39
|
+
variant: @variant,
|
40
|
+
quantity: add_item_params[:quantity],
|
41
|
+
public_metadata: add_item_params[:public_metadata],
|
42
|
+
private_metadata: add_item_params[:private_metadata],
|
43
|
+
options: add_item_params[:options]
|
44
|
+
)
|
45
|
+
|
46
|
+
render_order(result)
|
47
|
+
end
|
48
|
+
|
49
|
+
def remove_line_item
|
50
|
+
spree_authorize! :update, spree_current_order, order_token
|
51
|
+
|
52
|
+
remove_line_item_service.call(
|
53
|
+
order: spree_current_order,
|
54
|
+
line_item: line_item
|
55
|
+
)
|
56
|
+
|
57
|
+
render_serialized_payload { serialized_current_order }
|
58
|
+
end
|
59
|
+
|
60
|
+
def empty
|
61
|
+
spree_authorize! :update, spree_current_order, order_token
|
62
|
+
|
63
|
+
result = empty_cart_service.call(order: spree_current_order)
|
64
|
+
|
65
|
+
if result.success?
|
66
|
+
render_serialized_payload { serialized_current_order }
|
67
|
+
else
|
68
|
+
render_error_payload(result.error)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def destroy
|
73
|
+
spree_authorize! :update, spree_current_order, order_token
|
74
|
+
|
75
|
+
result = destroy_cart_service.call(order: spree_current_order)
|
76
|
+
|
77
|
+
if result.success?
|
78
|
+
head 204
|
79
|
+
else
|
80
|
+
render_error_payload(result.error)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def set_quantity
|
85
|
+
return render_error_item_quantity unless params[:quantity].to_i > 0
|
86
|
+
|
87
|
+
spree_authorize! :update, spree_current_order, order_token
|
88
|
+
|
89
|
+
result = set_item_quantity_service.call(order: spree_current_order, line_item: line_item, quantity: params[:quantity])
|
90
|
+
|
91
|
+
render_order(result)
|
92
|
+
end
|
93
|
+
|
94
|
+
def show
|
95
|
+
spree_authorize! :show, spree_current_order, order_token
|
96
|
+
|
97
|
+
render_serialized_payload { serialized_current_order }
|
98
|
+
end
|
99
|
+
|
100
|
+
def apply_coupon_code
|
101
|
+
spree_authorize! :update, spree_current_order, order_token
|
102
|
+
|
103
|
+
spree_current_order.coupon_code = params[:coupon_code]
|
104
|
+
result = coupon_handler.new(spree_current_order).apply
|
105
|
+
|
106
|
+
if result.error.blank?
|
107
|
+
render_serialized_payload { serialized_current_order }
|
108
|
+
else
|
109
|
+
render_error_payload(result.error)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def remove_coupon_code
|
114
|
+
spree_authorize! :update, spree_current_order, order_token
|
115
|
+
|
116
|
+
coupon_codes = select_coupon_codes
|
117
|
+
|
118
|
+
return render_error_payload(I18n.t('spree.api.v2.cart.no_coupon_code')) if coupon_codes.empty?
|
119
|
+
|
120
|
+
result_errors = coupon_codes.count > 1 ? select_errors(coupon_codes) : select_error(coupon_codes)
|
121
|
+
|
122
|
+
if result_errors.blank?
|
123
|
+
render_serialized_payload { serialized_current_order }
|
124
|
+
else
|
125
|
+
render_error_payload(result_errors)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
def estimate_shipping_rates
|
130
|
+
spree_authorize! :show, spree_current_order, order_token
|
131
|
+
|
132
|
+
result = estimate_shipping_rates_service.call(order: spree_current_order, country_iso: params[:country_iso])
|
133
|
+
|
134
|
+
if result.error.blank?
|
135
|
+
render_serialized_payload { serialize_estimated_shipping_rates(result.value) }
|
136
|
+
else
|
137
|
+
render_error_payload(result.error)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
def associate
|
142
|
+
guest_order_token = params[:guest_order_token]
|
143
|
+
guest_order = ::Spree::Api::Dependencies.storefront_current_order_finder.constantize.new.execute(
|
144
|
+
store: current_store,
|
145
|
+
user: nil,
|
146
|
+
token: guest_order_token,
|
147
|
+
currency: current_currency
|
148
|
+
)
|
149
|
+
|
150
|
+
spree_authorize! :update, guest_order, guest_order_token
|
151
|
+
|
152
|
+
result = associate_service.call(guest_order: guest_order, user: spree_current_user)
|
153
|
+
|
154
|
+
if result.success?
|
155
|
+
render_serialized_payload { serialize_resource(guest_order) }
|
156
|
+
else
|
157
|
+
render_error_payload(result.error)
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
def change_currency
|
162
|
+
spree_authorize! :update, spree_current_order, order_token
|
163
|
+
|
164
|
+
result = change_currency_service.call(order: spree_current_order, new_currency: params[:new_currency])
|
165
|
+
|
166
|
+
render_order(result)
|
167
|
+
end
|
168
|
+
|
169
|
+
private
|
170
|
+
|
171
|
+
def resource_serializer
|
172
|
+
Spree::Api::Dependencies.storefront_cart_serializer.constantize
|
173
|
+
end
|
174
|
+
|
175
|
+
def create_service
|
176
|
+
Spree::Api::Dependencies.storefront_cart_create_service.constantize
|
177
|
+
end
|
178
|
+
|
179
|
+
def add_item_service
|
180
|
+
Spree::Api::Dependencies.storefront_cart_add_item_service.constantize
|
181
|
+
end
|
182
|
+
|
183
|
+
def empty_cart_service
|
184
|
+
Spree::Api::Dependencies.storefront_cart_empty_service.constantize
|
185
|
+
end
|
186
|
+
|
187
|
+
def destroy_cart_service
|
188
|
+
Spree::Api::Dependencies.storefront_cart_destroy_service.constantize
|
189
|
+
end
|
190
|
+
|
191
|
+
def set_item_quantity_service
|
192
|
+
Spree::Api::Dependencies.storefront_cart_set_item_quantity_service.constantize
|
193
|
+
end
|
194
|
+
|
195
|
+
def remove_line_item_service
|
196
|
+
Spree::Api::Dependencies.storefront_cart_remove_line_item_service.constantize
|
197
|
+
end
|
198
|
+
|
199
|
+
def coupon_handler
|
200
|
+
Spree::Api::Dependencies.storefront_coupon_handler.constantize
|
201
|
+
end
|
202
|
+
|
203
|
+
def estimate_shipping_rates_service
|
204
|
+
Spree::Api::Dependencies.storefront_cart_estimate_shipping_rates_service.constantize
|
205
|
+
end
|
206
|
+
|
207
|
+
def associate_service
|
208
|
+
Spree::Api::Dependencies.storefront_cart_associate_service.constantize
|
209
|
+
end
|
210
|
+
|
211
|
+
def change_currency_service
|
212
|
+
Spree::Api::Dependencies.storefront_cart_change_currency_service.constantize
|
213
|
+
end
|
214
|
+
|
215
|
+
def line_item
|
216
|
+
@line_item ||= spree_current_order.line_items.find(params[:line_item_id])
|
217
|
+
end
|
218
|
+
|
219
|
+
def load_variant
|
220
|
+
@variant = current_store.variants.find(add_item_params[:variant_id])
|
221
|
+
end
|
222
|
+
|
223
|
+
def render_error_item_quantity
|
224
|
+
render json: { error: I18n.t(:wrong_quantity, scope: 'spree.api.v2.cart') }, status: 422
|
225
|
+
end
|
226
|
+
|
227
|
+
def estimate_shipping_rates_serializer
|
228
|
+
Spree::Api::Dependencies.storefront_estimated_shipment_serializer.constantize
|
229
|
+
end
|
230
|
+
|
231
|
+
def serialize_estimated_shipping_rates(shipping_rates)
|
232
|
+
estimate_shipping_rates_serializer.new(
|
233
|
+
shipping_rates,
|
234
|
+
params: serializer_params
|
235
|
+
).serializable_hash
|
236
|
+
end
|
237
|
+
|
238
|
+
def add_item_params
|
239
|
+
params.permit(:quantity, :variant_id, public_metadata: {}, private_metadata: {}, options: {})
|
240
|
+
end
|
241
|
+
end
|
242
|
+
end
|
243
|
+
end
|
244
|
+
end
|
245
|
+
end
|
@@ -0,0 +1,160 @@
|
|
1
|
+
module Spree
|
2
|
+
module Api
|
3
|
+
module V2
|
4
|
+
module Storefront
|
5
|
+
class CheckoutController < ::Spree::Api::V2::BaseController
|
6
|
+
include Spree::Api::V2::Storefront::OrderConcern
|
7
|
+
before_action :ensure_order
|
8
|
+
|
9
|
+
def next
|
10
|
+
spree_authorize! :update, spree_current_order, order_token
|
11
|
+
|
12
|
+
result = next_service.call(order: spree_current_order)
|
13
|
+
|
14
|
+
render_order(result)
|
15
|
+
end
|
16
|
+
|
17
|
+
def advance
|
18
|
+
spree_authorize! :update, spree_current_order, order_token
|
19
|
+
|
20
|
+
result = advance_service.call(order: spree_current_order)
|
21
|
+
|
22
|
+
render_order(result)
|
23
|
+
end
|
24
|
+
|
25
|
+
def complete
|
26
|
+
spree_authorize! :update, spree_current_order, order_token
|
27
|
+
|
28
|
+
result = complete_service.call(order: spree_current_order)
|
29
|
+
|
30
|
+
render_order(result)
|
31
|
+
end
|
32
|
+
|
33
|
+
def update
|
34
|
+
spree_authorize! :update, spree_current_order, order_token
|
35
|
+
|
36
|
+
result = update_service.call(
|
37
|
+
order: spree_current_order,
|
38
|
+
params: params,
|
39
|
+
# defined in https://github.com/spree/spree/blob/master/core/lib/spree/core/controller_helpers/strong_parameters.rb#L19
|
40
|
+
permitted_attributes: permitted_checkout_attributes,
|
41
|
+
request_env: request.headers.env
|
42
|
+
)
|
43
|
+
|
44
|
+
render_order(result)
|
45
|
+
end
|
46
|
+
|
47
|
+
def create_payment
|
48
|
+
result = create_payment_service.call(order: spree_current_order, params: params)
|
49
|
+
|
50
|
+
if result.success?
|
51
|
+
render_serialized_payload(201) { serialize_resource(spree_current_order.reload) }
|
52
|
+
else
|
53
|
+
render_error_payload(result.error)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def select_shipping_method
|
58
|
+
result = select_shipping_method_service.call(order: spree_current_order, params: params)
|
59
|
+
|
60
|
+
render_order(result)
|
61
|
+
end
|
62
|
+
|
63
|
+
def add_store_credit
|
64
|
+
spree_authorize! :update, spree_current_order, order_token
|
65
|
+
|
66
|
+
result = add_store_credit_service.call(
|
67
|
+
order: spree_current_order,
|
68
|
+
amount: params[:amount].try(:to_f)
|
69
|
+
)
|
70
|
+
|
71
|
+
render_order(result)
|
72
|
+
end
|
73
|
+
|
74
|
+
def remove_store_credit
|
75
|
+
spree_authorize! :update, spree_current_order, order_token
|
76
|
+
|
77
|
+
result = remove_store_credit_service.call(order: spree_current_order)
|
78
|
+
render_order(result)
|
79
|
+
end
|
80
|
+
|
81
|
+
def shipping_rates
|
82
|
+
result = shipping_rates_service.call(order: spree_current_order)
|
83
|
+
|
84
|
+
if result.success?
|
85
|
+
render_serialized_payload { serialize_shipping_rates(result.value) }
|
86
|
+
else
|
87
|
+
render_error_payload(result.error)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def payment_methods
|
92
|
+
render_serialized_payload { serialize_payment_methods(spree_current_order.available_payment_methods) }
|
93
|
+
end
|
94
|
+
|
95
|
+
private
|
96
|
+
|
97
|
+
def resource_serializer
|
98
|
+
Spree::Api::Dependencies.storefront_cart_serializer.constantize
|
99
|
+
end
|
100
|
+
|
101
|
+
def next_service
|
102
|
+
Spree::Api::Dependencies.storefront_checkout_next_service.constantize
|
103
|
+
end
|
104
|
+
|
105
|
+
def advance_service
|
106
|
+
Spree::Api::Dependencies.storefront_checkout_advance_service.constantize
|
107
|
+
end
|
108
|
+
|
109
|
+
def add_store_credit_service
|
110
|
+
Spree::Api::Dependencies.storefront_checkout_add_store_credit_service.constantize
|
111
|
+
end
|
112
|
+
|
113
|
+
def remove_store_credit_service
|
114
|
+
Spree::Api::Dependencies.storefront_checkout_remove_store_credit_service.constantize
|
115
|
+
end
|
116
|
+
|
117
|
+
def complete_service
|
118
|
+
Spree::Api::Dependencies.storefront_checkout_complete_service.constantize
|
119
|
+
end
|
120
|
+
|
121
|
+
def update_service
|
122
|
+
Spree::Api::Dependencies.storefront_checkout_update_service.constantize
|
123
|
+
end
|
124
|
+
|
125
|
+
def payment_methods_serializer
|
126
|
+
Spree::Api::Dependencies.storefront_payment_method_serializer.constantize
|
127
|
+
end
|
128
|
+
|
129
|
+
def shipping_rates_service
|
130
|
+
Spree::Api::Dependencies.storefront_checkout_get_shipping_rates_service.constantize
|
131
|
+
end
|
132
|
+
|
133
|
+
def shipping_rates_serializer
|
134
|
+
Spree::Api::Dependencies.storefront_shipment_serializer.constantize
|
135
|
+
end
|
136
|
+
|
137
|
+
def create_payment_service
|
138
|
+
Spree::Api::Dependencies.storefront_payment_create_service.constantize
|
139
|
+
end
|
140
|
+
|
141
|
+
def select_shipping_method_service
|
142
|
+
Spree::Api::Dependencies.storefront_checkout_select_shipping_method_service.constantize
|
143
|
+
end
|
144
|
+
|
145
|
+
def serialize_payment_methods(payment_methods)
|
146
|
+
payment_methods_serializer.new(payment_methods, params: serializer_params).serializable_hash
|
147
|
+
end
|
148
|
+
|
149
|
+
def serialize_shipping_rates(shipments)
|
150
|
+
shipping_rates_serializer.new(
|
151
|
+
shipments,
|
152
|
+
params: serializer_params,
|
153
|
+
include: [:shipping_rates, :stock_location, :line_items]
|
154
|
+
).serializable_hash
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Spree
|
2
|
+
module Api
|
3
|
+
module V2
|
4
|
+
module Storefront
|
5
|
+
class CmsPagesController < ::Spree::Api::V2::ResourceController
|
6
|
+
private
|
7
|
+
|
8
|
+
def model_class
|
9
|
+
Spree::CmsPage
|
10
|
+
end
|
11
|
+
|
12
|
+
def resource
|
13
|
+
@resource ||= scope.find_by(slug: params[:id]) || scope.find(params[:id])
|
14
|
+
end
|
15
|
+
|
16
|
+
def resource_serializer
|
17
|
+
Spree::Api::Dependencies.storefront_cms_page_serializer.constantize
|
18
|
+
end
|
19
|
+
|
20
|
+
def collection_serializer
|
21
|
+
Spree::Api::Dependencies.storefront_cms_page_serializer.constantize
|
22
|
+
end
|
23
|
+
|
24
|
+
def collection_finder
|
25
|
+
Spree::Api::Dependencies.storefront_cms_page_finder.constantize
|
26
|
+
end
|
27
|
+
|
28
|
+
def scope
|
29
|
+
super.by_locale(I18n.locale)
|
30
|
+
end
|
31
|
+
|
32
|
+
def scope_includes
|
33
|
+
{
|
34
|
+
cms_sections: :linked_resource
|
35
|
+
}
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module Spree
|
2
|
+
module Api
|
3
|
+
module V2
|
4
|
+
module Storefront
|
5
|
+
class CountriesController < ::Spree::Api::V2::ResourceController
|
6
|
+
before_action :set_default_per_page
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def serialize_collection(collection)
|
11
|
+
collection_serializer.new(
|
12
|
+
collection,
|
13
|
+
collection_options(collection).merge(params: collection_serializer_params)
|
14
|
+
).serializable_hash
|
15
|
+
end
|
16
|
+
|
17
|
+
def serializer_params
|
18
|
+
super.merge(include_states: true)
|
19
|
+
end
|
20
|
+
|
21
|
+
def collection_serializer_params
|
22
|
+
serializer_params.merge(include_states: false)
|
23
|
+
end
|
24
|
+
|
25
|
+
def resource
|
26
|
+
return current_store.default_country if params[:iso] == 'default'
|
27
|
+
|
28
|
+
scope.find_by(iso: params[:iso]&.upcase) ||
|
29
|
+
scope.find_by(id: params[:iso]&.upcase) ||
|
30
|
+
scope.find_by(iso3: params[:iso]&.upcase)
|
31
|
+
end
|
32
|
+
|
33
|
+
def resource_serializer
|
34
|
+
Spree::Api::Dependencies.storefront_country_serializer.constantize
|
35
|
+
end
|
36
|
+
|
37
|
+
def collection_serializer
|
38
|
+
Spree::Api::Dependencies.storefront_country_serializer.constantize
|
39
|
+
end
|
40
|
+
|
41
|
+
def collection_finder
|
42
|
+
Spree::Api::Dependencies.storefront_country_finder.constantize
|
43
|
+
end
|
44
|
+
|
45
|
+
def model_class
|
46
|
+
Spree::Country
|
47
|
+
end
|
48
|
+
|
49
|
+
# by default we want to return all countries on a single page
|
50
|
+
def set_default_per_page
|
51
|
+
params[:per_page] ||= Spree::Country.count
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module Spree
|
2
|
+
module Api
|
3
|
+
module V2
|
4
|
+
module Storefront
|
5
|
+
class DigitalsController < ::Spree::Api::V2::ResourceController
|
6
|
+
def download
|
7
|
+
if attachment.present?
|
8
|
+
if digital_link.authorize!
|
9
|
+
if defined?(ActiveStorage::Service::DiskService) && ActiveStorage::Blob.service.instance_of?(ActiveStorage::Service::DiskService)
|
10
|
+
# The asset is hosted on disk, use send_file.
|
11
|
+
|
12
|
+
send_file(
|
13
|
+
ActiveStorage::Blob.service.path_for(attachment.key),
|
14
|
+
filename: attachment.filename.to_s,
|
15
|
+
type: attachment.content_type.to_s,
|
16
|
+
status: :ok
|
17
|
+
) and return
|
18
|
+
|
19
|
+
else
|
20
|
+
# The asset is hosted on a 3rd party service, use an expiring url with disposition: 'attachment'.
|
21
|
+
|
22
|
+
redirect_to attachment.url(
|
23
|
+
expires_in: current_store.digital_asset_link_expire_time.seconds,
|
24
|
+
disposition: 'attachment',
|
25
|
+
host: digital_attachment_host
|
26
|
+
) and return
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
else
|
31
|
+
Rails.logger.error I18n.t('spree.api.v2.digitals.missing_file')
|
32
|
+
end
|
33
|
+
|
34
|
+
render json: { error: I18n.t('spree.api.v2.digitals.unauthorized') }, status: 403
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def model_class
|
40
|
+
Spree::Digital
|
41
|
+
end
|
42
|
+
|
43
|
+
def digital_link
|
44
|
+
@digital_link ||= DigitalLink.find_by!(token: params[:token])
|
45
|
+
end
|
46
|
+
|
47
|
+
def attachment
|
48
|
+
@attachment ||= digital_link.digital.try(:attachment) if digital_link.present?
|
49
|
+
end
|
50
|
+
|
51
|
+
def digital_attachment_host
|
52
|
+
current_store.formatted_url
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Spree
|
2
|
+
module Api
|
3
|
+
module V2
|
4
|
+
module Storefront
|
5
|
+
class MenusController < ::Spree::Api::V2::ResourceController
|
6
|
+
private
|
7
|
+
|
8
|
+
def resource_serializer
|
9
|
+
Spree::Api::Dependencies.storefront_menu_serializer.constantize
|
10
|
+
end
|
11
|
+
|
12
|
+
def collection_serializer
|
13
|
+
Spree::Api::Dependencies.storefront_menu_serializer.constantize
|
14
|
+
end
|
15
|
+
|
16
|
+
def collection_finder
|
17
|
+
Spree::Api::Dependencies.storefront_menu_finder.constantize
|
18
|
+
end
|
19
|
+
|
20
|
+
def model_class
|
21
|
+
Spree::Menu
|
22
|
+
end
|
23
|
+
|
24
|
+
def scope
|
25
|
+
super.by_locale(I18n.locale)
|
26
|
+
end
|
27
|
+
|
28
|
+
def scope_includes
|
29
|
+
{ menu_items: [:children, :parent, :icon] }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Spree
|
2
|
+
module Api
|
3
|
+
module V2
|
4
|
+
module Storefront
|
5
|
+
class OrderStatusController < ::Spree::Api::V2::ResourceController
|
6
|
+
include Spree::Api::V2::Storefront::OrderConcern
|
7
|
+
|
8
|
+
before_action :ensure_order_token
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def resource
|
13
|
+
resource = resource_finder.new(number: params[:number], token: order_token, store: current_store).execute.take
|
14
|
+
raise ActiveRecord::RecordNotFound if resource.nil?
|
15
|
+
|
16
|
+
resource
|
17
|
+
end
|
18
|
+
|
19
|
+
def resource_finder
|
20
|
+
Spree::Api::Dependencies.storefront_completed_order_finder.constantize
|
21
|
+
end
|
22
|
+
|
23
|
+
def resource_serializer
|
24
|
+
Spree::Api::Dependencies.storefront_cart_serializer.constantize
|
25
|
+
end
|
26
|
+
|
27
|
+
def ensure_order_token
|
28
|
+
raise ActiveRecord::RecordNotFound unless order_token.present?
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module Spree
|
2
|
+
module Api
|
3
|
+
module V2
|
4
|
+
module Storefront
|
5
|
+
class ProductsController < ::Spree::Api::V2::ResourceController
|
6
|
+
include ::Spree::Api::V2::ProductListIncludes
|
7
|
+
|
8
|
+
protected
|
9
|
+
|
10
|
+
def sorted_collection
|
11
|
+
collection_sorter.new(collection, current_currency, params, allowed_sort_attributes).call
|
12
|
+
end
|
13
|
+
|
14
|
+
def collection
|
15
|
+
@collection ||= collection_finder.new(scope: scope, params: finder_params).execute
|
16
|
+
end
|
17
|
+
|
18
|
+
def resource
|
19
|
+
@resource ||= scope.find_by(slug: params[:id]) || scope.find(params[:id])
|
20
|
+
end
|
21
|
+
|
22
|
+
def collection_sorter
|
23
|
+
Spree::Api::Dependencies.storefront_products_sorter.constantize
|
24
|
+
end
|
25
|
+
|
26
|
+
def collection_finder
|
27
|
+
Spree::Api::Dependencies.storefront_products_finder.constantize
|
28
|
+
end
|
29
|
+
|
30
|
+
def collection_serializer
|
31
|
+
Spree::Api::Dependencies.storefront_product_serializer.constantize
|
32
|
+
end
|
33
|
+
|
34
|
+
def resource_serializer
|
35
|
+
Spree::Api::Dependencies.storefront_product_serializer.constantize
|
36
|
+
end
|
37
|
+
|
38
|
+
def model_class
|
39
|
+
Spree::Product
|
40
|
+
end
|
41
|
+
|
42
|
+
def scope_includes
|
43
|
+
product_list_includes
|
44
|
+
end
|
45
|
+
|
46
|
+
def allowed_sort_attributes
|
47
|
+
super << :available_on
|
48
|
+
end
|
49
|
+
|
50
|
+
def collection_meta(collection)
|
51
|
+
super(collection).merge(filters: filters_meta)
|
52
|
+
end
|
53
|
+
|
54
|
+
def filters_meta
|
55
|
+
Spree::Api::Products::FiltersPresenter.new(current_store, current_currency, params).to_h
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|