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
@@ -1,100 +0,0 @@
|
|
1
|
-
module Spree
|
2
|
-
module Api
|
3
|
-
module V1
|
4
|
-
class TaxonsController < Spree::Api::BaseController
|
5
|
-
def index
|
6
|
-
@taxons = if taxonomy
|
7
|
-
taxonomy.root.children
|
8
|
-
elsif params[:ids]
|
9
|
-
Spree::Taxon.includes(:children).accessible_by(current_ability).where(id: params[:ids].split(','))
|
10
|
-
else
|
11
|
-
Spree::Taxon.includes(:children).accessible_by(current_ability).order(:taxonomy_id, :lft)
|
12
|
-
end
|
13
|
-
@taxons = @taxons.ransack(params[:q]).result
|
14
|
-
@taxons = @taxons.page(params[:page]).per(params[:per_page])
|
15
|
-
respond_with(@taxons)
|
16
|
-
end
|
17
|
-
|
18
|
-
def show
|
19
|
-
@taxon = taxon
|
20
|
-
respond_with(@taxon)
|
21
|
-
end
|
22
|
-
|
23
|
-
def jstree
|
24
|
-
show
|
25
|
-
end
|
26
|
-
|
27
|
-
def new; end
|
28
|
-
|
29
|
-
def create
|
30
|
-
authorize! :create, Taxon
|
31
|
-
@taxon = Spree::Taxon.new(taxon_params)
|
32
|
-
@taxon.taxonomy_id = params[:taxonomy_id]
|
33
|
-
taxonomy = Spree::Taxonomy.find_by(id: params[:taxonomy_id])
|
34
|
-
|
35
|
-
if taxonomy.nil?
|
36
|
-
@taxon.errors.add(:taxonomy_id, I18n.t('spree.api.invalid_taxonomy_id'))
|
37
|
-
invalid_resource!(@taxon) and return
|
38
|
-
end
|
39
|
-
|
40
|
-
@taxon.parent_id = taxonomy.root_id unless params[:taxon][:parent_id]
|
41
|
-
|
42
|
-
if @taxon.save
|
43
|
-
respond_with(@taxon, status: 201, default_template: :show)
|
44
|
-
else
|
45
|
-
invalid_resource!(@taxon)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def update
|
50
|
-
authorize! :update, taxon
|
51
|
-
if taxon.update(taxon_params)
|
52
|
-
respond_with(taxon, status: 200, default_template: :show)
|
53
|
-
else
|
54
|
-
invalid_resource!(taxon)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def destroy
|
59
|
-
authorize! :destroy, taxon
|
60
|
-
taxon.destroy
|
61
|
-
respond_with(taxon, status: 204)
|
62
|
-
end
|
63
|
-
|
64
|
-
def products
|
65
|
-
# Returns the products sorted by their position with the classification
|
66
|
-
# Products#index does not do the sorting.
|
67
|
-
taxon = Spree::Taxon.find(params[:id])
|
68
|
-
@products = taxon.products.ransack(params[:q]).result
|
69
|
-
@products = @products.page(params[:page]).per(params[:per_page] || 500)
|
70
|
-
render 'spree/api/v1/products/index'
|
71
|
-
end
|
72
|
-
|
73
|
-
private
|
74
|
-
|
75
|
-
def taxonomy
|
76
|
-
if params[:taxonomy_id].present?
|
77
|
-
@taxonomy ||=
|
78
|
-
if defined?(SpreeGlobalize)
|
79
|
-
Spree::Taxonomy.includes(:translations, taxons: [:translations]).accessible_by(current_ability, :show).find(params[:taxonomy_id])
|
80
|
-
else
|
81
|
-
Spree::Taxonomy.accessible_by(current_ability, :show).find(params[:taxonomy_id])
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
def taxon
|
87
|
-
@taxon ||= taxonomy.taxons.accessible_by(current_ability, :show).find(params[:id])
|
88
|
-
end
|
89
|
-
|
90
|
-
def taxon_params
|
91
|
-
if params[:taxon] && !params[:taxon].empty?
|
92
|
-
params.require(:taxon).permit(permitted_taxon_attributes)
|
93
|
-
else
|
94
|
-
{}
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
@@ -1,97 +0,0 @@
|
|
1
|
-
module Spree
|
2
|
-
module Api
|
3
|
-
module V1
|
4
|
-
class UsersController < Spree::Api::BaseController
|
5
|
-
rescue_from Spree::Core::DestroyWithOrdersError, with: :error_during_processing
|
6
|
-
|
7
|
-
def index
|
8
|
-
users
|
9
|
-
|
10
|
-
if params[:ids]
|
11
|
-
load_users_by_ids
|
12
|
-
elsif params.dig(:q, :ship_address_firstname_start)
|
13
|
-
load_users_by_address
|
14
|
-
elsif params.dig(:q, :email_start)
|
15
|
-
load_users_by_email
|
16
|
-
end
|
17
|
-
|
18
|
-
prepare_index_response
|
19
|
-
respond_with(@users)
|
20
|
-
end
|
21
|
-
|
22
|
-
def users
|
23
|
-
@users ||= Spree.user_class.accessible_by(current_ability, :show)
|
24
|
-
end
|
25
|
-
|
26
|
-
def load_users_by_ids
|
27
|
-
@users = @users.where(id: params[:ids])
|
28
|
-
end
|
29
|
-
|
30
|
-
def load_users_by_address
|
31
|
-
address_params = params[:q][:ship_address_firstname_start] ||
|
32
|
-
params[:q][:ship_address_lastname_start] ||
|
33
|
-
params[:q][:bill_address_firstname_start] ||
|
34
|
-
params[:q][:bill_address_lastname_start]
|
35
|
-
@users = @users.with_email_or_address(params[:q][:email_start], address_params)
|
36
|
-
end
|
37
|
-
|
38
|
-
def load_users_by_email
|
39
|
-
@users = @users.with_email(params[:q][:email_start])
|
40
|
-
end
|
41
|
-
|
42
|
-
def paginate_users
|
43
|
-
@users = @users.page(params[:page]).per(params[:per_page])
|
44
|
-
end
|
45
|
-
|
46
|
-
def prepare_index_response
|
47
|
-
paginate_users
|
48
|
-
expires_in 15.minutes, public: true
|
49
|
-
headers['Surrogate-Control'] = "max-age=#{15.minutes}"
|
50
|
-
end
|
51
|
-
|
52
|
-
def show
|
53
|
-
respond_with(user)
|
54
|
-
end
|
55
|
-
|
56
|
-
def new; end
|
57
|
-
|
58
|
-
def create
|
59
|
-
authorize! :create, Spree.user_class
|
60
|
-
@user = Spree.user_class.new(user_params)
|
61
|
-
if @user.save
|
62
|
-
respond_with(@user, status: 201, default_template: :show)
|
63
|
-
else
|
64
|
-
invalid_resource!(@user)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
def update
|
69
|
-
authorize! :update, user
|
70
|
-
if user.update(user_params)
|
71
|
-
respond_with(user, status: 200, default_template: :show)
|
72
|
-
else
|
73
|
-
invalid_resource!(user)
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
def destroy
|
78
|
-
authorize! :destroy, user
|
79
|
-
user.destroy
|
80
|
-
respond_with(user, status: 204)
|
81
|
-
end
|
82
|
-
|
83
|
-
private
|
84
|
-
|
85
|
-
def user
|
86
|
-
@user ||= Spree.user_class.accessible_by(current_ability, :show).find(params[:id])
|
87
|
-
end
|
88
|
-
|
89
|
-
def user_params
|
90
|
-
params.require(:user).permit(permitted_user_attributes |
|
91
|
-
[bill_address_attributes: permitted_address_attributes,
|
92
|
-
ship_address_attributes: permitted_address_attributes])
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
@@ -1,81 +0,0 @@
|
|
1
|
-
module Spree
|
2
|
-
module Api
|
3
|
-
module V1
|
4
|
-
class VariantsController < Spree::Api::BaseController
|
5
|
-
before_action :product
|
6
|
-
|
7
|
-
def create
|
8
|
-
authorize! :create, Variant
|
9
|
-
@variant = scope.new(variant_params)
|
10
|
-
if @variant.save
|
11
|
-
respond_with(@variant, status: 201, default_template: :show)
|
12
|
-
else
|
13
|
-
invalid_resource!(@variant)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def destroy
|
18
|
-
@variant = scope.accessible_by(current_ability, :destroy).find(params[:id])
|
19
|
-
@variant.destroy
|
20
|
-
respond_with(@variant, status: 204)
|
21
|
-
end
|
22
|
-
|
23
|
-
# The lazyloaded associations here are pretty much attached to which nodes
|
24
|
-
# we render on the view so we better update it any time a node is included
|
25
|
-
# or removed from the views.
|
26
|
-
def index
|
27
|
-
@variants = scope.includes(*variant_includes).for_currency_and_available_price_amount.
|
28
|
-
ransack(params[:q]).result.page(params[:page]).per(params[:per_page])
|
29
|
-
respond_with(@variants)
|
30
|
-
end
|
31
|
-
|
32
|
-
def new; end
|
33
|
-
|
34
|
-
def show
|
35
|
-
@variant = scope.includes(*variant_includes).find(params[:id])
|
36
|
-
respond_with(@variant)
|
37
|
-
end
|
38
|
-
|
39
|
-
def update
|
40
|
-
@variant = scope.accessible_by(current_ability, :update).find(params[:id])
|
41
|
-
if @variant.update(variant_params)
|
42
|
-
respond_with(@variant, status: 200, default_template: :show)
|
43
|
-
else
|
44
|
-
invalid_resource!(@product)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
private
|
49
|
-
|
50
|
-
def product
|
51
|
-
if params[:product_id]
|
52
|
-
@product ||= Spree::Product.accessible_by(current_ability, :show).
|
53
|
-
friendly.find(params[:product_id])
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
def scope
|
58
|
-
variants = if @product
|
59
|
-
@product.variants_including_master
|
60
|
-
else
|
61
|
-
Variant
|
62
|
-
end
|
63
|
-
|
64
|
-
if current_ability.can?(:manage, Variant) && params[:show_deleted]
|
65
|
-
variants = variants.with_deleted
|
66
|
-
end
|
67
|
-
|
68
|
-
variants.eligible.accessible_by(current_ability)
|
69
|
-
end
|
70
|
-
|
71
|
-
def variant_params
|
72
|
-
params.require(:variant).permit(permitted_variant_attributes)
|
73
|
-
end
|
74
|
-
|
75
|
-
def variant_includes
|
76
|
-
[{ option_values: :option_type }, :product, :default_price, :images, { stock_items: :stock_location }]
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
@@ -1,55 +0,0 @@
|
|
1
|
-
module Spree
|
2
|
-
module Api
|
3
|
-
module V1
|
4
|
-
class ZonesController < Spree::Api::BaseController
|
5
|
-
def create
|
6
|
-
authorize! :create, Zone
|
7
|
-
@zone = Spree::Zone.new(zone_params)
|
8
|
-
if @zone.save
|
9
|
-
respond_with(@zone, status: 201, default_template: :show)
|
10
|
-
else
|
11
|
-
invalid_resource!(@zone)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def destroy
|
16
|
-
authorize! :destroy, zone
|
17
|
-
zone.destroy
|
18
|
-
respond_with(zone, status: 204)
|
19
|
-
end
|
20
|
-
|
21
|
-
def index
|
22
|
-
@zones = Zone.accessible_by(current_ability).order('name ASC').ransack(params[:q]).result.page(params[:page]).per(params[:per_page])
|
23
|
-
respond_with(@zones)
|
24
|
-
end
|
25
|
-
|
26
|
-
def show
|
27
|
-
respond_with(zone)
|
28
|
-
end
|
29
|
-
|
30
|
-
def update
|
31
|
-
authorize! :update, zone
|
32
|
-
if zone.update(zone_params)
|
33
|
-
respond_with(zone, status: 200, default_template: :show)
|
34
|
-
else
|
35
|
-
invalid_resource!(zone)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
private
|
40
|
-
|
41
|
-
def zone_params
|
42
|
-
attrs = params.require(:zone).permit!
|
43
|
-
if attrs[:zone_members]
|
44
|
-
attrs[:zone_members_attributes] = attrs.delete(:zone_members)
|
45
|
-
end
|
46
|
-
attrs
|
47
|
-
end
|
48
|
-
|
49
|
-
def zone
|
50
|
-
@zone ||= Spree::Zone.accessible_by(current_ability, :show).find(params[:id])
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
@@ -1,190 +0,0 @@
|
|
1
|
-
module Spree
|
2
|
-
module Api
|
3
|
-
module ApiHelpers
|
4
|
-
ATTRIBUTES = [
|
5
|
-
:product_attributes,
|
6
|
-
:product_property_attributes,
|
7
|
-
:variant_attributes,
|
8
|
-
:image_attributes,
|
9
|
-
:option_value_attributes,
|
10
|
-
:order_attributes,
|
11
|
-
:line_item_attributes,
|
12
|
-
:option_type_attributes,
|
13
|
-
:payment_attributes,
|
14
|
-
:payment_method_attributes,
|
15
|
-
:shipment_attributes,
|
16
|
-
:taxonomy_attributes,
|
17
|
-
:taxon_attributes,
|
18
|
-
:address_attributes,
|
19
|
-
:country_attributes,
|
20
|
-
:state_attributes,
|
21
|
-
:adjustment_attributes,
|
22
|
-
:inventory_unit_attributes,
|
23
|
-
:return_authorization_attributes,
|
24
|
-
:creditcard_attributes,
|
25
|
-
:payment_source_attributes,
|
26
|
-
:user_attributes,
|
27
|
-
:property_attributes,
|
28
|
-
:stock_location_attributes,
|
29
|
-
:stock_movement_attributes,
|
30
|
-
:stock_item_attributes,
|
31
|
-
:promotion_attributes,
|
32
|
-
:store_attributes,
|
33
|
-
:tag_attributes,
|
34
|
-
:customer_return_attributes,
|
35
|
-
:reimbursement_attributes
|
36
|
-
]
|
37
|
-
|
38
|
-
mattr_reader *ATTRIBUTES
|
39
|
-
|
40
|
-
def required_fields_for(model)
|
41
|
-
required_fields = model._validators.select do |_field, validations|
|
42
|
-
validations.any? { |v| v.is_a?(ActiveModel::Validations::PresenceValidator) }
|
43
|
-
end.map(&:first) # get fields that are invalid
|
44
|
-
# Permalinks presence is validated, but are really automatically generated
|
45
|
-
# Therefore we shouldn't tell API clients that they MUST send one through
|
46
|
-
required_fields.map!(&:to_s).delete('permalink')
|
47
|
-
# Do not require slugs, either
|
48
|
-
required_fields.delete('slug')
|
49
|
-
required_fields
|
50
|
-
end
|
51
|
-
|
52
|
-
@@product_attributes = [
|
53
|
-
:id, :name, :description, :price, :display_price, :available_on,
|
54
|
-
:slug, :meta_description, :meta_keywords, :shipping_category_id,
|
55
|
-
:taxon_ids, :total_on_hand
|
56
|
-
]
|
57
|
-
|
58
|
-
@@product_property_attributes = [
|
59
|
-
:id, :product_id, :property_id, :value, :property_name
|
60
|
-
]
|
61
|
-
|
62
|
-
@@variant_attributes = [
|
63
|
-
:id, :name, :sku, :price, :weight, :height, :width, :depth, :is_master,
|
64
|
-
:slug, :description, :track_inventory
|
65
|
-
]
|
66
|
-
|
67
|
-
@@image_attributes = [
|
68
|
-
:id, :position, :attachment_content_type, :attachment_file_name, :type,
|
69
|
-
:attachment_updated_at, :attachment_width, :attachment_height, :alt
|
70
|
-
]
|
71
|
-
|
72
|
-
@@option_value_attributes = [
|
73
|
-
:id, :name, :presentation, :option_type_name, :option_type_id,
|
74
|
-
:option_type_presentation
|
75
|
-
]
|
76
|
-
|
77
|
-
@@order_attributes = [
|
78
|
-
:id, :number, :item_total, :total, :ship_total, :state, :adjustment_total,
|
79
|
-
:user_id, :created_at, :updated_at, :completed_at, :payment_total,
|
80
|
-
:shipment_state, :payment_state, :email, :special_instructions, :channel,
|
81
|
-
:included_tax_total, :additional_tax_total, :display_included_tax_total,
|
82
|
-
:display_additional_tax_total, :tax_total, :currency, :considered_risky,
|
83
|
-
:canceler_id
|
84
|
-
]
|
85
|
-
|
86
|
-
@@line_item_attributes = [:id, :quantity, :price, :variant_id]
|
87
|
-
|
88
|
-
@@option_type_attributes = [:id, :name, :presentation, :position]
|
89
|
-
|
90
|
-
@@payment_attributes = [
|
91
|
-
:id, :source_type, :source_id, :amount, :display_amount,
|
92
|
-
:payment_method_id, :state, :avs_response, :created_at,
|
93
|
-
:updated_at, :number
|
94
|
-
]
|
95
|
-
|
96
|
-
@@payment_method_attributes = [:id, :name, :description]
|
97
|
-
|
98
|
-
@@shipment_attributes = [:id, :tracking, :number, :cost, :shipped_at, :state]
|
99
|
-
|
100
|
-
@@taxonomy_attributes = [:id, :name]
|
101
|
-
|
102
|
-
@@taxon_attributes = [
|
103
|
-
:id, :name, :pretty_name, :permalink, :parent_id,
|
104
|
-
:taxonomy_id, :meta_title, :meta_description
|
105
|
-
]
|
106
|
-
|
107
|
-
@@inventory_unit_attributes = [
|
108
|
-
:id, :lock_version, :state, :variant_id, :shipment_id,
|
109
|
-
:return_authorization_id
|
110
|
-
]
|
111
|
-
|
112
|
-
@@return_authorization_attributes = [
|
113
|
-
:id, :number, :state, :order_id, :memo, :created_at, :updated_at
|
114
|
-
]
|
115
|
-
|
116
|
-
@@address_attributes = [
|
117
|
-
:id, :firstname, :lastname, :full_name, :address1, :address2, :city,
|
118
|
-
:zipcode, :phone, :company, :alternative_phone, :country_id, :state_id,
|
119
|
-
:label, :state_name, :state_text
|
120
|
-
]
|
121
|
-
|
122
|
-
@@country_attributes = [:id, :iso_name, :iso, :iso3, :name, :numcode]
|
123
|
-
|
124
|
-
@@state_attributes = [:id, :name, :abbr, :country_id]
|
125
|
-
|
126
|
-
@@adjustment_attributes = [
|
127
|
-
:id, :source_type, :source_id, :adjustable_type, :adjustable_id,
|
128
|
-
:originator_type, :originator_id, :amount, :label, :mandatory,
|
129
|
-
:locked, :eligible, :created_at, :updated_at
|
130
|
-
]
|
131
|
-
|
132
|
-
@@creditcard_attributes = [
|
133
|
-
:id, :month, :year, :cc_type, :last_digits, :name,
|
134
|
-
:gateway_customer_profile_id, :gateway_payment_profile_id
|
135
|
-
]
|
136
|
-
|
137
|
-
@@payment_source_attributes = [
|
138
|
-
:id, :month, :year, :cc_type, :last_digits, :name
|
139
|
-
]
|
140
|
-
|
141
|
-
@@user_attributes = [:id, :email, :created_at, :updated_at]
|
142
|
-
|
143
|
-
@@property_attributes = [:id, :name, :presentation]
|
144
|
-
|
145
|
-
@@stock_location_attributes = [
|
146
|
-
:id, :name, :address1, :address2, :city, :state_id, :state_name,
|
147
|
-
:country_id, :zipcode, :phone, :active
|
148
|
-
]
|
149
|
-
|
150
|
-
@@stock_movement_attributes = [:id, :quantity, :stock_item_id]
|
151
|
-
|
152
|
-
@@stock_item_attributes = [
|
153
|
-
:id, :count_on_hand, :backorderable, :lock_version, :stock_location_id,
|
154
|
-
:variant_id
|
155
|
-
]
|
156
|
-
|
157
|
-
@@promotion_attributes = [
|
158
|
-
:id, :name, :description, :expires_at, :starts_at, :type, :usage_limit,
|
159
|
-
:match_policy, :code, :advertise, :path
|
160
|
-
]
|
161
|
-
|
162
|
-
@@store_attributes = [
|
163
|
-
:id, :name, :url, :meta_description, :meta_keywords, :seo_title,
|
164
|
-
:mail_from_address, :customer_support_email, :default_currency,
|
165
|
-
:code, :default, :facebook, :twitter, :instagram,
|
166
|
-
:supported_currencies, :default_locale, :supported_locales
|
167
|
-
]
|
168
|
-
|
169
|
-
@@tag_attributes = [:id, :name]
|
170
|
-
|
171
|
-
@@customer_return_attributes = [
|
172
|
-
:id, :number, :order_id, :fully_reimbursed?, :pre_tax_total,
|
173
|
-
:created_at, :updated_at
|
174
|
-
]
|
175
|
-
|
176
|
-
@@reimbursement_attributes = [
|
177
|
-
:id, :reimbursement_status, :customer_return_id, :order_id,
|
178
|
-
:number, :total, :created_at, :updated_at
|
179
|
-
]
|
180
|
-
|
181
|
-
def variant_attributes
|
182
|
-
if @current_user_roles&.include?('admin')
|
183
|
-
@@variant_attributes + [:cost_price]
|
184
|
-
else
|
185
|
-
@@variant_attributes
|
186
|
-
end
|
187
|
-
end
|
188
|
-
end
|
189
|
-
end
|
190
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
module Spree
|
2
|
-
class ApiConfiguration < Preferences::Configuration
|
3
|
-
preference :requires_authentication, :boolean, default: true
|
4
|
-
preference :api_v2_serializers_cache_ttl, :integer, default: 3600 # 1 hour in seconds
|
5
|
-
preference :api_v2_collection_cache_ttl, :integer, default: 3600 # 1 hour in seconds
|
6
|
-
preference :api_v2_collection_cache_namespace, :string, default: 'api_v2_collection_cache'
|
7
|
-
preference :api_v2_content_type, :string, default: 'application/vnd.api+json'
|
8
|
-
preference :api_v2_per_page_limit, :integer, default: 500
|
9
|
-
end
|
10
|
-
end
|
@@ -1,111 +0,0 @@
|
|
1
|
-
module Spree
|
2
|
-
class ApiDependencies
|
3
|
-
include Spree::DependenciesHelper
|
4
|
-
|
5
|
-
INJECTION_POINTS = [
|
6
|
-
:storefront_cart_create_service, :storefront_cart_add_item_service, :storefront_cart_remove_line_item_service,
|
7
|
-
:storefront_cart_remove_item_service, :storefront_cart_set_item_quantity_service, :storefront_cart_recalculate_service,
|
8
|
-
:storefront_cms_page_serializer, :storefront_cms_page_finder,
|
9
|
-
:storefront_cart_update, :storefront_coupon_handler, :storefront_checkout_next_service, :storefront_checkout_advance_service,
|
10
|
-
:storefront_checkout_update_service, :storefront_checkout_complete_service, :storefront_checkout_add_store_credit_service,
|
11
|
-
:storefront_checkout_remove_store_credit_service, :storefront_checkout_get_shipping_rates_service,
|
12
|
-
:storefront_cart_compare_line_items_service, :storefront_cart_serializer, :storefront_credit_card_serializer,
|
13
|
-
:storefront_credit_card_finder, :storefront_shipment_serializer, :storefront_payment_method_serializer, :storefront_country_finder,
|
14
|
-
:storefront_country_serializer, :storefront_menu_serializer, :storefront_menu_finder, :storefront_current_order_finder,
|
15
|
-
:storefront_completed_order_finder, :storefront_order_sorter, :storefront_collection_paginator, :storefront_user_serializer,
|
16
|
-
:storefront_products_sorter, :storefront_products_finder, :storefront_product_serializer, :storefront_taxon_serializer,
|
17
|
-
:storefront_taxon_finder, :storefront_find_by_variant_finder, :storefront_cart_update_service, :storefront_cart_associate_service,
|
18
|
-
:storefront_cart_estimate_shipping_rates_service, :storefront_estimated_shipment_serializer,
|
19
|
-
:storefront_store_serializer, :storefront_address_serializer, :storefront_order_serializer,
|
20
|
-
:storefront_account_create_address_service, :storefront_account_update_address_service, :storefront_address_finder,
|
21
|
-
:storefront_account_create_service, :storefront_account_update_service, :storefront_collection_sorter, :error_handler,
|
22
|
-
:storefront_cart_empty_service, :storefront_cart_destroy_service, :storefront_credit_cards_destroy_service, :platform_products_sorter,
|
23
|
-
:storefront_cart_change_currency_service
|
24
|
-
].freeze
|
25
|
-
|
26
|
-
attr_accessor *INJECTION_POINTS
|
27
|
-
|
28
|
-
def initialize
|
29
|
-
set_storefront_defaults
|
30
|
-
end
|
31
|
-
|
32
|
-
private
|
33
|
-
|
34
|
-
def set_storefront_defaults
|
35
|
-
# cart services
|
36
|
-
@storefront_cart_create_service = Spree::Dependencies.cart_create_service
|
37
|
-
@storefront_cart_add_item_service = Spree::Dependencies.cart_add_item_service
|
38
|
-
@storefront_cart_compare_line_items_service = Spree::Dependencies.cart_compare_line_items_service
|
39
|
-
@storefront_cart_update_service = Spree::Dependencies.cart_update_service
|
40
|
-
@storefront_cart_remove_line_item_service = Spree::Dependencies.cart_remove_line_item_service
|
41
|
-
@storefront_cart_remove_item_service = Spree::Dependencies.cart_remove_item_service
|
42
|
-
@storefront_cart_set_item_quantity_service = Spree::Dependencies.cart_set_item_quantity_service
|
43
|
-
@storefront_cart_recalculate_service = Spree::Dependencies.cart_recalculate_service
|
44
|
-
@storefront_cart_estimate_shipping_rates_service = Spree::Dependencies.cart_estimate_shipping_rates_service
|
45
|
-
@storefront_cart_empty_service = Spree::Dependencies.cart_empty_service
|
46
|
-
@storefront_cart_destroy_service = Spree::Dependencies.cart_destroy_service
|
47
|
-
@storefront_cart_associate_service = Spree::Dependencies.cart_associate_service
|
48
|
-
@storefront_cart_change_currency_service = Spree::Dependencies.cart_change_currency_service
|
49
|
-
|
50
|
-
# coupon code handler
|
51
|
-
@storefront_coupon_handler = Spree::Dependencies.coupon_handler
|
52
|
-
|
53
|
-
# checkout services
|
54
|
-
@storefront_checkout_next_service = Spree::Dependencies.checkout_next_service
|
55
|
-
@storefront_checkout_advance_service = Spree::Dependencies.checkout_advance_service
|
56
|
-
@storefront_checkout_update_service = Spree::Dependencies.checkout_update_service
|
57
|
-
@storefront_checkout_complete_service = Spree::Dependencies.checkout_complete_service
|
58
|
-
@storefront_checkout_add_store_credit_service = Spree::Dependencies.checkout_add_store_credit_service
|
59
|
-
@storefront_checkout_remove_store_credit_service = Spree::Dependencies.checkout_remove_store_credit_service
|
60
|
-
@storefront_checkout_get_shipping_rates_service = Spree::Dependencies.checkout_get_shipping_rates_service
|
61
|
-
|
62
|
-
# account services
|
63
|
-
@storefront_account_create_service = Spree::Dependencies.account_create_service
|
64
|
-
@storefront_account_update_service = Spree::Dependencies.account_update_service
|
65
|
-
@storefront_account_create_address_service = Spree::Dependencies.account_create_address_service
|
66
|
-
@storefront_account_update_address_service = Spree::Dependencies.account_update_address_service
|
67
|
-
|
68
|
-
# credit cards
|
69
|
-
@storefront_credit_cards_destroy_service = Spree::Dependencies.credit_cards_destroy_service
|
70
|
-
|
71
|
-
# serializers
|
72
|
-
@storefront_address_serializer = 'Spree::V2::Storefront::AddressSerializer'
|
73
|
-
@storefront_cart_serializer = 'Spree::V2::Storefront::CartSerializer'
|
74
|
-
@storefront_cms_page_serializer = 'Spree::V2::Storefront::CmsPageSerializer'
|
75
|
-
@storefront_credit_card_serializer = 'Spree::V2::Storefront::CreditCardSerializer'
|
76
|
-
@storefront_country_serializer = 'Spree::V2::Storefront::CountrySerializer'
|
77
|
-
@storefront_menu_serializer = 'Spree::V2::Storefront::MenuSerializer'
|
78
|
-
@storefront_user_serializer = 'Spree::V2::Storefront::UserSerializer'
|
79
|
-
@storefront_shipment_serializer = 'Spree::V2::Storefront::ShipmentSerializer'
|
80
|
-
@storefront_taxon_serializer = 'Spree::V2::Storefront::TaxonSerializer'
|
81
|
-
@storefront_payment_method_serializer = 'Spree::V2::Storefront::PaymentMethodSerializer'
|
82
|
-
@storefront_product_serializer = 'Spree::V2::Storefront::ProductSerializer'
|
83
|
-
@storefront_estimated_shipment_serializer = 'Spree::V2::Storefront::EstimatedShippingRateSerializer'
|
84
|
-
@storefront_store_serializer = 'Spree::V2::Storefront::StoreSerializer'
|
85
|
-
@storefront_order_serializer = 'Spree::V2::Storefront::CartSerializer'
|
86
|
-
|
87
|
-
# sorters
|
88
|
-
@storefront_collection_sorter = Spree::Dependencies.collection_sorter
|
89
|
-
@storefront_order_sorter = Spree::Dependencies.collection_sorter
|
90
|
-
@storefront_products_sorter = Spree::Dependencies.products_sorter
|
91
|
-
@platform_products_sorter = Spree::Dependencies.products_sorter
|
92
|
-
|
93
|
-
# paginators
|
94
|
-
@storefront_collection_paginator = Spree::Dependencies.collection_paginator
|
95
|
-
|
96
|
-
# finders
|
97
|
-
@storefront_address_finder = Spree::Dependencies.address_finder
|
98
|
-
@storefront_country_finder = Spree::Dependencies.country_finder
|
99
|
-
@storefront_cms_page_finder = Spree::Dependencies.cms_page_finder
|
100
|
-
@storefront_menu_finder = Spree::Dependencies.menu_finder
|
101
|
-
@storefront_current_order_finder = Spree::Dependencies.current_order_finder
|
102
|
-
@storefront_completed_order_finder = Spree::Dependencies.completed_order_finder
|
103
|
-
@storefront_credit_card_finder = Spree::Dependencies.credit_card_finder
|
104
|
-
@storefront_find_by_variant_finder = Spree::Dependencies.line_item_by_variant_finder
|
105
|
-
@storefront_products_finder = Spree::Dependencies.products_finder
|
106
|
-
@storefront_taxon_finder = Spree::Dependencies.taxon_finder
|
107
|
-
|
108
|
-
@error_handler = 'Spree::Api::ErrorHandler'
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|