spree_api 4.2.4 → 4.3.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +14 -1
  3. data/app/controllers/concerns/spree/api/v2/caching.rb +33 -0
  4. data/app/controllers/concerns/spree/api/v2/product_list_includes.rb +23 -0
  5. data/app/controllers/spree/api/v1/classifications_controller.rb +4 -3
  6. data/app/controllers/spree/api/v1/orders_controller.rb +5 -1
  7. data/app/controllers/spree/api/v1/products_controller.rb +2 -2
  8. data/app/controllers/spree/api/v1/taxonomies_controller.rb +1 -1
  9. data/app/controllers/spree/api/v2/base_controller.rb +31 -6
  10. data/app/controllers/spree/api/v2/platform/addresses_controller.rb +19 -0
  11. data/app/controllers/spree/api/v2/platform/classifications_controller.rb +43 -0
  12. data/app/controllers/spree/api/v2/platform/cms_pages_controller.rb +15 -0
  13. data/app/controllers/spree/api/v2/platform/cms_sections_controller.rb +34 -0
  14. data/app/controllers/spree/api/v2/platform/countries_controller.rb +19 -0
  15. data/app/controllers/spree/api/v2/platform/menu_items_controller.rb +35 -0
  16. data/app/controllers/spree/api/v2/platform/menus_controller.rb +23 -0
  17. data/app/controllers/spree/api/v2/platform/option_types_controller.rb +15 -0
  18. data/app/controllers/spree/api/v2/platform/option_values_controller.rb +19 -0
  19. data/app/controllers/spree/api/v2/platform/products_controller.rb +33 -0
  20. data/app/controllers/spree/api/v2/platform/resource_controller.rb +115 -0
  21. data/app/controllers/spree/api/v2/platform/taxons_controller.rb +30 -0
  22. data/app/controllers/spree/api/v2/platform/users_controller.rb +28 -0
  23. data/app/controllers/spree/api/v2/resource_controller.rb +24 -7
  24. data/app/controllers/spree/api/v2/storefront/account/addresses_controller.rb +2 -14
  25. data/app/controllers/spree/api/v2/storefront/account/credit_cards_controller.rb +13 -11
  26. data/app/controllers/spree/api/v2/storefront/account/orders_controller.rb +6 -2
  27. data/app/controllers/spree/api/v2/storefront/account_controller.rb +32 -1
  28. data/app/controllers/spree/api/v2/storefront/cart_controller.rb +28 -6
  29. data/app/controllers/spree/api/v2/storefront/checkout_controller.rb +2 -1
  30. data/app/controllers/spree/api/v2/storefront/cms_pages_controller.rb +41 -0
  31. data/app/controllers/spree/api/v2/storefront/countries_controller.rb +16 -14
  32. data/app/controllers/spree/api/v2/storefront/menus_controller.rb +35 -0
  33. data/app/controllers/spree/api/v2/storefront/order_status_controller.rb +1 -1
  34. data/app/controllers/spree/api/v2/storefront/products_controller.rb +10 -12
  35. data/app/controllers/spree/api/v2/storefront/stores_controller.rb +1 -1
  36. data/app/controllers/spree/api/v2/storefront/taxons_controller.rb +7 -8
  37. data/app/helpers/spree/api/v2/display_money_helper.rb +2 -2
  38. data/app/models/spree/api_configuration.rb +4 -1
  39. data/app/models/spree/api_dependencies.rb +20 -5
  40. data/app/serializers/concerns/spree/api/v2/image_transformation_concern.rb +15 -0
  41. data/app/serializers/concerns/spree/api/v2/resource_serializer_concern.rb +16 -0
  42. data/app/serializers/concerns/spree/api/v2/taxon_image_transformation_concern.rb +15 -0
  43. data/app/serializers/spree/api/v2/base_serializer.rb +32 -0
  44. data/app/serializers/spree/api/v2/platform/address_serializer.rb +15 -0
  45. data/app/serializers/spree/api/v2/platform/base_serializer.rb +10 -0
  46. data/app/serializers/spree/api/v2/platform/classification_serializer.rb +14 -0
  47. data/app/serializers/spree/api/v2/platform/cms_page_serializer.rb +13 -0
  48. data/app/serializers/spree/api/v2/platform/cms_section_serializer.rb +11 -0
  49. data/app/serializers/spree/api/v2/platform/country_serializer.rb +13 -0
  50. data/app/serializers/spree/api/v2/platform/icon_serializer.rb +16 -0
  51. data/app/serializers/spree/api/v2/platform/image_serializer.rb +17 -0
  52. data/app/serializers/spree/api/v2/platform/menu_item_serializer.rb +45 -0
  53. data/app/serializers/spree/api/v2/platform/menu_serializer.rb +13 -0
  54. data/app/serializers/spree/api/v2/platform/option_type_serializer.rb +13 -0
  55. data/app/serializers/spree/api/v2/platform/option_value_serializer.rb +13 -0
  56. data/app/serializers/spree/api/v2/platform/product_property_serializer.rb +11 -0
  57. data/app/serializers/spree/api/v2/platform/product_serializer.rb +78 -0
  58. data/app/serializers/spree/api/v2/platform/state_serializer.rb +13 -0
  59. data/app/serializers/spree/api/v2/platform/stock_item_serializer.rb +20 -0
  60. data/app/serializers/spree/api/v2/platform/stock_location_serializer.rb +16 -0
  61. data/app/serializers/spree/api/v2/platform/store_serializer.rb +14 -0
  62. data/app/serializers/spree/api/v2/platform/tax_category_serializer.rb +13 -0
  63. data/app/serializers/spree/api/v2/platform/taxon_image_serializer.rb +15 -0
  64. data/app/serializers/spree/api/v2/platform/taxon_serializer.rb +38 -0
  65. data/app/serializers/spree/api/v2/platform/taxonomy_serializer.rb +14 -0
  66. data/app/serializers/spree/api/v2/platform/user_serializer.rb +37 -0
  67. data/app/serializers/spree/api/v2/platform/variant_serializer.rb +57 -0
  68. data/app/serializers/spree/v2/storefront/base_serializer.rb +3 -2
  69. data/app/serializers/spree/v2/storefront/cms_page_serializer.rb +14 -0
  70. data/app/serializers/spree/v2/storefront/cms_section_serializer.rb +28 -0
  71. data/app/serializers/spree/v2/storefront/country_serializer.rb +4 -4
  72. data/app/serializers/spree/v2/storefront/estimated_shipping_rate_serializer.rb +2 -0
  73. data/app/serializers/spree/v2/storefront/icon_serializer.rb +14 -0
  74. data/app/serializers/spree/v2/storefront/image_serializer.rb +3 -1
  75. data/app/serializers/spree/v2/storefront/menu_item_serializer.rb +43 -0
  76. data/app/serializers/spree/v2/storefront/menu_serializer.rb +13 -0
  77. data/app/serializers/spree/v2/storefront/payment_method_serializer.rb +4 -0
  78. data/app/serializers/spree/v2/storefront/product_property_serializer.rb +1 -1
  79. data/app/serializers/spree/v2/storefront/product_serializer.rb +21 -12
  80. data/app/serializers/spree/v2/storefront/store_serializer.rb +10 -0
  81. data/app/serializers/spree/v2/storefront/taxon_image_serializer.rb +3 -1
  82. data/app/serializers/spree/v2/storefront/taxon_serializer.rb +6 -5
  83. data/config/initializers/doorkeeper.rb +8 -1
  84. data/config/initializers/rabl.rb +9 -0
  85. data/config/locales/en.yml +1 -1
  86. data/config/routes.rb +115 -3
  87. data/db/migrate/20210727102516_change_integer_id_columns_type.rb +9 -0
  88. data/docs/oauth/index.yml +4 -4
  89. data/docs/v2/platform/index.yaml +3597 -0
  90. data/docs/v2/storefront/index.yaml +12117 -1610
  91. data/lib/spree/api/engine.rb +6 -17
  92. data/lib/spree/api/testing_support/v2/base.rb +1 -1
  93. data/lib/spree/api/testing_support/v2/platform_contexts.rb +214 -0
  94. data/lib/spree/api/testing_support/v2/serializers_params.rb +14 -0
  95. data/lib/spree/api.rb +1 -0
  96. data/spree_api.gemspec +6 -3
  97. metadata +114 -13
  98. data/app/assets/javascripts/spree/api/main.js +0 -36
  99. data/app/assets/javascripts/spree/api/storefront/cart.js +0 -49
