spree_api 3.7.13 → 4.0.0.beta

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of spree_api might be problematic. Click here for more details.

Files changed (139) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/app/controllers/spree/api/base_controller.rb +3 -3
  4. data/app/controllers/spree/api/v1/addresses_controller.rb +2 -2
  5. data/app/controllers/spree/api/v1/countries_controller.rb +2 -2
  6. data/app/controllers/spree/api/v1/credit_cards_controller.rb +2 -2
  7. data/app/controllers/spree/api/v1/images_controller.rb +3 -3
  8. data/app/controllers/spree/api/v1/inventory_units_controller.rb +2 -2
  9. data/app/controllers/spree/api/v1/option_types_controller.rb +4 -4
  10. data/app/controllers/spree/api/v1/option_values_controller.rb +3 -3
  11. data/app/controllers/spree/api/v1/payments_controller.rb +2 -2
  12. data/app/controllers/spree/api/v1/product_properties_controller.rb +4 -4
  13. data/app/controllers/spree/api/v1/properties_controller.rb +4 -4
  14. data/app/controllers/spree/api/v1/return_authorizations_controller.rb +4 -4
  15. data/app/controllers/spree/api/v1/shipments_controller.rb +3 -3
  16. data/app/controllers/spree/api/v1/states_controller.rb +3 -3
  17. data/app/controllers/spree/api/v1/stock_items_controller.rb +2 -2
  18. data/app/controllers/spree/api/v1/stock_locations_controller.rb +5 -4
  19. data/app/controllers/spree/api/v1/stock_movements_controller.rb +3 -3
  20. data/app/controllers/spree/api/v1/stores_controller.rb +4 -4
  21. data/app/controllers/spree/api/v1/taxonomies_controller.rb +3 -3
  22. data/app/controllers/spree/api/v1/taxons_controller.rb +5 -5
  23. data/app/controllers/spree/api/v1/users_controller.rb +3 -3
  24. data/app/controllers/spree/api/v1/variants_controller.rb +3 -3
  25. data/app/controllers/spree/api/v1/zones_controller.rb +3 -3
  26. data/app/controllers/spree/api/v2/base_controller.rb +1 -6
  27. data/app/controllers/spree/api/v2/storefront/account/credit_cards_controller.rb +1 -1
  28. data/app/controllers/spree/api/v2/storefront/countries_controller.rb +2 -1
  29. data/app/controllers/spree/api/v2/storefront/order_status_controller.rb +0 -6
  30. data/app/controllers/spree/api/v2/storefront/products_controller.rb +1 -1
  31. data/app/controllers/spree/api/v2/storefront/taxons_controller.rb +1 -1
  32. data/app/views/spree/api/errors/{gateway_error.v1.rabl → gateway_error.rabl} +0 -0
  33. data/app/views/spree/api/errors/{invalid_api_key.v1.rabl → invalid_api_key.rabl} +0 -0
  34. data/app/views/spree/api/errors/{invalid_resource.v1.rabl → invalid_resource.rabl} +0 -0
  35. data/app/views/spree/api/errors/{must_specify_api_key.v1.rabl → must_specify_api_key.rabl} +0 -0
  36. data/app/views/spree/api/errors/{not_found.v1.rabl → not_found.rabl} +0 -0
  37. data/app/views/spree/api/errors/{unauthorized.v1.rabl → unauthorized.rabl} +0 -0
  38. data/app/views/spree/api/v1/addresses/{show.v1.rabl → show.rabl} +0 -0
  39. data/app/views/spree/api/v1/adjustments/{show.v1.rabl → show.rabl} +0 -0
  40. data/app/views/spree/api/v1/countries/{index.v1.rabl → index.rabl} +0 -0
  41. data/app/views/spree/api/v1/countries/{show.v1.rabl → show.rabl} +0 -0
  42. data/app/views/spree/api/v1/credit_cards/{index.v1.rabl → index.rabl} +0 -0
  43. data/app/views/spree/api/v1/credit_cards/{show.v1.rabl → show.rabl} +0 -0
  44. data/app/views/spree/api/v1/customer_returns/{index.v1.rabl → index.rabl} +0 -0
  45. data/app/views/spree/api/v1/images/{index.v1.rabl → index.rabl} +0 -0
  46. data/app/views/spree/api/v1/images/{new.v1.rabl → new.rabl} +0 -0
  47. data/app/views/spree/api/v1/images/{show.v1.rabl → show.rabl} +0 -0
  48. data/app/views/spree/api/v1/line_items/{new.v1.rabl → new.rabl} +0 -0
  49. data/app/views/spree/api/v1/line_items/{show.v1.rabl → show.rabl} +0 -0
  50. data/app/views/spree/api/v1/option_types/{index.v1.rabl → index.rabl} +0 -0
  51. data/app/views/spree/api/v1/option_types/{new.v1.rabl → new.rabl} +0 -0
  52. data/app/views/spree/api/v1/option_types/{show.v1.rabl → show.rabl} +0 -0
  53. data/app/views/spree/api/v1/option_values/{index.v1.rabl → index.rabl} +0 -0
  54. data/app/views/spree/api/v1/option_values/{new.v1.rabl → new.rabl} +0 -0
  55. data/app/views/spree/api/v1/option_values/{show.v1.rabl → show.rabl} +0 -0
  56. data/app/views/spree/api/v1/orders/{address.v1.rabl → address.rabl} +0 -0
  57. data/app/views/spree/api/v1/orders/{canceled.v1.rabl → canceled.rabl} +0 -0
  58. data/app/views/spree/api/v1/orders/{cart.v1.rabl → cart.rabl} +0 -0
  59. data/app/views/spree/api/v1/orders/{complete.v1.rabl → complete.rabl} +0 -0
  60. data/app/views/spree/api/v1/orders/{could_not_apply_coupon.v1.rabl → could_not_apply_coupon.rabl} +0 -0
  61. data/app/views/spree/api/v1/orders/{could_not_transition.v1.rabl → could_not_transition.rabl} +0 -0
  62. data/app/views/spree/api/v1/orders/{index.v1.rabl → index.rabl} +0 -0
  63. data/app/views/spree/api/v1/orders/{insufficient_quantity.v1.rabl → insufficient_quantity.rabl} +0 -0
  64. data/app/views/spree/api/v1/orders/{invalid_shipping_method.v1.rabl → invalid_shipping_method.rabl} +0 -0
  65. data/app/views/spree/api/v1/orders/{mine.v1.rabl → mine.rabl} +0 -0
  66. data/app/views/spree/api/v1/orders/{order.v1.rabl → order.rabl} +0 -0
  67. data/app/views/spree/api/v1/orders/{payment.v1.rabl → payment.rabl} +0 -0
  68. data/app/views/spree/api/v1/orders/{show.v1.rabl → show.rabl} +0 -0
  69. data/app/views/spree/api/v1/payments/{credit_over_limit.v1.rabl → credit_over_limit.rabl} +0 -0
  70. data/app/views/spree/api/v1/payments/{index.v1.rabl → index.rabl} +0 -0
  71. data/app/views/spree/api/v1/payments/{new.v1.rabl → new.rabl} +0 -0
  72. data/app/views/spree/api/v1/payments/{show.v1.rabl → show.rabl} +0 -0
  73. data/app/views/spree/api/v1/payments/{update_forbidden.v1.rabl → update_forbidden.rabl} +0 -0
  74. data/app/views/spree/api/v1/product_properties/{index.v1.rabl → index.rabl} +0 -0
  75. data/app/views/spree/api/v1/product_properties/{new.v1.rabl → new.rabl} +0 -0
  76. data/app/views/spree/api/v1/product_properties/{show.v1.rabl → show.rabl} +0 -0
  77. data/app/views/spree/api/v1/products/{index.v1.rabl → index.rabl} +0 -0
  78. data/app/views/spree/api/v1/products/{new.v1.rabl → new.rabl} +0 -0
  79. data/app/views/spree/api/v1/products/{product.v1.rabl → product.rabl} +0 -0
  80. data/app/views/spree/api/v1/products/{show.v1.rabl → show.rabl} +0 -0
  81. data/app/views/spree/api/v1/promotions/{handler.v1.rabl → handler.rabl} +0 -0
  82. data/app/views/spree/api/v1/promotions/{show.v1.rabl → show.rabl} +0 -0
  83. data/app/views/spree/api/v1/properties/{index.v1.rabl → index.rabl} +0 -0
  84. data/app/views/spree/api/v1/properties/{new.v1.rabl → new.rabl} +0 -0
  85. data/app/views/spree/api/v1/properties/{show.v1.rabl → show.rabl} +0 -0
  86. data/app/views/spree/api/v1/reimbursements/{index.v1.rabl → index.rabl} +0 -0
  87. data/app/views/spree/api/v1/return_authorizations/{index.v1.rabl → index.rabl} +0 -0
  88. data/app/views/spree/api/v1/return_authorizations/{new.v1.rabl → new.rabl} +0 -0
  89. data/app/views/spree/api/v1/return_authorizations/{show.v1.rabl → show.rabl} +0 -0
  90. data/app/views/spree/api/v1/shared/{stock_location_required.v1.rabl → stock_location_required.rabl} +0 -0
  91. data/app/views/spree/api/v1/shipments/{big.v1.rabl → big.rabl} +0 -0
  92. data/app/views/spree/api/v1/shipments/{cannot_ready_shipment.v1.rabl → cannot_ready_shipment.rabl} +0 -0
  93. data/app/views/spree/api/v1/shipments/{mine.v1.rabl → mine.rabl} +0 -0
  94. data/app/views/spree/api/v1/shipments/{show.v1.rabl → show.rabl} +0 -0
  95. data/app/views/spree/api/v1/shipments/{small.v1.rabl → small.rabl} +0 -0
  96. data/app/views/spree/api/v1/shipping_rates/{show.v1.rabl → show.rabl} +0 -0
  97. data/app/views/spree/api/v1/states/{index.v1.rabl → index.rabl} +0 -0
  98. data/app/views/spree/api/v1/states/{show.v1.rabl → show.rabl} +0 -0
  99. data/app/views/spree/api/v1/stock_items/{index.v1.rabl → index.rabl} +0 -0
  100. data/app/views/spree/api/v1/stock_items/{show.v1.rabl → show.rabl} +0 -0
  101. data/app/views/spree/api/v1/stock_locations/{index.v1.rabl → index.rabl} +0 -0
  102. data/app/views/spree/api/v1/stock_locations/{show.v1.rabl → show.rabl} +0 -0
  103. data/app/views/spree/api/v1/stock_movements/{index.v1.rabl → index.rabl} +0 -0
  104. data/app/views/spree/api/v1/stock_movements/{show.v1.rabl → show.rabl} +0 -0
  105. data/app/views/spree/api/v1/stores/{index.v1.rabl → index.rabl} +0 -0
  106. data/app/views/spree/api/v1/stores/{show.v1.rabl → show.rabl} +0 -0
  107. data/app/views/spree/api/v1/tags/{index.v1.rabl → index.rabl} +0 -0
  108. data/app/views/spree/api/v1/taxonomies/{index.v1.rabl → index.rabl} +0 -0
  109. data/app/views/spree/api/v1/taxonomies/{nested.v1.rabl → nested.rabl} +0 -0
  110. data/app/views/spree/api/v1/taxonomies/{new.v1.rabl → new.rabl} +0 -0
  111. data/app/views/spree/api/v1/taxonomies/{show.v1.rabl → show.rabl} +0 -0
  112. data/app/views/spree/api/v1/taxons/{index.v1.rabl → index.rabl} +0 -0
  113. data/app/views/spree/api/v1/taxons/{new.v1.rabl → new.rabl} +0 -0
  114. data/app/views/spree/api/v1/taxons/{show.v1.rabl → show.rabl} +0 -0
  115. data/app/views/spree/api/v1/taxons/{taxons.v1.rabl → taxons.rabl} +0 -0
  116. data/app/views/spree/api/v1/users/{index.v1.rabl → index.rabl} +0 -0
  117. data/app/views/spree/api/v1/users/{new.v1.rabl → new.rabl} +0 -0
  118. data/app/views/spree/api/v1/users/{show.v1.rabl → show.rabl} +0 -0
  119. data/app/views/spree/api/v1/variants/{big.v1.rabl → big.rabl} +0 -0
  120. data/app/views/spree/api/v1/variants/{index.v1.rabl → index.rabl} +0 -0
  121. data/app/views/spree/api/v1/variants/{new.v1.rabl → new.rabl} +0 -0
  122. data/app/views/spree/api/v1/variants/{show.v1.rabl → show.rabl} +0 -0
  123. data/app/views/spree/api/v1/variants/{small.v1.rabl → small.rabl} +0 -0
  124. data/app/views/spree/api/v1/zones/{index.v1.rabl → index.rabl} +0 -0
  125. data/app/views/spree/api/v1/zones/{show.v1.rabl → show.rabl} +0 -0
  126. data/config/initializers/doorkeeper.rb +12 -0
  127. data/config/initializers/rabl_rails6_fix.rb +16 -0
  128. data/config/routes.rb +0 -2
  129. data/docs/v2/storefront/index.yaml +36 -31
  130. data/lib/spree/api/engine.rb +0 -19
  131. data/lib/spree/api/testing_support/v2/base.rb +1 -1
  132. data/lib/spree_api.rb +0 -1
  133. data/spree_api.gemspec +2 -3
  134. metadata +108 -126
  135. data/app/controllers/spree/api/v1/tags_controller.rb +0 -28
  136. data/app/models/doorkeeper/access_grant_decorator.rb +0 -3
  137. data/app/models/doorkeeper/access_token_decorator.rb +0 -3
  138. data/app/models/doorkeeper/application_decorator.rb +0 -3
  139. data/config/initializers/metal_load_paths.rb +0 -1
