solidus_api 4.5.1 → 4.6.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/app/controllers/spree/api/base_controller.rb +26 -10
- data/app/controllers/spree/api/line_items_controller.rb +1 -1
- data/app/helpers/spree/api/api_helpers.rb +1 -1
- data/app/views/spree/api/line_items/new.json.jbuilder +1 -1
- data/app/views/spree/api/payments/source_views/_gateway.json.jbuilder +1 -1
- data/app/views/spree/api/products/_product.json.jbuilder +1 -1
- data/lib/spree/api/testing_support/helpers.rb +1 -1
- data/lib/spree/api_configuration.rb +2 -2
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5549be04b7ef5d8383c6d7496a7b7e4064a5358a821c30144ab815a69904cbae
|
4
|
+
data.tar.gz: 73a9a781462acef1a5acab160abf72e7efdfec3d98fa6a933d8d7c5c03cb9d00
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4210a7c4b2a60d3c352019287ba0dacce4084079d98d65b57c9967964917fdbb4839d78f1c4fa9ca0cddd917d1dfed57b033565ca69be84a8a6b69fbdffd723
|
7
|
+
data.tar.gz: 73e352d81bdada984ff2ba8fcbd1656bcf335c868a08c7f304e657dccefaf5a176454e461134e8dde443a828d270ee9a76ee643cbb094072236218d284ba4391
|
@@ -21,12 +21,11 @@ module Spree
|
|
21
21
|
class_attribute :admin_metadata_attributes
|
22
22
|
self.admin_metadata_attributes = [{ admin_metadata: {} }]
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
before_action :load_user
|
24
|
+
before_action :deprecated_load_user
|
27
25
|
before_action :authorize_for_order, if: proc { order_token.present? }
|
28
26
|
before_action :authenticate_user
|
29
|
-
|
27
|
+
# This is deprecated and will be removed in Spree 5.0
|
28
|
+
before_action :load_deprecated_user_roles
|
30
29
|
|
31
30
|
rescue_from ActionController::ParameterMissing, with: :parameter_missing_error
|
32
31
|
rescue_from ActiveRecord::RecordNotFound, with: :not_found
|
@@ -35,6 +34,7 @@ module Spree
|
|
35
34
|
rescue_from StateMachines::InvalidTransition, with: :invalid_transition
|
36
35
|
|
37
36
|
helper Spree::Api::ApiHelpers
|
37
|
+
helper_method :current_user_roles, :current_api_user
|
38
38
|
|
39
39
|
private
|
40
40
|
|
@@ -61,12 +61,12 @@ module Spree
|
|
61
61
|
can?(:admin, Spree.user_class) ? super + admin_metadata_attributes : super
|
62
62
|
end
|
63
63
|
|
64
|
-
def
|
65
|
-
@
|
64
|
+
def current_api_user
|
65
|
+
@_current_api_user ||= Spree.user_class.find_by(spree_api_key: api_key.to_s)
|
66
66
|
end
|
67
67
|
|
68
68
|
def authenticate_user
|
69
|
-
unless
|
69
|
+
unless current_api_user
|
70
70
|
if requires_authentication? && api_key.blank? && order_token.blank?
|
71
71
|
render "spree/api/errors/must_specify_api_key", status: :unauthorized
|
72
72
|
elsif order_token.blank? && (requires_authentication? || api_key.present?)
|
@@ -75,9 +75,25 @@ module Spree
|
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
78
|
-
def
|
79
|
-
@current_user_roles = if
|
80
|
-
|
78
|
+
def load_deprecated_user_roles
|
79
|
+
@current_user_roles = if Rails.version < Gem::Version.new("7.2.0")
|
80
|
+
ActiveSupport::Deprecation::DeprecatedInstanceVariableProxy.new(self, :current_user_roles, :@current_user_roles, Spree.deprecator)
|
81
|
+
else
|
82
|
+
ActiveSupport::Deprecation::DeprecatedInstanceVariableProxy.new(self, :current_user_roles, :@current_user_roles, deprecator: Spree.deprecator)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def deprecated_load_user
|
87
|
+
@current_api_user = if Rails.version < Gem::Version.new("7.2.0")
|
88
|
+
ActiveSupport::Deprecation::DeprecatedInstanceVariableProxy.new(self, :current_api_user, :@current_api_user, Spree.deprecator)
|
89
|
+
else
|
90
|
+
ActiveSupport::Deprecation::DeprecatedInstanceVariableProxy.new(self, :current_api_user, :@current_api_user, deprecator: Spree.deprecator)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def current_user_roles
|
95
|
+
@_current_user_roles ||= if current_api_user
|
96
|
+
current_api_user.spree_roles.pluck(:name)
|
81
97
|
else
|
82
98
|
[]
|
83
99
|
end
|
@@ -66,7 +66,7 @@ module Spree
|
|
66
66
|
def extract_metadata
|
67
67
|
metadata = { customer_metadata: line_item_params[:customer_metadata] }
|
68
68
|
|
69
|
-
if
|
69
|
+
if current_user_roles&.include?("admin")
|
70
70
|
metadata[:admin_metadata] = line_item_params[:admin_metadata]
|
71
71
|
end
|
72
72
|
|
@@ -67,7 +67,7 @@ module Spree
|
|
67
67
|
|
68
68
|
def variant_attributes
|
69
69
|
preference_attributes = Spree::Api::Config.variant_attributes
|
70
|
-
if
|
70
|
+
if current_user_roles&.include?("admin")
|
71
71
|
preference_attributes + [:cost_price]
|
72
72
|
else
|
73
73
|
preference_attributes
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
@product_attributes ||= product_attributes
|
4
|
-
json.cache! [I18n.locale,
|
4
|
+
json.cache! [I18n.locale, current_user_roles.include?('admin'), current_pricing_options, @product_attributes, @exclude_data, product] do
|
5
5
|
json.(product, *(@product_attributes - [:total_on_hand]))
|
6
6
|
json.total_on_hand(total_on_hand_for(product))
|
7
7
|
json.price(product.price_for_options(current_pricing_options)&.amount)
|
@@ -30,7 +30,7 @@ module Spree
|
|
30
30
|
# This method can be overridden (with a let block) inside a context
|
31
31
|
# For instance, if you wanted to have an admin user instead.
|
32
32
|
def current_api_user
|
33
|
-
@
|
33
|
+
@_current_api_user ||= stub_model(Spree::LegacyUser, email: "solidus@example.com", spree_roles: [])
|
34
34
|
end
|
35
35
|
|
36
36
|
def image(filename)
|
@@ -85,7 +85,7 @@ module Spree
|
|
85
85
|
preference :address_attributes, :array, default: [
|
86
86
|
:id, :name, :address1, :address2, :city, :zipcode, :phone, :company,
|
87
87
|
:alternative_phone, :country_id, :country_iso, :state_id, :state_name,
|
88
|
-
:state_text
|
88
|
+
:state_text, :email, :vat_id, :reverse_charge_status
|
89
89
|
]
|
90
90
|
|
91
91
|
preference :country_attributes, :array, default: [:id, :iso_name, :iso, :iso3, :name, :numcode]
|
@@ -149,7 +149,7 @@ module Spree
|
|
149
149
|
preference :store_attributes, :array, default: [
|
150
150
|
:id, :name, :url, :meta_description, :meta_keywords, :seo_title,
|
151
151
|
:mail_from_address, :default_currency, :code, :default, :available_locales,
|
152
|
-
:bcc_email
|
152
|
+
:bcc_email, :reverse_charge_status
|
153
153
|
]
|
154
154
|
|
155
155
|
preference :store_credit_history_attributes, :array, default: [
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solidus_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Solidus Team
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: jbuilder
|
@@ -57,14 +57,14 @@ dependencies:
|
|
57
57
|
requirements:
|
58
58
|
- - '='
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: 4.
|
60
|
+
version: 4.6.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.6.0
|
68
68
|
description: REST API for the Solidus e-commerce framework.
|
69
69
|
email: contact@solidus.io
|
70
70
|
executables: []
|
@@ -270,7 +270,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
270
270
|
- !ruby/object:Gem::Version
|
271
271
|
version: 1.8.23
|
272
272
|
requirements: []
|
273
|
-
rubygems_version: 3.6.
|
273
|
+
rubygems_version: 3.6.9
|
274
274
|
specification_version: 4
|
275
275
|
summary: REST API for the Solidus e-commerce framework.
|
276
276
|
test_files: []
|