@@ -50,11 +50,25 @@ module Spree
50
50
  def empty
51
51
  spree_authorize! :update, spree_current_order, order_token
52
52
 
53
- # TODO: we should extract this logic into service and let
54
- # developers overwrite it
55
- spree_current_order.empty!
53
+ result = empty_cart_service.call(order: spree_current_order)
56
54
 
57
- render_serialized_payload { serialized_current_order }
55
+ if result.success?
56
+ render_serialized_payload { serialized_current_order }
57
+ else
58
+ render_error_payload(result.error)
59
+ end
60
+ end
61
+
62
+ def destroy
63
+ spree_authorize! :update, spree_current_order, order_token
64
+
65
+ result = destroy_cart_service.call(order: spree_current_order)
66
+
67
+ if result.success?
68
+ head 204
69
+ else
70
+ render_error_payload(result.error)
71
+ end
58
72
  end
59
73
 
60
74
  def set_quantity
@@ -128,6 +142,14 @@ module Spree
128
142
  Spree::Api::Dependencies.storefront_cart_add_item_service.constantize
129
143
  end
130
144
 
145
+ def empty_cart_service
146
+ Spree::Api::Dependencies.storefront_cart_empty_service.constantize
147
+ end
148
+
149
+ def destroy_cart_service
150
+ Spree::Api::Dependencies.storefront_cart_destroy_service.constantize
151
+ end
152
+
131
153
  def set_item_quantity_service