@@ -29,7 +29,7 @@ module Spree
29
29
 
30
30
  def update
31
31
  authorize! :update, taxonomy
32
- if taxonomy.update_attributes(taxonomy_params)
32
+ if taxonomy.update(taxonomy_params)
33
33
  respond_with(taxonomy, status: 200, default_template: :show)
34
34
  else
35
35
  invalid_resource!(taxonomy)
@@ -45,13 +45,13 @@ module Spree
45
45
  private
46
46
 
47
47
  def taxonomies
48
- @taxonomies = Taxonomy.accessible_by(current_ability, :read).order('name').includes(root: :children).
48
+ @taxonomies = Taxonomy.accessible_by(current_ability).order('name').includes(root: :children).
49
49
  ransack(params[:q]).result.
50
50
  page(params[:page]).per(params[:per_page])
51
51
  end
52
52
 
53
53
  def taxonomy
54
- @taxonomy ||= Taxonomy.accessible_by(current_ability, :read).find(params[:id])
54
+ @taxonomy ||= Taxonomy.accessible_by(current_ability, :show).find(params[:id])
55
55
  end
56
56
 
57
57
  def taxonomy_params
@@ -6,9 +6,9 @@ module Spree
6
6
  @taxons = if taxonomy
7
7
  taxonomy.root.children
