solidus_api 4.7.3 → 4.8.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.
- checksums.yaml +4 -4
- data/LICENSE +3 -0
- data/app/controllers/spree/api/addresses_controller.rb +1 -1
- data/app/controllers/spree/api/base_controller.rb +2 -2
- data/app/controllers/spree/api/checkouts_controller.rb +5 -3
- data/app/controllers/spree/api/orders_controller.rb +7 -16
- data/app/controllers/spree/api/products_controller.rb +17 -15
- data/app/controllers/spree/api/shipments_controller.rb +2 -5
- data/app/controllers/spree/api/stock_movements_controller.rb +1 -0
- data/app/controllers/spree/api/users_controller.rb +1 -0
- data/app/controllers/spree/api/variants_controller.rb +9 -1
- data/app/views/spree/api/config/money.json.jbuilder +1 -1
- data/app/views/spree/api/config/show.json.jbuilder +1 -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/stores/_store.json.jbuilder +10 -0
- data/app/views/spree/api/stores/index.json.jbuilder +1 -1
- data/app/views/spree/api/stores/show.json.jbuilder +1 -1
- data/app/views/spree/api/variants/_big.json.jbuilder +2 -2
- data/app/views/spree/api/variants/_small.json.jbuilder +1 -1
- data/lib/spree/api.rb +1 -0
- data/openapi/solidus-api.oas.yml +4 -0
- metadata +5 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f4ff5000b131bd3d2fce8bc9e81165d860447f4c5a94d5364852af656fa4de8d
|
|
4
|
+
data.tar.gz: b46b662948606c65253e766a0b207ea00ad473aa217811b70a0d4bdee2c69c8a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8519bddff6d7f9b5dc478d19a1ef09b7f68473a89f94ab044c5c45e462bf93e72986888f2a6e5bc2dd0075f43d41330da07e0e9ba6955f751720f24a61fffbed
|
|
7
|
+
data.tar.gz: d0ee7c6a4d2584a00bbeb88e8442c3d6985e1c6f66590007458744cd3f11a2a9bbe9a06b88eddcba449dd7cf0d8fa239e513380ae9df3466fffb0726c8391ca1
|
data/LICENSE
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
Copyright (c) 2007-2014, Spree Commerce, Inc. and other contributors
|
|
2
2
|
All rights reserved.
|
|
3
3
|
|
|
4
|
+
Copyright (c) 2015-2026, Solidus contributors
|
|
5
|
+
All rights reserved.
|
|
6
|
+
|
|
4
7
|
Redistribution and use in source and binary forms, with or without modification,
|
|
5
8
|
are permitted provided that the following conditions are met:
|
|
6
9
|
|
|
@@ -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.update({"#{@order_source}_attributes" => address_params})
|
|
19
19
|
@address = @order.send(@order_source)
|
|
20
20
|
|
|
21
21
|
if success
|
|
@@ -7,7 +7,7 @@ module Spree
|
|
|
7
7
|
class BaseController < ActionController::Base
|
|
8
8
|
self.responder = Spree::Api::Responders::AppResponder
|
|
9
9
|
respond_to :json
|
|
10
|
-
protect_from_forgery unless: -> { request.format.json? }
|
|
10
|
+
protect_from_forgery with: :exception, unless: -> { request.format.json? }
|
|
11
11
|
|
|
12
12
|
include CanCan::ControllerAdditions
|
|
13
13
|
include ActiveStorage::SetCurrent
|
|
@@ -122,7 +122,7 @@ module Spree
|
|
|
122
122
|
end
|
|
123
123
|
|
|
124
124
|
def requires_authentication?
|
|
125
|
-
Spree::Api::Config
|
|
125
|
+
Spree::Api::Config.requires_authentication
|
|
126
126
|
end
|
|
127
127
|
|
|
128
128
|
def not_found
|
|
@@ -42,10 +42,12 @@ module Spree
|
|
|
42
42
|
def update
|
|
43
43
|
authorize! :update, @order, order_token
|
|
44
44
|
|
|
45
|
+
if can?(:admin, @order) && user_id.present?
|
|
46
|
+
user = Spree.user_class.accessible_by(current_ability, :show).find(user_id)
|
|
47
|
+
end
|
|
48
|
+
|
|
45
49
|
if Spree::Config.order_update_attributes_class.new(@order, update_params, request_env: request.headers.env).call
|
|
46
|
-
|
|
47
|
-
@order.associate_user!(Spree.user_class.find(user_id))
|
|
48
|
-
end
|
|
50
|
+
@order.associate_user!(user) if user
|
|
49
51
|
|
|
50
52
|
return if after_update_attributes
|
|
51
53
|
|
|
@@ -85,11 +85,13 @@ module Spree
|
|
|
85
85
|
def update
|
|
86
86
|
authorize! :update, @order, order_token
|
|
87
87
|
|
|
88
|
+
user_id = params[:order][:user_id]
|
|
89
|
+
if can?(:admin, @order) && user_id
|
|
90
|
+
user = Spree.user_class.accessible_by(current_ability, :show).find(user_id)
|
|
91
|
+
end
|
|
92
|
+
|
|
88
93
|
if @order.contents.update_cart(order_params)
|
|
89
|
-
|
|
90
|
-
if can?(:admin, @order) && user_id
|
|
91
|
-
@order.associate_user!(Spree.user_class.find(user_id))
|
|
92
|
-
end
|
|
94
|
+
@order.associate_user!(user) if user
|
|
93
95
|
respond_with(@order, default_template: :show)
|
|
94
96
|
else
|
|
95
97
|
invalid_resource!(@order)
|
|
@@ -119,7 +121,6 @@ module Spree
|
|
|
119
121
|
if params[:order]
|
|
120
122
|
normalize_params
|
|
121
123
|
prevent_customer_metadata_update
|
|
122
|
-
prevent_line_item_variant_update
|
|
123
124
|
params.require(:order).permit(permitted_order_attributes)
|
|
124
125
|
else
|
|
125
126
|
{}
|
|
@@ -132,16 +133,6 @@ module Spree
|
|
|
132
133
|
params[:order]&.delete(:customer_metadata)
|
|
133
134
|
end
|
|
134
135
|
|
|
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
|
-
|
|
145
136
|
def normalize_params
|
|
146
137
|
if params[:order][:payments]
|
|
147
138
|
payments_params = params[:order].delete(:payments)
|
|
@@ -159,7 +150,7 @@ module Spree
|
|
|
159
150
|
# @api public
|
|
160
151
|
def determine_order_user
|
|
161
152
|
if order_params[:user_id].present?
|
|
162
|
-
Spree.user_class.find(order_params[:user_id])
|
|
153
|
+
Spree.user_class.accessible_by(current_ability, :show).find(order_params[:user_id])
|
|
163
154
|
else
|
|
164
155
|
current_api_user
|
|
165
156
|
end
|
|
@@ -8,20 +8,15 @@ module Spree
|
|
|
8
8
|
ids = params[:ids].split(",").flatten
|
|
9
9
|
@products = product_scope.where(id: ids)
|
|
10
10
|
else
|
|
11
|
-
products_includes = [
|
|
12
|
-
:variants,
|
|
13
|
-
:option_types,
|
|
14
|
-
:product_properties,
|
|
15
|
-
{classifications: :taxon}
|
|
16
|
-
]
|
|
17
11
|
@products = product_scope
|
|
18
12
|
.ransack(params[:q])
|
|
19
13
|
.result
|
|
20
|
-
.includes(products_includes)
|
|
21
14
|
end
|
|
22
15
|
|
|
16
|
+
@products = @products.includes(products_includes)
|
|
23
17
|
@products = paginate(@products.distinct)
|
|
24
|
-
|
|
18
|
+
expires_in 15.minutes, public: true
|
|
19
|
+
headers["Surrogate-Control"] = "max-age=#{15.minutes}"
|
|
25
20
|
respond_with(@products)
|
|
26
21
|
end
|
|
27
22
|
|
|
@@ -30,7 +25,9 @@ module Spree
|
|
|
30
25
|
|
|
31
26
|
def show
|
|
32
27
|
@product = find_product(params[:id])
|
|
33
|
-
|
|
28
|
+
expires_in 15.minutes, public: true
|
|
29
|
+
headers["Surrogate-Control"] = "max-age=#{15.minutes}"
|
|
30
|
+
headers["Surrogate-Key"] = "product_id=1"
|
|
34
31
|
respond_with(@product)
|
|
35
32
|
end
|
|
36
33
|
|
|
@@ -105,14 +102,19 @@ module Spree
|
|
|
105
102
|
|
|
106
103
|
private
|
|
107
104
|
|
|
108
|
-
def
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
105
|
+
def products_includes
|
|
106
|
+
[
|
|
107
|
+
:option_types,
|
|
108
|
+
:product_properties,
|
|
109
|
+
{classifications: :taxon},
|
|
110
|
+
{master: variants_includes},
|
|
111
|
+
{variants: variants_includes},
|
|
112
|
+
{variants_including_master: variants_includes}
|
|
113
|
+
]
|
|
114
114
|
end
|
|
115
115
|
|
|
116
|
+
def variants_includes = {stock_items: :stock_location, images: Spree::Image.attachment_preloads}
|
|
117
|
+
|
|
116
118
|
def product_params
|
|
117
119
|
product_params = params.require(:product).permit(permitted_product_attributes)
|
|
118
120
|
if product_params[:taxon_ids].present?
|
|
@@ -93,16 +93,13 @@ module Spree
|
|
|
93
93
|
end
|
|
94
94
|
|
|
95
95
|
def transfer_to_location
|
|
96
|
-
@desired_stock_location = Spree::StockLocation.find(params[:stock_location_id])
|
|
96
|
+
@desired_stock_location = Spree::StockLocation.accessible_by(current_ability, :show).find(params[:stock_location_id])
|
|
97
97
|
@desired_shipment = @original_shipment.order.shipments.build(stock_location: @desired_stock_location)
|
|
98
98
|
transfer_to_shipment
|
|
99
99
|
end
|
|
100
100
|
|
|
101
101
|
def transfer_to_shipment
|
|
102
|
-
|
|
103
|
-
@desired_shipment = @original_shipment.order.shipments.find_by!(number: params[:target_shipment_number])
|
|
104
|
-
authorize! :update, @desired_shipment
|
|
105
|
-
end
|
|
102
|
+
@desired_shipment ||= Spree::Shipment.find_by!(number: params[:target_shipment_number])
|
|
106
103
|
|
|
107
104
|
fulfilment_changer = Spree::FulfilmentChanger.new(
|
|
108
105
|
current_shipment: @original_shipment,
|
|
@@ -5,6 +5,7 @@ class Spree::Api::UsersController < Spree::Api::BaseController
|
|
|
5
5
|
|
|
6
6
|
def index
|
|
7
7
|
user_scope = user_class.accessible_by(current_ability, :show)
|
|
8
|
+
.includes(bill_address: [:state, :country], ship_address: [:state, :country])
|
|
8
9
|
if params[:ids]
|
|
9
10
|
ids = params[:ids].split(",").flatten
|
|
10
11
|
@users = user_scope.where(id: ids)
|
|
@@ -89,8 +89,16 @@ module Spree
|
|
|
89
89
|
end
|
|
90
90
|
|
|
91
91
|
def include_list
|
|
92
|
-
[
|
|
92
|
+
[
|
|
93
|
+
{option_values: :option_type},
|
|
94
|
+
{product: {master: images_includes}},
|
|
95
|
+
:prices,
|
|
96
|
+
images_includes,
|
|
97
|
+
{stock_items: :stock_location}
|
|
98
|
+
]
|
|
93
99
|
end
|
|
100
|
+
|
|
101
|
+
def images_includes = {images: Spree::Image.attachment_preloads}
|
|
94
102
|
end
|
|
95
103
|
end
|
|
96
104
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
json.cache! [I18n.locale, line_item
|
|
3
|
+
json.cache! [I18n.locale, line_item] 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
|
|
3
|
+
json.cache! [I18n.locale, order] 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
|
|
3
|
+
json.cache! [I18n.locale, shipment] 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
|
|
3
|
+
json.cache! [I18n.locale, shipment] 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
|
|
3
|
+
json.cache! [I18n.locale, @shipment] 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,12 +1,12 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
json.cache! [I18n.locale, Spree::StockLocation.accessible_by(current_ability), variant
|
|
3
|
+
json.cache! [I18n.locale, Spree::StockLocation.accessible_by(current_ability), variant] 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|
|
|
7
7
|
json.call(variant_property, *variant_property_attributes)
|
|
8
8
|
end
|
|
9
|
-
json.stock_items(variant.stock_items.
|
|
9
|
+
json.stock_items(variant.stock_items.select { can?(:read, _1) }) do |stock_item|
|
|
10
10
|
json.call(stock_item, :id, :count_on_hand, :stock_location_id, :backorderable)
|
|
11
11
|
json.available stock_item.available?
|
|
12
12
|
json.stock_location_name(stock_item.stock_location.name)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
json.cache! [I18n.locale, current_pricing_options, variant
|
|
3
|
+
json.cache! [I18n.locale, current_pricing_options, variant] 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)
|
data/lib/spree/api.rb
CHANGED
data/openapi/solidus-api.oas.yml
CHANGED
|
@@ -6474,6 +6474,8 @@ components:
|
|
|
6474
6474
|
type: string
|
|
6475
6475
|
url:
|
|
6476
6476
|
type: string
|
|
6477
|
+
address:
|
|
6478
|
+
$ref: '#/components/schemas/address'
|
|
6477
6479
|
taxonomy:
|
|
6478
6480
|
type: object
|
|
6479
6481
|
properties:
|
|
@@ -6955,6 +6957,8 @@ components:
|
|
|
6955
6957
|
type: string
|
|
6956
6958
|
cart_tax_country_iso:
|
|
6957
6959
|
type: string
|
|
6960
|
+
address_attributes:
|
|
6961
|
+
$ref: '#/components/schemas/address-input'
|
|
6958
6962
|
taxonomy-input:
|
|
6959
6963
|
type: object
|
|
6960
6964
|
title: Taxonomy input
|
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.
|
|
4
|
+
version: 4.8.0
|
|
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.
|
|
60
|
+
version: 4.8.0
|
|
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.
|
|
67
|
+
version: 4.8.0
|
|
68
68
|
description: REST API for the Solidus e-commerce framework.
|
|
69
69
|
email: contact@solidus.io
|
|
70
70
|
executables: []
|
|
@@ -198,6 +198,7 @@ files:
|
|
|
198
198
|
- app/views/spree/api/stock_movements/index.json.jbuilder
|
|
199
199
|
- app/views/spree/api/stock_movements/show.json.jbuilder
|
|
200
200
|
- app/views/spree/api/store_credit_events/mine.json.jbuilder
|
|
201
|
+
- app/views/spree/api/stores/_store.json.jbuilder
|
|
201
202
|
- app/views/spree/api/stores/index.json.jbuilder
|
|
202
203
|
- app/views/spree/api/stores/show.json.jbuilder
|
|
203
204
|
- app/views/spree/api/taxonomies/_nested.json.jbuilder
|
|
@@ -271,7 +272,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
271
272
|
- !ruby/object:Gem::Version
|
|
272
273
|
version: 1.8.23
|
|
273
274
|
requirements: []
|
|
274
|
-
rubygems_version: 4.0.
|
|
275
|
+
rubygems_version: 4.0.20
|
|
275
276
|
specification_version: 4
|
|
276
277
|
summary: REST API for the Solidus e-commerce framework.
|
|
277
278
|
test_files: []
|