spree_api 4.3.0 → 4.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/concerns/spree/api/v2/caching.rb +7 -3
- 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 +10 -8
- data/app/controllers/concerns/spree/api/v2/storefront/metadata_controller_concern.rb +18 -0
- data/app/controllers/spree/api/v2/base_controller.rb +7 -5
- data/app/controllers/spree/api/v2/platform/adjustments_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/classifications_controller.rb +1 -22
- data/app/controllers/spree/api/v2/platform/cms_pages_controller.rb +4 -0
- data/app/controllers/spree/api/v2/platform/cms_sections_controller.rb +13 -18
- 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/line_items_controller.rb +59 -0
- data/app/controllers/spree/api/v2/platform/menu_items_controller.rb +5 -19
- data/app/controllers/spree/api/v2/platform/menus_controller.rb +0 -4
- 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 +5 -1
- 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 +47 -16
- 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/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 +25 -0
- data/app/controllers/spree/api/v2/platform/users_controller.rb +4 -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 +3 -3
- data/app/controllers/spree/api/v2/storefront/account/addresses_controller.rb +2 -2
- data/app/controllers/spree/api/v2/storefront/account/credit_cards_controller.rb +4 -1
- data/app/controllers/spree/api/v2/storefront/cart_controller.rb +18 -28
- data/app/controllers/spree/api/v2/storefront/checkout_controller.rb +25 -1
- data/app/controllers/spree/api/v2/storefront/digitals_controller.rb +58 -0
- data/app/controllers/spree/api/v2/storefront/stores_controller.rb +4 -0
- data/app/controllers/spree/api/v2/storefront/wishlists_controller.rb +171 -0
- data/app/helpers/spree/api/v2/collection_options_helpers.rb +1 -1
- 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/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/serializers/concerns/spree/api/v2/resource_serializer_concern.rb +19 -1
- data/app/serializers/spree/api/v2/base_serializer.rb +11 -4
- data/app/serializers/spree/api/v2/platform/address_serializer.rb +1 -1
- 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/calculator_serializer.rb +17 -0
- data/app/serializers/spree/api/v2/platform/classification_serializer.rb +1 -1
- data/app/serializers/spree/api/v2/platform/cms_page_serializer.rb +1 -1
- 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 +8 -1
- data/app/serializers/spree/api/v2/platform/country_serializer.rb +1 -1
- 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/image_gallery_serializer.rb +10 -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 +1 -1
- data/app/serializers/spree/api/v2/platform/menu_serializer.rb +1 -1
- data/app/serializers/spree/api/v2/platform/option_type_serializer.rb +1 -1
- data/app/serializers/spree/api/v2/platform/option_value_serializer.rb +1 -1
- 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 +1 -1
- data/app/serializers/spree/api/v2/platform/product_serializer.rb +7 -3
- 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 +1 -1
- data/app/serializers/spree/api/v2/platform/stock_item_serializer.rb +1 -3
- data/app/serializers/spree/api/v2/platform/stock_location_serializer.rb +2 -4
- 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 +2 -1
- data/app/serializers/spree/api/v2/platform/tax_category_serializer.rb +2 -2
- data/app/serializers/spree/api/v2/platform/tax_rate_serializer.rb +14 -0
- data/app/serializers/spree/api/v2/platform/taxon_serializer.rb +1 -1
- data/app/serializers/spree/api/v2/platform/taxonomy_serializer.rb +1 -1
- data/app/serializers/spree/api/v2/platform/user_serializer.rb +1 -1
- data/app/serializers/spree/api/v2/platform/variant_serializer.rb +3 -2
- 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 +1 -1
- data/app/serializers/spree/v2/storefront/cart_serializer.rb +1 -1
- data/app/serializers/spree/v2/storefront/cms_section_serializer.rb +8 -4
- data/app/serializers/spree/v2/storefront/credit_card_serializer.rb +1 -1
- data/app/serializers/spree/v2/storefront/digital_link_serializer.rb +11 -0
- data/app/serializers/spree/v2/storefront/estimated_shipping_rate_serializer.rb +2 -2
- data/app/serializers/spree/v2/storefront/line_item_serializer.rb +2 -1
- data/app/serializers/spree/v2/storefront/option_type_serializer.rb +1 -1
- data/app/serializers/spree/v2/storefront/option_value_serializer.rb +1 -1
- data/app/serializers/spree/v2/storefront/order_serializer.rb +9 -0
- data/app/serializers/spree/v2/storefront/payment_method_serializer.rb +1 -1
- data/app/serializers/spree/v2/storefront/payment_serializer.rb +1 -1
- data/app/serializers/spree/v2/storefront/product_property_serializer.rb +1 -1
- data/app/serializers/spree/v2/storefront/product_serializer.rb +2 -2
- data/app/serializers/spree/v2/storefront/promotion_serializer.rb +1 -1
- data/app/serializers/spree/v2/storefront/shipment_serializer.rb +5 -1
- data/app/serializers/spree/v2/storefront/store_credit_serializer.rb +1 -1
- data/app/serializers/spree/v2/storefront/store_serializer.rb +5 -10
- data/app/serializers/spree/v2/storefront/taxon_serializer.rb +1 -1
- data/app/serializers/spree/v2/storefront/taxonomy_serializer.rb +1 -1
- data/app/serializers/spree/v2/storefront/user_serializer.rb +1 -1
- data/app/serializers/spree/v2/storefront/variant_serializer.rb +1 -1
- 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/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 +12 -12
- data/config/locales/en.yml +29 -27
- data/config/routes.rb +84 -179
- 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 +126 -33
- data/docs/v2/platform/index.yaml +19696 -1734
- data/docs/v2/storefront/index.yaml +15050 -14553
- data/lib/spree/api/configuration.rb +11 -0
- data/lib/spree/api/dependencies.rb +165 -0
- data/lib/spree/api/engine.rb +10 -5
- 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 +1 -1
- data/lib/spree/api/testing_support/v2/current_order.rb +34 -1
- data/lib/spree/api/testing_support/v2/platform_contexts.rb +100 -52
- data/lib/spree/api/testing_support/v2/serializers_params.rb +3 -1
- data/lib/spree/api.rb +0 -3
- data/lib/spree_api.rb +0 -1
- data/spec/fixtures/files/icon_256x256.jpg +0 -0
- data/spree_api.gemspec +15 -16
- metadata +163 -177
- data/app/controllers/spree/api/base_controller.rb +0 -171
- data/app/controllers/spree/api/errors_controller.rb +0 -9
- data/app/controllers/spree/api/v1/addresses_controller.rb +0 -46
- data/app/controllers/spree/api/v1/checkouts_controller.rb +0 -106
- data/app/controllers/spree/api/v1/classifications_controller.rb +0 -21
- data/app/controllers/spree/api/v1/countries_controller.rb +0 -22
- data/app/controllers/spree/api/v1/credit_cards_controller.rb +0 -26
- data/app/controllers/spree/api/v1/customer_returns_controller.rb +0 -25
- data/app/controllers/spree/api/v1/images_controller.rb +0 -58
- data/app/controllers/spree/api/v1/inventory_units_controller.rb +0 -54
- data/app/controllers/spree/api/v1/line_items_controller.rb +0 -70
- data/app/controllers/spree/api/v1/option_types_controller.rb +0 -60
- data/app/controllers/spree/api/v1/option_values_controller.rb +0 -62
- data/app/controllers/spree/api/v1/orders_controller.rb +0 -160
- data/app/controllers/spree/api/v1/payments_controller.rb +0 -82
- data/app/controllers/spree/api/v1/product_properties_controller.rb +0 -73
- data/app/controllers/spree/api/v1/products_controller.rb +0 -131
- data/app/controllers/spree/api/v1/promotions_controller.rb +0 -30
- data/app/controllers/spree/api/v1/properties_controller.rb +0 -70
- data/app/controllers/spree/api/v1/reimbursements_controller.rb +0 -25
- data/app/controllers/spree/api/v1/return_authorizations_controller.rb +0 -70
- data/app/controllers/spree/api/v1/shipments_controller.rb +0 -196
- data/app/controllers/spree/api/v1/states_controller.rb +0 -36
- data/app/controllers/spree/api/v1/stock_items_controller.rb +0 -82
- data/app/controllers/spree/api/v1/stock_locations_controller.rb +0 -53
- data/app/controllers/spree/api/v1/stock_movements_controller.rb +0 -45
- data/app/controllers/spree/api/v1/stores_controller.rb +0 -56
- data/app/controllers/spree/api/v1/taxonomies_controller.rb +0 -67
- data/app/controllers/spree/api/v1/taxons_controller.rb +0 -100
- data/app/controllers/spree/api/v1/users_controller.rb +0 -97
- data/app/controllers/spree/api/v1/variants_controller.rb +0 -81
- data/app/controllers/spree/api/v1/zones_controller.rb +0 -55
- data/app/helpers/spree/api/api_helpers.rb +0 -190
- data/app/models/spree/api_configuration.rb +0 -10
- data/app/models/spree/api_dependencies.rb +0 -111
- data/app/views/spree/api/errors/gateway_error.rabl +0 -2
- data/app/views/spree/api/errors/invalid_api_key.rabl +0 -2
- data/app/views/spree/api/errors/invalid_resource.rabl +0 -3
- data/app/views/spree/api/errors/must_specify_api_key.rabl +0 -2
- data/app/views/spree/api/errors/not_found.rabl +0 -2
- data/app/views/spree/api/errors/unauthorized.rabl +0 -2
- data/app/views/spree/api/v1/addresses/show.rabl +0 -10
- data/app/views/spree/api/v1/adjustments/show.rabl +0 -4
- data/app/views/spree/api/v1/countries/index.rabl +0 -7
- data/app/views/spree/api/v1/countries/show.rabl +0 -5
- data/app/views/spree/api/v1/credit_cards/index.rabl +0 -7
- data/app/views/spree/api/v1/credit_cards/show.rabl +0 -3
- data/app/views/spree/api/v1/customer_returns/index.rabl +0 -7
- data/app/views/spree/api/v1/images/index.rabl +0 -4
- data/app/views/spree/api/v1/images/new.rabl +0 -3
- data/app/views/spree/api/v1/images/show.rabl +0 -6
- data/app/views/spree/api/v1/inventory_units/show.rabl +0 -2
- data/app/views/spree/api/v1/line_items/new.rabl +0 -3
- data/app/views/spree/api/v1/line_items/show.rabl +0 -14
- data/app/views/spree/api/v1/option_types/index.rabl +0 -3
- data/app/views/spree/api/v1/option_types/new.rabl +0 -3
- data/app/views/spree/api/v1/option_types/show.rabl +0 -5
- data/app/views/spree/api/v1/option_values/index.rabl +0 -3
- data/app/views/spree/api/v1/option_values/new.rabl +0 -3
- data/app/views/spree/api/v1/option_values/show.rabl +0 -2
- data/app/views/spree/api/v1/orders/address.rabl +0 -0
- data/app/views/spree/api/v1/orders/canceled.rabl +0 -0
- data/app/views/spree/api/v1/orders/cart.rabl +0 -0
- data/app/views/spree/api/v1/orders/complete.rabl +0 -0
- data/app/views/spree/api/v1/orders/could_not_apply_coupon.rabl +0 -2
- data/app/views/spree/api/v1/orders/could_not_transition.rabl +0 -3
- data/app/views/spree/api/v1/orders/index.rabl +0 -7
- data/app/views/spree/api/v1/orders/insufficient_quantity.rabl +0 -2
- data/app/views/spree/api/v1/orders/invalid_shipping_method.rabl +0 -2
- data/app/views/spree/api/v1/orders/mine.rabl +0 -9
- data/app/views/spree/api/v1/orders/order.rabl +0 -10
- data/app/views/spree/api/v1/orders/payment.rabl +0 -3
- data/app/views/spree/api/v1/orders/show.rabl +0 -51
- data/app/views/spree/api/v1/payments/credit_over_limit.rabl +0 -2
- data/app/views/spree/api/v1/payments/index.rabl +0 -7
- data/app/views/spree/api/v1/payments/new.rabl +0 -5
- data/app/views/spree/api/v1/payments/show.rabl +0 -2
- data/app/views/spree/api/v1/payments/update_forbidden.rabl +0 -2
- data/app/views/spree/api/v1/product_properties/index.rabl +0 -7
- data/app/views/spree/api/v1/product_properties/new.rabl +0 -2
- data/app/views/spree/api/v1/product_properties/show.rabl +0 -2
- data/app/views/spree/api/v1/products/index.rabl +0 -9
- data/app/views/spree/api/v1/products/new.rabl +0 -3
- data/app/views/spree/api/v1/products/product.rabl +0 -1
- data/app/views/spree/api/v1/products/show.rabl +0 -36
- data/app/views/spree/api/v1/promotions/handler.rabl +0 -5
- data/app/views/spree/api/v1/promotions/show.rabl +0 -2
- data/app/views/spree/api/v1/properties/index.rabl +0 -7
- data/app/views/spree/api/v1/properties/new.rabl +0 -2
- data/app/views/spree/api/v1/properties/show.rabl +0 -2
- data/app/views/spree/api/v1/reimbursements/index.rabl +0 -7
- data/app/views/spree/api/v1/return_authorizations/index.rabl +0 -7
- data/app/views/spree/api/v1/return_authorizations/new.rabl +0 -3
- data/app/views/spree/api/v1/return_authorizations/show.rabl +0 -2
- data/app/views/spree/api/v1/shared/stock_location_required.rabl +0 -2
- data/app/views/spree/api/v1/shipments/big.rabl +0 -48
- data/app/views/spree/api/v1/shipments/cannot_ready_shipment.rabl +0 -2
- data/app/views/spree/api/v1/shipments/mine.rabl +0 -9
- data/app/views/spree/api/v1/shipments/show.rabl +0 -32
- data/app/views/spree/api/v1/shipments/small.rabl +0 -37
- data/app/views/spree/api/v1/shipping_rates/show.rabl +0 -2
- data/app/views/spree/api/v1/states/index.rabl +0 -12
- data/app/views/spree/api/v1/states/show.rabl +0 -2
- data/app/views/spree/api/v1/stock_items/index.rabl +0 -7
- data/app/views/spree/api/v1/stock_items/show.rabl +0 -5
- data/app/views/spree/api/v1/stock_locations/index.rabl +0 -7
- data/app/views/spree/api/v1/stock_locations/show.rabl +0 -8
- data/app/views/spree/api/v1/stock_movements/index.rabl +0 -7
- data/app/views/spree/api/v1/stock_movements/show.rabl +0 -5
- data/app/views/spree/api/v1/stores/index.rabl +0 -4
- data/app/views/spree/api/v1/stores/show.rabl +0 -2
- data/app/views/spree/api/v1/tags/index.rabl +0 -9
- data/app/views/spree/api/v1/taxonomies/index.rabl +0 -7
- data/app/views/spree/api/v1/taxonomies/jstree.rabl +0 -7
- data/app/views/spree/api/v1/taxonomies/nested.rabl +0 -11
- data/app/views/spree/api/v1/taxonomies/new.rabl +0 -3
- data/app/views/spree/api/v1/taxonomies/show.rabl +0 -15
- data/app/views/spree/api/v1/taxons/index.rabl +0 -10
- data/app/views/spree/api/v1/taxons/jstree.rabl +0 -7
- data/app/views/spree/api/v1/taxons/new.rabl +0 -3
- data/app/views/spree/api/v1/taxons/show.rabl +0 -6
- data/app/views/spree/api/v1/taxons/taxons.rabl +0 -5
- data/app/views/spree/api/v1/users/index.rabl +0 -7
- data/app/views/spree/api/v1/users/new.rabl +0 -3
- data/app/views/spree/api/v1/users/show.rabl +0 -11
- data/app/views/spree/api/v1/variants/big.rabl +0 -14
- data/app/views/spree/api/v1/variants/index.rabl +0 -9
- data/app/views/spree/api/v1/variants/new.rabl +0 -2
- data/app/views/spree/api/v1/variants/show.rabl +0 -3
- data/app/views/spree/api/v1/variants/small.rabl +0 -18
- data/app/views/spree/api/v1/zones/index.rabl +0 -7
- data/app/views/spree/api/v1/zones/show.rabl +0 -6
- data/config/initializers/rabl.rb +0 -9
- data/lib/spree/api/controller_setup.rb +0 -19
- data/lib/spree/api/responders/rabl_template.rb +0 -28
- data/lib/spree/api/responders.rb +0 -11
- data/lib/spree/api/testing_support/helpers.rb +0 -44
- data/lib/spree/api/testing_support/setup.rb +0 -16
@@ -3,8 +3,29 @@ module Spree
|
|
3
3
|
module V2
|
4
4
|
module Platform
|
5
5
|
class TaxonsController < ResourceController
|
6
|
+
include ::Spree::Api::V2::Platform::NestedSetRepositionConcern
|
7
|
+
|
6
8
|
private
|
7
9
|
|
10
|
+
def successful_reposition_actions
|
11
|
+
reload_taxon_and_set_new_permalink(resource)
|
12
|
+
update_permalinks_on_child_taxons
|
13
|
+
|
14
|
+
render_serialized_payload { serialize_resource(resource) }
|
15
|
+
end
|
16
|
+
|
17
|
+
def reload_taxon_and_set_new_permalink(taxon)
|
18
|
+
taxon.reload
|
19
|
+
taxon.set_permalink
|
20
|
+
taxon.save!
|
21
|
+
end
|
22
|
+
|
23
|
+
def update_permalinks_on_child_taxons
|
24
|
+
resource.descendants.each do |taxon|
|
25
|
+
reload_taxon_and_set_new_permalink(taxon)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
8
29
|
def model_class
|
9
30
|
Spree::Taxon
|
10
31
|
end
|
@@ -23,6 +44,10 @@ module Spree
|
|
23
44
|
def serializer_params
|
24
45
|
super.merge(include_products: action_name == 'show')
|
25
46
|
end
|
47
|
+
|
48
|
+
def spree_permitted_attributes
|
49
|
+
super + [:new_parent_id, :new_position_idx]
|
50
|
+
end
|
26
51
|
end
|
27
52
|
end
|
28
53
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Spree
|
2
|
+
module Api
|
3
|
+
module V2
|
4
|
+
module Platform
|
5
|
+
class VariantsController < ResourceController
|
6
|
+
private
|
7
|
+
|
8
|
+
def model_class
|
9
|
+
Spree::Variant
|
10
|
+
end
|
11
|
+
|
12
|
+
def spree_permitted_attributes
|
13
|
+
super + [:option_value_ids, :price, :currency]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Spree
|
2
|
+
module Api
|
3
|
+
module V2
|
4
|
+
module Platform
|
5
|
+
module Webhooks
|
6
|
+
class EventsController < ResourceController
|
7
|
+
private
|
8
|
+
|
9
|
+
def model_class
|
10
|
+
Spree::Webhooks::Event
|
11
|
+
end
|
12
|
+
|
13
|
+
def scope_includes
|
14
|
+
%i[subscriber]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Spree
|
2
|
+
module Api
|
3
|
+
module V2
|
4
|
+
module Platform
|
5
|
+
module Webhooks
|
6
|
+
class SubscribersController < ResourceController
|
7
|
+
private
|
8
|
+
|
9
|
+
def model_class
|
10
|
+
Spree::Webhooks::Subscriber
|
11
|
+
end
|
12
|
+
|
13
|
+
def spree_permitted_attributes
|
14
|
+
super + [{ subscriptions: [] }]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Spree
|
2
|
+
module Api
|
3
|
+
module V2
|
4
|
+
module Platform
|
5
|
+
class WishedItemsController < ResourceController
|
6
|
+
private
|
7
|
+
|
8
|
+
def scope_includes
|
9
|
+
[:variant]
|
10
|
+
end
|
11
|
+
|
12
|
+
def model_class
|
13
|
+
Spree::WishedItem
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Spree
|
2
|
+
module Api
|
3
|
+
module V2
|
4
|
+
module Platform
|
5
|
+
class WishlistsController < ResourceController
|
6
|
+
private
|
7
|
+
|
8
|
+
def model_class
|
9
|
+
Spree::Wishlist
|
10
|
+
end
|
11
|
+
|
12
|
+
def scope_includes
|
13
|
+
[:wished_items]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -24,11 +24,11 @@ module Spree
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def allowed_sort_attributes
|
27
|
-
|
27
|
+
default_sort_attributes
|
28
28
|
end
|
29
29
|
|
30
|
-
def
|
31
|
-
[:id, :name, :number, :position, :updated_at, :created_at]
|
30
|
+
def default_sort_attributes
|
31
|
+
[:id, :name, :slug, :number, :position, :updated_at, :created_at, :deleted_at]
|
32
32
|
end
|
33
33
|
|
34
34
|
def scope(skip_cancancan: false)
|
@@ -59,11 +59,11 @@ module Spree
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def create_service
|
62
|
-
Spree::Api::Dependencies.
|
62
|
+
Spree::Api::Dependencies.storefront_address_create_service.constantize
|
63
63
|
end
|
64
64
|
|
65
65
|
def update_service
|
66
|
-
Spree::Api::Dependencies.
|
66
|
+
Spree::Api::Dependencies.storefront_address_update_service.constantize
|
67
67
|
end
|
68
68
|
|
69
69
|
def address_params
|
@@ -23,7 +23,10 @@ module Spree
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def scope
|
26
|
-
super.where(
|
26
|
+
super.not_expired.not_removed.where(
|
27
|
+
user: spree_current_user,
|
28
|
+
payment_method: current_store.payment_methods.available_on_front_end
|
29
|
+
)
|
27
30
|
end
|
28
31
|
|
29
32
|
def collection_serializer
|
@@ -3,7 +3,11 @@ module Spree
|
|
3
3
|
module V2
|
4
4
|
module Storefront
|
5
5
|
class CartController < ::Spree::Api::V2::BaseController
|
6
|
-
include
|
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]
|
7
11
|
before_action :ensure_order, except: %i[create associate]
|
8
12
|
before_action :load_variant, only: :add_item
|
9
13
|
before_action :require_spree_current_user, only: :associate
|
@@ -12,14 +16,16 @@ module Spree
|
|
12
16
|
def create
|
13
17
|
spree_authorize! :create, Spree::Order
|
14
18
|
|
15
|
-
|
19
|
+
create_cart_params = {
|
16
20
|
user: spree_current_user,
|
17
21
|
store: current_store,
|
18
|
-
currency: current_currency
|
22
|
+
currency: current_currency,
|
23
|
+
public_metadata: add_item_params[:public_metadata],
|
24
|
+
private_metadata: add_item_params[:private_metadata],
|
19
25
|
}
|
20
26
|
|
21
27
|
order = spree_current_order if spree_current_order.present?
|
22
|
-
order ||= create_service.call(
|
28
|
+
order ||= create_service.call(create_cart_params).value
|
23
29
|
|
24
30
|
render_serialized_payload(201) { serialize_resource(order) }
|
25
31
|
end
|
@@ -31,8 +37,10 @@ module Spree
|
|
31
37
|
result = add_item_service.call(
|
32
38
|
order: spree_current_order,
|
33
39
|
variant: @variant,
|
34
|
-
quantity:
|
35
|
-
|
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]
|
36
44
|
)
|
37
45
|
|
38
46
|
render_order(result)
|
@@ -107,7 +115,7 @@ module Spree
|
|
107
115
|
|
108
116
|
coupon_codes = select_coupon_codes
|
109
117
|
|
110
|
-
return render_error_payload(
|
118
|
+
return render_error_payload(I18n.t('spree.api.v2.cart.no_coupon_code')) if coupon_codes.empty?
|
111
119
|
|
112
120
|
result_errors = coupon_codes.count > 1 ? select_errors(coupon_codes) : select_error(coupon_codes)
|
113
121
|
|
@@ -209,7 +217,7 @@ module Spree
|
|
209
217
|
end
|
210
218
|
|
211
219
|
def load_variant
|
212
|
-
@variant = current_store.variants.find(
|
220
|
+
@variant = current_store.variants.find(add_item_params[:variant_id])
|
213
221
|
end
|
214
222
|
|
215
223
|
def render_error_item_quantity
|
@@ -227,26 +235,8 @@ module Spree
|
|
227
235
|
).serializable_hash
|
228
236
|
end
|
229
237
|
|
230
|
-
def
|
231
|
-
params
|
232
|
-
end
|
233
|
-
|
234
|
-
def check_coupon_codes
|
235
|
-
spree_current_order.promotions.coupons.map(&:code)
|
236
|
-
end
|
237
|
-
|
238
|
-
def select_error(coupon_codes)
|
239
|
-
result = coupon_handler.new(spree_current_order).remove(coupon_codes.first)
|
240
|
-
result.error
|
241
|
-
end
|
242
|
-
|
243
|
-
def select_errors(coupon_codes)
|
244
|
-
results = []
|
245
|
-
coupon_codes.each do |coupon_code|
|
246
|
-
results << coupon_handler.new(spree_current_order).remove(coupon_code)
|
247
|
-
end
|
248
|
-
|
249
|
-
results.select(&:error)
|
238
|
+
def add_item_params
|
239
|
+
params.permit(:quantity, :variant_id, public_metadata: {}, private_metadata: {}, options: {})
|
250
240
|
end
|
251
241
|
end
|
252
242
|
end
|
@@ -44,6 +44,22 @@ module Spree
|
|
44
44
|
render_order(result)
|
45
45
|
end
|
46
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
|
+
|
47
63
|
def add_store_credit
|
48
64
|
spree_authorize! :update, spree_current_order, order_token
|
49
65
|
|
@@ -118,6 +134,14 @@ module Spree
|
|
118
134
|
Spree::Api::Dependencies.storefront_shipment_serializer.constantize
|
119
135
|
end
|
120
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
|
+
|
121
145
|
def serialize_payment_methods(payment_methods)
|
122
146
|
payment_methods_serializer.new(payment_methods, params: serializer_params).serializable_hash
|
123
147
|
end
|
@@ -126,7 +150,7 @@ module Spree
|
|
126
150
|
shipping_rates_serializer.new(
|
127
151
|
shipments,
|
128
152
|
params: serializer_params,
|
129
|
-
include: [:shipping_rates, :stock_location]
|
153
|
+
include: [:shipping_rates, :stock_location, :line_items]
|
130
154
|
).serializable_hash
|
131
155
|
end
|
132
156
|
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,171 @@
|
|
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
|
+
private
|
104
|
+
|
105
|
+
def scope(skip_cancancan: true)
|
106
|
+
if action_name == 'show'
|
107
|
+
super
|
108
|
+
else
|
109
|
+
super.where(user: spree_current_user)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def resource
|
114
|
+
@resource ||= scope.find_by(token: params[:id])
|
115
|
+
end
|
116
|
+
|
117
|
+
def model_class
|
118
|
+
Spree::Wishlist
|
119
|
+
end
|
120
|
+
|
121
|
+
def resource_serializer
|
122
|
+
::Spree::V2::Storefront::WishlistSerializer
|
123
|
+
end
|
124
|
+
|
125
|
+
def collection_serializer
|
126
|
+
resource_serializer
|
127
|
+
end
|
128
|
+
|
129
|
+
def wishlist_attributes
|
130
|
+
params.require(:wishlist).permit(permitted_wishlist_attributes)
|
131
|
+
end
|
132
|
+
|
133
|
+
def wished_item_attributes
|
134
|
+
params.permit(permitted_wished_item_attributes)
|
135
|
+
end
|
136
|
+
|
137
|
+
def wished_item
|
138
|
+
@wished_item ||= resource.wished_items.find(params[:item_id])
|
139
|
+
end
|
140
|
+
|
141
|
+
def serialize_wished_item(wished_item)
|
142
|
+
::Spree::V2::Storefront::WishedItemSerializer.new(
|
143
|
+
wished_item,
|
144
|
+
params: serializer_params,
|
145
|
+
include: resource_includes,
|
146
|
+
fields: sparse_fields
|
147
|
+
).serializable_hash
|
148
|
+
end
|
149
|
+
|
150
|
+
def serializer_params
|
151
|
+
super.merge(is_variant_included: params[:is_variant_included])
|
152
|
+
end
|
153
|
+
|
154
|
+
def render_error_item_quantity
|
155
|
+
render json: { error: I18n.t('spree.api.v2.wishlist.wrong_quantity') }, status: 422
|
156
|
+
end
|
157
|
+
|
158
|
+
def ensure_valid_quantity
|
159
|
+
return render_error_item_quantity if params[:quantity].present? && params[:quantity].to_i <= 0
|
160
|
+
|
161
|
+
params[:quantity] = if params[:quantity].present?
|
162
|
+
params[:quantity].to_i
|
163
|
+
else
|
164
|
+
1
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
@@ -23,7 +23,7 @@ module Spree
|
|
23
23
|
# leaving this method in public scope so it's still possible to modify
|
24
24
|
# those params to support non-standard non-JSON API parameters
|
25
25
|
def collection_permitted_params
|
26
|
-
params.permit(:format, :page, :per_page, :sort, :include, :
|
26
|
+
params.permit(:format, :page, :per_page, :sort, :include, fields: {}, filter: {})
|
27
27
|
end
|
28
28
|
|
29
29
|
private
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Spree
|
2
|
+
module Api
|
3
|
+
module V2
|
4
|
+
module StoreMediaSerializerImagesConcern
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
included do
|
8
|
+
def self.store_image_url_for(store, attribute_name)
|
9
|
+
attachment = store.send(attribute_name)&.attachment
|
10
|
+
return unless attachment&.attached?
|
11
|
+
|
12
|
+
url_helpers = Rails.application.routes.url_helpers
|
13
|
+
if Spree.public_storage_service_name
|
14
|
+
url_helpers.cdn_image_url(attachment)
|
15
|
+
else
|
16
|
+
url_helpers.rails_blob_path(attachment)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
attribute :logo do |store|
|
21
|
+
store_image_url_for store, :logo
|
22
|
+
end
|
23
|
+
|
24
|
+
attribute :mailer_logo do |store|
|
25
|
+
store_image_url_for store, :mailer_logo
|
26
|
+
end
|
27
|
+
|
28
|
+
attribute :favicon_path do |store|
|
29
|
+
store_image_url_for store, :favicon_image
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Spree
|
2
|
+
module Webhooks
|
3
|
+
module Subscribers
|
4
|
+
class MakeRequestJob < Spree::BaseJob
|
5
|
+
queue_as :spree_webhooks
|
6
|
+
|
7
|
+
def perform(webhook_payload_body, event_name, subscriber)
|
8
|
+
Spree::Webhooks::Subscribers::HandleRequest.new(
|
9
|
+
event_name: event_name,
|
10
|
+
subscriber: subscriber,
|
11
|
+
webhook_payload_body: webhook_payload_body
|
12
|
+
).call
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|