spree_api 5.3.3 → 5.4.0.beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +71 -33
- data/Rakefile +25 -0
- data/app/controllers/concerns/spree/api/v3/api_key_authentication.rb +51 -0
- data/app/controllers/concerns/spree/api/v3/error_handler.rb +255 -0
- data/app/controllers/concerns/spree/api/v3/http_caching.rb +90 -0
- data/app/controllers/concerns/spree/api/v3/jwt_authentication.rb +95 -0
- data/app/controllers/concerns/spree/api/v3/locale_and_currency.rb +73 -0
- data/app/controllers/concerns/spree/api/v3/order_concern.rb +51 -0
- data/app/controllers/concerns/spree/api/v3/resource_serializer.rb +41 -0
- data/app/controllers/spree/api/v3/base_controller.rb +42 -0
- data/app/controllers/spree/api/v3/resource_controller.rb +210 -0
- data/app/controllers/spree/api/v3/store/auth_controller.rb +140 -0
- data/app/controllers/spree/api/v3/store/base_controller.rb +12 -0
- data/app/controllers/spree/api/v3/store/cart_controller.rb +82 -0
- data/app/controllers/spree/api/v3/store/countries_controller.rb +31 -0
- data/app/controllers/spree/api/v3/store/currencies_controller.rb +18 -0
- data/app/controllers/spree/api/v3/store/customer/account_controller.rb +38 -0
- data/app/controllers/spree/api/v3/store/customer/addresses_controller.rb +85 -0
- data/app/controllers/spree/api/v3/store/customer/credit_cards_controller.rb +31 -0
- data/app/controllers/spree/api/v3/store/customer/gift_cards_controller.rb +36 -0
- data/app/controllers/spree/api/v3/store/customer/orders_controller.rb +35 -0
- data/app/controllers/spree/api/v3/store/customer/payment_setup_sessions_controller.rb +83 -0
- data/app/controllers/spree/api/v3/store/digitals_controller.rb +37 -0
- data/app/controllers/spree/api/v3/store/locales_controller.rb +24 -0
- data/app/controllers/spree/api/v3/store/orders/coupon_codes_controller.rb +68 -0
- data/app/controllers/spree/api/v3/store/orders/line_items_controller.rb +87 -0
- data/app/controllers/spree/api/v3/store/orders/payment_methods_controller.rb +43 -0
- data/app/controllers/spree/api/v3/store/orders/payment_sessions_controller.rb +96 -0
- data/app/controllers/spree/api/v3/store/orders/payments_controller.rb +45 -0
- data/app/controllers/spree/api/v3/store/orders/shipments_controller.rb +53 -0
- data/app/controllers/spree/api/v3/store/orders/store_credits_controller.rb +42 -0
- data/app/controllers/spree/api/v3/store/orders_controller.rb +125 -0
- data/app/controllers/spree/api/v3/store/products/filters_controller.rb +38 -0
- data/app/controllers/spree/api/v3/store/products_controller.rb +74 -0
- data/app/controllers/spree/api/v3/store/resource_controller.rb +12 -0
- data/app/controllers/spree/api/v3/store/stores_controller.rb +26 -0
- data/app/controllers/spree/api/v3/store/taxonomies_controller.rb +19 -0
- data/app/controllers/spree/api/v3/store/taxons/products_controller.rb +37 -0
- data/app/controllers/spree/api/v3/store/taxons_controller.rb +34 -0
- data/app/controllers/spree/api/v3/store/wishlist_items_controller.rb +33 -0
- data/app/controllers/spree/api/v3/store/wishlists_controller.rb +41 -0
- data/app/serializers/spree/api/v3/address_serializer.rb +22 -0
- data/app/serializers/spree/api/v3/admin/customer_serializer.rb +43 -0
- data/app/serializers/spree/api/v3/admin/metafield_serializer.rb +15 -0
- data/app/serializers/spree/api/v3/admin/order_serializer.rb +39 -0
- data/app/serializers/spree/api/v3/admin/price_serializer.rb +21 -0
- data/app/serializers/spree/api/v3/admin/product_serializer.rb +47 -0
- data/app/serializers/spree/api/v3/admin/taxon_serializer.rb +20 -0
- data/app/serializers/spree/api/v3/admin/taxonomy_serializer.rb +15 -0
- data/app/serializers/spree/api/v3/admin/variant_serializer.rb +44 -0
- data/app/serializers/spree/api/v3/asset_serializer.rb +20 -0
- data/app/serializers/spree/api/v3/base_serializer.rb +98 -0
- data/app/serializers/spree/api/v3/country_serializer.rb +35 -0
- data/app/serializers/spree/api/v3/credit_card_serializer.rb +12 -0
- data/app/serializers/spree/api/v3/currency_serializer.rb +14 -0
- data/app/serializers/spree/api/v3/customer_return_serializer.rb +17 -0
- data/app/serializers/spree/api/v3/customer_serializer.rb +19 -0
- data/app/serializers/spree/api/v3/digital_link_serializer.rb +30 -0
- data/app/serializers/spree/api/v3/digital_serializer.rb +17 -0
- data/app/serializers/spree/api/v3/export_serializer.rb +19 -0
- data/app/serializers/spree/api/v3/gift_card_batch_serializer.rb +28 -0
- data/app/serializers/spree/api/v3/gift_card_serializer.rb +78 -0
- data/app/serializers/spree/api/v3/image_serializer.rb +43 -0
- data/app/serializers/spree/api/v3/import_row_serializer.rb +24 -0
- data/app/serializers/spree/api/v3/import_serializer.rb +32 -0
- data/app/serializers/spree/api/v3/invitation_serializer.rb +47 -0
- data/app/serializers/spree/api/v3/line_item_serializer.rb +48 -0
- data/app/serializers/spree/api/v3/locale_serializer.rb +14 -0
- data/app/serializers/spree/{v2/storefront → api/v3}/metafield_serializer.rb +5 -3
- data/app/serializers/spree/api/v3/newsletter_subscriber_serializer.rb +27 -0
- data/app/serializers/spree/api/v3/option_type_serializer.rb +11 -0
- data/app/serializers/spree/api/v3/option_value_serializer.rb +24 -0
- data/app/serializers/spree/api/v3/order_promotion_serializer.rb +16 -0
- data/app/serializers/spree/api/v3/order_serializer.rb +39 -0
- data/app/serializers/spree/api/v3/payment_method_serializer.rb +15 -0
- data/app/serializers/spree/api/v3/payment_serializer.rb +54 -0
- data/app/serializers/spree/api/v3/payment_session_serializer.rb +32 -0
- data/app/serializers/spree/api/v3/payment_setup_session_serializer.rb +33 -0
- data/app/serializers/spree/api/v3/payment_source_serializer.rb +18 -0
- data/app/serializers/spree/api/v3/post_category_serializer.rb +13 -0
- data/app/serializers/spree/api/v3/post_serializer.rb +25 -0
- data/app/serializers/spree/api/v3/price_serializer.rb +34 -0
- data/app/serializers/spree/api/v3/product_serializer.rb +108 -0
- data/app/serializers/spree/api/v3/promotion_serializer.rb +28 -0
- data/app/serializers/spree/api/v3/refund_serializer.rb +31 -0
- data/app/serializers/spree/api/v3/reimbursement_serializer.rb +28 -0
- data/app/serializers/spree/api/v3/report_serializer.rb +29 -0
- data/app/serializers/spree/api/v3/return_authorization_serializer.rb +31 -0
- data/app/serializers/spree/api/v3/return_item_serializer.rb +53 -0
- data/app/serializers/spree/api/v3/shipment_serializer.rb +19 -0
- data/app/serializers/spree/api/v3/shipping_method_serializer.rb +11 -0
- data/app/serializers/spree/api/v3/shipping_rate_serializer.rb +26 -0
- data/app/serializers/spree/api/v3/state_serializer.rb +14 -0
- data/app/serializers/spree/api/v3/stock_item_serializer.rb +23 -0
- data/app/serializers/spree/api/v3/stock_location_serializer.rb +18 -0
- data/app/serializers/spree/api/v3/stock_movement_serializer.rb +24 -0
- data/app/serializers/spree/api/v3/stock_transfer_serializer.rb +25 -0
- data/app/serializers/spree/api/v3/store_credit_serializer.rb +37 -0
- data/app/serializers/spree/api/v3/store_serializer.rb +38 -0
- data/app/serializers/spree/api/v3/taxon_serializer.rb +78 -0
- data/app/serializers/spree/api/v3/taxonomy_serializer.rb +33 -0
- data/app/serializers/spree/api/v3/variant_serializer.rb +86 -0
- data/app/serializers/spree/api/v3/wished_item_serializer.rb +22 -0
- data/app/serializers/spree/api/v3/wishlist_serializer.rb +25 -0
- data/app/services/spree/api/v3/filters_aggregator.rb +156 -0
- data/app/services/spree/api/v3/orders/update.rb +103 -0
- data/config/initializers/alba.rb +5 -0
- data/config/initializers/pagy.rb +10 -0
- data/config/initializers/typelizer.rb +25 -0
- data/config/locales/en.yml +1 -0
- data/config/routes.rb +63 -196
- data/lib/spree/api/dependencies.rb +68 -0
- data/lib/spree/api/engine.rb +0 -5
- data/lib/spree/api/openapi/schema_helper.rb +177 -0
- data/lib/spree/api/testing_support/factories.rb +1 -3
- data/lib/spree/api/testing_support/v3/base.rb +118 -0
- data/lib/spree/api.rb +7 -4
- metadata +131 -264
- data/LICENSE.md +0 -57
- data/app/controllers/concerns/spree/api/v2/caching.rb +0 -40
- data/app/controllers/concerns/spree/api/v2/coupon_codes_helper.rb +0 -29
- data/app/controllers/concerns/spree/api/v2/number_resource.rb +0 -11
- data/app/controllers/concerns/spree/api/v2/platform/nested_set_reposition_concern.rb +0 -37
- data/app/controllers/concerns/spree/api/v2/platform/promotion_calculator_params.rb +0 -17
- data/app/controllers/concerns/spree/api/v2/platform/promotion_rule_params.rb +0 -16
- data/app/controllers/concerns/spree/api/v2/product_list_includes.rb +0 -21
- data/app/controllers/concerns/spree/api/v2/storefront/metadata_controller_concern.rb +0 -18
- data/app/controllers/concerns/spree/api/v2/storefront/order_concern.rb +0 -49
- data/app/controllers/spree/api/v2/base_controller.rb +0 -233
- data/app/controllers/spree/api/v2/data_feeds/google_controller.rb +0 -24
- data/app/controllers/spree/api/v2/platform/addresses_controller.rb +0 -23
- data/app/controllers/spree/api/v2/platform/adjustments_controller.rb +0 -23
- data/app/controllers/spree/api/v2/platform/classifications_controller.rb +0 -26
- data/app/controllers/spree/api/v2/platform/countries_controller.rb +0 -23
- data/app/controllers/spree/api/v2/platform/data_feeds_controller.rb +0 -19
- data/app/controllers/spree/api/v2/platform/digital_links_controller.rb +0 -29
- data/app/controllers/spree/api/v2/platform/digitals_controller.rb +0 -23
- data/app/controllers/spree/api/v2/platform/gift_cards_controller.rb +0 -23
- data/app/controllers/spree/api/v2/platform/line_items_controller.rb +0 -63
- data/app/controllers/spree/api/v2/platform/option_types_controller.rb +0 -19
- data/app/controllers/spree/api/v2/platform/option_values_controller.rb +0 -23
- data/app/controllers/spree/api/v2/platform/orders_controller.rb +0 -167
- data/app/controllers/spree/api/v2/platform/payment_methods_controller.rb +0 -31
- data/app/controllers/spree/api/v2/platform/payments_controller.rb +0 -21
- data/app/controllers/spree/api/v2/platform/products_controller.rb +0 -41
- data/app/controllers/spree/api/v2/platform/promotion_actions_controller.rb +0 -34
- data/app/controllers/spree/api/v2/platform/promotion_categories_controller.rb +0 -23
- data/app/controllers/spree/api/v2/platform/promotion_rules_controller.rb +0 -29
- data/app/controllers/spree/api/v2/platform/promotions_controller.rb +0 -35
- data/app/controllers/spree/api/v2/platform/resource_controller.rb +0 -154
- data/app/controllers/spree/api/v2/platform/roles_controller.rb +0 -19
- data/app/controllers/spree/api/v2/platform/shipments_controller.rb +0 -147
- data/app/controllers/spree/api/v2/platform/shipping_categories_controller.rb +0 -19
- data/app/controllers/spree/api/v2/platform/shipping_methods_controller.rb +0 -28
- data/app/controllers/spree/api/v2/platform/states_controller.rb +0 -23
- data/app/controllers/spree/api/v2/platform/stock_items_controller.rb +0 -23
- data/app/controllers/spree/api/v2/platform/stock_locations_controller.rb +0 -23
- data/app/controllers/spree/api/v2/platform/store_credit_categories_controller.rb +0 -19
- data/app/controllers/spree/api/v2/platform/store_credit_types_controller.rb +0 -19
- data/app/controllers/spree/api/v2/platform/store_credits_controller.rb +0 -23
- data/app/controllers/spree/api/v2/platform/tax_categories_controller.rb +0 -23
- data/app/controllers/spree/api/v2/platform/tax_rates_controller.rb +0 -27
- data/app/controllers/spree/api/v2/platform/taxonomies_controller.rb +0 -23
- data/app/controllers/spree/api/v2/platform/taxons_controller.rb +0 -59
- data/app/controllers/spree/api/v2/platform/users_controller.rb +0 -37
- data/app/controllers/spree/api/v2/platform/variants_controller.rb +0 -23
- data/app/controllers/spree/api/v2/platform/wished_items_controller.rb +0 -23
- data/app/controllers/spree/api/v2/platform/wishlists_controller.rb +0 -23
- data/app/controllers/spree/api/v2/platform/zones_controller.rb +0 -23
- data/app/controllers/spree/api/v2/resource_controller.rb +0 -79
- data/app/controllers/spree/api/v2/storefront/account/addresses_controller.rb +0 -77
- data/app/controllers/spree/api/v2/storefront/account/credit_cards_controller.rb +0 -52
- data/app/controllers/spree/api/v2/storefront/account/orders_controller.rb +0 -50
- data/app/controllers/spree/api/v2/storefront/account_controller.rb +0 -52
- data/app/controllers/spree/api/v2/storefront/cart_controller.rb +0 -246
- data/app/controllers/spree/api/v2/storefront/checkout_controller.rb +0 -183
- data/app/controllers/spree/api/v2/storefront/countries_controller.rb +0 -57
- data/app/controllers/spree/api/v2/storefront/digitals_controller.rb +0 -58
- data/app/controllers/spree/api/v2/storefront/order_status_controller.rb +0 -34
- data/app/controllers/spree/api/v2/storefront/policies_controller.rb +0 -31
- data/app/controllers/spree/api/v2/storefront/post_categories_controller.rb +0 -35
- data/app/controllers/spree/api/v2/storefront/posts_controller.rb +0 -51
- data/app/controllers/spree/api/v2/storefront/products_controller.rb +0 -66
- data/app/controllers/spree/api/v2/storefront/stores_controller.rb +0 -27
- data/app/controllers/spree/api/v2/storefront/taxons_controller.rb +0 -51
- data/app/controllers/spree/api/v2/storefront/variants_controller.rb +0 -41
- data/app/controllers/spree/api/v2/storefront/wishlists_controller.rb +0 -214
- data/app/helpers/spree/api/v2/collection_options_helpers.rb +0 -46
- data/app/helpers/spree/api/v2/display_money_helper.rb +0 -63
- data/app/helpers/spree/api/v2/store_media_serializer_images_concern.rb +0 -30
- data/app/models/concerns/spree/user_api_authentication.rb +0 -19
- data/app/models/concerns/spree/user_api_methods.rb +0 -7
- data/app/models/spree/oauth_access_grant.rb +0 -7
- data/app/models/spree/oauth_access_token.rb +0 -7
- data/app/models/spree/oauth_application.rb +0 -22
- data/app/paginators/spree/api/paginate.rb +0 -68
- data/app/presenters/spree/api/products/filters_presenter.rb +0 -39
- data/app/serializers/concerns/spree/api/v2/image_transformation_concern.rb +0 -15
- data/app/serializers/concerns/spree/api/v2/public_metafields_concern.rb +0 -15
- data/app/serializers/concerns/spree/api/v2/resource_serializer_concern.rb +0 -42
- data/app/serializers/concerns/spree/api/v2/taxon_image_transformation_concern.rb +0 -15
- data/app/serializers/spree/api/v2/base_serializer.rb +0 -43
- data/app/serializers/spree/api/v2/platform/address_serializer.rb +0 -15
- data/app/serializers/spree/api/v2/platform/adjustment_serializer.rb +0 -20
- data/app/serializers/spree/api/v2/platform/admin_user_serializer.rb +0 -11
- data/app/serializers/spree/api/v2/platform/asset_serializer.rb +0 -13
- data/app/serializers/spree/api/v2/platform/base_serializer.rb +0 -10
- data/app/serializers/spree/api/v2/platform/calculator_serializer.rb +0 -17
- data/app/serializers/spree/api/v2/platform/classification_serializer.rb +0 -14
- data/app/serializers/spree/api/v2/platform/country_serializer.rb +0 -13
- data/app/serializers/spree/api/v2/platform/credit_card_serializer.rb +0 -14
- data/app/serializers/spree/api/v2/platform/customer_return_serializer.rb +0 -17
- data/app/serializers/spree/api/v2/platform/data_feed_serializer.rb +0 -13
- data/app/serializers/spree/api/v2/platform/digital_link_serializer.rb +0 -16
- data/app/serializers/spree/api/v2/platform/digital_serializer.rb +0 -29
- data/app/serializers/spree/api/v2/platform/gift_card_serializer.rb +0 -17
- data/app/serializers/spree/api/v2/platform/image_serializer.rb +0 -17
- data/app/serializers/spree/api/v2/platform/inventory_unit_serializer.rb +0 -19
- data/app/serializers/spree/api/v2/platform/line_item_serializer.rb +0 -19
- data/app/serializers/spree/api/v2/platform/log_entry_serializer.rb +0 -13
- data/app/serializers/spree/api/v2/platform/metafield_serializer.rb +0 -21
- data/app/serializers/spree/api/v2/platform/option_type_serializer.rb +0 -13
- data/app/serializers/spree/api/v2/platform/option_value_serializer.rb +0 -13
- data/app/serializers/spree/api/v2/platform/order_promotion_serializer.rb +0 -14
- data/app/serializers/spree/api/v2/platform/order_serializer.rb +0 -31
- data/app/serializers/spree/api/v2/platform/payment_capture_event_serializer.rb +0 -13
- data/app/serializers/spree/api/v2/platform/payment_method_serializer.rb +0 -18
- data/app/serializers/spree/api/v2/platform/payment_serializer.rb +0 -22
- data/app/serializers/spree/api/v2/platform/payment_source_serializer.rb +0 -12
- data/app/serializers/spree/api/v2/platform/price_serializer.rb +0 -19
- data/app/serializers/spree/api/v2/platform/product_property_serializer.rb +0 -11
- data/app/serializers/spree/api/v2/platform/product_serializer.rb +0 -90
- data/app/serializers/spree/api/v2/platform/promotion_action_line_item_serializer.rb +0 -14
- data/app/serializers/spree/api/v2/platform/promotion_action_serializer.rb +0 -19
- data/app/serializers/spree/api/v2/platform/promotion_category_serializer.rb +0 -13
- data/app/serializers/spree/api/v2/platform/promotion_rule_serializer.rb +0 -21
- data/app/serializers/spree/api/v2/platform/promotion_serializer.rb +0 -17
- data/app/serializers/spree/api/v2/platform/property_serializer.rb +0 -11
- data/app/serializers/spree/api/v2/platform/prototype_serializer.rb +0 -15
- data/app/serializers/spree/api/v2/platform/refund_reason_serializer.rb +0 -11
- data/app/serializers/spree/api/v2/platform/refund_serializer.rb +0 -17
- data/app/serializers/spree/api/v2/platform/reimbursement_credit_serializer.rb +0 -10
- data/app/serializers/spree/api/v2/platform/reimbursement_serializer.rb +0 -19
- data/app/serializers/spree/api/v2/platform/reimbursement_type_serializer.rb +0 -11
- data/app/serializers/spree/api/v2/platform/return_authorization_reason_serializer.rb +0 -11
- data/app/serializers/spree/api/v2/platform/return_authorization_serializer.rb +0 -17
- data/app/serializers/spree/api/v2/platform/return_item_serializer.rb +0 -16
- data/app/serializers/spree/api/v2/platform/role_serializer.rb +0 -11
- data/app/serializers/spree/api/v2/platform/shipment_serializer.rb +0 -22
- data/app/serializers/spree/api/v2/platform/shipping_category_serializer.rb +0 -11
- data/app/serializers/spree/api/v2/platform/shipping_method_serializer.rb +0 -16
- data/app/serializers/spree/api/v2/platform/shipping_rate_serializer.rb +0 -15
- data/app/serializers/spree/api/v2/platform/state_change_serializer.rb +0 -13
- data/app/serializers/spree/api/v2/platform/state_serializer.rb +0 -13
- data/app/serializers/spree/api/v2/platform/stock_item_serializer.rb +0 -18
- data/app/serializers/spree/api/v2/platform/stock_location_serializer.rb +0 -14
- data/app/serializers/spree/api/v2/platform/stock_movement_serializer.rb +0 -11
- data/app/serializers/spree/api/v2/platform/stock_transfer_serializer.rb +0 -15
- data/app/serializers/spree/api/v2/platform/store_credit_category_serializer.rb +0 -12
- data/app/serializers/spree/api/v2/platform/store_credit_event_serializer.rb +0 -14
- data/app/serializers/spree/api/v2/platform/store_credit_serializer.rb +0 -18
- data/app/serializers/spree/api/v2/platform/store_credit_type_serializer.rb +0 -12
- data/app/serializers/spree/api/v2/platform/store_serializer.rb +0 -14
- data/app/serializers/spree/api/v2/platform/tax_category_serializer.rb +0 -13
- data/app/serializers/spree/api/v2/platform/tax_rate_serializer.rb +0 -14
- data/app/serializers/spree/api/v2/platform/taxon_image_serializer.rb +0 -15
- data/app/serializers/spree/api/v2/platform/taxon_serializer.rb +0 -47
- data/app/serializers/spree/api/v2/platform/taxonomy_serializer.rb +0 -14
- data/app/serializers/spree/api/v2/platform/user_serializer.rb +0 -37
- data/app/serializers/spree/api/v2/platform/variant_serializer.rb +0 -66
- data/app/serializers/spree/api/v2/platform/wished_item_serializer.rb +0 -29
- data/app/serializers/spree/api/v2/platform/wishlist_serializer.rb +0 -19
- data/app/serializers/spree/api/v2/platform/zone_member_serializer.rb +0 -13
- data/app/serializers/spree/api/v2/platform/zone_serializer.rb +0 -13
- data/app/serializers/spree/v2/storefront/address_serializer.rb +0 -22
- data/app/serializers/spree/v2/storefront/base_serializer.rb +0 -10
- data/app/serializers/spree/v2/storefront/cart_serializer.rb +0 -67
- data/app/serializers/spree/v2/storefront/country_serializer.rb +0 -24
- data/app/serializers/spree/v2/storefront/credit_card_serializer.rb +0 -15
- data/app/serializers/spree/v2/storefront/digital_link_serializer.rb +0 -11
- data/app/serializers/spree/v2/storefront/estimated_shipping_rate_serializer.rb +0 -35
- data/app/serializers/spree/v2/storefront/gift_card_serializer.rb +0 -16
- data/app/serializers/spree/v2/storefront/image_serializer.rb +0 -13
- data/app/serializers/spree/v2/storefront/line_item_serializer.rb +0 -23
- data/app/serializers/spree/v2/storefront/option_type_serializer.rb +0 -15
- data/app/serializers/spree/v2/storefront/option_value_serializer.rb +0 -13
- data/app/serializers/spree/v2/storefront/order_promotion_serializer.rb +0 -14
- data/app/serializers/spree/v2/storefront/order_serializer.rb +0 -11
- data/app/serializers/spree/v2/storefront/payment_method_serializer.rb +0 -17
- data/app/serializers/spree/v2/storefront/payment_serializer.rb +0 -20
- data/app/serializers/spree/v2/storefront/payment_source_serializer.rb +0 -12
- data/app/serializers/spree/v2/storefront/policy_serializer.rb +0 -19
- data/app/serializers/spree/v2/storefront/post_category_serializer.rb +0 -23
- data/app/serializers/spree/v2/storefront/post_serializer.rb +0 -51
- data/app/serializers/spree/v2/storefront/product_property_serializer.rb +0 -19
- data/app/serializers/spree/v2/storefront/product_serializer.rb +0 -92
- data/app/serializers/spree/v2/storefront/shipment_serializer.rb +0 -26
- data/app/serializers/spree/v2/storefront/shipping_category_serializer.rb +0 -10
- data/app/serializers/spree/v2/storefront/shipping_method_serializer.rb +0 -12
- data/app/serializers/spree/v2/storefront/shipping_rate_serializer.rb +0 -26
- data/app/serializers/spree/v2/storefront/state_serializer.rb +0 -11
- data/app/serializers/spree/v2/storefront/stock_location_serializer.rb +0 -11
- data/app/serializers/spree/v2/storefront/store_credit_category_serializer.rb +0 -11
- data/app/serializers/spree/v2/storefront/store_credit_event_serializer.rb +0 -15
- data/app/serializers/spree/v2/storefront/store_credit_serializer.rb +0 -19
- data/app/serializers/spree/v2/storefront/store_credit_type_serializer.rb +0 -11
- data/app/serializers/spree/v2/storefront/store_serializer.rb +0 -18
- data/app/serializers/spree/v2/storefront/taxon_image_serializer.rb +0 -13
- data/app/serializers/spree/v2/storefront/taxon_serializer.rb +0 -55
- data/app/serializers/spree/v2/storefront/taxonomy_serializer.rb +0 -13
- data/app/serializers/spree/v2/storefront/user_serializer.rb +0 -33
- data/app/serializers/spree/v2/storefront/variant_serializer.rb +0 -58
- data/app/serializers/spree/v2/storefront/wished_item_serializer.rb +0 -29
- data/app/serializers/spree/v2/storefront/wishlist_serializer.rb +0 -17
- data/config/initializers/doorkeeper.rb +0 -50
- data/config/initializers/json_api_mime_types.rb +0 -8
- data/config/initializers/user_class_extensions.rb +0 -7
- data/db/migrate/20100107141738_add_api_key_to_spree_users.rb +0 -7
- data/db/migrate/20120411123334_resize_api_key_field.rb +0 -7
- data/db/migrate/20120530054546_rename_api_key_to_spree_api_key.rb +0 -7
- data/db/migrate/20131017162334_add_index_to_user_spree_api_key.rb +0 -7
- data/db/migrate/20180320110726_create_doorkeeper_tables.rb +0 -69
- data/db/migrate/20210727102516_change_integer_id_columns_type.rb +0 -9
- data/db/migrate/20210919183228_enable_polymorphic_resource_owner.rb +0 -21
- data/lib/generators/spree/api/install/install_generator.rb +0 -24
- data/lib/spree/api/testing_support/factories/oauth_application_factory.rb +0 -6
- data/lib/spree/api/testing_support/serializers.rb +0 -15
- data/lib/spree/api/testing_support/v2/base.rb +0 -13
- data/lib/spree/api/testing_support/v2/current_order.rb +0 -116
- data/lib/spree/api/testing_support/v2/platform_contexts.rb +0 -272
- data/lib/spree/api/testing_support/v2/serializers_params.rb +0 -16
|
@@ -1,57 +0,0 @@
|
|
|
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.storefront_country_serializer
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def collection_serializer
|
|
38
|
-
Spree.api.storefront_country_serializer
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def collection_finder
|
|
42
|
-
Spree.api.storefront_country_finder
|
|
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
|
|
@@ -1,58 +0,0 @@
|
|
|
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
|
|
@@ -1,34 +0,0 @@
|
|
|
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.storefront_completed_order_finder
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def resource_serializer
|
|
24
|
-
Spree.api.storefront_cart_serializer
|
|
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
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
module Spree
|
|
2
|
-
module Api
|
|
3
|
-
module V2
|
|
4
|
-
module Storefront
|
|
5
|
-
class PoliciesController < ::Spree::Api::V2::ResourceController
|
|
6
|
-
private
|
|
7
|
-
|
|
8
|
-
def collection_serializer
|
|
9
|
-
Spree.api.storefront_policy_serializer
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def resource_serializer
|
|
13
|
-
Spree.api.storefront_policy_serializer
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def resource
|
|
17
|
-
@resource ||= find_with_fallback_default_locale { scope.find_by(slug: params[:id]) } || scope.find(params[:id])
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def model_class
|
|
21
|
-
Spree::Policy
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def scope_includes
|
|
25
|
-
[:rich_text_translations]
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
module Spree
|
|
2
|
-
module Api
|
|
3
|
-
module V2
|
|
4
|
-
module Storefront
|
|
5
|
-
class PostCategoriesController < ::Spree::Api::V2::ResourceController
|
|
6
|
-
protected
|
|
7
|
-
|
|
8
|
-
def collection
|
|
9
|
-
@collection ||= scope
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def resource
|
|
13
|
-
@resource ||= find_with_fallback_default_locale { scope.friendly.find(params[:id]) } || scope.friendly.find(params[:id])
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def collection_serializer
|
|
17
|
-
Spree::V2::Storefront::PostCategorySerializer
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def resource_serializer
|
|
21
|
-
Spree::V2::Storefront::PostCategorySerializer
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def model_class
|
|
25
|
-
Spree::PostCategory
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def serializer_params
|
|
29
|
-
super.merge(include_posts: action_name == 'show')
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
module Spree
|
|
2
|
-
module Api
|
|
3
|
-
module V2
|
|
4
|
-
module Storefront
|
|
5
|
-
class PostsController < ::Spree::Api::V2::ResourceController
|
|
6
|
-
protected
|
|
7
|
-
|
|
8
|
-
def sorted_collection
|
|
9
|
-
collection_sorter.new(collection, params, allowed_sort_attributes).call
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def collection
|
|
13
|
-
@collection ||= collection_finder.new(scope: scope, params: finder_params).execute
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def resource
|
|
17
|
-
@resource ||= find_with_fallback_default_locale { scope.friendly.find(params[:id]) } || scope.friendly.find(params[:id])
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def collection_finder
|
|
21
|
-
Spree.api.storefront_posts_finder
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def collection_sorter
|
|
25
|
-
Spree.api.storefront_posts_sorter
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def collection_serializer
|
|
29
|
-
Spree::V2::Storefront::PostSerializer
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def resource_serializer
|
|
33
|
-
Spree::V2::Storefront::PostSerializer
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def model_class
|
|
37
|
-
Spree::Post
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def scope
|
|
41
|
-
super.published.includes(:post_category, image_attachment: :blob)
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def allowed_sort_attributes
|
|
45
|
-
super << :published_at << :title
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
end
|
|
@@ -1,66 +0,0 @@
|
|
|
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
|
-
# using FriendlyId so old slugs still work
|
|
20
|
-
@resource ||= find_with_fallback_default_locale { scope.includes(variants: variant_includes, master: variant_includes).friendly.find(params[:id]) } || scope.includes(variants: variant_includes, master: variant_includes).friendly.find(params[:id])
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def variant_includes
|
|
24
|
-
[:images, :prices, { stock_items: :stock_location }]
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def collection_sorter
|
|
28
|
-
Spree.api.storefront_products_sorter
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def collection_finder
|
|
32
|
-
Spree.api.storefront_products_finder
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def collection_serializer
|
|
36
|
-
Spree.api.storefront_product_serializer
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def resource_serializer
|
|
40
|
-
Spree.api.storefront_product_serializer
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def model_class
|
|
44
|
-
Spree::Product
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def scope_includes
|
|
48
|
-
product_list_includes
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
def allowed_sort_attributes
|
|
52
|
-
super << :available_on
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
def collection_meta(collection)
|
|
56
|
-
super(collection).merge(filters: filters_meta)
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def filters_meta
|
|
60
|
-
Spree::Api::Products::FiltersPresenter.new(current_store, current_currency, params).to_h
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
end
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
module Spree
|
|
2
|
-
module Api
|
|
3
|
-
module V2
|
|
4
|
-
module Storefront
|
|
5
|
-
class StoresController < ::Spree::Api::V2::ResourceController
|
|
6
|
-
def current
|
|
7
|
-
render_serialized_payload { serialize_resource(current_store) }
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
private
|
|
11
|
-
|
|
12
|
-
def model_class
|
|
13
|
-
Spree::Store
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def resource
|
|
17
|
-
@resource ||= scope.find_by!(code: params[:code])
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def resource_serializer
|
|
21
|
-
Spree.api.storefront_store_serializer
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
module Spree
|
|
2
|
-
module Api
|
|
3
|
-
module V2
|
|
4
|
-
module Storefront
|
|
5
|
-
class TaxonsController < ::Spree::Api::V2::ResourceController
|
|
6
|
-
private
|
|
7
|
-
|
|
8
|
-
def collection_serializer
|
|
9
|
-
Spree.api.storefront_taxon_serializer
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def resource_serializer
|
|
13
|
-
Spree.api.storefront_taxon_serializer
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def collection_finder
|
|
17
|
-
Spree.api.storefront_taxon_finder
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def paginated_collection
|
|
21
|
-
@paginated_collection ||= collection_paginator.new(collection, params).call
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def resource
|
|
25
|
-
@resource ||= find_with_fallback_default_locale { scope.find_by(permalink: params[:id]) } || scope.find(params[:id])
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def model_class
|
|
29
|
-
Spree::Taxon
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def scope_includes
|
|
33
|
-
node_includes = %i[icon parent taxonomy translations]
|
|
34
|
-
|
|
35
|
-
{
|
|
36
|
-
parent: node_includes,
|
|
37
|
-
children: node_includes,
|
|
38
|
-
taxonomy: [root: node_includes],
|
|
39
|
-
icon: [attachment_attachment: :blob],
|
|
40
|
-
translations: []
|
|
41
|
-
}
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def serializer_params
|
|
45
|
-
super.merge(include_products: action_name == 'show')
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
end
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
module Spree
|
|
2
|
-
module Api
|
|
3
|
-
module V2
|
|
4
|
-
module Storefront
|
|
5
|
-
class VariantsController < ::Spree::Api::V2::ResourceController
|
|
6
|
-
private
|
|
7
|
-
|
|
8
|
-
def model_class
|
|
9
|
-
Spree::Variant
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def scope
|
|
13
|
-
product_scope = Spree::Product.for_store(current_store)
|
|
14
|
-
product_scope = product_scope.accessible_by(current_ability, :show)
|
|
15
|
-
product_scope = product_scope.i18n if model_class.include?(TranslatableResource)
|
|
16
|
-
|
|
17
|
-
product = product_scope.friendly.find(params[:id])
|
|
18
|
-
product.variants_including_master
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def collection_finder
|
|
22
|
-
Spree.api.storefront_variant_finder
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def collection_serializer
|
|
26
|
-
Spree.api.storefront_variant_serializer
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def scope_includes
|
|
30
|
-
variant_includes = {
|
|
31
|
-
prices: [],
|
|
32
|
-
option_values: :option_type,
|
|
33
|
-
}
|
|
34
|
-
variant_includes[:images] = [] if params[:include]&.match(/images/)
|
|
35
|
-
variant_includes
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
module Spree
|
|
2
|
-
module Api
|
|
3
|
-
module V2
|
|
4
|
-
module Storefront
|
|
5
|
-
class WishlistsController < ::Spree::Api::V2::ResourceController
|
|
6
|
-
before_action :require_spree_current_user, except: [:show]
|
|
7
|
-
before_action :ensure_valid_quantity, only: [:add_item, :set_item_quantity]
|
|
8
|
-
|
|
9
|
-
def show
|
|
10
|
-
spree_authorize! :show, resource
|
|
11
|
-
super
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def create
|
|
15
|
-
spree_authorize! :create, Spree::Wishlist
|
|
16
|
-
|
|
17
|
-
@wishlist = spree_current_user.wishlists.new(wishlist_attributes)
|
|
18
|
-
|
|
19
|
-
ensure_current_store(@wishlist)
|
|
20
|
-
|
|
21
|
-
@wishlist.save
|
|
22
|
-
|
|
23
|
-
if @wishlist.persisted?
|
|
24
|
-
render_serialized_payload(201) { serialize_resource(@wishlist) }
|
|
25
|
-
else
|
|
26
|
-
render_error_payload(@wishlist.errors.full_messages.to_sentence)
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def update
|
|
31
|
-
authorize! :update, resource
|
|
32
|
-
|
|
33
|
-
resource.update wishlist_attributes
|
|
34
|
-
|
|
35
|
-
if resource.errors.empty?
|
|
36
|
-
render_serialized_payload { serialize_resource(resource) }
|
|
37
|
-
else
|
|
38
|
-
render_error_payload(resource.errors.full_messages.to_sentence)
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def destroy
|
|
43
|
-
authorize! :destroy, resource
|
|
44
|
-
|
|
45
|
-
if resource.destroy
|
|
46
|
-
head 204
|
|
47
|
-
else
|
|
48
|
-
render_error_payload(I18n.t('spree.api.v2.wishlist.errors.the_wishlist_could_not_be_destroyed'))
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
def default
|
|
53
|
-
spree_authorize! :create, Spree::Wishlist
|
|
54
|
-
|
|
55
|
-
@default_wishlist = spree_current_user.default_wishlist_for_store(current_store)
|
|
56
|
-
|
|
57
|
-
render_serialized_payload { serialize_resource(@default_wishlist) }
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
def add_item
|
|
61
|
-
spree_authorize! :create, Spree::WishedItem
|
|
62
|
-
|
|
63
|
-
if resource.wished_items.present? && resource.wished_items.detect { |wv| wv.variant_id.to_s == params[:variant_id].to_s }.present?
|
|
64
|
-
@wished_item = resource.wished_items.detect { |wi| wi.variant_id.to_s == params[:variant_id].to_s }
|
|
65
|
-
@wished_item.quantity = params[:quantity]
|
|
66
|
-
else
|
|
67
|
-
@wished_item = Spree::WishedItem.new(params.permit(:quantity, :variant_id))
|
|
68
|
-
@wished_item.wishlist = resource
|
|
69
|
-
@wished_item.save
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
resource.reload
|
|
73
|
-
|
|
74
|
-
if @wished_item.persisted?
|
|
75
|
-
render_serialized_payload { serialize_wished_item(@wished_item) }
|
|
76
|
-
else
|
|
77
|
-
render_error_payload(resource.errors.full_messages.to_sentence)
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
def set_item_quantity
|
|
82
|
-
spree_authorize! :update, wished_item
|
|
83
|
-
|
|
84
|
-
wished_item.update(params.permit(:quantity))
|
|
85
|
-
|
|
86
|
-
if wished_item.errors.empty?
|
|
87
|
-
render_serialized_payload { serialize_wished_item(wished_item) }
|
|
88
|
-
else
|
|
89
|
-
render_error_payload(resource.errors.full_messages.to_sentence)
|
|
90
|
-
end
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
def remove_item
|
|
94
|
-
spree_authorize! :destroy, wished_item
|
|
95
|
-
|
|
96
|
-
if wished_item.destroy
|
|
97
|
-
render_serialized_payload { serialize_wished_item(wished_item) }
|
|
98
|
-
else
|
|
99
|
-
render_error_payload(resource.errors.full_messages.to_sentence)
|
|
100
|
-
end
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
def add_items
|
|
104
|
-
spree_authorize! :create, Spree::WishedItem
|
|
105
|
-
|
|
106
|
-
@wished_items = resource.wished_items
|
|
107
|
-
ApplicationRecord.transaction do
|
|
108
|
-
wished_items_attributes.each do |wished_item_attributes|
|
|
109
|
-
wished_item = @wished_items.find_by(variant_id: wished_item_attributes[:variant_id])
|
|
110
|
-
|
|
111
|
-
if wished_item
|
|
112
|
-
wished_item.update!(quantity: wished_item_attributes[:quantity] || 1)
|
|
113
|
-
else
|
|
114
|
-
Spree::WishedItem.create!(wished_item_attributes.merge(wishlist: resource))
|
|
115
|
-
end
|
|
116
|
-
end
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
resource.reload
|
|
120
|
-
render_serialized_payload { serialize_resource(resource) }
|
|
121
|
-
rescue ActiveRecord::RecordInvalid => e
|
|
122
|
-
render json: { error: e.record.errors.full_messages.to_sentence }, status: 422
|
|
123
|
-
end
|
|
124
|
-
|
|
125
|
-
def remove_items
|
|
126
|
-
spree_authorize! :destroy, Spree::WishedItem
|
|
127
|
-
|
|
128
|
-
ApplicationRecord.transaction do
|
|
129
|
-
resource.wished_items.where(id: wished_items_ids).each(&:destroy!)
|
|
130
|
-
end
|
|
131
|
-
|
|
132
|
-
resource.reload
|
|
133
|
-
render_serialized_payload { serialize_resource(resource) }
|
|
134
|
-
rescue ActiveRecord::RecordNotDestroyed => e
|
|
135
|
-
render json: { error: e.record.errors.full_messages.to_sentence }, status: 422
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
private
|
|
139
|
-
|
|
140
|
-
def scope(skip_cancancan: true)
|
|
141
|
-
if action_name == 'show'
|
|
142
|
-
super
|
|
143
|
-
else
|
|
144
|
-
super.where(user: spree_current_user)
|
|
145
|
-
end
|
|
146
|
-
end
|
|
147
|
-
|
|
148
|
-
def resource
|
|
149
|
-
@resource ||= scope.find_by(token: params[:id])
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
def model_class
|
|
153
|
-
Spree::Wishlist
|
|
154
|
-
end
|
|
155
|
-
|
|
156
|
-
def resource_serializer
|
|
157
|
-
::Spree::V2::Storefront::WishlistSerializer
|
|
158
|
-
end
|
|
159
|
-
|
|
160
|
-
def collection_serializer
|
|
161
|
-
resource_serializer
|
|
162
|
-
end
|
|
163
|
-
|
|
164
|
-
def wishlist_attributes
|
|
165
|
-
params.require(:wishlist).permit(permitted_wishlist_attributes)
|
|
166
|
-
end
|
|
167
|
-
|
|
168
|
-
def wished_item_attributes
|
|
169
|
-
params.permit(permitted_wished_item_attributes)
|
|
170
|
-
end
|
|
171
|
-
|
|
172
|
-
def wished_item
|
|
173
|
-
@wished_item ||= resource.wished_items.find(params[:item_id])
|
|
174
|
-
end
|
|
175
|
-
|
|
176
|
-
def serialize_wished_item(wished_item)
|
|
177
|
-
::Spree::V2::Storefront::WishedItemSerializer.new(
|
|
178
|
-
wished_item,
|
|
179
|
-
params: serializer_params,
|
|
180
|
-
include: resource_includes,
|
|
181
|
-
fields: sparse_fields
|
|
182
|
-
).serializable_hash
|
|
183
|
-
end
|
|
184
|
-
|
|
185
|
-
def serializer_params
|
|
186
|
-
super.merge(is_variant_included: params[:is_variant_included])
|
|
187
|
-
end
|
|
188
|
-
|
|
189
|
-
def render_error_item_quantity
|
|
190
|
-
render json: { error: I18n.t('spree.api.v2.wishlist.wrong_quantity') }, status: 422
|
|
191
|
-
end
|
|
192
|
-
|
|
193
|
-
def ensure_valid_quantity
|
|
194
|
-
return render_error_item_quantity if params[:quantity].present? && params[:quantity].to_i <= 0
|
|
195
|
-
|
|
196
|
-
params[:quantity] = if params[:quantity].present?
|
|
197
|
-
params[:quantity].to_i
|
|
198
|
-
else
|
|
199
|
-
1
|
|
200
|
-
end
|
|
201
|
-
end
|
|
202
|
-
|
|
203
|
-
def wished_items_attributes
|
|
204
|
-
params.permit(wished_items: permitted_wished_item_attributes).require(:wished_items)
|
|
205
|
-
end
|
|
206
|
-
|
|
207
|
-
def wished_items_ids
|
|
208
|
-
params.require(:wished_items_ids)
|
|
209
|
-
end
|
|
210
|
-
end
|
|
211
|
-
end
|
|
212
|
-
end
|
|
213
|
-
end
|
|
214
|
-
end
|