132
154
  Spree::Api::Dependencies.storefront_cart_set_item_quantity_service.constantize
133
155
  end
@@ -149,7 +171,7 @@ module Spree
149
171
  end
150
172
 
151
173
  def load_variant
152
- @variant = Spree::Variant.find(params[:variant_id])
174
+ @variant = current_store.variants.find(params[:variant_id])
153
175
  end
154
176
 
155
177
  def render_error_item_quantity
@@ -163,7 +185,7 @@ module Spree
163
185
  def serialize_estimated_shipping_rates(shipping_rates)
164
186
  estimate_shipping_rates_serializer.new(
165
187
  shipping_rates,
166
- params: { currency: spree_current_order.currency }
188
+ params: serializer_params
167
189
  ).serializable_hash
168
190
  end
169
191
 
@@ -119,12 +119,13 @@ module Spree
119
119
  end
120
120
 
121
121
  def serialize_payment_methods(payment_methods)
122
- payment_methods_serializer.new(payment_methods).serializable_hash
122
+ payment_methods_serializer.new(payment_methods, params: serializer_params).serializable_hash
123
123
  end
124
124
 
125
125
  def serialize_shipping_rates(shipments)
126
126
  shipping_rates_serializer.new(
127
127
  shipments,
128
+ params: serializer_params,
128
129
  include: [:shipping_rates, :stock_location]
129
130
  ).serializable_hash
130
131
  end
@@ -0,0 +1,41 @@
1
+ module Spree
2
+ module Api
3
+ module V2
4
+ module Storefront
5
+ class CmsPagesController < ::Spree::Api::V2::ResourceController
6
+ private
7
+
8
+ def model_class
9
+ Spree::CmsPage
10
+ end
11
+
12
+ def resource
13
+ @resource ||= scope.find_by(slug: params[:id]) || scope.find(params[:id])
14
+ end
15
+
16
+ def resource_serializer
17
+ Spree::Api::Dependencies.storefront_cms_page_serializer.constantize
18
+ end
19
+
20
+ def collection_serializer
21
+ Spree::Api::Dependencies.storefront_cms_page_serializer.constantize
22
+ end
23
+
24
+ def collection_finder
25
+ Spree::Api::Dependencies.storefront_cms_page_finder.constantize
26
+ end
27
+
28
+ def scope
29
+ super.by_locale(I18n.locale)
30
+ end
31
+
32
+ def scope_includes
33
+ {
34
+ cms_sections: :linked_resource
35
+ }
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -3,30 +3,27 @@ module Spree
3
3
  module V2
4
4
  module Storefront
5
5
  class CountriesController < ::Spree::Api::V2::ResourceController
6
+ before_action :set_default_per_page
7
+
6
8
  private
7
9
 
8
10
  def serialize_collection(collection)
9
- collection_serializer.new(collection).serializable_hash
11
+ collection_serializer.new(
12
+ collection,
13
+ collection_options(collection).merge(params: collection_serializer_params)
14
+ ).serializable_hash
10
15
  end
