spree_legacy_api_v2 1.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/README.md +47 -0
- data/Rakefile +23 -0
- data/app/controllers/concerns/spree/api/v2/caching.rb +40 -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 +21 -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 +49 -0
- data/app/controllers/spree/admin/oauth_applications_controller.rb +23 -0
- data/app/controllers/spree/api/v2/base_controller.rb +233 -0
- data/app/controllers/spree/api/v2/data_feeds/google_controller.rb +24 -0
- data/app/controllers/spree/api/v2/platform/addresses_controller.rb +23 -0
- data/app/controllers/spree/api/v2/platform/adjustments_controller.rb +23 -0
- data/app/controllers/spree/api/v2/platform/classifications_controller.rb +26 -0
- data/app/controllers/spree/api/v2/platform/countries_controller.rb +23 -0
- data/app/controllers/spree/api/v2/platform/data_feeds_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/digital_links_controller.rb +29 -0
- data/app/controllers/spree/api/v2/platform/digitals_controller.rb +23 -0
- data/app/controllers/spree/api/v2/platform/gift_cards_controller.rb +23 -0
- data/app/controllers/spree/api/v2/platform/line_items_controller.rb +63 -0
- data/app/controllers/spree/api/v2/platform/option_types_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/option_values_controller.rb +23 -0
- data/app/controllers/spree/api/v2/platform/orders_controller.rb +167 -0
- data/app/controllers/spree/api/v2/platform/payment_methods_controller.rb +31 -0
- data/app/controllers/spree/api/v2/platform/payments_controller.rb +21 -0
- data/app/controllers/spree/api/v2/platform/products_controller.rb +41 -0
- data/app/controllers/spree/api/v2/platform/promotion_actions_controller.rb +34 -0
- data/app/controllers/spree/api/v2/platform/promotion_categories_controller.rb +23 -0
- data/app/controllers/spree/api/v2/platform/promotion_rules_controller.rb +29 -0
- data/app/controllers/spree/api/v2/platform/promotions_controller.rb +35 -0
- data/app/controllers/spree/api/v2/platform/resource_controller.rb +154 -0
- data/app/controllers/spree/api/v2/platform/roles_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/shipments_controller.rb +147 -0
- data/app/controllers/spree/api/v2/platform/shipping_categories_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/shipping_methods_controller.rb +28 -0
- data/app/controllers/spree/api/v2/platform/states_controller.rb +23 -0
- data/app/controllers/spree/api/v2/platform/stock_items_controller.rb +23 -0
- data/app/controllers/spree/api/v2/platform/stock_locations_controller.rb +23 -0
- data/app/controllers/spree/api/v2/platform/store_credit_categories_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/store_credit_types_controller.rb +19 -0
- data/app/controllers/spree/api/v2/platform/store_credits_controller.rb +23 -0
- data/app/controllers/spree/api/v2/platform/tax_categories_controller.rb +23 -0
- data/app/controllers/spree/api/v2/platform/tax_rates_controller.rb +27 -0
- data/app/controllers/spree/api/v2/platform/taxonomies_controller.rb +23 -0
- data/app/controllers/spree/api/v2/platform/taxons_controller.rb +59 -0
- data/app/controllers/spree/api/v2/platform/users_controller.rb +37 -0
- data/app/controllers/spree/api/v2/platform/variants_controller.rb +23 -0
- data/app/controllers/spree/api/v2/platform/wished_items_controller.rb +23 -0
- data/app/controllers/spree/api/v2/platform/wishlists_controller.rb +23 -0
- data/app/controllers/spree/api/v2/platform/zones_controller.rb +23 -0
- data/app/controllers/spree/api/v2/resource_controller.rb +79 -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 +246 -0
- data/app/controllers/spree/api/v2/storefront/checkout_controller.rb +183 -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/order_status_controller.rb +34 -0
- data/app/controllers/spree/api/v2/storefront/policies_controller.rb +31 -0
- data/app/controllers/spree/api/v2/storefront/post_categories_controller.rb +35 -0
- data/app/controllers/spree/api/v2/storefront/posts_controller.rb +51 -0
- data/app/controllers/spree/api/v2/storefront/products_controller.rb +66 -0
- data/app/controllers/spree/api/v2/storefront/stores_controller.rb +27 -0
- data/app/controllers/spree/api/v2/storefront/taxons_controller.rb +51 -0
- data/app/controllers/spree/api/v2/storefront/variants_controller.rb +41 -0
- data/app/controllers/spree/api/v2/storefront/wishlists_controller.rb +214 -0
- data/app/helpers/spree/api/v2/collection_options_helpers.rb +46 -0
- data/app/helpers/spree/api/v2/display_money_helper.rb +63 -0
- data/app/helpers/spree/api/v2/store_media_serializer_images_concern.rb +30 -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/spree/oauth_access_grant.rb +7 -0
- data/app/models/spree/oauth_access_token.rb +7 -0
- data/app/models/spree/oauth_application.rb +22 -0
- data/app/paginators/spree/api/paginate.rb +68 -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/public_metafields_concern.rb +15 -0
- data/app/serializers/concerns/spree/api/v2/resource_serializer_concern.rb +42 -0
- data/app/serializers/concerns/spree/api/v2/taxon_image_transformation_concern.rb +15 -0
- data/app/serializers/spree/api/v2/base_serializer.rb +43 -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/admin_user_serializer.rb +15 -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/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/data_feed_serializer.rb +13 -0
- data/app/serializers/spree/api/v2/platform/digital_link_serializer.rb +16 -0
- data/app/serializers/spree/api/v2/platform/digital_serializer.rb +29 -0
- data/app/serializers/spree/api/v2/platform/gift_card_serializer.rb +17 -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/metafield_serializer.rb +21 -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 +22 -0
- data/app/serializers/spree/api/v2/platform/payment_source_serializer.rb +12 -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 +90 -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 +17 -0
- data/app/serializers/spree/api/v2/platform/reimbursement_credit_serializer.rb +10 -0
- data/app/serializers/spree/api/v2/platform/reimbursement_serializer.rb +19 -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/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 +14 -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 +47 -0
- data/app/serializers/spree/api/v2/platform/taxonomy_serializer.rb +14 -0
- data/app/serializers/spree/api/v2/platform/user_serializer.rb +37 -0
- data/app/serializers/spree/api/v2/platform/variant_serializer.rb +66 -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 +22 -0
- data/app/serializers/spree/v2/storefront/base_serializer.rb +10 -0
- data/app/serializers/spree/v2/storefront/cart_serializer.rb +67 -0
- data/app/serializers/spree/v2/storefront/country_serializer.rb +24 -0
- data/app/serializers/spree/v2/storefront/credit_card_serializer.rb +15 -0
- data/app/serializers/spree/v2/storefront/digital_link_serializer.rb +11 -0
- data/app/serializers/spree/v2/storefront/estimated_shipping_rate_serializer.rb +35 -0
- data/app/serializers/spree/v2/storefront/gift_card_serializer.rb +16 -0
- data/app/serializers/spree/v2/storefront/image_serializer.rb +13 -0
- data/app/serializers/spree/v2/storefront/line_item_serializer.rb +23 -0
- data/app/serializers/spree/v2/storefront/metafield_serializer.rb +19 -0
- data/app/serializers/spree/v2/storefront/option_type_serializer.rb +15 -0
- data/app/serializers/spree/v2/storefront/option_value_serializer.rb +13 -0
- data/app/serializers/spree/v2/storefront/order_promotion_serializer.rb +14 -0
- data/app/serializers/spree/v2/storefront/order_serializer.rb +11 -0
- data/app/serializers/spree/v2/storefront/payment_method_serializer.rb +17 -0
- data/app/serializers/spree/v2/storefront/payment_serializer.rb +20 -0
- data/app/serializers/spree/v2/storefront/payment_source_serializer.rb +12 -0
- data/app/serializers/spree/v2/storefront/policy_serializer.rb +19 -0
- data/app/serializers/spree/v2/storefront/post_category_serializer.rb +23 -0
- data/app/serializers/spree/v2/storefront/post_serializer.rb +51 -0
- data/app/serializers/spree/v2/storefront/product_property_serializer.rb +19 -0
- data/app/serializers/spree/v2/storefront/product_serializer.rb +92 -0
- data/app/serializers/spree/v2/storefront/shipment_serializer.rb +26 -0
- data/app/serializers/spree/v2/storefront/shipping_category_serializer.rb +10 -0
- data/app/serializers/spree/v2/storefront/shipping_method_serializer.rb +12 -0
- data/app/serializers/spree/v2/storefront/shipping_rate_serializer.rb +26 -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 +19 -0
- data/app/serializers/spree/v2/storefront/store_credit_type_serializer.rb +11 -0
- data/app/serializers/spree/v2/storefront/store_serializer.rb +18 -0
- data/app/serializers/spree/v2/storefront/taxon_image_serializer.rb +13 -0
- data/app/serializers/spree/v2/storefront/taxon_serializer.rb +55 -0
- data/app/serializers/spree/v2/storefront/taxonomy_serializer.rb +13 -0
- data/app/serializers/spree/v2/storefront/user_serializer.rb +33 -0
- data/app/serializers/spree/v2/storefront/variant_serializer.rb +58 -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/views/spree/admin/oauth_applications/_form.html.erb +6 -0
- data/app/views/spree/admin/oauth_applications/_table_header.html.erb +7 -0
- data/app/views/spree/admin/oauth_applications/_table_row.html.erb +34 -0
- data/app/views/spree/admin/oauth_applications/create.turbo_stream.erb +31 -0
- data/app/views/spree/admin/oauth_applications/edit.html.erb +1 -0
- data/app/views/spree/admin/oauth_applications/index.html.erb +21 -0
- data/app/views/spree/admin/oauth_applications/new.html.erb +1 -0
- data/config/initializers/doorkeeper.rb +50 -0
- data/config/initializers/json_api_mime_types.rb +8 -0
- data/config/initializers/user_class_extensions.rb +7 -0
- data/config/routes.rb +219 -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/20210919183228_enable_polymorphic_resource_owner.rb +21 -0
- data/lib/generators/spree_legacy_api_v2/install/install_generator.rb +23 -0
- data/lib/spree_legacy_api_v2/engine.rb +77 -0
- data/lib/spree_legacy_api_v2/testing_support/factories/oauth_application_factory.rb +7 -0
- data/lib/spree_legacy_api_v2/testing_support/factories.rb +1 -0
- data/lib/spree_legacy_api_v2/testing_support/serializers.rb +15 -0
- data/lib/spree_legacy_api_v2/testing_support/v2/base.rb +13 -0
- data/lib/spree_legacy_api_v2/testing_support/v2/current_order.rb +116 -0
- data/lib/spree_legacy_api_v2/testing_support/v2/platform_contexts.rb +272 -0
- data/lib/spree_legacy_api_v2/testing_support/v2/serializers_params.rb +16 -0
- data/lib/spree_legacy_api_v2/version.rb +9 -0
- data/lib/spree_legacy_api_v2.rb +7 -0
- metadata +359 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: a0ad06cfe87057ca7696604c808ea23b46cb7e42a6e9619fa76e218307e64ab1
|
|
4
|
+
data.tar.gz: 3067eedec49aca26f5ef0ef30e486bcbde39e993da0679925e22da568eaf7353
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: d5d933f75f967e8dcf40b3c7a32b1a9239bb0a3944781b12435423a56740270491da3059e6e4c121d393f795c8b44d044937aef6f696634de1f2756637f678a8
|
|
7
|
+
data.tar.gz: 03ed42ab16c493f4913f5d09b4eb1a7c3fa5da474c62a7d70d4b44ae775f484c20d76a8da18e82f8e2795fd41063ad199a265764880b36b63adb57f8c42cbe23
|
data/README.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Spree Legacy API v2
|
|
2
|
+
|
|
3
|
+
> **⚠️ DEPRECATED**: This gem provides the legacy API v2 endpoints for Spree Commerce. We recommend using **API v3**.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This gem contains the legacy Storefront API v2 and Platform API v2 endpoints that were previously part of `spree_api`. These APIs are now deprecated in favor of the new API v3, which is much simpler, faster and more secure.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
Add this line to your application's Gemfile:
|
|
12
|
+
|
|
13
|
+
```ruby
|
|
14
|
+
gem 'spree_legacy_api_v2'
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
And run the following command:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
bundle exec rake spree_legacy_api_v2:install
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
This will install the database migrations and run them.
|
|
24
|
+
|
|
25
|
+
## Migration Guide
|
|
26
|
+
|
|
27
|
+
### Storefront API
|
|
28
|
+
|
|
29
|
+
The new Store API v3 provides similar functionality with improved consistency:
|
|
30
|
+
|
|
31
|
+
| Legacy v2 Endpoint | New v3 Endpoint |
|
|
32
|
+
|-------------------|-----------------|
|
|
33
|
+
| `GET /api/v2/storefront/products` | `GET /api/v3/store/products` |
|
|
34
|
+
| `GET /api/v2/storefront/cart` | `GET /api/v3/store/orders/:id` |
|
|
35
|
+
| `POST /api/v2/storefront/cart/add_item` | `POST /api/v3/store/orders/:id/line_items` |
|
|
36
|
+
| `GET /api/v2/storefront/account` | `GET /api/v3/store/customers` |
|
|
37
|
+
|
|
38
|
+
### Key Differences
|
|
39
|
+
|
|
40
|
+
1. **Serialization**: API v3 uses Alba serializers (faster, simpler) instead of JSONAPI::Serializer
|
|
41
|
+
2. **Response Format**: API v3 returns simple JSON objects instead of JSONAPI format
|
|
42
|
+
3. **Authentication**: API v3 requires publishable key authentication for Store API and uses JWT tokens for user authentication
|
|
43
|
+
4. **TypeScript Types**: API v3 automatically generates TypeScript types via Typelizer
|
|
44
|
+
|
|
45
|
+
## License
|
|
46
|
+
|
|
47
|
+
Spree is released under the [AGPL-3.0-or-later](https://www.gnu.org/licenses/agpl-3.0.html) and [BSD-3-Clause](https://opensource.org/licenses/BSD-3-Clause) licenses.
|
data/Rakefile
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'bundler'
|
|
4
|
+
Bundler::GemHelper.install_tasks
|
|
5
|
+
|
|
6
|
+
require 'rspec/core/rake_task'
|
|
7
|
+
require 'spree/testing_support/extension_rake'
|
|
8
|
+
|
|
9
|
+
RSpec::Core::RakeTask.new
|
|
10
|
+
|
|
11
|
+
task :default do
|
|
12
|
+
if Dir['spec/dummy'].empty?
|
|
13
|
+
Rake::Task[:test_app].invoke
|
|
14
|
+
Dir.chdir('../../')
|
|
15
|
+
end
|
|
16
|
+
Rake::Task[:spec].invoke
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
desc 'Generates a dummy app for testing'
|
|
20
|
+
task :test_app do
|
|
21
|
+
ENV['LIB_NAME'] = 'spree_legacy_api_v2'
|
|
22
|
+
Rake::Task['extension:test_app'].invoke
|
|
23
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module Api
|
|
3
|
+
module V2
|
|
4
|
+
module Caching
|
|
5
|
+
extend ActiveSupport::Concern
|
|
6
|
+
|
|
7
|
+
def collection_cache_key(collection)
|
|
8
|
+
params.delete(:page) if params[:page] == 1
|
|
9
|
+
|
|
10
|
+
cache_key_parts = [
|
|
11
|
+
collection.cache_key_with_version,
|
|
12
|
+
resource_includes,
|
|
13
|
+
sparse_fields,
|
|
14
|
+
serializer_params_cache_key,
|
|
15
|
+
params[:sort]&.strip,
|
|
16
|
+
params[:page]&.to_s&.strip,
|
|
17
|
+
params[:per_page]&.to_s&.strip,
|
|
18
|
+
]
|
|
19
|
+
cache_key_parts += additional_cache_key_parts if defined?(additional_cache_key_parts)
|
|
20
|
+
cache_key_parts = cache_key_parts.flatten.join('-')
|
|
21
|
+
|
|
22
|
+
Digest::MD5.hexdigest(cache_key_parts)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def collection_cache_opts
|
|
26
|
+
{
|
|
27
|
+
namespace: Spree::Api::Config[:api_v2_collection_cache_namespace],
|
|
28
|
+
expires_in: Spree::Api::Config[:api_v2_collection_cache_ttl],
|
|
29
|
+
}
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def serializer_params_cache_key
|
|
33
|
+
serializer_params.values.map do |param|
|
|
34
|
+
param.try(:cache_key) || param.try(:flatten).try(:join, '-') || param.try(:to_s)
|
|
35
|
+
end.compact.join('-')
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
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,21 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module Api
|
|
3
|
+
module V2
|
|
4
|
+
# These includes are not picked automatically by ar_lazy_preload gem so we need to specify them manually.
|
|
5
|
+
module ProductListIncludes
|
|
6
|
+
def product_list_includes
|
|
7
|
+
{
|
|
8
|
+
option_types: [],
|
|
9
|
+
product_properties: [],
|
|
10
|
+
metafields: [],
|
|
11
|
+
variant_images: [],
|
|
12
|
+
tags: [],
|
|
13
|
+
taxons: [:taxonomy],
|
|
14
|
+
master: [:prices, :images, { stock_items: :stock_location }, metafields: [], option_values: []],
|
|
15
|
+
variants: [:prices, :images, { stock_items: :stock_location }, metafields: [], option_values: []]
|
|
16
|
+
}
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
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,49 @@
|
|
|
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&.value || result.value)
|
|
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.storefront_current_order_finder.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
|
+
Spree::Deprecation.warn('OrderConcern#serialize_order is deprecated and will be removed in Spree 5.5. Please use `serialize_resource` method')
|
|
43
|
+
serialize_resource(order)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module Admin
|
|
3
|
+
class OauthApplicationsController < ResourceController
|
|
4
|
+
include Spree::Admin::SettingsConcern
|
|
5
|
+
|
|
6
|
+
before_action :set_default_scopes, only: [:new, :edit]
|
|
7
|
+
|
|
8
|
+
private
|
|
9
|
+
|
|
10
|
+
def create_turbo_stream_enabled?
|
|
11
|
+
true
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def set_default_scopes
|
|
15
|
+
@object.scopes = 'admin' if @object.scopes.blank?
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def permitted_resource_params
|
|
19
|
+
params.require(:oauth_application).permit(:name, :scopes)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module Api
|
|
3
|
+
module V2
|
|
4
|
+
class BaseController < ActionController::API
|
|
5
|
+
include ActiveStorage::SetCurrent
|
|
6
|
+
include CanCan::ControllerAdditions
|
|
7
|
+
include Spree::Core::ControllerHelpers::StrongParameters
|
|
8
|
+
include Spree::Core::ControllerHelpers::Store
|
|
9
|
+
include Spree::Core::ControllerHelpers::Locale
|
|
10
|
+
include Spree::Core::ControllerHelpers::Currency
|
|
11
|
+
|
|
12
|
+
rescue_from ActiveRecord::RecordNotFound, with: :record_not_found
|
|
13
|
+
rescue_from CanCan::AccessDenied, with: :access_denied
|
|
14
|
+
rescue_from Doorkeeper::Errors::DoorkeeperError, with: :access_denied_401
|
|
15
|
+
rescue_from Spree::Core::GatewayError, with: :gateway_error
|
|
16
|
+
rescue_from ActionController::ParameterMissing, with: :error_during_processing
|
|
17
|
+
if defined?(JSONAPI::Serializer::UnsupportedIncludeError)
|
|
18
|
+
rescue_from JSONAPI::Serializer::UnsupportedIncludeError, with: :error_during_processing
|
|
19
|
+
end
|
|
20
|
+
rescue_from ArgumentError, with: :error_during_processing
|
|
21
|
+
rescue_from ActionDispatch::Http::Parameters::ParseError, with: :error_during_processing
|
|
22
|
+
|
|
23
|
+
# Returns the content type for the API
|
|
24
|
+
# @return [String] The content type, eg 'application/vnd.api+json'
|
|
25
|
+
def content_type
|
|
26
|
+
Spree::Api::Config[:api_v2_content_type]
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
protected
|
|
30
|
+
|
|
31
|
+
def serialize_collection(collection)
|
|
32
|
+
collection_serializer.new(
|
|
33
|
+
collection,
|
|
34
|
+
collection_options(collection).merge(params: serializer_params)
|
|
35
|
+
).serializable_hash
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def serialize_resource(resource)
|
|
39
|
+
resource_serializer.new(
|
|
40
|
+
resource,
|
|
41
|
+
params: serializer_params,
|
|
42
|
+
include: resource_includes,
|
|
43
|
+
fields: sparse_fields
|
|
44
|
+
).serializable_hash
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Returns a paginated collection
|
|
48
|
+
# @return [Array] The paginated collection
|
|
49
|
+
def paginated_collection
|
|
50
|
+
@paginated_collection ||= collection_paginator.new(sorted_collection, params).call
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# Returns the collection paginator
|
|
54
|
+
# @return [Class] The collection paginator class, default is Spree::Shared::Paginate
|
|
55
|
+
def collection_paginator
|
|
56
|
+
Spree.api.storefront_collection_paginator
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# Renders a serialized payload with the given status code
|
|
60
|
+
# @param status [Integer] HTTP status code to return, eg 200, 201, 204
|
|
61
|
+
# @yield [Hash] The serialized data to render
|
|
62
|
+
def render_serialized_payload(status = 200)
|
|
63
|
+
render json: yield, status: status, content_type: content_type
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# Renders a serialized error payload with the given status code
|
|
67
|
+
# @param status [Integer] HTTP status code to return
|
|
68
|
+
# @yield [Hash] The serialized data to render
|
|
69
|
+
def render_error_payload(error, status = 422)
|
|
70
|
+
json = if error.is_a?(ActiveModel::Errors)
|
|
71
|
+
{ error: error.full_messages.to_sentence, errors: error.messages }
|
|
72
|
+
elsif error.is_a?(Struct)
|
|
73
|
+
{ error: error.to_s, errors: error.to_h }
|
|
74
|
+
else
|
|
75
|
+
{ error: error }
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
render json: json, status: status, content_type: content_type
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# Renders a serialized result payload with the given status code
|
|
82
|
+
# @param result [Object] The result to render
|
|
83
|
+
# @param ok_status [Integer] HTTP status code to return if the result is successful, eg 200, 201, 204
|
|
84
|
+
def render_result(result, ok_status = 200)
|
|
85
|
+
if result.success?
|
|
86
|
+
render_serialized_payload(ok_status) { serialize_resource(result.value) }
|
|
87
|
+
else
|
|
88
|
+
render_error_payload(result.error)
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# Returns the current Spree user
|
|
93
|
+
# @return [Spree.user_class] The current Spree user
|
|
94
|
+
def spree_current_user
|
|
95
|
+
return nil unless doorkeeper_token
|
|
96
|
+
return @spree_current_user if defined?(@spree_current_user)
|
|
97
|
+
|
|
98
|
+
@spree_current_user ||= ActiveRecord::Base.connected_to(role: :writing) do
|
|
99
|
+
doorkeeper_authorize!
|
|
100
|
+
doorkeeper_token.resource_owner
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
alias try_spree_current_user spree_current_user # for compatibility with spree_legacy_frontend
|
|
105
|
+
|
|
106
|
+
# Authorizes the current Spree user for the given action and subject
|
|
107
|
+
# @param action [Symbol] The action to authorize
|
|
108
|
+
# @param subject [Object] The subject to authorize
|
|
109
|
+
# @param args [Array] Additional arguments to pass to the authorize! method
|
|
110
|
+
# @return [void]
|
|
111
|
+
def spree_authorize!(action, subject, *args)
|
|
112
|
+
authorize!(action, subject, *args)
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
# Raises an AccessDenied error if the current Spree user is nil
|
|
116
|
+
# @raise [CanCan::AccessDenied] If the current Spree user is nil
|
|
117
|
+
def require_spree_current_user
|
|
118
|
+
raise CanCan::AccessDenied if spree_current_user.nil?
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
# Needs to be overridden so that we use Spree's Ability rather than anyone else's.
|
|
122
|
+
def current_ability
|
|
123
|
+
@current_ability ||= Spree.ability_class.new(spree_current_user, ability_options)
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
# this method can be extended in extensions or developer applications
|
|
127
|
+
# @return [Hash] The ability options
|
|
128
|
+
def ability_options
|
|
129
|
+
{ store: current_store }
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
# Returns the requested includes
|
|
133
|
+
# @return [Array] The requested includes
|
|
134
|
+
def request_includes
|
|
135
|
+
# if API user wants to receive only the bare-minimum
|
|
136
|
+
# the API will return only the main resource without any included
|
|
137
|
+
if params[:include]&.blank?
|
|
138
|
+
[]
|
|
139
|
+
elsif params[:include].present?
|
|
140
|
+
params[:include].split(',')
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
# Returns the resource includes, useful to avoid N+1 queries
|
|
145
|
+
# @return [Array] The resource includes, eg [:images, :variants]
|
|
146
|
+
def resource_includes
|
|
147
|
+
(request_includes || default_resource_includes).map(&:intern)
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
# overwrite this method in your controllers to set JSON API default include value
|
|
151
|
+
# https://jsonapi.org/format/#fetching-includes
|
|
152
|
+
# eg.:
|
|
153
|
+
# %w[images variants]
|
|
154
|
+
# ['variant.images', 'line_items']
|
|
155
|
+
def default_resource_includes
|
|
156
|
+
[]
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
# Returns the JSON API sparse fields
|
|
160
|
+
# @return [Hash] The sparse fields, eg { product: [:name, :description] }
|
|
161
|
+
def sparse_fields
|
|
162
|
+
return unless params[:fields]&.respond_to?(:each)
|
|
163
|
+
|
|
164
|
+
fields = {}
|
|
165
|
+
params[:fields].
|
|
166
|
+
select { |_, v| v.is_a?(String) }.
|
|
167
|
+
each { |type, values| fields[type.intern] = values.split(',').map(&:intern) }
|
|
168
|
+
fields.presence
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
# Returns the serializer global params
|
|
172
|
+
# all of these params are passed down to the serializer
|
|
173
|
+
# @return [Hash] The serializer params
|
|
174
|
+
def serializer_params
|
|
175
|
+
{
|
|
176
|
+
currency: current_currency,
|
|
177
|
+
locale: current_locale,
|
|
178
|
+
price_options: current_price_options,
|
|
179
|
+
store: current_store,
|
|
180
|
+
user: spree_current_user,
|
|
181
|
+
image_transformation: params[:image_transformation],
|
|
182
|
+
taxon_image_transformation: params[:taxon_image_transformation]
|
|
183
|
+
}
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
# Renders a 404 error payload
|
|
187
|
+
# @param exception [Exception] The exception to render
|
|
188
|
+
# @return [void]
|
|
189
|
+
def record_not_found(exception)
|
|
190
|
+
Rails.error.report(exception, context: { user_id: spree_current_user&.id }, source: 'spree.api')
|
|
191
|
+
|
|
192
|
+
render_error_payload(I18n.t(:resource_not_found, scope: 'spree.api'), 404)
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
# Renders a 403 error payload
|
|
196
|
+
# @param exception [Exception] The exception to render
|
|
197
|
+
# @return [void]
|
|
198
|
+
def access_denied(exception)
|
|
199
|
+
Rails.error.report(exception, context: { user_id: spree_current_user&.id }, source: 'spree.api')
|
|
200
|
+
|
|
201
|
+
render_error_payload(exception.message, 403)
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
# Renders a 401 error payload
|
|
205
|
+
# @param exception [Exception] The exception to render
|
|
206
|
+
# @return [void]
|
|
207
|
+
def access_denied_401(exception)
|
|
208
|
+
render_error_payload(exception.message, 401)
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
# Renders a 500 error payload when a payment gateway error occurs
|
|
212
|
+
# @param exception [Exception] The exception to render
|
|
213
|
+
# @return [void]
|
|
214
|
+
def gateway_error(exception)
|
|
215
|
+
Rails.error.report(exception, context: { user_id: spree_current_user&.id }, source: 'spree.api')
|
|
216
|
+
|
|
217
|
+
render_error_payload(exception.message)
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
# Renders a 400 error payload when an error occurs during parameter parsing
|
|
221
|
+
# @param exception [Exception] The exception to render
|
|
222
|
+
# @return [void]
|
|
223
|
+
def error_during_processing(exception)
|
|
224
|
+
Rails.error.report(exception, context: { user_id: spree_current_user&.id }, source: 'spree.api')
|
|
225
|
+
|
|
226
|
+
message = exception.respond_to?(:original_message) ? exception.original_message : exception.message
|
|
227
|
+
|
|
228
|
+
render_error_payload(message, 400)
|
|
229
|
+
end
|
|
230
|
+
end
|
|
231
|
+
end
|
|
232
|
+
end
|
|
233
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module Api
|
|
3
|
+
module V2
|
|
4
|
+
module DataFeeds
|
|
5
|
+
class GoogleController < ::Spree::Api::V2::BaseController
|
|
6
|
+
def rss_feed
|
|
7
|
+
send_data data_feeds_google_rss_service.value[:file], filename: 'products.rss', type: 'text/xml'
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
private
|
|
11
|
+
|
|
12
|
+
def settings
|
|
13
|
+
@settings ||= Spree::DataFeed::Google.find_by!(store: current_store, slug: params[:slug], active: true)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def data_feeds_google_rss_service
|
|
17
|
+
Spree.data_feeds_google_rss_service.new.call(settings)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
|
|
16
|
+
def resource_serializer
|
|
17
|
+
Spree.api.platform_address_serializer
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
|
|
16
|
+
def resource_serializer
|
|
17
|
+
Spree.api.platform_adjustment_serializer
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
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, :master, { variants: [:prices] }]
|
|
16
|
+
]
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def resource_serializer
|
|
20
|
+
Spree.api.platform_classification_serializer
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|