spree_api 4.4.1 → 4.5.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.
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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: db18ec57434be88149ce2ec6d1c139ab32cdbbf4a494b3a6ccb32185705201ec
4
- data.tar.gz: 9206637747a6f60b0ce14106e5266cbd4ed943945e010e7b8fe73d6a1d05e035
3
+ metadata.gz: 57236192b982b8939614697a3f1ea3b46e95456e2b9f43c324b4c4b88dd3a5be
4
+ data.tar.gz: 4cf278eeee9926968327b8e4746bec902a8067a8594f7d6c9fdea281d8fbef84
5
5
  SHA512:
6
- metadata.gz: b3126d0027ac32c8ab4a111f740ba16b6a3ffadf6c401de8c0fa95222ac3280012580c1aa5afb8c44538cdb35126925228e73335e413d1888e959cdae9371b57
7
- data.tar.gz: 7666b434e4c11bb62dbb9f6f8f936d8ab8201cb6515e871ecc99516c1e6f81a61db95db1027016735f9efadc79551cedc09ad0009447579f5f356aa83064abfb
6
+ metadata.gz: 3e43407ea4cf9ddefeb0921d6c244f0ac73e09856f7fb4bfbbf6ffb34f6c45f00104f7668cd6e4230122bd06db65e83e1f6425e22392b1f003ab5c4ef26689e5
7
+ data.tar.gz: 656fab17f5d7ed57b30fb71f13de42659364e62f52062923a89a3c0c0df2ab13902fc458446ee40af59add2b72b08ada892db05647dc1edd2308771d37279448
@@ -3,18 +3,20 @@ module Spree
3
3
  module V2
4
4
  module ProductListIncludes
5
5
  def product_list_includes
6
- variant_includes = {
7
- prices: [],
8
- option_values: :option_type,
9
- images: []
10
- }
11
-
12
6
  {
13
7
  product_properties: [],
14
8
  option_types: [],
15
9
  variant_images: [],
16
- master: variant_includes,
17
- variants: variant_includes
10
+ master: product_variant_includes,
11
+ variants: product_variant_includes
12
+ }
13
+ end
14
+
15
+ def product_variant_includes
16
+ {
17
+ prices: [],
18
+ option_values: :option_type,
19
+ images: []
18
20
  }
19
21
  end
20
22
  end
@@ -100,7 +100,7 @@ module Spree
100
100
  end
101
101
 
102
102
  def allowed_sort_attributes