11
16
 
12
- def serialize_resource(resource)
13
- resource_serializer.new(
14
- resource,
15
- include: resource_includes,
16
- fields: sparse_fields,
17
- params: resource_serializer_params
18
- ).serializable_hash
17
+ def serializer_params
18
+ super.merge(include_states: true)
19
19
  end
20
20
 
21
- def resource_serializer_params
22
- {
23
- include_states: true,
24
- current_store: current_store
25
- }
21
+ def collection_serializer_params
22
+ serializer_params.merge(include_states: false)
26
23
  end
27
24
 
28
25
  def resource
29
- return scope.default if params[:iso] == 'default'
26
+ return current_store.default_country if params[:iso] == 'default'
30
27
 
31
28
  scope.find_by(iso: params[:iso]&.upcase) ||
32
29
  scope.find_by(id: params[:iso]&.upcase) ||
@@ -48,6 +45,11 @@ module Spree
48
45
  def model_class
49
46
  Spree::Country
50
47
  end
48
+
49
+ # by default we want to return all countries on a single page
50
+ def set_default_per_page
51
+ params[:per_page] ||= Spree::Country.count
52
+ end
51
53
  end
52
54
  end
53
55
  end
@@ -0,0 +1,35 @@
1
+ module Spree
2
+ module Api
3
+ module V2
4
+ module Storefront
5
+ class MenusController < ::Spree::Api::V2::ResourceController
6
+ private
7
+
8
+ def resource_serializer
9
+ Spree::Api::Dependencies.storefront_menu_serializer.constantize
10
+ end
11
+
12
+ def collection_serializer
13
+ Spree::Api::Dependencies.storefront_menu_serializer.constantize
14
+ end
15
+
16
+ def collection_finder
17
+ Spree::Api::Dependencies.storefront_menu_finder.constantize
18
+ end
19
+
20
+ def model_class
21
+ Spree::Menu
22
+ end
23
+
24
+ def scope
25
+ super.by_locale(I18n.locale)
26
+ end
27
+
28
+ def scope_includes
29
+ { menu_items: [:children, :parent, :icon] }
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -10,7 +10,7 @@ module Spree
10
10
  private
11
11
 
12
12
  def resource
13
- resource = resource_finder.new(number: params[:number], token: order_token).execute.take
13
+ resource = resource_finder.new(number: params[:number], token: order_token, store: current_store).execute.take
14
14
  raise ActiveRecord::RecordNotFound if resource.nil?
15
15
 
16
16
  resource
@@ -3,18 +3,20 @@ module Spree
3
3
  module V2
4
4
  module Storefront
5
5
  class ProductsController < ::Spree::Api::V2::ResourceController
6
- private
6
+ include ::Spree::Api::V2::ProductListIncludes
7
+
8
+ protected
7
9
 
8
10
  def sorted_collection
9
11
  collection_sorter.new(collection, current_currency, params, allowed_sort_attributes).call
10
12
  end
11
13
 
12
14
  def collection
13
- collection_finder.new(scope: scope, params: params, current_currency: current_currency).execute
15
+ @collection ||= collection_finder.new(scope: scope, params: finder_params).execute
14
16
  end
15
17
 
16
18
  def resource
17
- scope.find_by(slug: params[:id]) || scope.find(params[:id])
19
+ @resource ||= scope.find_by(slug: params[:id]) || scope.find(params[:id])
18
20
  end
19
21
 
20
22
  def collection_sorter
@@ -38,15 +40,11 @@ module Spree
38
40
  end
39
41
 
40
42
  def scope_includes
41
- {
42
- master: :default_price,
43
- variants: [],
44
- variant_images: [],
45
- taxons: [],
46
- product_properties: :property,
47
- option_types: :option_values,
48
- variants_including_master: %i[default_price option_values]
49
- }
43
+ product_list_includes
44
+ end
45
+
46
+ def allowed_sort_attributes
47
+ super << :available_on
50
48
  end
51
49
  end
52
50
  end
@@ -10,7 +10,7 @@ module Spree
10
10
  end
11
11
 
12
12
  def resource
13
- scope.find_by!(code: params[:code])
13
+ @resource ||= scope.find_by!(code: params[:code])
14
14
  end
15
15
 
16
16
  def resource_serializer
