spree_api 4.0.0.rc3 → 4.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/spree/api/v1/users_controller.rb +10 -6
- data/app/controllers/spree/api/v2/base_controller.rb +6 -1
- data/app/controllers/spree/api/v2/storefront/order_status_controller.rb +6 -0
- data/app/serializers/spree/v2/storefront/cart_serializer.rb +1 -9
- data/docs/v2/storefront/index.yaml +2 -0
- data/lib/spree/api/testing_support/v2/base.rb +1 -1
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc158319298bbbcc29f0137370d6785232e6e9a03f1335a6759a1604daffd9d0
|
4
|
+
data.tar.gz: e4295163450d6523e8480f960fc239b72051b0ec8f5ad958ec95f6ea898334a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32baa584cd58b7e51784162c1b6f630013cb4af832465fb4cfb313e9c914684d0898cbacab9e7237b57b78fea2ed5244e7b2c6c8499287260f542361bab3d9b8
|
7
|
+
data.tar.gz: 6194748bc05257b57003d98f751c5729815171fce592027b3858f40e600ac252284d34fd26b2676075bfe64d6019a55cda9265806aa94cb18741d2cce5d684f0
|
@@ -7,13 +7,17 @@ module Spree
|
|
7
7
|
def index
|
8
8
|
@users = Spree.user_class.accessible_by(current_ability, :show)
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
if params[:ids]
|
11
|
+
@users = @users.where(id: params[:ids])
|
12
|
+
elsif params[:q]
|
13
|
+
users_with_ship_address = @users.with_address(params[:q][:ship_address_firstname_start])
|
14
|
+
users_with_bill_address = @users.with_address(params[:q][:ship_address_firstname_start], :bill_address)
|
15
15
|
|
16
|
-
|
16
|
+
users_with_addresses_ids = (users_with_ship_address.ids + users_with_bill_address.ids).compact.uniq
|
17
|
+
@users = @users.with_email_or_addresses_ids(params[:q][:email_start], users_with_addresses_ids)
|
18
|
+
end
|
19
|
+
|
20
|
+
@users = @users.page(params[:page]).per(params[:per_page])
|
17
21
|
expires_in 15.minutes, public: true
|
18
22
|
headers['Surrogate-Control'] = "max-age=#{15.minutes}"
|
19
23
|
respond_with(@users)
|
@@ -55,7 +55,12 @@ module Spree
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def spree_current_user
|
58
|
-
|
58
|
+
return nil unless doorkeeper_token
|
59
|
+
return @spree_current_user if @spree_current_user
|
60
|
+
|
61
|
+
doorkeeper_authorize!
|
62
|
+
|
63
|
+
@spree_current_user ||= Spree.user_class.find_by(id: doorkeeper_token.resource_owner_id)
|
59
64
|
end
|
60
65
|
|
61
66
|
def spree_authorize!(action, subject, *args)
|
@@ -5,6 +5,8 @@ module Spree
|
|
5
5
|
class OrderStatusController < ::Spree::Api::V2::BaseController
|
6
6
|
include Spree::Api::V2::Storefront::OrderConcern
|
7
7
|
|
8
|
+
before_action :ensure_order_token
|
9
|
+
|
8
10
|
def show
|
9
11
|
render_serialized_payload { serialize_resource(resource) }
|
10
12
|
end
|
@@ -25,6 +27,10 @@ module Spree
|
|
25
27
|
def resource_serializer
|
26
28
|
Spree::Api::Dependencies.storefront_cart_serializer.constantize
|
27
29
|
end
|
30
|
+
|
31
|
+
def ensure_order_token
|
32
|
+
raise ActiveRecord::RecordNotFound unless order_token
|
33
|
+
end
|
28
34
|
end
|
29
35
|
end
|
30
36
|
end
|
@@ -12,15 +12,7 @@ module Spree
|
|
12
12
|
|
13
13
|
has_many :line_items
|
14
14
|
has_many :variants
|
15
|
-
has_many :promotions,
|
16
|
-
# we only want to display applied and valid promotions
|
17
|
-
# sometimes Order can have multiple promotions but the promo engine
|
18
|
-
# will only apply those that are more beneficial for the customer
|
19
|
-
# TODO: we should probably move this code out of the serializer
|
20
|
-
promotion_ids = cart.all_adjustments.eligible.nonzero.promotion.map { |a| a.source.promotion_id }.uniq
|
21
|
-
|
22
|
-
cart.order_promotions.where(promotion_id: promotion_ids).uniq(&:promotion_id)
|
23
|
-
end
|
15
|
+
has_many :promotions, object_method_name: :valid_promotions, id_method_name: :valid_promotion_ids
|
24
16
|
has_many :payments do |cart|
|
25
17
|
cart.payments.valid
|
26
18
|
end
|
@@ -4,7 +4,7 @@ shared_context 'API v2 tokens' do
|
|
4
4
|
let(:headers_order_token) { { 'X-Spree-Order-Token' => order.token } }
|
5
5
|
end
|
6
6
|
|
7
|
-
[200, 201, 400, 404, 403, 422].each do |status_code|
|
7
|
+
[200, 201, 400, 401, 404, 403, 422].each do |status_code|
|
8
8
|
shared_examples "returns #{status_code} HTTP status" do
|
9
9
|
it "returns #{status_code}" do
|
10
10
|
expect(response.status).to eq(status_code)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Bigg
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-10-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jsonapi-rspec
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 4.0.
|
33
|
+
version: 4.0.4
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 4.0.
|
40
|
+
version: 4.0.4
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rabl
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -301,7 +301,7 @@ homepage: http://spreecommerce.org
|
|
301
301
|
licenses:
|
302
302
|
- BSD-3-Clause
|
303
303
|
metadata: {}
|
304
|
-
post_install_message:
|
304
|
+
post_install_message:
|
305
305
|
rdoc_options: []
|
306
306
|
require_paths:
|
307
307
|
- lib
|
@@ -312,12 +312,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
312
312
|
version: 2.5.0
|
313
313
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
314
314
|
requirements:
|
315
|
-
- - "
|
315
|
+
- - ">="
|
316
316
|
- !ruby/object:Gem::Version
|
317
|
-
version:
|
317
|
+
version: '0'
|
318
318
|
requirements: []
|
319
|
-
rubygems_version: 3.
|
320
|
-
signing_key:
|
319
|
+
rubygems_version: 3.1.4
|
320
|
+
signing_key:
|
321
321
|
specification_version: 4
|
322
322
|
summary: Spree's API
|
323
323
|
test_files: []
|