solidus_api 4.7.3 → 4.8.1

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: eccdd48bcff16941d9551a3033ae485cc07f7d44c5c20261649d8d81d5075b68
4
- data.tar.gz: 3eeb7c3954e19d82dc3ee4b55a1c860845f03e8f4d9f5a5cdab46940c7220469
3
+ metadata.gz: d263182b8d9ee2d2072f32c87022a1e0883b1522b898db8dadab534674cf70ce
4
+ data.tar.gz: 9c4036c14c41532ff348e3a444e8c720c589914ad3641f0e9f5132c21792c925
5
5
  SHA512:
6
- metadata.gz: 66b961c53c70065c4aa9d9678bf6af6592f9e66faa0821cac2fa362761483cae12f436dfd9754cf0de42c79df1bc86b301010ff6d4e45c7f6e0ff55c4771996e
7
- data.tar.gz: 754d8fae5afee560ce720c863c15a02d2f21d12f85a4bff6e1b07c86b3cd0549e5a57bf4e7fa003fb2853bd79e042f4b93843b3edc62d6e32c2031ac5dd3337c
6
+ metadata.gz: 5ee813760d0c3f5f2c1c15b276587ab109e8897b80ac71f014b064a5eb02628e07fbcab21c674539fd668d0b5e864d06eaf6e1600278978ec6565724ba99d869
7
+ data.tar.gz: 357c9e20c2accc9a98b78b408d440063b82fc2787f887061188981eb3fd788224cebdf3c76da59aa986f56b2894d9298833989c16252ac2aba3f3fa19098d8b6
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)
@@ -159,7 +161,7 @@ module Spree
159
161
  # @api public
160
162
  def determine_order_user
161
163
  if order_params[:user_id].present?
162
- Spree.user_class.find(order_params[:user_id])
164
+ Spree.user_class.accessible_by(current_ability, :show).find(order_params[:user_id])
163
165
  else
164
166
  current_api_user
165
167
  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
  set_cache_headers
25
19
  respond_with(@products)
@@ -105,6 +99,19 @@ module Spree
105
99
 
106
100
  private
107
101
 
102
+ def products_includes
103
+ [
104
+ :option_types,
105
+ :product_properties,
106
+ {classifications: :taxon},
107
+ {master: variants_includes},
108
+ {variants: variants_includes},
109
+ {variants_including_master: variants_includes}
110
+ ]
111
+ end
112
+
113
+ def variants_includes = {stock_items: :stock_location, images: Spree::Image.attachment_preloads}
114
+
108
115
  def set_cache_headers(surrogate_key: nil)
109
116
  return if current_api_user
110
117
 
@@ -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.3
4
+ version: 4.8.1
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.3
60
+ version: 4.8.1
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.3
67
+ version: 4.8.1
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