spree_api 4.4.1 → 4.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (176) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/concerns/spree/api/v2/product_list_includes.rb +10 -8
  3. data/app/controllers/spree/api/v2/platform/orders_controller.rb +1 -1
  4. data/app/controllers/spree/api/v2/platform/products_controller.rb +5 -1
  5. data/app/controllers/spree/api/v2/storefront/checkout_controller.rb +1 -1
  6. data/app/controllers/spree/api/v2/storefront/digitals_controller.rb +5 -1
  7. data/app/controllers/spree/api/v2/storefront/stores_controller.rb +4 -0
  8. data/app/helpers/spree/api/v2/store_media_serializer_images_concern.rb +35 -0
  9. data/app/models/concerns/spree/webhooks/has_webhooks.rb +31 -7
  10. data/app/models/spree/api/webhooks/product_decorator.rb +21 -2
  11. data/app/models/spree/webhooks/subscriber.rb +4 -0
  12. data/app/serializers/spree/api/v2/platform/cms_section_image_one_serializer.rb +9 -0
  13. data/app/serializers/spree/api/v2/platform/cms_section_image_three_serializer.rb +9 -0
  14. data/app/serializers/spree/api/v2/platform/cms_section_image_two_serializer.rb +9 -0
  15. data/app/serializers/spree/api/v2/platform/hero_image_serializer.rb +10 -0
  16. data/app/serializers/spree/api/v2/platform/image_gallery_serializer.rb +10 -0
  17. data/app/serializers/spree/api/v2/platform/side_by_side_image_serializer.rb +10 -0
  18. data/app/serializers/spree/api/v2/platform/store_serializer.rb +1 -0
  19. data/app/serializers/spree/api/v2/platform/user_serializer.rb +1 -1
  20. data/app/serializers/spree/v2/storefront/cms_section_serializer.rb +3 -3
  21. data/app/serializers/spree/v2/storefront/order_serializer.rb +9 -0
  22. data/app/serializers/spree/v2/storefront/product_property_serializer.rb +1 -1
  23. data/app/serializers/spree/v2/storefront/product_serializer.rb +1 -1
  24. data/app/serializers/spree/v2/storefront/shipment_serializer.rb +3 -0
  25. data/app/serializers/spree/v2/storefront/store_serializer.rb +5 -10
  26. data/app/serializers/spree/v2/storefront/user_serializer.rb +1 -1
  27. data/app/serializers/spree/v2/storefront/variant_serializer.rb +1 -1
  28. data/app/services/spree/webhooks/subscribers/queue_requests.rb +8 -2
  29. data/config/routes.rb +1 -120
  30. data/docs/v2/platform/index.yaml +1597 -998
  31. data/docs/v2/storefront/index.yaml +357 -33
  32. data/lib/spree/api/configuration.rb +11 -0
  33. data/lib/spree/api/dependencies.rb +165 -0
  34. data/lib/spree/api/engine.rb +5 -16
  35. data/lib/spree/api/testing_support/v2/platform_contexts.rb +0 -1
  36. data/lib/spree/api.rb +0 -4
  37. data/lib/spree_api.rb +0 -1
  38. data/spree_api.gemspec +0 -2
  39. metadata +17 -178
  40. data/app/controllers/spree/api/base_controller.rb +0 -171
  41. data/app/controllers/spree/api/v1/addresses_controller.rb +0 -46
  42. data/app/controllers/spree/api/v1/checkouts_controller.rb +0 -106
  43. data/app/controllers/spree/api/v1/classifications_controller.rb +0 -21
  44. data/app/controllers/spree/api/v1/countries_controller.rb +0 -22
  45. data/app/controllers/spree/api/v1/credit_cards_controller.rb +0 -26
  46. data/app/controllers/spree/api/v1/customer_returns_controller.rb +0 -25
  47. data/app/controllers/spree/api/v1/images_controller.rb +0 -58
  48. data/app/controllers/spree/api/v1/inventory_units_controller.rb +0 -54
  49. data/app/controllers/spree/api/v1/line_items_controller.rb +0 -70
  50. data/app/controllers/spree/api/v1/option_types_controller.rb +0 -60
  51. data/app/controllers/spree/api/v1/option_values_controller.rb +0 -62
  52. data/app/controllers/spree/api/v1/orders_controller.rb +0 -160
  53. data/app/controllers/spree/api/v1/payments_controller.rb +0 -82
  54. data/app/controllers/spree/api/v1/product_properties_controller.rb +0 -73
  55. data/app/controllers/spree/api/v1/products_controller.rb +0 -131
  56. data/app/controllers/spree/api/v1/promotions_controller.rb +0 -30
  57. data/app/controllers/spree/api/v1/properties_controller.rb +0 -70
  58. data/app/controllers/spree/api/v1/reimbursements_controller.rb +0 -25
  59. data/app/controllers/spree/api/v1/return_authorizations_controller.rb +0 -70
  60. data/app/controllers/spree/api/v1/shipments_controller.rb +0 -196
  61. data/app/controllers/spree/api/v1/states_controller.rb +0 -36
  62. data/app/controllers/spree/api/v1/stock_items_controller.rb +0 -82
  63. data/app/controllers/spree/api/v1/stock_locations_controller.rb +0 -53
  64. data/app/controllers/spree/api/v1/stock_movements_controller.rb +0 -45
  65. data/app/controllers/spree/api/v1/stores_controller.rb +0 -56
  66. data/app/controllers/spree/api/v1/taxonomies_controller.rb +0 -67
  67. data/app/controllers/spree/api/v1/taxons_controller.rb +0 -100
  68. data/app/controllers/spree/api/v1/users_controller.rb +0 -97
  69. data/app/controllers/spree/api/v1/variants_controller.rb +0 -81
  70. data/app/controllers/spree/api/v1/zones_controller.rb +0 -55
  71. data/app/helpers/spree/api/api_helpers.rb +0 -190
  72. data/app/models/spree/api_configuration.rb +0 -10
  73. data/app/views/spree/api/errors/gateway_error.rabl +0 -2
  74. data/app/views/spree/api/errors/invalid_api_key.rabl +0 -2
  75. data/app/views/spree/api/errors/invalid_resource.rabl +0 -3
  76. data/app/views/spree/api/errors/must_specify_api_key.rabl +0 -2
  77. data/app/views/spree/api/errors/not_found.rabl +0 -2
  78. data/app/views/spree/api/errors/unauthorized.rabl +0 -2
  79. data/app/views/spree/api/v1/addresses/show.rabl +0 -10
  80. data/app/views/spree/api/v1/adjustments/show.rabl +0 -4
  81. data/app/views/spree/api/v1/countries/index.rabl +0 -7
  82. data/app/views/spree/api/v1/countries/show.rabl +0 -5
  83. data/app/views/spree/api/v1/credit_cards/index.rabl +0 -7
  84. data/app/views/spree/api/v1/credit_cards/show.rabl +0 -3
  85. data/app/views/spree/api/v1/customer_returns/index.rabl +0 -7
  86. data/app/views/spree/api/v1/images/index.rabl +0 -4
  87. data/app/views/spree/api/v1/images/new.rabl +0 -3
  88. data/app/views/spree/api/v1/images/show.rabl +0 -6
  89. data/app/views/spree/api/v1/inventory_units/show.rabl +0 -2
  90. data/app/views/spree/api/v1/line_items/new.rabl +0 -3
  91. data/app/views/spree/api/v1/line_items/show.rabl +0 -14
  92. data/app/views/spree/api/v1/option_types/index.rabl +0 -3
  93. data/app/views/spree/api/v1/option_types/new.rabl +0 -3
  94. data/app/views/spree/api/v1/option_types/show.rabl +0 -5
  95. data/app/views/spree/api/v1/option_values/index.rabl +0 -3
  96. data/app/views/spree/api/v1/option_values/new.rabl +0 -3
  97. data/app/views/spree/api/v1/option_values/show.rabl +0 -2
  98. data/app/views/spree/api/v1/orders/address.rabl +0 -0
  99. data/app/views/spree/api/v1/orders/canceled.rabl +0 -0
  100. data/app/views/spree/api/v1/orders/cart.rabl +0 -0
  101. data/app/views/spree/api/v1/orders/complete.rabl +0 -0
  102. data/app/views/spree/api/v1/orders/could_not_apply_coupon.rabl +0 -2
  103. data/app/views/spree/api/v1/orders/could_not_transition.rabl +0 -3
  104. data/app/views/spree/api/v1/orders/index.rabl +0 -7
  105. data/app/views/spree/api/v1/orders/insufficient_quantity.rabl +0 -2
  106. data/app/views/spree/api/v1/orders/invalid_shipping_method.rabl +0 -2
  107. data/app/views/spree/api/v1/orders/mine.rabl +0 -9
  108. data/app/views/spree/api/v1/orders/order.rabl +0 -10
  109. data/app/views/spree/api/v1/orders/payment.rabl +0 -3
  110. data/app/views/spree/api/v1/orders/show.rabl +0 -51
  111. data/app/views/spree/api/v1/payments/credit_over_limit.rabl +0 -2
  112. data/app/views/spree/api/v1/payments/index.rabl +0 -7
  113. data/app/views/spree/api/v1/payments/new.rabl +0 -5
  114. data/app/views/spree/api/v1/payments/show.rabl +0 -2
  115. data/app/views/spree/api/v1/payments/update_forbidden.rabl +0 -2
  116. data/app/views/spree/api/v1/product_properties/index.rabl +0 -7
  117. data/app/views/spree/api/v1/product_properties/new.rabl +0 -2
  118. data/app/views/spree/api/v1/product_properties/show.rabl +0 -2
  119. data/app/views/spree/api/v1/products/index.rabl +0 -9
  120. data/app/views/spree/api/v1/products/new.rabl +0 -3
  121. data/app/views/spree/api/v1/products/product.rabl +0 -1
  122. data/app/views/spree/api/v1/products/show.rabl +0 -36
  123. data/app/views/spree/api/v1/promotions/handler.rabl +0 -5
  124. data/app/views/spree/api/v1/promotions/show.rabl +0 -2
  125. data/app/views/spree/api/v1/properties/index.rabl +0 -7
  126. data/app/views/spree/api/v1/properties/new.rabl +0 -2
  127. data/app/views/spree/api/v1/properties/show.rabl +0 -2
  128. data/app/views/spree/api/v1/reimbursements/index.rabl +0 -7
  129. data/app/views/spree/api/v1/return_authorizations/index.rabl +0 -7
  130. data/app/views/spree/api/v1/return_authorizations/new.rabl +0 -3
  131. data/app/views/spree/api/v1/return_authorizations/show.rabl +0 -2
  132. data/app/views/spree/api/v1/shared/stock_location_required.rabl +0 -2
  133. data/app/views/spree/api/v1/shipments/big.rabl +0 -48
  134. data/app/views/spree/api/v1/shipments/cannot_ready_shipment.rabl +0 -2
  135. data/app/views/spree/api/v1/shipments/mine.rabl +0 -9
  136. data/app/views/spree/api/v1/shipments/show.rabl +0 -32
  137. data/app/views/spree/api/v1/shipments/small.rabl +0 -37
  138. data/app/views/spree/api/v1/shipping_rates/show.rabl +0 -2
  139. data/app/views/spree/api/v1/states/index.rabl +0 -12
  140. data/app/views/spree/api/v1/states/show.rabl +0 -2
  141. data/app/views/spree/api/v1/stock_items/index.rabl +0 -7
  142. data/app/views/spree/api/v1/stock_items/show.rabl +0 -5
  143. data/app/views/spree/api/v1/stock_locations/index.rabl +0 -7
  144. data/app/views/spree/api/v1/stock_locations/show.rabl +0 -8
  145. data/app/views/spree/api/v1/stock_movements/index.rabl +0 -7
  146. data/app/views/spree/api/v1/stock_movements/show.rabl +0 -5
  147. data/app/views/spree/api/v1/stores/index.rabl +0 -4
  148. data/app/views/spree/api/v1/stores/show.rabl +0 -2
  149. data/app/views/spree/api/v1/tags/index.rabl +0 -9
  150. data/app/views/spree/api/v1/taxonomies/index.rabl +0 -7
  151. data/app/views/spree/api/v1/taxonomies/jstree.rabl +0 -7
  152. data/app/views/spree/api/v1/taxonomies/nested.rabl +0 -11
  153. data/app/views/spree/api/v1/taxonomies/new.rabl +0 -3
  154. data/app/views/spree/api/v1/taxonomies/show.rabl +0 -15
  155. data/app/views/spree/api/v1/taxons/index.rabl +0 -10
  156. data/app/views/spree/api/v1/taxons/jstree.rabl +0 -7
  157. data/app/views/spree/api/v1/taxons/new.rabl +0 -3
  158. data/app/views/spree/api/v1/taxons/show.rabl +0 -6
  159. data/app/views/spree/api/v1/taxons/taxons.rabl +0 -5
  160. data/app/views/spree/api/v1/users/index.rabl +0 -7
  161. data/app/views/spree/api/v1/users/new.rabl +0 -3
  162. data/app/views/spree/api/v1/users/show.rabl +0 -11
  163. data/app/views/spree/api/v1/variants/big.rabl +0 -14
  164. data/app/views/spree/api/v1/variants/index.rabl +0 -9
  165. data/app/views/spree/api/v1/variants/new.rabl +0 -2
  166. data/app/views/spree/api/v1/variants/show.rabl +0 -3
  167. data/app/views/spree/api/v1/variants/small.rabl +0 -18
  168. data/app/views/spree/api/v1/zones/index.rabl +0 -7
  169. data/app/views/spree/api/v1/zones/show.rabl +0 -6
  170. data/config/initializers/rabl.rb +0 -9
  171. data/lib/spree/api/api_dependencies.rb +0 -163
  172. data/lib/spree/api/controller_setup.rb +0 -19
  173. data/lib/spree/api/responders/rabl_template.rb +0 -28
  174. data/lib/spree/api/responders.rb +0 -11
  175. data/lib/spree/api/testing_support/helpers.rb +0 -44
  176. data/lib/spree/api/testing_support/setup.rb +0 -16