103
- super.push(:available_on, :total, :payment_total, :item_total, :shipment_total,
103
+ super.push(:available_on, :make_active_at, :total, :payment_total, :item_total, :shipment_total,
104
104
  :adjustment_total, :promo_total, :included_tax_total, :additional_tax_total,
105
105
  :item_count, :tax_total, :completed_at)
106
106
  end
@@ -15,8 +15,12 @@ module Spree
15
15
  product_list_includes
16
16
  end
17
17
 
18
+ def spree_permitted_attributes
19
+ super.push(:price)
20
+ end
21
+
18
22
  def allowed_sort_attributes
19
- super << :available_on
23
+ super.push(:available_on, :make_active_at)
20
24
  end
21
25
 
22
26
  def sorted_collection
@@ -150,7 +150,7 @@ module Spree
150
150
  shipping_rates_serializer.new(
151
151
  shipments,
152
152
  params: serializer_params,
153
- include: [:shipping_rates, :stock_location]
153
+ include: [:shipping_rates, :stock_location, :line_items]
154
154
  ).serializable_hash
155
155
  end
156
156
  end
@@ -22,7 +22,7 @@ module Spree
22
22
  redirect_to attachment.url(
23
23
  expires_in: current_store.digital_asset_link_expire_time.seconds,
24
24
  disposition: 'attachment',
25
- host: current_store.formatted_url
25
+ host: digital_attachment_host
26
26
  ) and return
27
27
 
28
28
  end
@@ -47,6 +47,10 @@ module Spree
47
47
  def attachment
48
48
  @attachment ||= digital_link.digital.try(:attachment) if digital_link.present?
49
49
  end
50
+
51
+ def digital_attachment_host
52
+ current_store.formatted_url
53
+ end
50
54
  end
51
55
  end
52
56
  end
@@ -3,6 +3,10 @@ module Spree
3
3
  module V2
4
4
  module Storefront
5
5
  class StoresController < ::Spree::Api::V2::ResourceController
6
+ def current
7
+ render_serialized_payload { serialize_resource(current_store) }
8
+ end
9
+
6
10
  private
7
11
 
8
12
  def model_class
@@ -0,0 +1,35 @@
1
+ module Spree
2
+ module Api
3
+ module V2
4
+ module StoreMediaSerializerImagesConcern
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ def self.store_image_url_for(store, attribute_name)
9
+ attachment = store.send(attribute_name)&.attachment
10
+ return unless attachment&.attached?
11
+
12
+ url_helpers = Rails.application.routes.url_helpers
13
+ if Spree.public_storage_service_name
14
+ url_helpers.cdn_image_url(attachment)
15
+ else
16
+ url_helpers.rails_blob_path(attachment)
17
+ end
18
+ end
19
+
20
+ attribute :logo do |store|
21
+ store_image_url_for store, :logo
22
+ end
23
+
24
+ attribute :mailer_logo do |store|
25
+ store_image_url_for store, :mailer_logo
26
+ end
27
+
28
+ attribute :favicon_path do |store|
29
+ store_image_url_for store, :favicon_image
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -11,10 +11,12 @@ module Spree
11
11
  def queue_webhooks_requests!(event_name)
12
12
  return if disable_spree_webhooks?
13
13
  return if Spree::Webhooks::Subscriber.active.with_urls_for(event_name).none?
14
- return if update_event?(event_name) && updating_only_timestamps?
14
+ return if update_event?(event_name) && updating_only_ignored_attributes?
15
15
  return if webhook_payload_body.blank?
16
16
 
17
- Spree::Webhooks::Subscribers::QueueRequests.call(event_name: event_name, webhook_payload_body: webhook_payload_body)
17
+ Spree::Webhooks::Subscribers::QueueRequests.call(
18
+ event_name: event_name, webhook_payload_body: webhook_payload_body, **webhooks_request_options
19
+ )
18
20
  end
19
21
 
20
22
  def self.default_webhook_events
@@ -32,20 +34,38 @@ module Spree
32
34
  private
33
35
 
34
36
  def webhook_payload_body
35
- resource_serializer.new(self).serializable_hash.to_json
37
+ resource_serializer.new(self, include: included_relationships).serializable_hash.to_json
36
38
  end
37
39
 
38
40
  def inferred_event_name(operation)
39
41
  "#{self.class.name.demodulize.tableize.singularize}.#{operation}"
40
42
  end
41
43
 
44
+ def included_relationships
45
+ if resource_serializer.relationships_to_serialize
46
+ resource_serializer.relationships_to_serialize.keys
47
+ else
48
+ []
49
+ end
50
+ end
51
+
42
52
  def resource_serializer
43
- demodulized_class_name = self.class.to_s.demodulize
44
- "Spree::Api::V2::Platform::#{demodulized_class_name}Serializer".constantize
53
+ @resource_serializer ||=
54
+ begin
55
+ demodulized_class_name = self.class.to_s.demodulize
56
+ "Spree::Api::V2::Platform::#{demodulized_class_name}Serializer".constantize
57
+ end
58
+ end
59
+
60
+ def updating_only_ignored_attributes?
61
+ (saved_changes.keys - ignored_attributes).empty?
45
62
  end
46
63
 
47
- def updating_only_timestamps?
48
- (saved_changes.keys - %w[created_at updated_at deleted_at]).empty?
64
+ def ignored_attributes
65
+ timestamps = %w[created_at updated_at deleted_at]
66
+ return timestamps unless self.class.respond_to?(:ignored_attributes_for_update_webhook_event)
67
+
68
+ timestamps + self.class.ignored_attributes_for_update_webhook_event
49
69
  end
50
70
 
51
71
  def update_event?(event_name)
@@ -55,6 +75,10 @@ module Spree
55
75
  def disable_spree_webhooks?
56
76
  ENV['DISABLE_SPREE_WEBHOOKS'] == 'true'
57
77
  end
78
+
79
+ def webhooks_request_options
80
+ {}
81
+ end
58
82
  end
59
83
  end
60
84
  end
@@ -4,12 +4,32 @@ module Spree
4
4
  module ProductDecorator
5
5
  def self.prepended(base)
6
6
  def base.custom_webhook_events
7
- %w[product.back_in_stock product.backorderable product.discontinued product.out_of_stock]
7
+ %w[product.back_in_stock product.backorderable product.discontinued
8
+ product.out_of_stock product.activated product.archived product.drafted]
9
+ end
10
+
11
+ def base.ignored_attributes_for_update_webhook_event
12
+ %w[status]
8
13
  end
9
14
 
10
15
  base.after_update_commit :queue_webhooks_requests_for_product_discontinued!
11
16
  end
12
17
 
18
+ def after_activate
19
+ super
20
+ queue_webhooks_requests!('product.activated')
21
+ end
22
+
23
+ def after_archive
24
+ super
25
+ queue_webhooks_requests!('product.archived')
26
+ end
27
+
28
+ def after_draft
29
+ super
30
+ queue_webhooks_requests!('product.drafted')
31
+ end
32
+
13
33
  private
14
34
 
15
35
  def queue_webhooks_requests_for_product_discontinued!
@@ -24,4 +44,3 @@ module Spree
24
44
  end
25
45
 
26
46
  Spree::Product.prepend(Spree::Api::Webhooks::ProductDecorator)
27
-
@@ -1,6 +1,10 @@
1
1
  module Spree
2
2
  module Webhooks
3
3
  class Subscriber < Spree::Webhooks::Base
4
+ if defined?(Spree::VendorConcern)
5
+ include Spree::VendorConcern
6
+ end
7
+
4
8
  has_many :events, inverse_of: :subscriber
5
9
 
6
10
  validates :url, 'spree/url': true, presence: true
@@ -0,0 +1,9 @@
1
+ module Spree
2
+ module Api
3
+ module V2
4
+ module Platform
5
+ class CmsSectionImageOneSerializer < AssetSerializer; end
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Spree
2
+ module Api
3
+ module V2
4
+ module Platform
5
+ class CmsSectionImageThreeSerializer < AssetSerializer; end
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Spree
2
+ module Api
3
+ module V2
4
+ module Platform
5
+ class CmsSectionImageTwoSerializer < AssetSerializer; end
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,10 @@
1
+ module Spree
2
+ module Api
3
+ module V2
4
+ module Platform
5
+ class HeroImageSerializer < CmsSectionSerializer
6
+ end
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ module Spree
2
+ module Api
3
+ module V2
4
+ module Platform
5
+ class ImageGallerySerializer < CmsSectionSerializer
6
+ end
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ module Spree
2
+ module Api
3
+ module V2
4
+ module Platform
5
+ class SideBySideImageSerializer < CmsSectionSerializer
6
+ end
7
+ end
8
+ end
9
+ end
10
+ end
@@ -4,6 +4,7 @@ module Spree
4
4
  module Platform
5
5
  class StoreSerializer < BaseSerializer
6
6
  include ResourceSerializerConcern
7
+ include StoreMediaSerializerImagesConcern
7
8
 
8
9
  has_many :menus
9
10
  has_one :default_country, serializer: :country, record_type: :country, id_method_name: :default_country_id
@@ -5,7 +5,7 @@ module Spree
5
5
  class UserSerializer < BaseSerializer
6
6
  set_type :user
7
7
 
8
- attributes :email, :created_at, :updated_at, :public_metadata, :private_metadata
8
+ attributes :email, :first_name, :last_name, :created_at, :updated_at, :public_metadata, :private_metadata
9
9
 
10
10
  attribute :average_order_value do |user, params|
11
11
  price_stats(user.report_values_for(:average_order_value, params[:store]))
@@ -6,10 +6,10 @@ module Spree
6
6
 
7
7
  attributes :name, :content, :settings, :link, :fit, :type, :position
8
8
 
9
- Spree::CmsSection::IMAGE_COUNT.each do |count|
10
- Spree::CmsSection::IMAGE_SIZE.each do |size|
9
+ Spree::CmsSectionImage::IMAGE_COUNT.each do |count|
10
+ Spree::CmsSectionImage::IMAGE_SIZE.each do |size|
11
11
  attribute "img_#{count}_#{size}".to_sym do |section|
12
- if section.send("image_#{count}").attached? && section.send("img_#{count}_#{size}").present?
12
+ if section.send("image_#{count}")&.attachment&.attached? && section.send("img_#{count}_#{size}").present?
13
13
  url_helpers = Rails.application.routes.url_helpers
14
14
  url_helpers.rails_representation_path(section.send("img_#{count}_#{size}"), only_path: true)
15
15
  end
@@ -0,0 +1,9 @@
1
+ module Spree
2
+ module V2
3
+ module Storefront
4
+ class OrderSerializer < CartSerializer
5
+ set_type :order
6
+ end
7
+ end
8
+ end
9
+ end
@@ -4,7 +4,7 @@ module Spree
4
4
  class ProductPropertySerializer < BaseSerializer
5
5
  set_type :product_property
6
6
 
7
- attribute :value, :filter_param
7
+ attribute :value, :filter_param, :show_property, :position
8
8
 
9
9
  attribute :name do |product_property|
10
10
  product_property.property_name
@@ -6,7 +6,7 @@ module Spree
6
6
 
7
7
  set_type :product
8
8
 
9
- attributes :name, :description, :available_on, :slug, :meta_description, :meta_keywords, :updated_at, :sku, :public_metadata
9
+ attributes :name, :description, :available_on, :slug, :meta_description, :meta_keywords, :updated_at, :sku, :barcode, :public_metadata
10
10
 
11
11
  attribute :purchasable do |product|
12
12
  product.purchasable?
@@ -15,6 +15,9 @@ module Spree
15
15
  has_one :selected_shipping_rate, serializer: :shipping_rate
16
16
 
17
17
  belongs_to :stock_location
18
+ has_many :line_items do |shipment|
19
+ shipment.line_items
20
+ end
18
21
  end
19
22
  end
20
23
  end
@@ -2,23 +2,18 @@ module Spree
2
2
  module V2
3
3
  module Storefront
4
4
  class StoreSerializer < BaseSerializer
5
+ include Spree::Api::V2::StoreMediaSerializerImagesConcern
6
+
5
7
  set_type :store
6
8
 
7
- attributes :name, :url, :meta_description, :meta_keywords, :seo_title, :default_currency, :default, :supported_currencies, :facebook,
8
- :twitter, :instagram, :default_locale, :customer_support_email, :default_country_id, :description,
9
- :address, :contact_phone, :supported_locales, :settings
9
+ attributes :name, :url, :meta_description, :meta_keywords, :seo_title, :default_currency,
10
+ :default, :supported_currencies, :facebook, :twitter, :instagram, :default_locale,
11
+ :customer_support_email, :description, :address, :contact_phone, :supported_locales
10
12
 
11
13
  has_many :menus
12
14
  has_many :cms_pages
13
15
 
14
16
  has_one :default_country, serializer: :country, record_type: :country, id_method_name: :default_country_id
15
-
16
- attribute :favicon_path do |store|
17
- if store.favicon_image.attached?
18
- url_helpers = Rails.application.routes.url_helpers
19
- url_helpers.rails_representation_path(store.favicon, only_path: true)
20
- end
21
- end
22
17
  end
23
18
  end
24
19
  end
@@ -4,7 +4,7 @@ module Spree
4
4
  class UserSerializer < BaseSerializer
5
5
  set_type :user
6
6
 
7
- attributes :email, :public_metadata
7
+ attributes :email, :first_name, :last_name, :public_metadata
8
8
 
9
9
  attribute :store_credits do |user|
10
10
  user.total_available_store_credit
@@ -6,7 +6,7 @@ module Spree
6
6
 
7
7
  set_type :variant
8
8
 
9
- attributes :sku, :weight, :height, :width, :depth, :is_master, :options_text, :public_metadata
9
+ attributes :sku, :barcode, :weight, :height, :width, :depth, :is_master, :options_text, :public_metadata
10
10
 
11
11
  attribute :purchasable do |variant|
12
12
  variant.purchasable?
@@ -4,13 +4,19 @@ module Spree
4
4
  class QueueRequests
5
5
  prepend Spree::ServiceModule::Base
6
6
 
7
- def call(event_name:, webhook_payload_body:)
8
- Spree::Webhooks::Subscriber.active.with_urls_for(event_name).each do |subscriber|
7
+ def call(event_name:, webhook_payload_body:, **options)
8
+ filtered_subscribers(event_name, webhook_payload_body, options).each do |subscriber|
9
9
  Spree::Webhooks::Subscribers::MakeRequestJob.perform_later(
10
10
  webhook_payload_body, event_name, subscriber
11
11
  )
12
12
  end
13
13
  end
14
+
15
+ private
16
+
17
+ def filtered_subscribers(event_name, _, _)
18
+ Spree::Webhooks::Subscriber.active.with_urls_for(event_name)
19
+ end
14
20
  end
15
21
  end
16
22
  end
data/config/routes.rb CHANGED
@@ -6,126 +6,6 @@ end
6
6
 
7
7
  Spree::Core::Engine.add_routes do
8
8
  namespace :api, defaults: { format: 'json' } do
9
- namespace :v1 do
10
- resources :promotions, only: [:show]
11
-
12
- resources :customer_returns, only: [:index]
13
- resources :reimbursements, only: [:index]
14
-
15
- resources :products do
16
- resources :images
17
- resources :variants
18
- resources :product_properties
19
- end
20
-
21
- concern :order_routes do
22
- member do
23
- put :approve
24
- put :cancel
25
- put :empty
26
- put :apply_coupon_code
27
- end
28
-
29
- resources :line_items
30
- resources :payments do
31
- member do
32
- put :authorize
33
- put :capture
34
- put :purchase
35
- put :void
36
- put :credit
37
- end
38
- end
39
-
40
- resources :addresses, only: [:show, :update]
41
-
42
- resources :return_authorizations do
43
- member do
44
- put :add
45
- put :cancel
46
- put :receive
47
- end
48
- end
49
- end
50
-
51
- resources :checkouts, only: [:update], concerns: :order_routes do
52
- member do
53
- put :next
54
- put :advance
55
- end
56
- end
57
-
58
- resources :variants do
59
- resources :images
60
- end
61
-
62
- resources :option_types do
63
- resources :option_values
64
- end
65
- resources :option_values
66
-
67
- resources :option_values, only: :index
68
-
69
- get '/orders/mine', to: 'orders#mine', as: 'my_orders'
70
- get '/orders/current', to: 'orders#current', as: 'current_order'
71
-
72
- resources :orders, concerns: :order_routes do
73
- put :remove_coupon_code, on: :member
74
- end
75
-
76
- resources :zones
77
- resources :countries, only: [:index, :show] do
78
- resources :states, only: [:index, :show]
79
- end
80
-
81
- resources :shipments, only: [:create, :update] do
82
- collection do
83
- post 'transfer_to_location'
84
- post 'transfer_to_shipment'
85
- get :mine
86
- end
87
-
88
- member do
89
- put :ready
90
- put :ship
91
- put :add
92
- put :remove
93
- end
94
- end
95
- resources :states, only: [:index, :show]
96
-
97
- resources :taxonomies do
98
- member do
99
- get :jstree
100
- end
101
- resources :taxons do
102
- member do
103
- get :jstree
104
- end
105
- end
106
- end
107
-
108
- resources :taxons, only: [:index]
109
-
110
- resources :inventory_units, only: [:show, :update]
111
-
112
- resources :users do
113
- resources :credit_cards, only: [:index]
114
- end
115
-
116
- resources :properties
117
- resources :stock_locations do
118
- resources :stock_movements
119
- resources :stock_items
120
- end
121
-
122
- resources :stock_items, only: [:index, :update, :destroy]
123
- resources :stores
124
-
125
- put '/classifications', to: 'classifications#update', as: :classifications
126
- get '/taxons/products', to: 'taxons#products', as: :taxon_products
127
- end
128
-
129
9
  namespace :v2 do
130
10
  namespace :storefront do
131
11
  resource :cart, controller: :cart, only: %i[show create destroy] do
@@ -167,6 +47,7 @@ Spree::Core::Engine.add_routes do
167
47
  resources :products, only: %i[index show]
168
48
  resources :taxons, only: %i[index show], id: /.+/
169
49
  get '/stores/:code', to: 'stores#show', as: :store
50
+ get '/store', to: 'stores#current', as: :current_store
170
51
 
171
52
  resources :menus, only: %i[index show]
172
53
  resources :cms_pages, only: %i[index show]