8
8
  elsif params[:ids]
9
- Spree::Taxon.includes(:children).accessible_by(current_ability, :read).where(id: params[:ids].split(','))
9
+ Spree::Taxon.includes(:children).accessible_by(current_ability).where(id: params[:ids].split(','))
10
10
  else
11
- Spree::Taxon.includes(:children).accessible_by(current_ability, :read).order(:taxonomy_id, :lft)
11
+ Spree::Taxon.includes(:children).accessible_by(current_ability).order(:taxonomy_id, :lft)
12
12
  end
13
13
  @taxons = @taxons.ransack(params[:q]).result
14
14
  @taxons = @taxons.page(params[:page]).per(params[:per_page])
@@ -48,7 +48,7 @@ module Spree
48
48
 
49
49
  def update
50
50
  authorize! :update, taxon
51
- if taxon.update_attributes(taxon_params)
51
+ if taxon.update(taxon_params)
52
52
  respond_with(taxon, status: 200, default_template: :show)
53
53
  else
54
54
  invalid_resource!(taxon)
@@ -74,12 +74,12 @@ module Spree
74
74
 
75
75
  def taxonomy
76
76
  if params[:taxonomy_id].present?
77
- @taxonomy ||= Spree::Taxonomy.accessible_by(current_ability, :read).find(params[:taxonomy_id])
77
+ @taxonomy ||= Spree::Taxonomy.accessible_by(current_ability, :show).find(params[:taxonomy_id])
78
78
  end