@@ -1,14 +0,0 @@
1
- object @variant
2
-
3
- cache [I18n.locale, @current_user_roles.include?('admin'), 'big_variant', root_object]
4
-
5
- extends 'spree/api/v1/variants/small'
6
-
7
- child(stock_items: :stock_items) do
8
- attributes :id, :count_on_hand, :stock_location_id, :backorderable
9
- attribute available?: :available
10
-
11
- glue(:stock_location) do
12
- attribute name: :stock_location_name
13
- end
14
- end
@@ -1,9 +0,0 @@
1
- object false
2
- node(:count) { @variants.count }
3
- node(:total_count) { @variants.total_count }
4
- node(:current_page) { params[:page] ? params[:page].to_i : 1 }
5
- node(:pages) { @variants.total_pages }
6
-
7
- child(@variants => :variants) do
8
- extends 'spree/api/v1/variants/big'
9
- end
@@ -1,2 +0,0 @@
1
- node(:attributes) { [*variant_attributes] }
2
- node(:required_attributes) { [] }
@@ -1,3 +0,0 @@
1
- object @variant
2
- cache [I18n.locale, @current_user_roles.include?('admin'), 'show', root_object]
3
- extends 'spree/api/v1/variants/big'
@@ -1,18 +0,0 @@
1
- cache [I18n.locale, @current_user_roles.include?('admin'), 'small_variant', root_object]
2
-
3
- attributes *variant_attributes
4
-
5
- node(:display_price) { |p| p.display_price.to_s }
6
- node(:options_text, &:options_text)
7
- node(:track_inventory, &:should_track_inventory?)
8
- node(:in_stock, &:in_stock?)
9
- node(:is_backorderable, &:is_backorderable?)
10
- node(:is_orderable) { |v| v.is_backorderable? || v.in_stock? }
11
- node(:total_on_hand, &:total_on_hand)
12
- node(:is_destroyed, &:destroyed?)
13
-
14
- child option_values: :option_values do
15
- attributes *option_value_attributes
16
- end
17
-
18
- child(images: :images) { extends 'spree/api/v1/images/show' }
@@ -1,7 +0,0 @@
1
- object false
2
- child(@zones => :zones) do
3
- extends 'spree/api/v1/zones/show'
4
- end
5
- node(:count) { @zones.count }
6
- node(:current_page) { params[:page].try(:to_i) || 1 }
7
- node(:pages) { @zones.total_pages }
@@ -1,6 +0,0 @@
1
- object @zone
2
- attributes :id, :name, :description
3
-
4
- child zone_members: :zone_members do
5
- attributes :id, :name, :zoneable_type, :zoneable_id
6
- end
@@ -1,9 +0,0 @@
1
- Rabl.configure do |config|
2
- config.include_json_root = false
3
- config.include_child_root = false
4
-
5
- # Motivation here it make it call as_json when rendering timestamps
6
- # and therefore display milliseconds. Otherwise it would fall to
7
- # JSON.dump which doesn't display the milliseconds
8
- config.json_engine = ActiveSupport::JSON
9
- end
@@ -1,163 +0,0 @@
1
- module Spree
2
- class ApiDependencies
3
- include Spree::DependenciesHelper
4
-
5
- INJECTION_POINTS = [
6
- :storefront_cart_create_service, :storefront_cart_add_item_service, :storefront_cart_remove_line_item_service,
7
- :storefront_cart_remove_item_service, :storefront_cart_set_item_quantity_service, :storefront_cart_recalculate_service,
8
- :storefront_cms_page_serializer, :storefront_cms_page_finder,
9
- :storefront_cart_update, :storefront_coupon_handler, :storefront_checkout_next_service, :storefront_checkout_advance_service,
10
- :storefront_checkout_update_service, :storefront_checkout_complete_service, :storefront_checkout_add_store_credit_service,
11
- :storefront_checkout_remove_store_credit_service, :storefront_checkout_get_shipping_rates_service,
12
- :storefront_cart_compare_line_items_service, :storefront_cart_serializer, :storefront_credit_card_serializer,
13
- :storefront_credit_card_finder, :storefront_shipment_serializer, :storefront_payment_method_serializer, :storefront_country_finder,
14
- :storefront_country_serializer, :storefront_menu_serializer, :storefront_menu_finder, :storefront_current_order_finder,
15
- :storefront_completed_order_finder, :storefront_order_sorter, :storefront_collection_paginator, :storefront_user_serializer,
16
- :storefront_products_sorter, :storefront_products_finder, :storefront_product_serializer, :storefront_taxon_serializer,
17
- :storefront_taxon_finder, :storefront_find_by_variant_finder, :storefront_cart_update_service, :storefront_cart_associate_service,
18
- :storefront_cart_estimate_shipping_rates_service, :storefront_estimated_shipment_serializer,
19
- :storefront_store_serializer, :storefront_address_serializer, :storefront_order_serializer,
20
- :storefront_account_create_address_service, :storefront_account_update_address_service, :storefront_address_finder,
21
- :storefront_account_create_service, :storefront_account_update_service, :storefront_collection_sorter, :error_handler,
22
- :storefront_cart_empty_service, :storefront_cart_destroy_service, :storefront_credit_cards_destroy_service, :platform_products_sorter,
23
- :storefront_cart_change_currency_service, :storefront_payment_serializer,
24
- :storefront_payment_create_service, :storefront_address_create_service, :storefront_address_update_service,
25
- :storefront_checkout_select_shipping_method_service,
26
-
27
- :platform_admin_user_serializer, :platform_coupon_handler, :platform_order_update_service,
28
- :platform_order_use_store_credit_service, :platform_order_remove_store_credit_service,
29
- :platform_order_complete_service, :platform_order_empty_service, :platform_order_destroy_service,
30
- :platform_order_next_service, :platform_order_advance_service,
31
- :platform_line_item_create_service, :platform_line_item_update_service, :platform_line_item_destroy_service,
32
- :platform_order_approve_service, :platform_order_cancel_service,
33
- :platform_shipment_change_state_service, :platform_shipment_create_service, :platform_shipment_update_service,
34
- :platform_shipment_add_item_service, :platform_shipment_remove_item_service
35
- ].freeze
36
-
37
- attr_accessor *INJECTION_POINTS
38
-
39
- def initialize
40
- set_storefront_defaults
41
- set_platform_defaults
42
- end
43
-
44
- private
45
-
46
- def set_storefront_defaults
47
- # cart services
48
- @storefront_cart_create_service = Spree::Dependencies.cart_create_service
49
- @storefront_cart_add_item_service = Spree::Dependencies.cart_add_item_service
50
- @storefront_cart_compare_line_items_service = Spree::Dependencies.cart_compare_line_items_service
51
- @storefront_cart_update_service = Spree::Dependencies.cart_update_service
52
- @storefront_cart_remove_line_item_service = Spree::Dependencies.cart_remove_line_item_service
53
- @storefront_cart_remove_item_service = Spree::Dependencies.cart_remove_item_service
54
- @storefront_cart_set_item_quantity_service = Spree::Dependencies.cart_set_item_quantity_service
55
- @storefront_cart_recalculate_service = Spree::Dependencies.cart_recalculate_service
56
- @storefront_cart_estimate_shipping_rates_service = Spree::Dependencies.cart_estimate_shipping_rates_service
57
- @storefront_cart_empty_service = Spree::Dependencies.cart_empty_service
58
- @storefront_cart_destroy_service = Spree::Dependencies.cart_destroy_service
59
- @storefront_cart_associate_service = Spree::Dependencies.cart_associate_service
60
- @storefront_cart_change_currency_service = Spree::Dependencies.cart_change_currency_service
61
-
62
- # coupon code handler
63
- @storefront_coupon_handler = Spree::Dependencies.coupon_handler
64
-
65
- # checkout services
66
- @storefront_checkout_next_service = Spree::Dependencies.checkout_next_service
67
- @storefront_checkout_advance_service = Spree::Dependencies.checkout_advance_service
68
- @storefront_checkout_update_service = Spree::Dependencies.checkout_update_service
69
- @storefront_checkout_complete_service = Spree::Dependencies.checkout_complete_service
70
- @storefront_checkout_add_store_credit_service = Spree::Dependencies.checkout_add_store_credit_service
71
- @storefront_checkout_remove_store_credit_service = Spree::Dependencies.checkout_remove_store_credit_service
72
- @storefront_checkout_get_shipping_rates_service = Spree::Dependencies.checkout_get_shipping_rates_service
73
- @storefront_checkout_select_shipping_method_service = Spree::Dependencies.checkout_select_shipping_method_service
74
-
75
- # account services
76
- @storefront_account_create_service = Spree::Dependencies.account_create_service
77
- @storefront_account_update_service = Spree::Dependencies.account_update_service
78
-
79
- # address services
80
- @storefront_address_create_service = Spree::Dependencies.address_create_service
81
- @storefront_address_update_service = Spree::Dependencies.address_update_service
82
-
83
- # credit card services
84
- @storefront_credit_cards_destroy_service = Spree::Dependencies.credit_cards_destroy_service
85
-
86
- # payment services
87
- @storefront_payment_create_service = Spree::Dependencies.payment_create_service
88
-
89
- # serializers
90
- @storefront_address_serializer = 'Spree::V2::Storefront::AddressSerializer'
91
- @storefront_cart_serializer = 'Spree::V2::Storefront::CartSerializer'
92
- @storefront_cms_page_serializer = 'Spree::V2::Storefront::CmsPageSerializer'
93
- @storefront_credit_card_serializer = 'Spree::V2::Storefront::CreditCardSerializer'
94
- @storefront_country_serializer = 'Spree::V2::Storefront::CountrySerializer'
95
- @storefront_menu_serializer = 'Spree::V2::Storefront::MenuSerializer'
96
- @storefront_user_serializer = 'Spree::V2::Storefront::UserSerializer'
97
- @storefront_shipment_serializer = 'Spree::V2::Storefront::ShipmentSerializer'
98
- @storefront_taxon_serializer = 'Spree::V2::Storefront::TaxonSerializer'
99
- @storefront_payment_method_serializer = 'Spree::V2::Storefront::PaymentMethodSerializer'
100
- @storefront_payment_serializer = 'Spree::V2::Storefront::PaymentSerializer'
101
- @storefront_product_serializer = 'Spree::V2::Storefront::ProductSerializer'
102
- @storefront_estimated_shipment_serializer = 'Spree::V2::Storefront::EstimatedShippingRateSerializer'
103
- @storefront_store_serializer = 'Spree::V2::Storefront::StoreSerializer'
104
- @storefront_order_serializer = 'Spree::V2::Storefront::CartSerializer'
105
-
106
- # sorters
107
- @storefront_collection_sorter = Spree::Dependencies.collection_sorter
108
- @storefront_order_sorter = Spree::Dependencies.collection_sorter
109
- @storefront_products_sorter = Spree::Dependencies.products_sorter
110
- @platform_products_sorter = Spree::Dependencies.products_sorter
111
-
112
- # paginators
113
- @storefront_collection_paginator = Spree::Dependencies.collection_paginator
114
-
115
- # finders
116
- @storefront_address_finder = Spree::Dependencies.address_finder
117
- @storefront_country_finder = Spree::Dependencies.country_finder
118
- @storefront_cms_page_finder = Spree::Dependencies.cms_page_finder
119
- @storefront_menu_finder = Spree::Dependencies.menu_finder
120
- @storefront_current_order_finder = Spree::Dependencies.current_order_finder
121
- @storefront_completed_order_finder = Spree::Dependencies.completed_order_finder
122
- @storefront_credit_card_finder = Spree::Dependencies.credit_card_finder
123
- @storefront_find_by_variant_finder = Spree::Dependencies.line_item_by_variant_finder
124
- @storefront_products_finder = Spree::Dependencies.products_finder
125
- @storefront_taxon_finder = Spree::Dependencies.taxon_finder
126
-
127
- @error_handler = 'Spree::Api::ErrorHandler'
128
- end
129
-
130
- def set_platform_defaults
131
- # serializers
132
- @platform_admin_user_serializer = 'Spree::Api::V2::Platform::UserSerializer'
133
-
134
- # coupon code handler
135
- @platform_coupon_handler = Spree::Dependencies.coupon_handler
136
-
137
- # order services
138
- @platform_order_recalculate_service = Spree::Dependencies.cart_recalculate_service
139
- @platform_order_update_service = Spree::Dependencies.checkout_update_service
140
- @platform_order_empty_service = Spree::Dependencies.cart_empty_service
141
- @platform_order_destroy_service = Spree::Dependencies.cart_destroy_service
142
- @platform_order_next_service = Spree::Dependencies.checkout_next_service
143
- @platform_order_advance_service = Spree::Dependencies.checkout_advance_service
144
- @platform_order_complete_service = Spree::Dependencies.checkout_complete_service
145
- @platform_order_use_store_credit_service = Spree::Dependencies.checkout_add_store_credit_service
146
- @platform_order_remove_store_credit_service = Spree::Dependencies.checkout_remove_store_credit_service
147
- @platform_order_approve_service = Spree::Dependencies.order_approve_service
148
- @platform_order_cancel_service = Spree::Dependencies.order_cancel_service
149
-
150
- # line item services
151
- @platform_line_item_create_service = Spree::Dependencies.line_item_create_service
152
- @platform_line_item_update_service = Spree::Dependencies.line_item_update_service
153
- @platform_line_item_destroy_service = Spree::Dependencies.line_item_destroy_service
154
-
155
- # shipment services
156
- @platform_shipment_create_service = Spree::Dependencies.shipment_create_service
157
- @platform_shipment_update_service = Spree::Dependencies.shipment_update_service
158
- @platform_shipment_change_state_service = Spree::Dependencies.shipment_change_state_service
159
- @platform_shipment_add_item_service = Spree::Dependencies.shipment_add_item_service
160
- @platform_shipment_remove_item_service = Spree::Dependencies.shipment_remove_item_service
161
- end
162
- end
163
- end
@@ -1,19 +0,0 @@
1
- require 'spree/api/responders'
2
-
3
- module Spree
4
- module Api
5
- module ControllerSetup
6
- def self.included(klass)
7
- klass.class_eval do
8
- include CanCan::ControllerAdditions
9
-
10
- prepend_view_path Rails.root + 'app/views'
11
- append_view_path File.expand_path('../../../app/views', File.dirname(__FILE__))
12
-
13
- self.responder = Spree::Api::Responders::AppResponder
14
- respond_to :json
15
- end
16
- end
17
- end
18
- end
19
- end
@@ -1,28 +0,0 @@
1
- module Spree
2
- module Api
3
- module Responders
4
- module RablTemplate
5
- def to_format
6
- if template
7
- render template, status: options[:status] || 200
8
- else
9
- super
10
- end
11
- rescue ActionView::MissingTemplate => e
12
- api_behavior
13
- end
14
-
15
- def template
16
- options[:default_template]
17
- end
18
-
19
- def api_behavior
20
- if controller.params[:action] == 'destroy'
21
- # Render a blank template
22
- super
23
- end
24
- end
25
- end
26
- end
27
- end
28
- end
@@ -1,11 +0,0 @@
1
- require 'spree/api/responders/rabl_template'
2
-
3
- module Spree
4
- module Api
5
- module Responders
6
- class AppResponder < ActionController::Responder
7
- include RablTemplate
8
- end
9
- end
10
- end
11
- end
@@ -1,44 +0,0 @@
1
- module Spree
2
- module Api
3
- module TestingSupport
4
- module Helpers
5
- def json_response
6
- case body = JSON.parse(response.body)
7
- when Hash
8
- body.with_indifferent_access
9
- when Array
10
- body
11
- end
12
- end
13
-
14
- def assert_not_found!
15
- expect(json_response).to eq('error' => 'The resource you were looking for could not be found.')
16
- expect(response.status).to eq 404
17
- end
18
-
19
- def assert_unauthorized!
20
- expect(json_response).to eq('error' => 'You are not authorized to perform that action.')
21
- expect(response.status).to eq 401
22
- end
23
-
24
- def stub_authentication!
25
- allow(Spree.user_class).to receive(:find_by).with(hash_including(:spree_api_key)) { current_api_user }
26
- end
27
-
28
- # This method can be overridden (with a let block) inside a context
29
- # For instance, if you wanted to have an admin user instead.
30
- def current_api_user
31
- @current_api_user ||= stub_model(Spree.user_class, email: 'spree@example.com')
32
- end
33
-
34
- def image(filename)
35
- File.open(Spree::Api::Engine.root + 'spec/fixtures' + filename)
36
- end
37
-
38
- def upload_image(filename)
39
- fixture_file_upload(image(filename).path, 'image/jpg')
40
- end
41
- end
42
- end
43
- end
44
- end
@@ -1,16 +0,0 @@
1
- module Spree
2
- module Api
3
- module TestingSupport
4
- module Setup
5
- def sign_in_as_admin!
6
- let!(:current_api_user) do
7
- user = stub_model(Spree.user_class)
8
- allow(user).to receive_message_chain(:spree_roles, :pluck).and_return(['admin'])
9
- allow(user).to receive(:has_spree_role?).with('admin').and_return(true)
10
- user
11
- end
12
- end
13
- end
14
- end
15
- end
16
- end