spree_api 3.3.3 → 3.3.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6915e8f0e8af6dc55d88e85a9c3a0211fe6bfbfa
4
- data.tar.gz: 3928d9716a7dc2f3c62fe7a9f77e9e4647649ebc
3
+ metadata.gz: 740146e6e06bfaba423598030a2f2906075f4eca
4
+ data.tar.gz: 3fe9cd0b5b6f906f6e9ec563f81bf876a0d0cf9e
5
5
  SHA512:
6
- metadata.gz: cdf0580320b0432d991c35ae8c94ba6401d518e63e3f775a99cf7f4df59f57add00160ceb9bdf7550ec406b5ac491c2f3d1d8e022c5e9957cfe6d354af1fb0ab
7
- data.tar.gz: 3b59ed63cbf9b2beee4ff47d856be8d1a2ac4a5a69aba39b43f30c8bb554488e77fa453a15e52e6504032df1662b2f35abb990a2031d399a136f9b17bfa3285c
6
+ metadata.gz: 55589923a2e6de34eebc3ee9c60b60c872b68822d2b106255a7be3c1d1b4fc9e6942d8901b640947d2e3440b32321caf168939fc2e95152cd8461b7c26475737
7
+ data.tar.gz: 6900cbbc53bd1aa8adfc852237bcaa80f0d15172115ba55b65f655f89d065b7150735b7a0a92c3854cd12cfd2ec34b99e7ce296069cff1aa1f48314f0280bb45
@@ -27,21 +27,32 @@ module Spree
27
27
  end
28
28
 
29
29
  def create
30
- authorize! :create, Order
31
- order_user = if @current_user_roles.include?('admin') && order_params[:user_id]
32
- Spree.user_class.find(order_params[:user_id])
33
- else
34
- current_api_user
35
- end
30
+ authorize! :create, Spree::Order
31
+ if can?(:admin, Spree::Order)
32
+
33
+ order_user = if @current_user_roles.include?('admin') && order_params[:user_id]
34
+ Spree.user_class.find(order_params[:user_id])
35
+ else
36
+ current_api_user
37
+ end
38
+
39
+ import_params = if @current_user_roles.include?("admin")
40
+ params[:order].present? ? params[:order].permit! : {}
41
+ else
42
+ order_params
43
+ end
44
+
45
+ @order = Spree::Core::Importer::Order.import(order_user, import_params)
36
46
 
37
- import_params = if @current_user_roles.include?("admin")
38
- params[:order].present? ? params[:order].permit! : {}
47
+ respond_with(@order, default_template: :show, status: 201)
39
48
  else
40
- order_params
49
+ @order = Spree::Order.create!(user: current_api_user, store: current_store)
50
+ if @order.contents.update_cart(order_params)
51
+ respond_with(@order, default_template: :show, status: 201)
52
+ else
53
+ invalid_resource!(@order)
54
+ end
41
55
  end
42
-
43
- @order = Spree::Core::Importer::Order.import(order_user, import_params)
44
- respond_with(@order, default_template: :show, status: 201)
45
56
  end
46
57
 
47
58
  def empty
@@ -17,6 +17,7 @@ module Spree
17
17
  end
18
18
 
19
19
  def create
20
+ @order.validate_payments_attributes([payment_params])
20
21
  @payment = @order.payments.build(payment_params)
21
22
  if @payment.save
22
23
  respond_with(@payment, status: 201, default_template: :show)
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: 3.3.3
4
+ version: 3.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Bigg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-08 00:00:00.000000000 Z
11
+ date: 2017-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: spree_core
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 3.3.3
19
+ version: 3.3.4
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 3.3.3
26
+ version: 3.3.4
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rabl
29
29
  requirement: !ruby/object:Gem::Requirement