solidus_api 4.7.2 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a09ac9341a0721a7b5cd1ee955557b6659e0baa689adcd3abfc0b73b6e96cfc0
4
- data.tar.gz: 473737cd41360507d3d6eacffcbf64d6dffb65d05c8d3d6b85b934ebcc2a1137
3
+ metadata.gz: f4ff5000b131bd3d2fce8bc9e81165d860447f4c5a94d5364852af656fa4de8d
4
+ data.tar.gz: b46b662948606c65253e766a0b207ea00ad473aa217811b70a0d4bdee2c69c8a
5
5
  SHA512:
6
- metadata.gz: ed264bfc8321d2072db352b6820fbbcee2c72918f500279e940fe7f11ff329442baf4c657eb7ddf67870fd44eeb7966044cf55033f032d29ecb1516d14d5dd6d
7
- data.tar.gz: 6f220657fb6b51d027586734957b61ae6e8b22f68acfc9637a7c983ce56f5b6e0684e4ad5e6b893b62472430c8f99dac15930b0826dd7869f1c4baf29a7929b0
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
 
@@ -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[:requires_authentication]
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
- if can?(:admin, @order) && user_id.present?
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
- user_id = params[:order][:user_id]
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)
@@ -148,7 +150,7 @@ module Spree
148
150
  # @api public
149
151
  def determine_order_user
150
152
  if order_params[:user_id].present?
151
- Spree.user_class.find(order_params[:user_id])
153
+ Spree.user_class.accessible_by(current_ability, :show).find(order_params[:user_id])
152
154
  else
153
155
  current_api_user
154
156
  end
@@ -8,18 +8,12 @@ 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
25
19
  headers["Surrogate-Control"] = "max-age=#{15.minutes}"
@@ -108,6 +102,19 @@ module Spree
108
102
 
109
103
  private
110
104
 
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
+ end
115
+
116
+ def variants_includes = {stock_items: :stock_location, images: Spree::Image.attachment_preloads}
117
+
111
118
  def product_params
112
119
  product_params = params.require(:product).permit(permitted_product_attributes)
113
120
  if product_params[:taxon_ids].present?
@@ -93,7 +93,7 @@ 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
@@ -34,6 +34,7 @@ module Spree
34
34
 
35
35
  def scope
36
36
  @stock_location.stock_movements.accessible_by(current_ability)
37
+ .includes(stock_item: {variant: [:product, :prices, :stock_items, :images, {option_values: :option_type}]})
37
38
  end
38
39
 
39
40
  def stock_movement_params
@@ -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
- [{option_values: :option_type}, :product, :prices, :images, {stock_items: :stock_location}]
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,3 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- json.symbol(::Money.new(1, Spree::Config[:currency]).symbol)
3
+ json.symbol(::Money.new(1, Spree::Config.currency).symbol)
@@ -1,3 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- json.default_country_iso(Spree::Config[:default_country_iso])
3
+ json.default_country_iso(Spree::Config.default_country_iso)
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ json.call(store, *store_attributes)
4
+ json.address do
5
+ if store.address
6
+ json.partial!("spree/api/addresses/address", address: store.address)
7
+ else
8
+ json.nil!
9
+ end
10
+ end
@@ -1,3 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- json.stores(@stores) { |store| json.call(store, *store_attributes) }
3
+ json.stores(@stores) { |store| json.partial!("spree/api/stores/store", store:) }
@@ -1,3 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- json.call(@store, *store_attributes)
3
+ json.partial!("spree/api/stores/store", store: @store)
@@ -6,7 +6,7 @@ json.cache! [I18n.locale, Spree::StockLocation.accessible_by(current_ability), v
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.accessible_by(current_ability)) do |stock_item|
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)
data/lib/spree/api.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "kaminari/activerecord"
3
4
  require "spree/core"
4
5
 
5
6
  require "spree/api/engine"
@@ -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.7.2
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.7.2
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.7.2
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.10
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: []