@@ -18,15 +18,11 @@ module Spree
18
18
  end
19
19
 
20
20
  def paginated_collection
21
- collection_paginator.new(collection, params).call
22
- end
23
-
24
- def collection
25
- collection_finder.new(scope: scope, params: params).execute
21
+ @paginated_collection ||= collection_paginator.new(collection, params).call
26
22
  end
27
23
 
28
24
  def resource
29
- scope.find_by(permalink: params[:id]) || scope.find(params[:id])
25
+ @resource ||= scope.find_by(permalink: params[:id]) || scope.find(params[:id])
30
26
  end
31
27
 
32
28
  def model_class
@@ -34,16 +30,19 @@ module Spree
34
30
  end
35
31
 
36
32
  def scope_includes
37
- node_includes = %i[icon products parent taxonomy]
33
+ node_includes = %i[icon parent taxonomy]
38
34
 
39
35
  {
40
36
  parent: node_includes,
41
37
  children: node_includes,
42
38
  taxonomy: [root: node_includes],
43
- products: [],
44
39
  icon: [attachment_attachment: :blob]
45
40
  }
46
41
  end
42
+
43
+ def serializer_params
44
+ super.merge(include_products: action_name == 'show')
45
+ end
47
46
  end
48
47
  end
49
48
  end
@@ -13,7 +13,7 @@ module Spree
13
13
  price = find_price(product_or_variant, currency)
14
14
  return nil if price.new_record?
15
15
 
16
- format('%.2f', price.amount)
16
+ price.amount
17
17
  end
18
18
 
19
19
  def display_price(product_or_variant, currency)
@@ -27,7 +27,7 @@ module Spree
27
27
  price = find_price(product_or_variant, currency)
28
28
  return nil if price.new_record? || price.compare_at_amount.blank?
29
29
 
30
- format('%.2f', price.compare_at_amount)
30
+ price.compare_at_amount
31
31
  end
32
32
 
33
33
  def display_compare_at_price(product_or_variant, currency)
@@ -1,7 +1,10 @@
1
1
  module Spree
2
2
  class ApiConfiguration < Preferences::Configuration
3
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'
4
7
  preference :api_v2_content_type, :string, default: 'application/vnd.api+json'
5
- preference :api_v2_per_page_limit, :integer, default: 100
8
+ preference :api_v2_per_page_limit, :integer, default: 500
6
9
  end
7
10
  end
@@ -5,18 +5,21 @@ module Spree
5
5
  INJECTION_POINTS = [
6
6
  :storefront_cart_create_service, :storefront_cart_add_item_service, :storefront_cart_remove_line_item_service,
7
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,
8
9
  :storefront_cart_update, :storefront_coupon_handler, :storefront_checkout_next_service, :storefront_checkout_advance_service,
9
10
  :storefront_checkout_update_service, :storefront_checkout_complete_service, :storefront_checkout_add_store_credit_service,
10
11
  :storefront_checkout_remove_store_credit_service, :storefront_checkout_get_shipping_rates_service,
11
12
  :storefront_cart_compare_line_items_service, :storefront_cart_serializer, :storefront_credit_card_serializer,
12
13
  :storefront_credit_card_finder, :storefront_shipment_serializer, :storefront_payment_method_serializer, :storefront_country_finder,
13
- :storefront_country_serializer, :storefront_current_order_finder, :storefront_completed_order_finder, :storefront_order_sorter,
14
- :storefront_collection_paginator, :storefront_user_serializer, :storefront_products_sorter, :storefront_products_finder,
15
- :storefront_product_serializer, :storefront_taxon_serializer, :storefront_taxon_finder, :storefront_find_by_variant_finder,
16
- :storefront_cart_update_service, :storefront_cart_estimate_shipping_rates_service, :storefront_estimated_shipment_serializer,
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,
18
+ :storefront_cart_estimate_shipping_rates_service, :storefront_estimated_shipment_serializer,
17
19
  :storefront_store_serializer, :storefront_address_serializer, :storefront_order_serializer,
18
20
  :storefront_account_create_address_service, :storefront_account_update_address_service, :storefront_address_finder,
19
- :storefront_collection_sorter, :error_handler
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
20
23
  ].freeze
21
24
 
22
25
  attr_accessor *INJECTION_POINTS
