atkhayar-dev-spree-api 0.0.0
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 +7 -0
- data/.gitignore +17 -0
- data/Gemfile +5 -0
- data/LICENSE +26 -0
- data/Rakefile +29 -0
- data/app/controllers/concerns/spree/api/v2/caching.rb +37 -0
- data/app/controllers/concerns/spree/api/v2/coupon_codes_helper.rb +29 -0
- data/app/controllers/concerns/spree/api/v2/number_resource.rb +11 -0
- data/app/controllers/concerns/spree/api/v2/platform/nested_set_reposition_concern.rb +37 -0
- data/app/controllers/concerns/spree/api/v2/platform/promotion_calculator_params.rb +17 -0
- data/app/controllers/concerns/spree/api/v2/platform/promotion_rule_params.rb +16 -0
- data/app/controllers/concerns/spree/api/v2/product_list_includes.rb +25 -0
- data/app/controllers/concerns/spree/api/v2/storefront/metadata_controller_concern.rb +18 -0
- data/app/controllers/concerns/spree/api/v2/storefront/order_concern.rb +52 -0
- data/app/controllers/spree/api/v2/base_controller.rb +171 -0
- data/app/controllers/spree/api/v2/platform/addresses_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/adjustments_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/classifications_controller.rb +22 -0
- data/app/controllers/spree/api/v2/platform/cms_pages_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/cms_sections_controller.rb +29 -0
- data/app/controllers/spree/api/v2/platform/countries_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/digital_links_controller.rb +25 -0
- data/app/controllers/spree/api/v2/platform/digitals_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/firebase_controller.rb +76 -0
- data/app/controllers/spree/api/v2/platform/images_controller.rb +20 -0
- data/app/controllers/spree/api/v2/platform/line_items_controller.rb +59 -0
- data/app/controllers/spree/api/v2/platform/menu_items_controller.rb +21 -0
- data/app/controllers/spree/api/v2/platform/menus_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/option_types_controller.rb +15 -0
- data/app/controllers/spree/api/v2/platform/option_values_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/orders_controller.rb +163 -0
- data/app/controllers/spree/api/v2/platform/payment_methods_controller.rb +27 -0
- data/app/controllers/spree/api/v2/platform/payments_controller.rb +17 -0
- data/app/controllers/spree/api/v2/platform/products_controller.rb +37 -0
- data/app/controllers/spree/api/v2/platform/promotion_actions_controller.rb +30 -0
- data/app/controllers/spree/api/v2/platform/promotion_categories_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/promotion_rules_controller.rb +25 -0
- data/app/controllers/spree/api/v2/platform/promotions_controller.rb +31 -0
- data/app/controllers/spree/api/v2/platform/resource_controller.rb +146 -0
- data/app/controllers/spree/api/v2/platform/roles_controller.rb +15 -0
- data/app/controllers/spree/api/v2/platform/shipments_controller.rb +143 -0
- data/app/controllers/spree/api/v2/platform/shipping_categories_controller.rb +15 -0
- data/app/controllers/spree/api/v2/platform/shipping_methods_controller.rb +24 -0
- data/app/controllers/spree/api/v2/platform/states_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/stock_items_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/stock_locations_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/store_credit_categories_controller.rb +15 -0
- data/app/controllers/spree/api/v2/platform/store_credit_types_controller.rb +15 -0
- data/app/controllers/spree/api/v2/platform/store_credits_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/stores_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/tax_categories_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/tax_rates_controller.rb +23 -0
- data/app/controllers/spree/api/v2/platform/taxonomies_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/taxons_controller.rb +55 -0
- data/app/controllers/spree/api/v2/platform/users_controller.rb +32 -0
- data/app/controllers/spree/api/v2/platform/users_resource_controller.rb +144 -0
- data/app/controllers/spree/api/v2/platform/variants_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/webhooks/events_controller.rb +21 -0
- data/app/controllers/spree/api/v2/platform/webhooks/subscribers_controller.rb +21 -0
- data/app/controllers/spree/api/v2/platform/wished_items_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/wishlists_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/zones_controller.rb +19 -0
- data/app/controllers/spree/api/v2/resource_controller.rb +76 -0
- data/app/controllers/spree/api/v2/storefront/account/addresses_controller.rb +77 -0
- data/app/controllers/spree/api/v2/storefront/account/credit_cards_controller.rb +52 -0
- data/app/controllers/spree/api/v2/storefront/account/orders_controller.rb +50 -0
- data/app/controllers/spree/api/v2/storefront/account_controller.rb +52 -0
- data/app/controllers/spree/api/v2/storefront/cart_controller.rb +245 -0
- data/app/controllers/spree/api/v2/storefront/checkout_controller.rb +160 -0
- data/app/controllers/spree/api/v2/storefront/cms_pages_controller.rb +41 -0
- data/app/controllers/spree/api/v2/storefront/countries_controller.rb +57 -0
- data/app/controllers/spree/api/v2/storefront/digitals_controller.rb +58 -0
- data/app/controllers/spree/api/v2/storefront/menus_controller.rb +35 -0
- data/app/controllers/spree/api/v2/storefront/order_status_controller.rb +34 -0
- data/app/controllers/spree/api/v2/storefront/products_controller.rb +61 -0
- data/app/controllers/spree/api/v2/storefront/stores_controller.rb +27 -0
- data/app/controllers/spree/api/v2/storefront/taxons_controller.rb +50 -0
- data/app/controllers/spree/api/v2/storefront/wishlists_controller.rb +171 -0
- data/app/helpers/spree/api/v2/collection_options_helpers.rb +46 -0
- data/app/helpers/spree/api/v2/display_money_helper.rb +43 -0
- data/app/helpers/spree/api/v2/store_media_serializer_images_concern.rb +35 -0
- data/app/jobs/spree/webhooks/subscribers/make_request_job.rb +17 -0
- data/app/models/concerns/spree/user_api_authentication.rb +19 -0
- data/app/models/concerns/spree/user_api_methods.rb +7 -0
- data/app/models/concerns/spree/webhooks/has_webhooks.rb +84 -0
- data/app/models/spree/api/webhooks/order_decorator.rb +43 -0
- data/app/models/spree/api/webhooks/payment_decorator.rb +26 -0
- data/app/models/spree/api/webhooks/product_decorator.rb +46 -0
- data/app/models/spree/api/webhooks/shipment_decorator.rb +21 -0
- data/app/models/spree/api/webhooks/stock_item_decorator.rb +43 -0
- data/app/models/spree/api/webhooks/stock_movement_decorator.rb +52 -0
- data/app/models/spree/api/webhooks/variant_decorator.rb +26 -0
- data/app/models/spree/oauth_access_grant.rb +7 -0
- data/app/models/spree/oauth_access_token.rb +7 -0
- data/app/models/spree/oauth_application.rb +15 -0
- data/app/models/spree/webhooks/base.rb +11 -0
- data/app/models/spree/webhooks/event.rb +12 -0
- data/app/models/spree/webhooks/subscriber.rb +61 -0
- data/app/presenters/spree/api/products/filters_presenter.rb +39 -0
- data/app/serializers/concerns/spree/api/v2/image_transformation_concern.rb +15 -0
- data/app/serializers/concerns/spree/api/v2/resource_serializer_concern.rb +34 -0
- data/app/serializers/concerns/spree/api/v2/taxon_image_transformation_concern.rb +15 -0
- data/app/serializers/spree/api/v2/base_serializer.rb +39 -0
- data/app/serializers/spree/api/v2/platform/address_serializer.rb +15 -0
- data/app/serializers/spree/api/v2/platform/adjustment_serializer.rb +20 -0
- data/app/serializers/spree/api/v2/platform/asset_serializer.rb +13 -0
- data/app/serializers/spree/api/v2/platform/base_serializer.rb +10 -0
- data/app/serializers/spree/api/v2/platform/calculator_serializer.rb +17 -0
- data/app/serializers/spree/api/v2/platform/classification_serializer.rb +14 -0
- data/app/serializers/spree/api/v2/platform/cms_page_serializer.rb +13 -0
- data/app/serializers/spree/api/v2/platform/cms_section_image_one_serializer.rb +9 -0
- data/app/serializers/spree/api/v2/platform/cms_section_image_three_serializer.rb +9 -0
- data/app/serializers/spree/api/v2/platform/cms_section_image_two_serializer.rb +9 -0
- data/app/serializers/spree/api/v2/platform/cms_section_serializer.rb +18 -0
- data/app/serializers/spree/api/v2/platform/country_serializer.rb +13 -0
- data/app/serializers/spree/api/v2/platform/credit_card_serializer.rb +14 -0
- data/app/serializers/spree/api/v2/platform/customer_return_serializer.rb +17 -0
- data/app/serializers/spree/api/v2/platform/digital_link_serializer.rb +16 -0
- data/app/serializers/spree/api/v2/platform/digital_serializer.rb +30 -0
- data/app/serializers/spree/api/v2/platform/feature_page_serializer.rb +11 -0
- data/app/serializers/spree/api/v2/platform/hero_image_serializer.rb +10 -0
- data/app/serializers/spree/api/v2/platform/homepage_serializer.rb +11 -0
- data/app/serializers/spree/api/v2/platform/icon_serializer.rb +16 -0
- data/app/serializers/spree/api/v2/platform/image_gallery_serializer.rb +10 -0
- data/app/serializers/spree/api/v2/platform/image_serializer.rb +17 -0
- data/app/serializers/spree/api/v2/platform/inventory_unit_serializer.rb +19 -0
- data/app/serializers/spree/api/v2/platform/line_item_serializer.rb +19 -0
- data/app/serializers/spree/api/v2/platform/log_entry_serializer.rb +13 -0
- data/app/serializers/spree/api/v2/platform/menu_item_serializer.rb +45 -0
- data/app/serializers/spree/api/v2/platform/menu_serializer.rb +13 -0
- data/app/serializers/spree/api/v2/platform/option_type_serializer.rb +13 -0
- data/app/serializers/spree/api/v2/platform/option_value_serializer.rb +13 -0
- data/app/serializers/spree/api/v2/platform/order_promotion_serializer.rb +14 -0
- data/app/serializers/spree/api/v2/platform/order_serializer.rb +31 -0
- data/app/serializers/spree/api/v2/platform/payment_capture_event_serializer.rb +13 -0
- data/app/serializers/spree/api/v2/platform/payment_method_serializer.rb +18 -0
- data/app/serializers/spree/api/v2/platform/payment_serializer.rb +21 -0
- data/app/serializers/spree/api/v2/platform/price_serializer.rb +19 -0
- data/app/serializers/spree/api/v2/platform/product_property_serializer.rb +11 -0
- data/app/serializers/spree/api/v2/platform/product_serializer.rb +82 -0
- data/app/serializers/spree/api/v2/platform/promotion_action_line_item_serializer.rb +14 -0
- data/app/serializers/spree/api/v2/platform/promotion_action_serializer.rb +19 -0
- data/app/serializers/spree/api/v2/platform/promotion_category_serializer.rb +13 -0
- data/app/serializers/spree/api/v2/platform/promotion_rule_serializer.rb +21 -0
- data/app/serializers/spree/api/v2/platform/promotion_serializer.rb +17 -0
- data/app/serializers/spree/api/v2/platform/property_serializer.rb +11 -0
- data/app/serializers/spree/api/v2/platform/prototype_serializer.rb +15 -0
- data/app/serializers/spree/api/v2/platform/refund_reason_serializer.rb +11 -0
- data/app/serializers/spree/api/v2/platform/refund_serializer.rb +16 -0
- data/app/serializers/spree/api/v2/platform/reimbursement_credit_serializer.rb +10 -0
- data/app/serializers/spree/api/v2/platform/reimbursement_serializer.rb +18 -0
- data/app/serializers/spree/api/v2/platform/reimbursement_type_serializer.rb +11 -0
- data/app/serializers/spree/api/v2/platform/return_authorization_reason_serializer.rb +11 -0
- data/app/serializers/spree/api/v2/platform/return_authorization_serializer.rb +17 -0
- data/app/serializers/spree/api/v2/platform/return_item_serializer.rb +16 -0
- data/app/serializers/spree/api/v2/platform/role_serializer.rb +11 -0
- data/app/serializers/spree/api/v2/platform/shipment_serializer.rb +22 -0
- data/app/serializers/spree/api/v2/platform/shipping_category_serializer.rb +11 -0
- data/app/serializers/spree/api/v2/platform/shipping_method_serializer.rb +16 -0
- data/app/serializers/spree/api/v2/platform/shipping_rate_serializer.rb +15 -0
- data/app/serializers/spree/api/v2/platform/side_by_side_image_serializer.rb +10 -0
- data/app/serializers/spree/api/v2/platform/standard_page_serializer.rb +11 -0
- data/app/serializers/spree/api/v2/platform/state_change_serializer.rb +13 -0
- data/app/serializers/spree/api/v2/platform/state_serializer.rb +13 -0
- data/app/serializers/spree/api/v2/platform/stock_item_serializer.rb +18 -0
- data/app/serializers/spree/api/v2/platform/stock_location_serializer.rb +14 -0
- data/app/serializers/spree/api/v2/platform/stock_movement_serializer.rb +11 -0
- data/app/serializers/spree/api/v2/platform/stock_transfer_serializer.rb +15 -0
- data/app/serializers/spree/api/v2/platform/store_credit_category_serializer.rb +12 -0
- data/app/serializers/spree/api/v2/platform/store_credit_event_serializer.rb +14 -0
- data/app/serializers/spree/api/v2/platform/store_credit_serializer.rb +18 -0
- data/app/serializers/spree/api/v2/platform/store_credit_type_serializer.rb +12 -0
- data/app/serializers/spree/api/v2/platform/store_serializer.rb +15 -0
- data/app/serializers/spree/api/v2/platform/tax_category_serializer.rb +13 -0
- data/app/serializers/spree/api/v2/platform/tax_rate_serializer.rb +14 -0
- data/app/serializers/spree/api/v2/platform/taxon_image_serializer.rb +15 -0
- data/app/serializers/spree/api/v2/platform/taxon_serializer.rb +38 -0
- data/app/serializers/spree/api/v2/platform/taxonomy_serializer.rb +14 -0
- data/app/serializers/spree/api/v2/platform/user_serializer.rb +39 -0
- data/app/serializers/spree/api/v2/platform/variant_serializer.rb +58 -0
- data/app/serializers/spree/api/v2/platform/webhooks/event_serializer.rb +15 -0
- data/app/serializers/spree/api/v2/platform/webhooks/subscriber_serializer.rb +13 -0
- data/app/serializers/spree/api/v2/platform/wished_item_serializer.rb +29 -0
- data/app/serializers/spree/api/v2/platform/wishlist_serializer.rb +19 -0
- data/app/serializers/spree/api/v2/platform/zone_member_serializer.rb +13 -0
- data/app/serializers/spree/api/v2/platform/zone_serializer.rb +13 -0
- data/app/serializers/spree/v2/storefront/address_serializer.rb +20 -0
- data/app/serializers/spree/v2/storefront/base_serializer.rb +10 -0
- data/app/serializers/spree/v2/storefront/cart_serializer.rb +36 -0
- data/app/serializers/spree/v2/storefront/cms_page_serializer.rb +14 -0
- data/app/serializers/spree/v2/storefront/cms_section_serializer.rb +32 -0
- data/app/serializers/spree/v2/storefront/country_serializer.rb +24 -0
- data/app/serializers/spree/v2/storefront/credit_card_serializer.rb +13 -0
- data/app/serializers/spree/v2/storefront/digital_link_serializer.rb +11 -0
- data/app/serializers/spree/v2/storefront/estimated_shipping_rate_serializer.rb +29 -0
- data/app/serializers/spree/v2/storefront/icon_serializer.rb +14 -0
- data/app/serializers/spree/v2/storefront/image_serializer.rb +13 -0
- data/app/serializers/spree/v2/storefront/line_item_serializer.rb +20 -0
- data/app/serializers/spree/v2/storefront/menu_item_serializer.rb +43 -0
- data/app/serializers/spree/v2/storefront/menu_serializer.rb +13 -0
- data/app/serializers/spree/v2/storefront/option_type_serializer.rb +13 -0
- data/app/serializers/spree/v2/storefront/option_value_serializer.rb +13 -0
- data/app/serializers/spree/v2/storefront/order_serializer.rb +9 -0
- data/app/serializers/spree/v2/storefront/payment_method_serializer.rb +15 -0
- data/app/serializers/spree/v2/storefront/payment_serializer.rb +15 -0
- data/app/serializers/spree/v2/storefront/product_property_serializer.rb +19 -0
- data/app/serializers/spree/v2/storefront/product_serializer.rb +76 -0
- data/app/serializers/spree/v2/storefront/promotion_serializer.rb +12 -0
- data/app/serializers/spree/v2/storefront/shipment_serializer.rb +24 -0
- data/app/serializers/spree/v2/storefront/shipping_rate_serializer.rb +16 -0
- data/app/serializers/spree/v2/storefront/state_serializer.rb +11 -0
- data/app/serializers/spree/v2/storefront/stock_location_serializer.rb +11 -0
- data/app/serializers/spree/v2/storefront/store_credit_category_serializer.rb +11 -0
- data/app/serializers/spree/v2/storefront/store_credit_event_serializer.rb +15 -0
- data/app/serializers/spree/v2/storefront/store_credit_serializer.rb +17 -0
- data/app/serializers/spree/v2/storefront/store_credit_type_serializer.rb +11 -0
- data/app/serializers/spree/v2/storefront/store_serializer.rb +20 -0
- data/app/serializers/spree/v2/storefront/taxon_image_serializer.rb +13 -0
- data/app/serializers/spree/v2/storefront/taxon_serializer.rb +37 -0
- data/app/serializers/spree/v2/storefront/taxonomy_serializer.rb +11 -0
- data/app/serializers/spree/v2/storefront/user_serializer.rb +31 -0
- data/app/serializers/spree/v2/storefront/variant_serializer.rb +49 -0
- data/app/serializers/spree/v2/storefront/wished_item_serializer.rb +29 -0
- data/app/serializers/spree/v2/storefront/wishlist_serializer.rb +17 -0
- data/app/services/spree/api/error_handler.rb +40 -0
- data/app/services/spree/webhooks/subscribers/handle_request.rb +73 -0
- data/app/services/spree/webhooks/subscribers/make_request.rb +82 -0
- data/app/services/spree/webhooks/subscribers/queue_requests.rb +23 -0
- data/app/services/spree/webhooks.rb +13 -0
- data/config/i18n-tasks.yml +40 -0
- data/config/initializers/doorkeeper.rb +48 -0
- data/config/initializers/json_api_mime_types.rb +8 -0
- data/config/initializers/user_class_extensions.rb +7 -0
- data/config/locales/en.yml +38 -0
- data/config/routes.rb +214 -0
- data/db/migrate/20100107141738_add_api_key_to_spree_users.rb +7 -0
- data/db/migrate/20120411123334_resize_api_key_field.rb +7 -0
- data/db/migrate/20120530054546_rename_api_key_to_spree_api_key.rb +7 -0
- data/db/migrate/20131017162334_add_index_to_user_spree_api_key.rb +7 -0
- data/db/migrate/20180320110726_create_doorkeeper_tables.rb +69 -0
- data/db/migrate/20210727102516_change_integer_id_columns_type.rb +9 -0
- data/db/migrate/20210902162826_create_spree_webhooks_tables.rb +16 -0
- data/db/migrate/20210919183228_enable_polymorphic_resource_owner.rb +21 -0
- data/db/migrate/20211025162826_create_spree_webhooks_events.rb +14 -0
- data/docs/oauth/index.yml +233 -0
- data/docs/v2/platform/index.yaml +21111 -0
- data/docs/v2/storefront/index.yaml +16504 -0
- data/lib/spree/api/configuration.rb +11 -0
- data/lib/spree/api/dependencies.rb +165 -0
- data/lib/spree/api/engine.rb +34 -0
- data/lib/spree/api/testing_support/caching.rb +10 -0
- data/lib/spree/api/testing_support/factories/oauth_application_factory.rb +6 -0
- data/lib/spree/api/testing_support/factories/webhook_event_factory.rb +27 -0
- data/lib/spree/api/testing_support/factories/webhook_subscriber_factory.rb +13 -0
- data/lib/spree/api/testing_support/factories.rb +3 -0
- data/lib/spree/api/testing_support/jobs.rb +18 -0
- data/lib/spree/api/testing_support/matchers/webhooks.rb +67 -0
- data/lib/spree/api/testing_support/serializers.rb +25 -0
- data/lib/spree/api/testing_support/spree_webhooks.rb +9 -0
- data/lib/spree/api/testing_support/v2/base.rb +13 -0
- data/lib/spree/api/testing_support/v2/current_order.rb +112 -0
- data/lib/spree/api/testing_support/v2/platform_contexts.rb +273 -0
- data/lib/spree/api/testing_support/v2/serializers_params.rb +16 -0
- data/lib/spree/api.rb +8 -0
- data/lib/spree_api.rb +3 -0
- data/script/rails +9 -0
- data/spec/fixtures/files/icon_256x256.jpg +0 -0
- data/spec/fixtures/thinking-cat.jpg +0 -0
- data/spree_api.gemspec +35 -0
- metadata +427 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 6f2910992efa7a7f60ad7bf6a8dce1fff95bad61dff49f616facc520f963ed11
|
|
4
|
+
data.tar.gz: c4aa8b10a7945a8a1205e45fa51d9c23ee977471e4909fc8dc9802faac8eb77f
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 7fbea24f6a458686e17340be98faf15afb7e2516a1d766fb243b356e5579a37958a987a62e77e186d80898ed5f5dea6950873de28fc124ea9bc708066f50fbcf
|
|
7
|
+
data.tar.gz: d7d2c22f20a91509a21de101be57485135e6cdb32155bfb1fe01c4d2937d0f4da31a2323a03419e12feaf80c2b19cd60dc4788d9b94afcace58135836f03a845
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
Copyright (c) 2007-2015, Spree Commerce, Inc. and other contributors
|
|
2
|
+
All rights reserved.
|
|
3
|
+
|
|
4
|
+
Redistribution and use in source and binary forms, with or without modification,
|
|
5
|
+
are permitted provided that the following conditions are met:
|
|
6
|
+
|
|
7
|
+
* Redistributions of source code must retain the above copyright notice,
|
|
8
|
+
this list of conditions and the following disclaimer.
|
|
9
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
|
10
|
+
this list of conditions and the following disclaimer in the documentation
|
|
11
|
+
and/or other materials provided with the distribution.
|
|
12
|
+
* Neither the name Spree nor the names of its contributors may be used to
|
|
13
|
+
endorse or promote products derived from this software without specific
|
|
14
|
+
prior written permission.
|
|
15
|
+
|
|
16
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
17
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
18
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
19
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
20
|
+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
21
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
22
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
23
|
+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
24
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
25
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
26
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/Rakefile
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'rake'
|
|
3
|
+
require 'rake/testtask'
|
|
4
|
+
require 'rspec/core/rake_task'
|
|
5
|
+
require 'spree/testing_support/common_rake'
|
|
6
|
+
|
|
7
|
+
RSpec::Core::RakeTask.new
|
|
8
|
+
|
|
9
|
+
task default: :spec
|
|
10
|
+
|
|
11
|
+
desc "Generates a dummy app for testing"
|
|
12
|
+
task :test_app do
|
|
13
|
+
ENV['LIB_NAME'] = 'spree/api'
|
|
14
|
+
Rake::Task['common:test_app'].invoke
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
namespace :rswag do
|
|
18
|
+
namespace :specs do
|
|
19
|
+
desc 'Generate Swagger JSON files from integration specs'
|
|
20
|
+
RSpec::Core::RakeTask.new('swaggerize') do |t|
|
|
21
|
+
t.pattern = ENV.fetch(
|
|
22
|
+
'PATTERN',
|
|
23
|
+
'spec/integration/**/*_spec.rb'
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
t.rspec_opts = ['--format Rswag::Specs::SwaggerFormatter', '--order defined']
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module Api
|
|
3
|
+
module V2
|
|
4
|
+
module Caching
|
|
5
|
+
extend ActiveSupport::Concern
|
|
6
|
+
|
|
7
|
+
def collection_cache_key(collection)
|
|
8
|
+
ids_and_timestamps = collection.unscope(:includes).unscope(:order).pluck(:id, :updated_at)
|
|
9
|
+
|
|
10
|
+
ids = ids_and_timestamps.map(&:first)
|
|
11
|
+
max_updated_at = ids_and_timestamps.map(&:last).max
|
|
12
|
+
|
|
13
|
+
cache_key_parts = [
|
|
14
|
+
self.class.to_s,
|
|
15
|
+
max_updated_at,
|
|
16
|
+
ids,
|
|
17
|
+
resource_includes,
|
|
18
|
+
sparse_fields,
|
|
19
|
+
serializer_params,
|
|
20
|
+
params[:sort]&.strip,
|
|
21
|
+
params[:page]&.to_s&.strip,
|
|
22
|
+
params[:per_page]&.to_s&.strip,
|
|
23
|
+
].flatten.join('-')
|
|
24
|
+
|
|
25
|
+
Digest::MD5.hexdigest(cache_key_parts)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def collection_cache_opts
|
|
29
|
+
{
|
|
30
|
+
namespace: Spree::Api::Config[:api_v2_collection_cache_namespace],
|
|
31
|
+
expires_in: Spree::Api::Config[:api_v2_collection_cache_ttl],
|
|
32
|
+
}
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module Api
|
|
3
|
+
module V2
|
|
4
|
+
module CouponCodesHelper
|
|
5
|
+
def select_coupon_codes
|
|
6
|
+
params[:coupon_code].present? ? [params[:coupon_code]] : check_coupon_codes
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def check_coupon_codes
|
|
10
|
+
spree_current_order.promotions.coupons.map(&:code)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def select_error(coupon_codes)
|
|
14
|
+
result = coupon_handler.new(spree_current_order).remove(coupon_codes.first)
|
|
15
|
+
result.error
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def select_errors(coupon_codes)
|
|
19
|
+
results = []
|
|
20
|
+
coupon_codes.each do |coupon_code|
|
|
21
|
+
results << coupon_handler.new(spree_current_order).remove(coupon_code)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
results.select(&:error)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module Api
|
|
3
|
+
module V2
|
|
4
|
+
module Platform
|
|
5
|
+
module NestedSetRepositionConcern
|
|
6
|
+
def reposition
|
|
7
|
+
spree_authorize! :update, resource if spree_current_user.present?
|
|
8
|
+
|
|
9
|
+
@new_parent = scope.find(permitted_resource_params[:new_parent_id])
|
|
10
|
+
new_index = permitted_resource_params[:new_position_idx].to_i
|
|
11
|
+
|
|
12
|
+
if resource.move_to_child_with_index(@new_parent, new_index)
|
|
13
|
+
# If successful reposition call the custom method for handling success.
|
|
14
|
+
successful_reposition_actions
|
|
15
|
+
elsif resource.errors.any?
|
|
16
|
+
# If there are errors output them to the response
|
|
17
|
+
render_error_payload(resource.errors.full_messages.to_sentence)
|
|
18
|
+
else
|
|
19
|
+
# If the user drops the re-positioned item in the same location it came from
|
|
20
|
+
# we just render the serialized payload, nothing has changed, we don't need to
|
|
21
|
+
# render any errors, or fire any custom success methods.
|
|
22
|
+
render_serialized_payload { serialize_resource(resource) }
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
|
|
28
|
+
def successful_reposition_actions
|
|
29
|
+
# Call a separate method for a successful reposition so this can be easily overridden
|
|
30
|
+
# if a more complex set of events need to occur after a successful reposition.
|
|
31
|
+
render_serialized_payload { serialize_resource(resource) }
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module Api
|
|
3
|
+
module V2
|
|
4
|
+
module Platform
|
|
5
|
+
module PromotionCalculatorParams
|
|
6
|
+
private
|
|
7
|
+
|
|
8
|
+
def calculator_params
|
|
9
|
+
[:preferred_flat_percent, :preferred_amount, :preferred_first_item, :preferred_additional_item,
|
|
10
|
+
:preferred_max_items, :preferred_percent, :preferred_minimal_amount, :preferred_normal_amount,
|
|
11
|
+
:preferred_discount_amount, :preferred_currency, :preferred_base_amount, :preferred_base_percent, { preferred_tiers: {} }]
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module Api
|
|
3
|
+
module V2
|
|
4
|
+
module Platform
|
|
5
|
+
module PromotionRuleParams
|
|
6
|
+
private
|
|
7
|
+
|
|
8
|
+
def rule_params
|
|
9
|
+
[:preferred_match_policy, :preferred_country_id, :preferred_amount_min, :preferred_operator_min, :preferred_amount_max,
|
|
10
|
+
:preferred_operator_max, { taxon_ids: [], user_ids: [], product_ids: [], preferred_eligible_values: {} }]
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module Api
|
|
3
|
+
module V2
|
|
4
|
+
module ProductListIncludes
|
|
5
|
+
def product_list_includes
|
|
6
|
+
{
|
|
7
|
+
product_properties: [],
|
|
8
|
+
option_types: [],
|
|
9
|
+
variant_images: [],
|
|
10
|
+
master: product_variant_includes,
|
|
11
|
+
variants: product_variant_includes
|
|
12
|
+
}
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def product_variant_includes
|
|
16
|
+
{
|
|
17
|
+
prices: [],
|
|
18
|
+
option_values: :option_type,
|
|
19
|
+
images: []
|
|
20
|
+
}
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module Api
|
|
3
|
+
module V2
|
|
4
|
+
module Storefront
|
|
5
|
+
module MetadataControllerConcern
|
|
6
|
+
protected
|
|
7
|
+
|
|
8
|
+
def ensure_valid_metadata
|
|
9
|
+
if params[:public_metadata].present? && !params[:public_metadata].is_a?(ActionController::Parameters) ||
|
|
10
|
+
params[:private_metadata].present? && !params[:private_metadata].is_a?(ActionController::Parameters)
|
|
11
|
+
render_error_payload(I18n.t(:invalid_params, scope: 'spree.api.v2.metadata'))
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module Api
|
|
3
|
+
module V2
|
|
4
|
+
module Storefront
|
|
5
|
+
module OrderConcern
|
|
6
|
+
private
|
|
7
|
+
|
|
8
|
+
def render_order(result)
|
|
9
|
+
if result.success?
|
|
10
|
+
render_serialized_payload { serialized_current_order }
|
|
11
|
+
else
|
|
12
|
+
render_error_payload(result.error)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def ensure_order
|
|
17
|
+
raise ActiveRecord::RecordNotFound if spree_current_order.nil?
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def order_token
|
|
21
|
+
request.headers['X-Spree-Order-Token'] || params[:order_token]
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def spree_current_order
|
|
25
|
+
@spree_current_order ||= find_spree_current_order
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def find_spree_current_order
|
|
29
|
+
Spree::Api::Dependencies.storefront_current_order_finder.constantize.new.execute(
|
|
30
|
+
store: current_store,
|
|
31
|
+
user: spree_current_user,
|
|
32
|
+
token: order_token,
|
|
33
|
+
currency: current_currency
|
|
34
|
+
)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def serialized_current_order
|
|
38
|
+
serialize_resource(spree_current_order)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def serialize_order(order)
|
|
42
|
+
ActiveSupport::Deprecation.warn(<<-DEPRECATION, caller)
|
|
43
|
+
`OrderConcern#serialize_order` is deprecated and will be removed in Spree 5.0.
|
|
44
|
+
Please use `serializer_resource` method
|
|
45
|
+
DEPRECATION
|
|
46
|
+
serialize_resource(order)
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module Api
|
|
3
|
+
module V2
|
|
4
|
+
class BaseController < ActionController::API
|
|
5
|
+
include CanCan::ControllerAdditions
|
|
6
|
+
include Spree::Core::ControllerHelpers::StrongParameters
|
|
7
|
+
include Spree::Core::ControllerHelpers::Store
|
|
8
|
+
include Spree::Core::ControllerHelpers::Locale
|
|
9
|
+
include Spree::Core::ControllerHelpers::Currency
|
|
10
|
+
|
|
11
|
+
rescue_from ActiveRecord::RecordNotFound, with: :record_not_found
|
|
12
|
+
rescue_from CanCan::AccessDenied, with: :access_denied
|
|
13
|
+
rescue_from Doorkeeper::Errors::DoorkeeperError, with: :access_denied_401
|
|
14
|
+
rescue_from Spree::Core::GatewayError, with: :gateway_error
|
|
15
|
+
rescue_from ActionController::ParameterMissing, with: :error_during_processing
|
|
16
|
+
if defined?(JSONAPI::Serializer::UnsupportedIncludeError)
|
|
17
|
+
rescue_from JSONAPI::Serializer::UnsupportedIncludeError, with: :error_during_processing
|
|
18
|
+
end
|
|
19
|
+
rescue_from ArgumentError, with: :error_during_processing
|
|
20
|
+
rescue_from ActionDispatch::Http::Parameters::ParseError, with: :error_during_processing
|
|
21
|
+
|
|
22
|
+
def content_type
|
|
23
|
+
Spree::Api::Config[:api_v2_content_type]
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
protected
|
|
27
|
+
|
|
28
|
+
def serialize_collection(collection)
|
|
29
|
+
collection_serializer.new(
|
|
30
|
+
collection,
|
|
31
|
+
collection_options(collection).merge(params: serializer_params)
|
|
32
|
+
).serializable_hash
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def serialize_resource(resource)
|
|
36
|
+
resource_serializer.new(
|
|
37
|
+
resource,
|
|
38
|
+
params: serializer_params,
|
|
39
|
+
include: resource_includes,
|
|
40
|
+
fields: sparse_fields
|
|
41
|
+
).serializable_hash
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def paginated_collection
|
|
45
|
+
@paginated_collection ||= collection_paginator.new(sorted_collection, params).call
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def collection_paginator
|
|
49
|
+
Spree::Api::Dependencies.storefront_collection_paginator.constantize
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def render_serialized_payload(status = 200)
|
|
53
|
+
render json: yield, status: status, content_type: content_type
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def render_error_payload(error, status = 422)
|
|
57
|
+
json = if error.is_a?(ActiveModel::Errors)
|
|
58
|
+
{ error: error.full_messages.to_sentence, errors: error.messages }
|
|
59
|
+
elsif error.is_a?(Struct)
|
|
60
|
+
{ error: error.to_s, errors: error.to_h }
|
|
61
|
+
else
|
|
62
|
+
{ error: error }
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
render json: json, status: status, content_type: content_type
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def render_result(result, ok_status = 200)
|
|
69
|
+
if result.success?
|
|
70
|
+
render_serialized_payload(ok_status) { serialize_resource(result.value) }
|
|
71
|
+
else
|
|
72
|
+
render_error_payload(result.error)
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def spree_current_user
|
|
77
|
+
return nil unless doorkeeper_token
|
|
78
|
+
return @spree_current_user if @spree_current_user
|
|
79
|
+
|
|
80
|
+
doorkeeper_authorize!
|
|
81
|
+
|
|
82
|
+
@spree_current_user ||= doorkeeper_token.resource_owner
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def spree_authorize!(action, subject, *args)
|
|
86
|
+
authorize!(action, subject, *args)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def require_spree_current_user
|
|
90
|
+
raise CanCan::AccessDenied if spree_current_user.nil?
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# Needs to be overridden so that we use Spree's Ability rather than anyone else's.
|
|
94
|
+
def current_ability
|
|
95
|
+
@current_ability ||= Spree::Dependencies.ability_class.constantize.new(spree_current_user)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def request_includes
|
|
99
|
+
# if API user wants to receive only the bare-minimum
|
|
100
|
+
# the API will return only the main resource without any included
|
|
101
|
+
if params[:include]&.blank?
|
|
102
|
+
[]
|
|
103
|
+
elsif params[:include].present?
|
|
104
|
+
params[:include].split(',')
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def resource_includes
|
|
109
|
+
(request_includes || default_resource_includes).map(&:intern)
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
# overwrite this method in your controllers to set JSON API default include value
|
|
113
|
+
# https://jsonapi.org/format/#fetching-includes
|
|
114
|
+
# eg.:
|
|
115
|
+
# %w[images variants]
|
|
116
|
+
# ['variant.images', 'line_items']
|
|
117
|
+
def default_resource_includes
|
|
118
|
+
[]
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def sparse_fields
|
|
122
|
+
return unless params[:fields]&.respond_to?(:each)
|
|
123
|
+
|
|
124
|
+
fields = {}
|
|
125
|
+
params[:fields].
|
|
126
|
+
select { |_, v| v.is_a?(String) }.
|
|
127
|
+
each { |type, values| fields[type.intern] = values.split(',').map(&:intern) }
|
|
128
|
+
fields.presence
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
def serializer_params
|
|
132
|
+
{
|
|
133
|
+
currency: current_currency,
|
|
134
|
+
locale: current_locale,
|
|
135
|
+
price_options: current_price_options,
|
|
136
|
+
store: current_store,
|
|
137
|
+
user: spree_current_user,
|
|
138
|
+
image_transformation: params[:image_transformation],
|
|
139
|
+
taxon_image_transformation: params[:taxon_image_transformation]
|
|
140
|
+
}
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
def record_not_found
|
|
144
|
+
render_error_payload(I18n.t(:resource_not_found, scope: 'spree.api'), 404)
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
def access_denied(exception)
|
|
148
|
+
render_error_payload(exception.message, 403)
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
def access_denied_401(exception)
|
|
152
|
+
render_error_payload(exception.message, 401)
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
def gateway_error(exception)
|
|
156
|
+
render_error_payload(exception.message)
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
def error_during_processing(exception)
|
|
160
|
+
result = error_handler.call(exception: exception, opts: { user: spree_current_user })
|
|
161
|
+
|
|
162
|
+
render_error_payload(result.value[:message], 400)
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
def error_handler
|
|
166
|
+
Spree::Api::Dependencies.error_handler.constantize
|
|
167
|
+
end
|
|
168
|
+
end
|
|
169
|
+
end
|
|
170
|
+
end
|
|
171
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module Api
|
|
3
|
+
module V2
|
|
4
|
+
module Platform
|
|
5
|
+
class AddressesController < ResourceController
|
|
6
|
+
private
|
|
7
|
+
|
|
8
|
+
def model_class
|
|
9
|
+
Spree::Address
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def scope_includes
|
|
13
|
+
[:country, :state, :user]
|
|
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 AdjustmentsController < ResourceController
|
|
6
|
+
private
|
|
7
|
+
|
|
8
|
+
def model_class
|
|
9
|
+
Spree::Adjustment
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def scope_includes
|
|
13
|
+
[:order, :adjustable]
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module Api
|
|
3
|
+
module V2
|
|
4
|
+
module Platform
|
|
5
|
+
class ClassificationsController < ResourceController
|
|
6
|
+
private
|
|
7
|
+
|
|
8
|
+
def model_class
|
|
9
|
+
Spree::Classification
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def scope_includes
|
|
13
|
+
[
|
|
14
|
+
taxon: [],
|
|
15
|
+
product: [:variants_including_master, :variant_images, :master, { variants: [:prices] }]
|
|
16
|
+
]
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module Api
|
|
3
|
+
module V2
|
|
4
|
+
module Platform
|
|
5
|
+
class CmsPagesController < ResourceController
|
|
6
|
+
private
|
|
7
|
+
|
|
8
|
+
def model_class
|
|
9
|
+
Spree::CmsPage
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def scope_includes
|
|
13
|
+
[:cms_sections]
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module Api
|
|
3
|
+
module V2
|
|
4
|
+
module Platform
|
|
5
|
+
class CmsSectionsController < ResourceController
|
|
6
|
+
private
|
|
7
|
+
|
|
8
|
+
def model_class
|
|
9
|
+
Spree::CmsSection
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def spree_permitted_attributes
|
|
13
|
+
stored_attributes = []
|
|
14
|
+
|
|
15
|
+
Spree::CmsSection::TYPES.each do |type|
|
|
16
|
+
type.constantize.stored_attributes.each do |_name, values|
|
|
17
|
+
values.each do |value|
|
|
18
|
+
stored_attributes << value
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
super + stored_attributes.compact.uniq!
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module Api
|
|
3
|
+
module V2
|
|
4
|
+
module Platform
|
|
5
|
+
class CountriesController < ResourceController
|
|
6
|
+
private
|
|
7
|
+
|
|
8
|
+
def model_class
|
|
9
|
+
Spree::Country
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def scope_includes
|
|
13
|
+
[:states, :zones]
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module Api
|
|
3
|
+
module V2
|
|
4
|
+
module Platform
|
|
5
|
+
class DigitalLinksController < ResourceController
|
|
6
|
+
def reset
|
|
7
|
+
spree_authorize! :update, resource if spree_current_user.present?
|
|
8
|
+
|
|
9
|
+
if resource.reset!
|
|
10
|
+
render_serialized_payload { serialize_resource(resource) }
|
|
11
|
+
else
|
|
12
|
+
render_error_payload(resource.errors)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
private
|
|
17
|
+
|
|
18
|
+
def model_class
|
|
19
|
+
Spree::DigitalLink
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|