solidus_api 4.7.2 → 4.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/spree/api/addresses_controller.rb +1 -1
- data/app/controllers/spree/api/orders_controller.rb +11 -0
- data/app/controllers/spree/api/products_controller.rb +10 -5
- data/app/controllers/spree/api/shipments_controller.rb +4 -1
- data/app/views/spree/api/line_items/_line_item.json.jbuilder +1 -1
- data/app/views/spree/api/orders/_order.json.jbuilder +1 -1
- data/app/views/spree/api/shipments/_big.json.jbuilder +1 -1
- data/app/views/spree/api/shipments/_small.json.jbuilder +1 -1
- data/app/views/spree/api/shipments/show.json.jbuilder +1 -1
- data/app/views/spree/api/variants/_big.json.jbuilder +1 -1
- data/app/views/spree/api/variants/_small.json.jbuilder +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: eccdd48bcff16941d9551a3033ae485cc07f7d44c5c20261649d8d81d5075b68
|
|
4
|
+
data.tar.gz: 3eeb7c3954e19d82dc3ee4b55a1c860845f03e8f4d9f5a5cdab46940c7220469
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 66b961c53c70065c4aa9d9678bf6af6592f9e66faa0821cac2fa362761483cae12f436dfd9754cf0de42c79df1bc86b301010ff6d4e45c7f6e0ff55c4771996e
|
|
7
|
+
data.tar.gz: 754d8fae5afee560ce720c863c15a02d2f21d12f85a4bff6e1b07c86b3cd0549e5a57bf4e7fa003fb2853bd79e042f4b93843b3edc62d6e32c2031ac5dd3337c
|
|
@@ -15,7 +15,7 @@ module Spree
|
|
|
15
15
|
authorize! :update, @order, order_token
|
|
16
16
|
find_address
|
|
17
17
|
|
|
18
|
-
success = @order.
|
|
18
|
+
success = @order.contents.update_cart({"#{@order_source}_attributes" => address_params})
|
|
19
19
|
@address = @order.send(@order_source)
|
|
20
20
|
|
|
21
21
|
if success
|
|
@@ -119,6 +119,7 @@ module Spree
|
|
|
119
119
|
if params[:order]
|
|
120
120
|
normalize_params
|
|
121
121
|
prevent_customer_metadata_update
|
|
122
|
+
prevent_line_item_variant_update
|
|
122
123
|
params.require(:order).permit(permitted_order_attributes)
|
|
123
124
|
else
|
|
124
125
|
{}
|
|
@@ -131,6 +132,16 @@ module Spree
|
|
|
131
132
|
params[:order]&.delete(:customer_metadata)
|
|
132
133
|
end
|
|
133
134
|
|
|
135
|
+
def prevent_line_item_variant_update
|
|
136
|
+
line_items_attributes = params[:order][:line_items_attributes]
|
|
137
|
+
return unless line_items_attributes
|
|
138
|
+
|
|
139
|
+
line_items_attributes = line_items_attributes.values unless line_items_attributes.is_a?(Array)
|
|
140
|
+
line_items_attributes.each do |line_item_attributes|
|
|
141
|
+
line_item_attributes.delete(:variant_id) if line_item_attributes[:id].present?
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
|
|
134
145
|
def normalize_params
|
|
135
146
|
if params[:order][:payments]
|
|
136
147
|
payments_params = params[:order].delete(:payments)
|
|
@@ -21,8 +21,7 @@ module Spree
|
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
@products = paginate(@products.distinct)
|
|
24
|
-
|
|
25
|
-
headers["Surrogate-Control"] = "max-age=#{15.minutes}"
|
|
24
|
+
set_cache_headers
|
|
26
25
|
respond_with(@products)
|
|
27
26
|
end
|
|
28
27
|
|
|
@@ -31,9 +30,7 @@ module Spree
|
|
|
31
30
|
|
|
32
31
|
def show
|
|
33
32
|
@product = find_product(params[:id])
|
|
34
|
-
|
|
35
|
-
headers["Surrogate-Control"] = "max-age=#{15.minutes}"
|
|
36
|
-
headers["Surrogate-Key"] = "product_id=1"
|
|
33
|
+
set_cache_headers(surrogate_key: "product_id=#{@product.id}")
|
|
37
34
|
respond_with(@product)
|
|
38
35
|
end
|
|
39
36
|
|
|
@@ -108,6 +105,14 @@ module Spree
|
|
|
108
105
|
|
|
109
106
|
private
|
|
110
107
|
|
|
108
|
+
def set_cache_headers(surrogate_key: nil)
|
|
109
|
+
return if current_api_user
|
|
110
|
+
|
|
111
|
+
expires_in 15.minutes, public: true
|
|
112
|
+
headers["Surrogate-Control"] = "max-age=#{15.minutes}"
|
|
113
|
+
headers["Surrogate-Key"] = surrogate_key if surrogate_key
|
|
114
|
+
end
|
|
115
|
+
|
|
111
116
|
def product_params
|
|
112
117
|
product_params = params.require(:product).permit(permitted_product_attributes)
|
|
113
118
|
if product_params[:taxon_ids].present?
|
|
@@ -99,7 +99,10 @@ module Spree
|
|
|
99
99
|
end
|
|
100
100
|
|
|
101
101
|
def transfer_to_shipment
|
|
102
|
-
@desired_shipment
|
|
102
|
+
unless @desired_shipment
|
|
103
|
+
@desired_shipment = @original_shipment.order.shipments.find_by!(number: params[:target_shipment_number])
|
|
104
|
+
authorize! :update, @desired_shipment
|
|
105
|
+
end
|
|
103
106
|
|
|
104
107
|
fulfilment_changer = Spree::FulfilmentChanger.new(
|
|
105
108
|
current_shipment: @original_shipment,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
json.cache! [I18n.locale, line_item] do
|
|
3
|
+
json.cache! [I18n.locale, line_item, line_item_attributes, variant_attributes] do
|
|
4
4
|
json.call(line_item, *line_item_attributes)
|
|
5
5
|
json.single_display_amount(line_item.single_display_amount.to_s)
|
|
6
6
|
json.display_amount(line_item.display_amount.to_s)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
json.cache! [I18n.locale, order] do
|
|
3
|
+
json.cache! [I18n.locale, order, order_attributes] do
|
|
4
4
|
json.call(order, *order_attributes)
|
|
5
5
|
json.display_item_total(order.display_item_total.to_s)
|
|
6
6
|
json.total_quantity(order.line_items.to_a.sum(&:quantity))
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
json.cache! [I18n.locale, shipment] do
|
|
3
|
+
json.cache! [I18n.locale, shipment, shipment_attributes, line_item_attributes, order_attributes, variant_attributes] do
|
|
4
4
|
json.call(shipment, *shipment_attributes)
|
|
5
5
|
json.partial!("spree/api/shipments/small", shipment:)
|
|
6
6
|
json.inventory_units(shipment.inventory_units) do |inventory_unit|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
json.cache! [I18n.locale, shipment] do
|
|
3
|
+
json.cache! [I18n.locale, shipment, shipment_attributes] do
|
|
4
4
|
json.call(shipment, *shipment_attributes)
|
|
5
5
|
json.order_id(shipment.order.number)
|
|
6
6
|
json.stock_location_name(shipment.stock_location.name)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
json.cache! [I18n.locale, @shipment] do
|
|
3
|
+
json.cache! [I18n.locale, @shipment, shipment_attributes, variant_attributes] do
|
|
4
4
|
json.call(@shipment, *shipment_attributes)
|
|
5
5
|
json.order_id(@shipment.order.number)
|
|
6
6
|
json.stock_location_name(@shipment.stock_location.name)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
json.cache! [I18n.locale, Spree::StockLocation.accessible_by(current_ability), variant] do
|
|
3
|
+
json.cache! [I18n.locale, Spree::StockLocation.accessible_by(current_ability), variant, variant_attributes] do
|
|
4
4
|
json.call(variant, *variant_attributes)
|
|
5
5
|
json.partial!("spree/api/variants/small", variant:)
|
|
6
6
|
json.variant_properties(variant.variant_properties) do |variant_property|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
json.cache! [I18n.locale, current_pricing_options, variant] do
|
|
3
|
+
json.cache! [I18n.locale, current_pricing_options, variant, variant_attributes] do
|
|
4
4
|
json.call(variant, *variant_attributes)
|
|
5
5
|
json.price(variant.price_for_options(current_pricing_options)&.amount)
|
|
6
6
|
json.display_price(variant.price_for_options(current_pricing_options)&.money&.to_s)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: solidus_api
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.7.
|
|
4
|
+
version: 4.7.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Solidus Team
|
|
@@ -57,14 +57,14 @@ dependencies:
|
|
|
57
57
|
requirements:
|
|
58
58
|
- - '='
|
|
59
59
|
- !ruby/object:Gem::Version
|
|
60
|
-
version: 4.7.
|
|
60
|
+
version: 4.7.3
|
|
61
61
|
type: :runtime
|
|
62
62
|
prerelease: false
|
|
63
63
|
version_requirements: !ruby/object:Gem::Requirement
|
|
64
64
|
requirements:
|
|
65
65
|
- - '='
|
|
66
66
|
- !ruby/object:Gem::Version
|
|
67
|
-
version: 4.7.
|
|
67
|
+
version: 4.7.3
|
|
68
68
|
description: REST API for the Solidus e-commerce framework.
|
|
69
69
|
email: contact@solidus.io
|
|
70
70
|
executables: []
|