@@ -38,6 +41,8 @@ module Spree
38
41
  @storefront_cart_set_item_quantity_service = Spree::Dependencies.cart_set_item_quantity_service
39
42
  @storefront_cart_recalculate_service = Spree::Dependencies.cart_recalculate_service
40
43
  @storefront_cart_estimate_shipping_rates_service = Spree::Dependencies.cart_estimate_shipping_rates_service
44
+ @storefront_cart_empty_service = Spree::Dependencies.cart_empty_service
45
+ @storefront_cart_destroy_service = Spree::Dependencies.cart_destroy_service
41
46
 
42
47
  # coupon code handler
43
48
  @storefront_coupon_handler = Spree::Dependencies.coupon_handler
@@ -52,14 +57,21 @@ module Spree
52
57
  @storefront_checkout_get_shipping_rates_service = Spree::Dependencies.checkout_get_shipping_rates_service
53
58
 
54
59
  # account services
60
+ @storefront_account_create_service = Spree::Dependencies.account_create_service
61
+ @storefront_account_update_service = Spree::Dependencies.account_update_service
55
62
  @storefront_account_create_address_service = Spree::Dependencies.account_create_address_service
56
63
  @storefront_account_update_address_service = Spree::Dependencies.account_update_address_service
57
64
 
65
+ # credit cards
66
+ @storefront_credit_cards_destroy_service = Spree::Dependencies.credit_cards_destroy_service
67
+
58
68
  # serializers
59
69
  @storefront_address_serializer = 'Spree::V2::Storefront::AddressSerializer'
60
70
  @storefront_cart_serializer = 'Spree::V2::Storefront::CartSerializer'
71
+ @storefront_cms_page_serializer = 'Spree::V2::Storefront::CmsPageSerializer'
61
72
  @storefront_credit_card_serializer = 'Spree::V2::Storefront::CreditCardSerializer'
62
73
  @storefront_country_serializer = 'Spree::V2::Storefront::CountrySerializer'
74
+ @storefront_menu_serializer = 'Spree::V2::Storefront::MenuSerializer'
63
75
  @storefront_user_serializer = 'Spree::V2::Storefront::UserSerializer'
64
76
  @storefront_shipment_serializer = 'Spree::V2::Storefront::ShipmentSerializer'
65
77
  @storefront_taxon_serializer = 'Spree::V2::Storefront::TaxonSerializer'
@@ -73,6 +85,7 @@ module Spree
73
85
  @storefront_collection_sorter = Spree::Dependencies.collection_sorter
74
86
  @storefront_order_sorter = Spree::Dependencies.collection_sorter
75
87
  @storefront_products_sorter = Spree::Dependencies.products_sorter
88
+ @platform_products_sorter = Spree::Dependencies.products_sorter
76
89
 
77
90
  # paginators
78
91
  @storefront_collection_paginator = Spree::Dependencies.collection_paginator
@@ -80,6 +93,8 @@ module Spree
80
93
  # finders
81
94
  @storefront_address_finder = Spree::Dependencies.address_finder
82
95
  @storefront_country_finder = Spree::Dependencies.country_finder
96
+ @storefront_cms_page_finder = Spree::Dependencies.cms_page_finder
97
+ @storefront_menu_finder = Spree::Dependencies.menu_finder
83
98
  @storefront_current_order_finder = Spree::Dependencies.current_order_finder
84
99
  @storefront_completed_order_finder = Spree::Dependencies.completed_order_finder
85
100
  @storefront_credit_card_finder = Spree::Dependencies.credit_card_finder
@@ -0,0 +1,15 @@
1
+ module Spree
2
+ module Api
3
+ module V2
4
+ module ImageTransformationConcern
5
+ extend ActiveSupport::Concern
6
+
7
+ def self.included(base)
8
+ base.attribute :transformed_url do |image, params|
9
+ image.generate_url(size: params.dig(:image_transformation, :size))
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,16 @@
1
+ module Spree
2
+ module Api
3
+ module V2
4
+ module ResourceSerializerConcern
5
+ extend ActiveSupport::Concern
6
+
7
+ def self.included(base)
8
+ model_klazz = "Spree::#{base.to_s.demodulize.gsub(/Serializer/, '')}".constantize
9
+
10
+ base.set_type model_klazz.json_api_type
11
+ base.attributes(*model_klazz.json_api_columns)
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end