79
79
  end
80
80
 
81
81
  def taxon
82
- @taxon ||= taxonomy.taxons.accessible_by(current_ability, :read).find(params[:id])
82
+ @taxon ||= taxonomy.taxons.accessible_by(current_ability, :show).find(params[:id])
83
83
  end
84
84
 
85
85
  def taxon_params
@@ -5,7 +5,7 @@ module Spree
5
5
  rescue_from Spree::Core::DestroyWithOrdersError, with: :error_during_processing
6
6
 
7
7
  def index
8
- @users = Spree.user_class.accessible_by(current_ability, :read)
8
+ @users = Spree.user_class.accessible_by(current_ability, :show)
9
9
 
10
10
  @users = if params[:ids]
11
11
  @users.ransack(id_in: params[:ids].split(','))
@@ -37,7 +37,7 @@ module Spree
37
37
 
38
38
  def update
39
39
  authorize! :update, user
40
- if user.update_attributes(user_params)
40
+ if user.update(user_params)
41
41
  respond_with(user, status: 200, default_template: :show)
42
42
  else
43
43
  invalid_resource!(user)
@@ -53,7 +53,7 @@ module Spree
53
53
  private
54
54
 
55
55
  def user
56
- @user ||= Spree.user_class.accessible_by(current_ability, :read).find(params[:id])
56
+ @user ||= Spree.user_class.accessible_by(current_ability, :show).find(params[:id])
57
57
  end
58
58
 
59
59
  def user_params
@@ -38,7 +38,7 @@ module Spree
38
38
 
39
39
  def update
40
40
  @variant = scope.accessible_by(current_ability, :update).find(params[:id])
