spree_api 4.4.0 → 4.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/concerns/spree/api/v2/product_list_includes.rb +10 -8
- data/app/controllers/spree/api/v2/platform/orders_controller.rb +1 -1
- data/app/controllers/spree/api/v2/platform/products_controller.rb +5 -1
- data/app/controllers/spree/api/v2/storefront/checkout_controller.rb +1 -1
- data/app/controllers/spree/api/v2/storefront/digitals_controller.rb +5 -1
- data/app/controllers/spree/api/v2/storefront/stores_controller.rb +4 -0
- data/app/helpers/spree/api/v2/store_media_serializer_images_concern.rb +35 -0
- data/app/models/concerns/spree/webhooks/has_webhooks.rb +31 -7
- data/app/models/spree/api/webhooks/product_decorator.rb +21 -2
- data/app/models/spree/webhooks/subscriber.rb +4 -0
- data/app/serializers/spree/api/v2/platform/cms_section_image_one_serializer.rb +9 -0
- data/app/serializers/spree/api/v2/platform/cms_section_image_three_serializer.rb +9 -0
- data/app/serializers/spree/api/v2/platform/cms_section_image_two_serializer.rb +9 -0
- data/app/serializers/spree/api/v2/platform/hero_image_serializer.rb +10 -0
- data/app/serializers/spree/api/v2/platform/image_gallery_serializer.rb +10 -0
- data/app/serializers/spree/api/v2/platform/side_by_side_image_serializer.rb +10 -0
- data/app/serializers/spree/api/v2/platform/store_serializer.rb +1 -0
- data/app/serializers/spree/api/v2/platform/user_serializer.rb +1 -1
- data/app/serializers/spree/v2/storefront/cms_section_serializer.rb +3 -3
- data/app/serializers/spree/v2/storefront/order_serializer.rb +9 -0
- data/app/serializers/spree/v2/storefront/product_property_serializer.rb +1 -1
- data/app/serializers/spree/v2/storefront/product_serializer.rb +1 -1
- data/app/serializers/spree/v2/storefront/shipment_serializer.rb +3 -0
- data/app/serializers/spree/v2/storefront/store_serializer.rb +5 -10
- data/app/serializers/spree/v2/storefront/user_serializer.rb +1 -1
- data/app/serializers/spree/v2/storefront/variant_serializer.rb +1 -1
- data/app/services/spree/webhooks/subscribers/queue_requests.rb +8 -2
- data/config/routes.rb +1 -120
- data/docs/v2/platform/index.yaml +1597 -998
- data/docs/v2/storefront/index.yaml +357 -33
- data/lib/spree/api/configuration.rb +11 -0
- data/lib/spree/api/dependencies.rb +165 -0
- data/lib/spree/api/engine.rb +5 -16
- data/lib/spree/api/testing_support/v2/platform_contexts.rb +0 -1
- data/lib/spree/api.rb +0 -4
- data/lib/spree_api.rb +0 -1
- data/spree_api.gemspec +0 -2
- metadata +16 -177
- data/app/controllers/spree/api/base_controller.rb +0 -171
- data/app/controllers/spree/api/v1/addresses_controller.rb +0 -46
- data/app/controllers/spree/api/v1/checkouts_controller.rb +0 -106
- data/app/controllers/spree/api/v1/classifications_controller.rb +0 -21
- data/app/controllers/spree/api/v1/countries_controller.rb +0 -22
- data/app/controllers/spree/api/v1/credit_cards_controller.rb +0 -26
- data/app/controllers/spree/api/v1/customer_returns_controller.rb +0 -25
- data/app/controllers/spree/api/v1/images_controller.rb +0 -58
- data/app/controllers/spree/api/v1/inventory_units_controller.rb +0 -54
- data/app/controllers/spree/api/v1/line_items_controller.rb +0 -70
- data/app/controllers/spree/api/v1/option_types_controller.rb +0 -60
- data/app/controllers/spree/api/v1/option_values_controller.rb +0 -62
- data/app/controllers/spree/api/v1/orders_controller.rb +0 -160
- data/app/controllers/spree/api/v1/payments_controller.rb +0 -82
- data/app/controllers/spree/api/v1/product_properties_controller.rb +0 -73
- data/app/controllers/spree/api/v1/products_controller.rb +0 -131
- data/app/controllers/spree/api/v1/promotions_controller.rb +0 -30
- data/app/controllers/spree/api/v1/properties_controller.rb +0 -70
- data/app/controllers/spree/api/v1/reimbursements_controller.rb +0 -25
- data/app/controllers/spree/api/v1/return_authorizations_controller.rb +0 -70
- data/app/controllers/spree/api/v1/shipments_controller.rb +0 -196
- data/app/controllers/spree/api/v1/states_controller.rb +0 -36
- data/app/controllers/spree/api/v1/stock_items_controller.rb +0 -82
- data/app/controllers/spree/api/v1/stock_locations_controller.rb +0 -53
- data/app/controllers/spree/api/v1/stock_movements_controller.rb +0 -45
- data/app/controllers/spree/api/v1/stores_controller.rb +0 -56
- data/app/controllers/spree/api/v1/taxonomies_controller.rb +0 -67
- data/app/controllers/spree/api/v1/taxons_controller.rb +0 -100
- data/app/controllers/spree/api/v1/users_controller.rb +0 -97
- data/app/controllers/spree/api/v1/variants_controller.rb +0 -81
- data/app/controllers/spree/api/v1/zones_controller.rb +0 -55
- data/app/helpers/spree/api/api_helpers.rb +0 -190
- data/app/models/spree/api_configuration.rb +0 -10
- data/app/views/spree/api/errors/gateway_error.rabl +0 -2
- data/app/views/spree/api/errors/invalid_api_key.rabl +0 -2
- data/app/views/spree/api/errors/invalid_resource.rabl +0 -3
- data/app/views/spree/api/errors/must_specify_api_key.rabl +0 -2
- data/app/views/spree/api/errors/not_found.rabl +0 -2
- data/app/views/spree/api/errors/unauthorized.rabl +0 -2
- data/app/views/spree/api/v1/addresses/show.rabl +0 -10
- data/app/views/spree/api/v1/adjustments/show.rabl +0 -4
- data/app/views/spree/api/v1/countries/index.rabl +0 -7
- data/app/views/spree/api/v1/countries/show.rabl +0 -5
- data/app/views/spree/api/v1/credit_cards/index.rabl +0 -7
- data/app/views/spree/api/v1/credit_cards/show.rabl +0 -3
- data/app/views/spree/api/v1/customer_returns/index.rabl +0 -7
- data/app/views/spree/api/v1/images/index.rabl +0 -4
- data/app/views/spree/api/v1/images/new.rabl +0 -3
- data/app/views/spree/api/v1/images/show.rabl +0 -6
- data/app/views/spree/api/v1/inventory_units/show.rabl +0 -2
- data/app/views/spree/api/v1/line_items/new.rabl +0 -3
- data/app/views/spree/api/v1/line_items/show.rabl +0 -14
- data/app/views/spree/api/v1/option_types/index.rabl +0 -3
- data/app/views/spree/api/v1/option_types/new.rabl +0 -3
- data/app/views/spree/api/v1/option_types/show.rabl +0 -5
- data/app/views/spree/api/v1/option_values/index.rabl +0 -3
- data/app/views/spree/api/v1/option_values/new.rabl +0 -3
- data/app/views/spree/api/v1/option_values/show.rabl +0 -2
- data/app/views/spree/api/v1/orders/address.rabl +0 -0
- data/app/views/spree/api/v1/orders/canceled.rabl +0 -0
- data/app/views/spree/api/v1/orders/cart.rabl +0 -0
- data/app/views/spree/api/v1/orders/complete.rabl +0 -0
- data/app/views/spree/api/v1/orders/could_not_apply_coupon.rabl +0 -2
- data/app/views/spree/api/v1/orders/could_not_transition.rabl +0 -3
- data/app/views/spree/api/v1/orders/index.rabl +0 -7
- data/app/views/spree/api/v1/orders/insufficient_quantity.rabl +0 -2
- data/app/views/spree/api/v1/orders/invalid_shipping_method.rabl +0 -2
- data/app/views/spree/api/v1/orders/mine.rabl +0 -9
- data/app/views/spree/api/v1/orders/order.rabl +0 -10
- data/app/views/spree/api/v1/orders/payment.rabl +0 -3
- data/app/views/spree/api/v1/orders/show.rabl +0 -51
- data/app/views/spree/api/v1/payments/credit_over_limit.rabl +0 -2
- data/app/views/spree/api/v1/payments/index.rabl +0 -7
- data/app/views/spree/api/v1/payments/new.rabl +0 -5
- data/app/views/spree/api/v1/payments/show.rabl +0 -2
- data/app/views/spree/api/v1/payments/update_forbidden.rabl +0 -2
- data/app/views/spree/api/v1/product_properties/index.rabl +0 -7
- data/app/views/spree/api/v1/product_properties/new.rabl +0 -2
- data/app/views/spree/api/v1/product_properties/show.rabl +0 -2
- data/app/views/spree/api/v1/products/index.rabl +0 -9
- data/app/views/spree/api/v1/products/new.rabl +0 -3
- data/app/views/spree/api/v1/products/product.rabl +0 -1
- data/app/views/spree/api/v1/products/show.rabl +0 -36
- data/app/views/spree/api/v1/promotions/handler.rabl +0 -5
- data/app/views/spree/api/v1/promotions/show.rabl +0 -2
- data/app/views/spree/api/v1/properties/index.rabl +0 -7
- data/app/views/spree/api/v1/properties/new.rabl +0 -2
- data/app/views/spree/api/v1/properties/show.rabl +0 -2
- data/app/views/spree/api/v1/reimbursements/index.rabl +0 -7
- data/app/views/spree/api/v1/return_authorizations/index.rabl +0 -7
- data/app/views/spree/api/v1/return_authorizations/new.rabl +0 -3
- data/app/views/spree/api/v1/return_authorizations/show.rabl +0 -2
- data/app/views/spree/api/v1/shared/stock_location_required.rabl +0 -2
- data/app/views/spree/api/v1/shipments/big.rabl +0 -48
- data/app/views/spree/api/v1/shipments/cannot_ready_shipment.rabl +0 -2
- data/app/views/spree/api/v1/shipments/mine.rabl +0 -9
- data/app/views/spree/api/v1/shipments/show.rabl +0 -32
- data/app/views/spree/api/v1/shipments/small.rabl +0 -37
- data/app/views/spree/api/v1/shipping_rates/show.rabl +0 -2
- data/app/views/spree/api/v1/states/index.rabl +0 -12
- data/app/views/spree/api/v1/states/show.rabl +0 -2
- data/app/views/spree/api/v1/stock_items/index.rabl +0 -7
- data/app/views/spree/api/v1/stock_items/show.rabl +0 -5
- data/app/views/spree/api/v1/stock_locations/index.rabl +0 -7
- data/app/views/spree/api/v1/stock_locations/show.rabl +0 -8
- data/app/views/spree/api/v1/stock_movements/index.rabl +0 -7
- data/app/views/spree/api/v1/stock_movements/show.rabl +0 -5
- data/app/views/spree/api/v1/stores/index.rabl +0 -4
- data/app/views/spree/api/v1/stores/show.rabl +0 -2
- data/app/views/spree/api/v1/tags/index.rabl +0 -9
- data/app/views/spree/api/v1/taxonomies/index.rabl +0 -7
- data/app/views/spree/api/v1/taxonomies/jstree.rabl +0 -7
- data/app/views/spree/api/v1/taxonomies/nested.rabl +0 -11
- data/app/views/spree/api/v1/taxonomies/new.rabl +0 -3
- data/app/views/spree/api/v1/taxonomies/show.rabl +0 -15
- data/app/views/spree/api/v1/taxons/index.rabl +0 -10
- data/app/views/spree/api/v1/taxons/jstree.rabl +0 -7
- data/app/views/spree/api/v1/taxons/new.rabl +0 -3
- data/app/views/spree/api/v1/taxons/show.rabl +0 -6
- data/app/views/spree/api/v1/taxons/taxons.rabl +0 -5
- data/app/views/spree/api/v1/users/index.rabl +0 -7
- data/app/views/spree/api/v1/users/new.rabl +0 -3
- data/app/views/spree/api/v1/users/show.rabl +0 -11
- data/app/views/spree/api/v1/variants/big.rabl +0 -14
- data/app/views/spree/api/v1/variants/index.rabl +0 -9
- data/app/views/spree/api/v1/variants/new.rabl +0 -2
- data/app/views/spree/api/v1/variants/show.rabl +0 -3
- data/app/views/spree/api/v1/variants/small.rabl +0 -18
- data/app/views/spree/api/v1/zones/index.rabl +0 -7
- data/app/views/spree/api/v1/zones/show.rabl +0 -6
- data/config/initializers/rabl.rb +0 -9
- data/lib/spree/api/api_dependencies.rb +0 -163
- data/lib/spree/api/controller_setup.rb +0 -19
- data/lib/spree/api/responders/rabl_template.rb +0 -28
- data/lib/spree/api/responders.rb +0 -11
- data/lib/spree/api/testing_support/helpers.rb +0 -44
- 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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 57236192b982b8939614697a3f1ea3b46e95456e2b9f43c324b4c4b88dd3a5be
|
4
|
+
data.tar.gz: 4cf278eeee9926968327b8e4746bec902a8067a8594f7d6c9fdea281d8fbef84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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:
|
17
|
-
variants:
|
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
|
23
|
+
super.push(:available_on, :make_active_at)
|
20
24
|
end
|
21
25
|
|
22
26
|
def sorted_collection
|
@@ -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:
|
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
|
@@ -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) &&
|
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(
|
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
|
-
|
44
|
-
|
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
|
48
|
-
|
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
|
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
|
-
|
@@ -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::
|
10
|
-
Spree::
|
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}")
|
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
|
@@ -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?
|
@@ -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,
|
8
|
-
:
|
9
|
-
:address, :contact_phone, :supported_locales
|
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
|
@@ -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
|
-
|
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]
|