41
- if @variant.update_attributes(variant_params)
41
+ if @variant.update(variant_params)
42
42
  respond_with(@variant, status: 200, default_template: :show)
43
43
  else
44
44
  invalid_resource!(@product)
@@ -49,7 +49,7 @@ module Spree
49
49
 
50
50
  def product
51
51
  if params[:product_id]
52
- @product ||= Spree::Product.accessible_by(current_ability, :read).
52
+ @product ||= Spree::Product.accessible_by(current_ability, :show).
53
53
  friendly.find(params[:product_id])
54
54
  end
55
55
  end
@@ -65,7 +65,7 @@ module Spree
65
65
  variants = variants.with_deleted
66
66
  end
67
67
 
68
- variants.eligible.accessible_by(current_ability, :read)
68
+ variants.eligible.accessible_by(current_ability)
69
69
  end
70
70
 
71
71
  def variant_params
@@ -19,7 +19,7 @@ module Spree
19
19
  end
20
20
 
21
21
  def index
22
- @zones = Zone.accessible_by(current_ability, :read).order('name ASC').ransack(params[:q]).result.page(params[:page]).per(params[:per_page])
22
+ @zones = Zone.accessible_by(current_ability).order('name ASC').ransack(params[:q]).result.page(params[:page]).per(params[:per_page])
23
23
  respond_with(@zones)
24
24
  end
25
25
 
@@ -29,7 +29,7 @@ module Spree
29
29
 
30
30
  def update
31
31
  authorize! :update, zone
32
- if zone.update_attributes(zone_params)
32
+ if zone.update(zone_params)
33
33
  respond_with(zone, status: 200, default_template: :show)
34
34
  else
35
35
  invalid_resource!(zone)
@@ -47,7 +47,7 @@ module Spree
47
47
  end
48
48
 
49
49
  def zone
50
- @zone ||= Spree::Zone.accessible_by(current_ability, :read).find(params[:id])
50
+ @zone ||= Spree::Zone.accessible_by(current_ability, :show).find(params[:id])
51
51
  end
52
52
  end
53
53
  end
@@ -55,12 +55,7 @@ module Spree
55
55
  end
56
56
 
57
57
  def spree_current_user
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)
58
+ @spree_current_user ||= Spree.user_class.find_by(id: doorkeeper_token.resource_owner_id) if doorkeeper_token
64
59
  end
65
60
 
66
61
  def spree_authorize!(action, subject, *args)
@@ -41,7 +41,7 @@ module Spree
41
41
  end
42
42
 
43
43
  def scope
44
- spree_current_user.credit_cards.accessible_by(current_ability, :read)
44
+ spree_current_user.credit_cards.accessible_by(current_ability, :show)
45
45
  end
46
46
  end
47
47
  end
@@ -36,6 +36,7 @@ module Spree
36
36
  return scope.default if params[:iso] == 'default'
37
37
 
38
38
  scope.find_by(iso: params[:iso]&.upcase) ||
39
+ scope.find_by(id: params[:iso]&.upcase) ||
39
40
  scope.find_by(iso3: params[:iso]&.upcase)
40
41
  end
41
42
 
@@ -52,7 +53,7 @@ module Spree
52
53
  end
53
54
 
54
55
  def scope
55
- Spree::Country.accessible_by(current_ability, :read)
56
+ Spree::Country.accessible_by(current_ability, :show)
56
57
  end
57
58
  end
58
59
  end
@@ -5,8 +5,6 @@ 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
-
10
8
  def show
11
9
  render_serialized_payload { serialize_resource(resource) }
12
10
  end
@@ -27,10 +25,6 @@ module Spree
27
25
  def resource_serializer
28
26
  Spree::Api::Dependencies.storefront_cart_serializer.constantize
29
27
  end
30
-
31
- def ensure_order_token
32
- raise ActiveRecord::RecordNotFound unless order_token.present?
33
- end
34
28
  end
35
29
  end
36
30
  end
@@ -44,7 +44,7 @@ module Spree
44
44
  end
45
45
 
46
46
  def scope
47
- Spree::Product.accessible_by(current_ability, :read).includes(scope_includes)
47
+ Spree::Product.accessible_by(current_ability, :show).includes(scope_includes)
48
48
  end
49
49
 
50
50
  def scope_includes
@@ -40,7 +40,7 @@ module Spree
40
40
  end
41
41
 
42
42
  def scope
43
- Spree::Taxon.accessible_by(current_ability, :read).includes(scope_includes)
43
+ Spree::Taxon.accessible_by(current_ability, :show).includes(scope_includes)
44
44
  end
45
45
 
46
46
  def scope_includes